babylon.d.txt 2.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. let Epsilon: number;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Color3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Adds the translation vector (using 3 floats) in the current matrix
  2941. * @param x defines the 1st component of the translation
  2942. * @param y defines the 2nd component of the translation
  2943. * @param z defines the 3rd component of the translation
  2944. * @returns the current updated matrix
  2945. */
  2946. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2947. /**
  2948. * Inserts the translation vector in the current matrix
  2949. * @param vector3 defines the translation to insert
  2950. * @returns the current updated matrix
  2951. */
  2952. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2953. /**
  2954. * Gets the translation value of the current matrix
  2955. * @returns a new Vector3 as the extracted translation from the matrix
  2956. */
  2957. getTranslation(): Vector3;
  2958. /**
  2959. * Fill a Vector3 with the extracted translation from the matrix
  2960. * @param result defines the Vector3 where to store the translation
  2961. * @returns the current matrix
  2962. */
  2963. getTranslationToRef(result: Vector3): Matrix;
  2964. /**
  2965. * Remove rotation and scaling part from the matrix
  2966. * @returns the updated matrix
  2967. */
  2968. removeRotationAndScaling(): Matrix;
  2969. /**
  2970. * Multiply two matrices
  2971. * @param other defines the second operand
  2972. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2973. */
  2974. multiply(other: DeepImmutable<Matrix>): Matrix;
  2975. /**
  2976. * Copy the current matrix from the given one
  2977. * @param other defines the source matrix
  2978. * @returns the current updated matrix
  2979. */
  2980. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2981. /**
  2982. * Populates the given array from the starting index with the current matrix values
  2983. * @param array defines the target array
  2984. * @param offset defines the offset in the target array where to start storing values
  2985. * @returns the current matrix
  2986. */
  2987. copyToArray(array: Float32Array, offset?: number): Matrix;
  2988. /**
  2989. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2990. * @param other defines the second operand
  2991. * @param result defines the matrix where to store the multiplication
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2995. /**
  2996. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2997. * @param other defines the second operand
  2998. * @param result defines the array where to store the multiplication
  2999. * @param offset defines the offset in the target array where to start storing values
  3000. * @returns the current matrix
  3001. */
  3002. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3003. /**
  3004. * Check equality between this matrix and a second one
  3005. * @param value defines the second matrix to compare
  3006. * @returns true is the current matrix and the given one values are strictly equal
  3007. */
  3008. equals(value: DeepImmutable<Matrix>): boolean;
  3009. /**
  3010. * Clone the current matrix
  3011. * @returns a new matrix from the current matrix
  3012. */
  3013. clone(): Matrix;
  3014. /**
  3015. * Returns the name of the current matrix class
  3016. * @returns the string "Matrix"
  3017. */
  3018. getClassName(): string;
  3019. /**
  3020. * Gets the hash code of the current matrix
  3021. * @returns the hash code
  3022. */
  3023. getHashCode(): number;
  3024. /**
  3025. * Decomposes the current Matrix into a translation, rotation and scaling components
  3026. * @param scale defines the scale vector3 given as a reference to update
  3027. * @param rotation defines the rotation quaternion given as a reference to update
  3028. * @param translation defines the translation vector3 given as a reference to update
  3029. * @returns true if operation was successful
  3030. */
  3031. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3032. /**
  3033. * Gets specific row of the matrix
  3034. * @param index defines the number of the row to get
  3035. * @returns the index-th row of the current matrix as a new Vector4
  3036. */
  3037. getRow(index: number): Nullable<Vector4>;
  3038. /**
  3039. * Sets the index-th row of the current matrix to the vector4 values
  3040. * @param index defines the number of the row to set
  3041. * @param row defines the target vector4
  3042. * @returns the updated current matrix
  3043. */
  3044. setRow(index: number, row: Vector4): Matrix;
  3045. /**
  3046. * Compute the transpose of the matrix
  3047. * @returns the new transposed matrix
  3048. */
  3049. transpose(): Matrix;
  3050. /**
  3051. * Compute the transpose of the matrix and store it in a given matrix
  3052. * @param result defines the target matrix
  3053. * @returns the current matrix
  3054. */
  3055. transposeToRef(result: Matrix): Matrix;
  3056. /**
  3057. * Sets the index-th row of the current matrix with the given 4 x float values
  3058. * @param index defines the row index
  3059. * @param x defines the x component to set
  3060. * @param y defines the y component to set
  3061. * @param z defines the z component to set
  3062. * @param w defines the w component to set
  3063. * @returns the updated current matrix
  3064. */
  3065. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3066. /**
  3067. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3068. * @param scale defines the scale factor
  3069. * @returns a new matrix
  3070. */
  3071. scale(scale: number): Matrix;
  3072. /**
  3073. * Scale the current matrix values by a factor to a given result matrix
  3074. * @param scale defines the scale factor
  3075. * @param result defines the matrix to store the result
  3076. * @returns the current matrix
  3077. */
  3078. scaleToRef(scale: number, result: Matrix): Matrix;
  3079. /**
  3080. * Scale the current matrix values by a factor and add the result to a given matrix
  3081. * @param scale defines the scale factor
  3082. * @param result defines the Matrix to store the result
  3083. * @returns the current matrix
  3084. */
  3085. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3086. /**
  3087. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3088. * @param ref matrix to store the result
  3089. */
  3090. toNormalMatrix(ref: Matrix): void;
  3091. /**
  3092. * Gets only rotation part of the current matrix
  3093. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3094. */
  3095. getRotationMatrix(): Matrix;
  3096. /**
  3097. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3098. * @param result defines the target matrix to store data to
  3099. * @returns the current matrix
  3100. */
  3101. getRotationMatrixToRef(result: Matrix): Matrix;
  3102. /**
  3103. * Toggles model matrix from being right handed to left handed in place and vice versa
  3104. */
  3105. toggleModelMatrixHandInPlace(): void;
  3106. /**
  3107. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleProjectionMatrixHandInPlace(): void;
  3110. /**
  3111. * Creates a matrix from an array
  3112. * @param array defines the source array
  3113. * @param offset defines an offset in the source array
  3114. * @returns a new Matrix set from the starting index of the given array
  3115. */
  3116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3117. /**
  3118. * Copy the content of an array into a given matrix
  3119. * @param array defines the source array
  3120. * @param offset defines an offset in the source array
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3124. /**
  3125. * Stores an array into a matrix after having multiplied each component by a given factor
  3126. * @param array defines the source array
  3127. * @param offset defines the offset in the source array
  3128. * @param scale defines the scaling factor
  3129. * @param result defines the target matrix
  3130. */
  3131. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3132. /**
  3133. * Gets an identity matrix that must not be updated
  3134. */
  3135. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3136. /**
  3137. * Stores a list of values (16) inside a given matrix
  3138. * @param initialM11 defines 1st value of 1st row
  3139. * @param initialM12 defines 2nd value of 1st row
  3140. * @param initialM13 defines 3rd value of 1st row
  3141. * @param initialM14 defines 4th value of 1st row
  3142. * @param initialM21 defines 1st value of 2nd row
  3143. * @param initialM22 defines 2nd value of 2nd row
  3144. * @param initialM23 defines 3rd value of 2nd row
  3145. * @param initialM24 defines 4th value of 2nd row
  3146. * @param initialM31 defines 1st value of 3rd row
  3147. * @param initialM32 defines 2nd value of 3rd row
  3148. * @param initialM33 defines 3rd value of 3rd row
  3149. * @param initialM34 defines 4th value of 3rd row
  3150. * @param initialM41 defines 1st value of 4th row
  3151. * @param initialM42 defines 2nd value of 4th row
  3152. * @param initialM43 defines 3rd value of 4th row
  3153. * @param initialM44 defines 4th value of 4th row
  3154. * @param result defines the target matrix
  3155. */
  3156. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3157. /**
  3158. * Creates new matrix from a list of values (16)
  3159. * @param initialM11 defines 1st value of 1st row
  3160. * @param initialM12 defines 2nd value of 1st row
  3161. * @param initialM13 defines 3rd value of 1st row
  3162. * @param initialM14 defines 4th value of 1st row
  3163. * @param initialM21 defines 1st value of 2nd row
  3164. * @param initialM22 defines 2nd value of 2nd row
  3165. * @param initialM23 defines 3rd value of 2nd row
  3166. * @param initialM24 defines 4th value of 2nd row
  3167. * @param initialM31 defines 1st value of 3rd row
  3168. * @param initialM32 defines 2nd value of 3rd row
  3169. * @param initialM33 defines 3rd value of 3rd row
  3170. * @param initialM34 defines 4th value of 3rd row
  3171. * @param initialM41 defines 1st value of 4th row
  3172. * @param initialM42 defines 2nd value of 4th row
  3173. * @param initialM43 defines 3rd value of 4th row
  3174. * @param initialM44 defines 4th value of 4th row
  3175. * @returns the new matrix
  3176. */
  3177. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3178. /**
  3179. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @returns a new matrix
  3184. */
  3185. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3186. /**
  3187. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3188. * @param scale defines the scale vector3
  3189. * @param rotation defines the rotation quaternion
  3190. * @param translation defines the translation vector3
  3191. * @param result defines the target matrix
  3192. */
  3193. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3194. /**
  3195. * Creates a new identity matrix
  3196. * @returns a new identity matrix
  3197. */
  3198. static Identity(): Matrix;
  3199. /**
  3200. * Creates a new identity matrix and stores the result in a given matrix
  3201. * @param result defines the target matrix
  3202. */
  3203. static IdentityToRef(result: Matrix): void;
  3204. /**
  3205. * Creates a new zero matrix
  3206. * @returns a new zero matrix
  3207. */
  3208. static Zero(): Matrix;
  3209. /**
  3210. * Creates a new rotation matrix for "angle" radians around the X axis
  3211. * @param angle defines the angle (in radians) to use
  3212. * @return the new matrix
  3213. */
  3214. static RotationX(angle: number): Matrix;
  3215. /**
  3216. * Creates a new matrix as the invert of a given matrix
  3217. * @param source defines the source matrix
  3218. * @returns the new matrix
  3219. */
  3220. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3221. /**
  3222. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3223. * @param angle defines the angle (in radians) to use
  3224. * @param result defines the target matrix
  3225. */
  3226. static RotationXToRef(angle: number, result: Matrix): void;
  3227. /**
  3228. * Creates a new rotation matrix for "angle" radians around the Y axis
  3229. * @param angle defines the angle (in radians) to use
  3230. * @return the new matrix
  3231. */
  3232. static RotationY(angle: number): Matrix;
  3233. /**
  3234. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3235. * @param angle defines the angle (in radians) to use
  3236. * @param result defines the target matrix
  3237. */
  3238. static RotationYToRef(angle: number, result: Matrix): void;
  3239. /**
  3240. * Creates a new rotation matrix for "angle" radians around the Z axis
  3241. * @param angle defines the angle (in radians) to use
  3242. * @return the new matrix
  3243. */
  3244. static RotationZ(angle: number): Matrix;
  3245. /**
  3246. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3247. * @param angle defines the angle (in radians) to use
  3248. * @param result defines the target matrix
  3249. */
  3250. static RotationZToRef(angle: number, result: Matrix): void;
  3251. /**
  3252. * Creates a new rotation matrix for "angle" radians around the given axis
  3253. * @param axis defines the axis to use
  3254. * @param angle defines the angle (in radians) to use
  3255. * @return the new matrix
  3256. */
  3257. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3258. /**
  3259. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3260. * @param axis defines the axis to use
  3261. * @param angle defines the angle (in radians) to use
  3262. * @param result defines the target matrix
  3263. */
  3264. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3265. /**
  3266. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3267. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3268. * @param from defines the vector to align
  3269. * @param to defines the vector to align to
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3273. /**
  3274. * Creates a rotation matrix
  3275. * @param yaw defines the yaw angle in radians (Y axis)
  3276. * @param pitch defines the pitch angle in radians (X axis)
  3277. * @param roll defines the roll angle in radians (X axis)
  3278. * @returns the new rotation matrix
  3279. */
  3280. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3281. /**
  3282. * Creates a rotation matrix and stores it in a given matrix
  3283. * @param yaw defines the yaw angle in radians (Y axis)
  3284. * @param pitch defines the pitch angle in radians (X axis)
  3285. * @param roll defines the roll angle in radians (X axis)
  3286. * @param result defines the target matrix
  3287. */
  3288. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3289. /**
  3290. * Creates a scaling matrix
  3291. * @param x defines the scale factor on X axis
  3292. * @param y defines the scale factor on Y axis
  3293. * @param z defines the scale factor on Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Scaling(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a scaling matrix and stores it in a given matrix
  3299. * @param x defines the scale factor on X axis
  3300. * @param y defines the scale factor on Y axis
  3301. * @param z defines the scale factor on Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Creates a translation matrix
  3307. * @param x defines the translation on X axis
  3308. * @param y defines the translation on Y axis
  3309. * @param z defines the translationon Z axis
  3310. * @returns the new matrix
  3311. */
  3312. static Translation(x: number, y: number, z: number): Matrix;
  3313. /**
  3314. * Creates a translation matrix and stores it in a given matrix
  3315. * @param x defines the translation on X axis
  3316. * @param y defines the translation on Y axis
  3317. * @param z defines the translationon Z axis
  3318. * @param result defines the target matrix
  3319. */
  3320. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3321. /**
  3322. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3323. * @param startValue defines the start value
  3324. * @param endValue defines the end value
  3325. * @param gradient defines the gradient factor
  3326. * @returns the new matrix
  3327. */
  3328. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3329. /**
  3330. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3331. * @param startValue defines the start value
  3332. * @param endValue defines the end value
  3333. * @param gradient defines the gradient factor
  3334. * @param result defines the Matrix object where to store data
  3335. */
  3336. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3337. /**
  3338. * Builds a new matrix whose values are computed by:
  3339. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3340. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3341. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3342. * @param startValue defines the first matrix
  3343. * @param endValue defines the second matrix
  3344. * @param gradient defines the gradient between the two matrices
  3345. * @returns the new matrix
  3346. */
  3347. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3348. /**
  3349. * Update a matrix to values which are computed by:
  3350. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3351. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3352. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3353. * @param startValue defines the first matrix
  3354. * @param endValue defines the second matrix
  3355. * @param gradient defines the gradient between the two matrices
  3356. * @param result defines the target matrix
  3357. */
  3358. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3359. /**
  3360. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3361. * This function works in left handed mode
  3362. * @param eye defines the final position of the entity
  3363. * @param target defines where the entity should look at
  3364. * @param up defines the up vector for the entity
  3365. * @returns the new matrix
  3366. */
  3367. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3368. /**
  3369. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3370. * This function works in left handed mode
  3371. * @param eye defines the final position of the entity
  3372. * @param target defines where the entity should look at
  3373. * @param up defines the up vector for the entity
  3374. * @param result defines the target matrix
  3375. */
  3376. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3377. /**
  3378. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3379. * This function works in right handed mode
  3380. * @param eye defines the final position of the entity
  3381. * @param target defines where the entity should look at
  3382. * @param up defines the up vector for the entity
  3383. * @returns the new matrix
  3384. */
  3385. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3386. /**
  3387. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3388. * This function works in right handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @param result defines the target matrix
  3393. */
  3394. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3395. /**
  3396. * Create a left-handed orthographic projection matrix
  3397. * @param width defines the viewport width
  3398. * @param height defines the viewport height
  3399. * @param znear defines the near clip plane
  3400. * @param zfar defines the far clip plane
  3401. * @returns a new matrix as a left-handed orthographic projection matrix
  3402. */
  3403. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3404. /**
  3405. * Store a left-handed orthographic projection to a given matrix
  3406. * @param width defines the viewport width
  3407. * @param height defines the viewport height
  3408. * @param znear defines the near clip plane
  3409. * @param zfar defines the far clip plane
  3410. * @param result defines the target matrix
  3411. */
  3412. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3413. /**
  3414. * Create a left-handed orthographic projection matrix
  3415. * @param left defines the viewport left coordinate
  3416. * @param right defines the viewport right coordinate
  3417. * @param bottom defines the viewport bottom coordinate
  3418. * @param top defines the viewport top coordinate
  3419. * @param znear defines the near clip plane
  3420. * @param zfar defines the far clip plane
  3421. * @returns a new matrix as a left-handed orthographic projection matrix
  3422. */
  3423. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3424. /**
  3425. * Stores a left-handed orthographic projection into a given matrix
  3426. * @param left defines the viewport left coordinate
  3427. * @param right defines the viewport right coordinate
  3428. * @param bottom defines the viewport bottom coordinate
  3429. * @param top defines the viewport top coordinate
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @param result defines the target matrix
  3433. */
  3434. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3435. /**
  3436. * Creates a right-handed orthographic projection matrix
  3437. * @param left defines the viewport left coordinate
  3438. * @param right defines the viewport right coordinate
  3439. * @param bottom defines the viewport bottom coordinate
  3440. * @param top defines the viewport top coordinate
  3441. * @param znear defines the near clip plane
  3442. * @param zfar defines the far clip plane
  3443. * @returns a new matrix as a right-handed orthographic projection matrix
  3444. */
  3445. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3446. /**
  3447. * Stores a right-handed orthographic projection into a given matrix
  3448. * @param left defines the viewport left coordinate
  3449. * @param right defines the viewport right coordinate
  3450. * @param bottom defines the viewport bottom coordinate
  3451. * @param top defines the viewport top coordinate
  3452. * @param znear defines the near clip plane
  3453. * @param zfar defines the far clip plane
  3454. * @param result defines the target matrix
  3455. */
  3456. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3457. /**
  3458. * Creates a left-handed perspective projection matrix
  3459. * @param width defines the viewport width
  3460. * @param height defines the viewport height
  3461. * @param znear defines the near clip plane
  3462. * @param zfar defines the far clip plane
  3463. * @returns a new matrix as a left-handed perspective projection matrix
  3464. */
  3465. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3466. /**
  3467. * Creates a left-handed perspective projection matrix
  3468. * @param fov defines the horizontal field of view
  3469. * @param aspect defines the aspect ratio
  3470. * @param znear defines the near clip plane
  3471. * @param zfar defines the far clip plane
  3472. * @returns a new matrix as a left-handed perspective projection matrix
  3473. */
  3474. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3475. /**
  3476. * Stores a left-handed perspective projection into a given matrix
  3477. * @param fov defines the horizontal field of view
  3478. * @param aspect defines the aspect ratio
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3483. */
  3484. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3485. /**
  3486. * Creates a right-handed perspective projection matrix
  3487. * @param fov defines the horizontal field of view
  3488. * @param aspect defines the aspect ratio
  3489. * @param znear defines the near clip plane
  3490. * @param zfar defines the far clip plane
  3491. * @returns a new matrix as a right-handed perspective projection matrix
  3492. */
  3493. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3494. /**
  3495. * Stores a right-handed perspective projection into a given matrix
  3496. * @param fov defines the horizontal field of view
  3497. * @param aspect defines the aspect ratio
  3498. * @param znear defines the near clip plane
  3499. * @param zfar defines the far clip plane
  3500. * @param result defines the target matrix
  3501. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3502. */
  3503. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3504. /**
  3505. * Stores a perspective projection for WebVR info a given matrix
  3506. * @param fov defines the field of view
  3507. * @param znear defines the near clip plane
  3508. * @param zfar defines the far clip plane
  3509. * @param result defines the target matrix
  3510. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3511. */
  3512. static PerspectiveFovWebVRToRef(fov: {
  3513. upDegrees: number;
  3514. downDegrees: number;
  3515. leftDegrees: number;
  3516. rightDegrees: number;
  3517. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3518. /**
  3519. * Computes a complete transformation matrix
  3520. * @param viewport defines the viewport to use
  3521. * @param world defines the world matrix
  3522. * @param view defines the view matrix
  3523. * @param projection defines the projection matrix
  3524. * @param zmin defines the near clip plane
  3525. * @param zmax defines the far clip plane
  3526. * @returns the transformation matrix
  3527. */
  3528. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3529. /**
  3530. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3531. * @param matrix defines the matrix to use
  3532. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3533. */
  3534. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3535. /**
  3536. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3537. * @param matrix defines the matrix to use
  3538. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3539. */
  3540. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3541. /**
  3542. * Compute the transpose of a given matrix
  3543. * @param matrix defines the matrix to transpose
  3544. * @returns the new matrix
  3545. */
  3546. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3547. /**
  3548. * Compute the transpose of a matrix and store it in a target matrix
  3549. * @param matrix defines the matrix to transpose
  3550. * @param result defines the target matrix
  3551. */
  3552. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3553. /**
  3554. * Computes a reflection matrix from a plane
  3555. * @param plane defines the reflection plane
  3556. * @returns a new matrix
  3557. */
  3558. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3559. /**
  3560. * Computes a reflection matrix from a plane
  3561. * @param plane defines the reflection plane
  3562. * @param result defines the target matrix
  3563. */
  3564. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3565. /**
  3566. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3567. * @param xaxis defines the value of the 1st axis
  3568. * @param yaxis defines the value of the 2nd axis
  3569. * @param zaxis defines the value of the 3rd axis
  3570. * @param result defines the target matrix
  3571. */
  3572. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3573. /**
  3574. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3575. * @param quat defines the quaternion to use
  3576. * @param result defines the target matrix
  3577. */
  3578. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3579. }
  3580. /**
  3581. * Represens a plane by the equation ax + by + cz + d = 0
  3582. */
  3583. export class Plane {
  3584. /**
  3585. * Normal of the plane (a,b,c)
  3586. */
  3587. normal: Vector3;
  3588. /**
  3589. * d component of the plane
  3590. */
  3591. d: number;
  3592. /**
  3593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3594. * @param a a component of the plane
  3595. * @param b b component of the plane
  3596. * @param c c component of the plane
  3597. * @param d d component of the plane
  3598. */
  3599. constructor(a: number, b: number, c: number, d: number);
  3600. /**
  3601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3602. */
  3603. asArray(): number[];
  3604. /**
  3605. * @returns a new plane copied from the current Plane.
  3606. */
  3607. clone(): Plane;
  3608. /**
  3609. * @returns the string "Plane".
  3610. */
  3611. getClassName(): string;
  3612. /**
  3613. * @returns the Plane hash code.
  3614. */
  3615. getHashCode(): number;
  3616. /**
  3617. * Normalize the current Plane in place.
  3618. * @returns the updated Plane.
  3619. */
  3620. normalize(): Plane;
  3621. /**
  3622. * Applies a transformation the plane and returns the result
  3623. * @param transformation the transformation matrix to be applied to the plane
  3624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3625. */
  3626. transform(transformation: DeepImmutable<Matrix>): Plane;
  3627. /**
  3628. * Calcualtte the dot product between the point and the plane normal
  3629. * @param point point to calculate the dot product with
  3630. * @returns the dot product (float) of the point coordinates and the plane normal.
  3631. */
  3632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3633. /**
  3634. * Updates the current Plane from the plane defined by the three given points.
  3635. * @param point1 one of the points used to contruct the plane
  3636. * @param point2 one of the points used to contruct the plane
  3637. * @param point3 one of the points used to contruct the plane
  3638. * @returns the updated Plane.
  3639. */
  3640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3641. /**
  3642. * Checks if the plane is facing a given direction
  3643. * @param direction the direction to check if the plane is facing
  3644. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3645. * @returns True is the vector "direction" is the same side than the plane normal.
  3646. */
  3647. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3648. /**
  3649. * Calculates the distance to a point
  3650. * @param point point to calculate distance to
  3651. * @returns the signed distance (float) from the given point to the Plane.
  3652. */
  3653. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3654. /**
  3655. * Creates a plane from an array
  3656. * @param array the array to create a plane from
  3657. * @returns a new Plane from the given array.
  3658. */
  3659. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3660. /**
  3661. * Creates a plane from three points
  3662. * @param point1 point used to create the plane
  3663. * @param point2 point used to create the plane
  3664. * @param point3 point used to create the plane
  3665. * @returns a new Plane defined by the three given points.
  3666. */
  3667. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Creates a plane from an origin point and a normal
  3670. * @param origin origin of the plane to be constructed
  3671. * @param normal normal of the plane to be constructed
  3672. * @returns a new Plane the normal vector to this plane at the given origin point.
  3673. * Note : the vector "normal" is updated because normalized.
  3674. */
  3675. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3676. /**
  3677. * Calculates the distance from a plane and a point
  3678. * @param origin origin of the plane to be constructed
  3679. * @param normal normal of the plane to be constructed
  3680. * @param point point to calculate distance to
  3681. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3682. */
  3683. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3684. }
  3685. /**
  3686. * Class used to represent a viewport on screen
  3687. */
  3688. export class Viewport {
  3689. /** viewport left coordinate */
  3690. x: number;
  3691. /** viewport top coordinate */
  3692. y: number;
  3693. /**viewport width */
  3694. width: number;
  3695. /** viewport height */
  3696. height: number;
  3697. /**
  3698. * Creates a Viewport object located at (x, y) and sized (width, height)
  3699. * @param x defines viewport left coordinate
  3700. * @param y defines viewport top coordinate
  3701. * @param width defines the viewport width
  3702. * @param height defines the viewport height
  3703. */
  3704. constructor(
  3705. /** viewport left coordinate */
  3706. x: number,
  3707. /** viewport top coordinate */
  3708. y: number,
  3709. /**viewport width */
  3710. width: number,
  3711. /** viewport height */
  3712. height: number);
  3713. /**
  3714. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3715. * @param renderWidth defines the rendering width
  3716. * @param renderHeight defines the rendering height
  3717. * @returns a new Viewport
  3718. */
  3719. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3720. /**
  3721. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3722. * @param renderWidth defines the rendering width
  3723. * @param renderHeight defines the rendering height
  3724. * @param ref defines the target viewport
  3725. * @returns the current viewport
  3726. */
  3727. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3728. /**
  3729. * Returns a new Viewport copied from the current one
  3730. * @returns a new Viewport
  3731. */
  3732. clone(): Viewport;
  3733. }
  3734. /**
  3735. * Reprasents a camera frustum
  3736. */
  3737. export class Frustum {
  3738. /**
  3739. * Gets the planes representing the frustum
  3740. * @param transform matrix to be applied to the returned planes
  3741. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3742. */
  3743. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3744. /**
  3745. * Gets the near frustum plane transformed by the transform matrix
  3746. * @param transform transformation matrix to be applied to the resulting frustum plane
  3747. * @param frustumPlane the resuling frustum plane
  3748. */
  3749. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3750. /**
  3751. * Gets the far frustum plane transformed by the transform matrix
  3752. * @param transform transformation matrix to be applied to the resulting frustum plane
  3753. * @param frustumPlane the resuling frustum plane
  3754. */
  3755. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3756. /**
  3757. * Gets the left frustum plane transformed by the transform matrix
  3758. * @param transform transformation matrix to be applied to the resulting frustum plane
  3759. * @param frustumPlane the resuling frustum plane
  3760. */
  3761. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3762. /**
  3763. * Gets the right frustum plane transformed by the transform matrix
  3764. * @param transform transformation matrix to be applied to the resulting frustum plane
  3765. * @param frustumPlane the resuling frustum plane
  3766. */
  3767. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3768. /**
  3769. * Gets the top frustum plane transformed by the transform matrix
  3770. * @param transform transformation matrix to be applied to the resulting frustum plane
  3771. * @param frustumPlane the resuling frustum plane
  3772. */
  3773. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3774. /**
  3775. * Gets the bottom frustum plane transformed by the transform matrix
  3776. * @param transform transformation matrix to be applied to the resulting frustum plane
  3777. * @param frustumPlane the resuling frustum plane
  3778. */
  3779. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3780. /**
  3781. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3782. * @param transform transformation matrix to be applied to the resulting frustum planes
  3783. * @param frustumPlanes the resuling frustum planes
  3784. */
  3785. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3786. }
  3787. /** Defines supported spaces */
  3788. export enum Space {
  3789. /** Local (object) space */
  3790. LOCAL = 0,
  3791. /** World space */
  3792. WORLD = 1,
  3793. /** Bone space */
  3794. BONE = 2
  3795. }
  3796. /** Defines the 3 main axes */
  3797. export class Axis {
  3798. /** X axis */
  3799. static X: Vector3;
  3800. /** Y axis */
  3801. static Y: Vector3;
  3802. /** Z axis */
  3803. static Z: Vector3;
  3804. }
  3805. /** Class used to represent a Bezier curve */
  3806. export class BezierCurve {
  3807. /**
  3808. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3809. * @param t defines the time
  3810. * @param x1 defines the left coordinate on X axis
  3811. * @param y1 defines the left coordinate on Y axis
  3812. * @param x2 defines the right coordinate on X axis
  3813. * @param y2 defines the right coordinate on Y axis
  3814. * @returns the interpolated value
  3815. */
  3816. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3817. }
  3818. /**
  3819. * Defines potential orientation for back face culling
  3820. */
  3821. export enum Orientation {
  3822. /**
  3823. * Clockwise
  3824. */
  3825. CW = 0,
  3826. /** Counter clockwise */
  3827. CCW = 1
  3828. }
  3829. /**
  3830. * Defines angle representation
  3831. */
  3832. export class Angle {
  3833. private _radians;
  3834. /**
  3835. * Creates an Angle object of "radians" radians (float).
  3836. * @param radians the angle in radians
  3837. */
  3838. constructor(radians: number);
  3839. /**
  3840. * Get value in degrees
  3841. * @returns the Angle value in degrees (float)
  3842. */
  3843. degrees(): number;
  3844. /**
  3845. * Get value in radians
  3846. * @returns the Angle value in radians (float)
  3847. */
  3848. radians(): number;
  3849. /**
  3850. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3851. * @param a defines first vector
  3852. * @param b defines second vector
  3853. * @returns a new Angle
  3854. */
  3855. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3856. /**
  3857. * Gets a new Angle object from the given float in radians
  3858. * @param radians defines the angle value in radians
  3859. * @returns a new Angle
  3860. */
  3861. static FromRadians(radians: number): Angle;
  3862. /**
  3863. * Gets a new Angle object from the given float in degrees
  3864. * @param degrees defines the angle value in degrees
  3865. * @returns a new Angle
  3866. */
  3867. static FromDegrees(degrees: number): Angle;
  3868. }
  3869. /**
  3870. * This represents an arc in a 2d space.
  3871. */
  3872. export class Arc2 {
  3873. /** Defines the start point of the arc */
  3874. startPoint: Vector2;
  3875. /** Defines the mid point of the arc */
  3876. midPoint: Vector2;
  3877. /** Defines the end point of the arc */
  3878. endPoint: Vector2;
  3879. /**
  3880. * Defines the center point of the arc.
  3881. */
  3882. centerPoint: Vector2;
  3883. /**
  3884. * Defines the radius of the arc.
  3885. */
  3886. radius: number;
  3887. /**
  3888. * Defines the angle of the arc (from mid point to end point).
  3889. */
  3890. angle: Angle;
  3891. /**
  3892. * Defines the start angle of the arc (from start point to middle point).
  3893. */
  3894. startAngle: Angle;
  3895. /**
  3896. * Defines the orientation of the arc (clock wise/counter clock wise).
  3897. */
  3898. orientation: Orientation;
  3899. /**
  3900. * Creates an Arc object from the three given points : start, middle and end.
  3901. * @param startPoint Defines the start point of the arc
  3902. * @param midPoint Defines the midlle point of the arc
  3903. * @param endPoint Defines the end point of the arc
  3904. */
  3905. constructor(
  3906. /** Defines the start point of the arc */
  3907. startPoint: Vector2,
  3908. /** Defines the mid point of the arc */
  3909. midPoint: Vector2,
  3910. /** Defines the end point of the arc */
  3911. endPoint: Vector2);
  3912. }
  3913. /**
  3914. * Represents a 2D path made up of multiple 2D points
  3915. */
  3916. export class Path2 {
  3917. private _points;
  3918. private _length;
  3919. /**
  3920. * If the path start and end point are the same
  3921. */
  3922. closed: boolean;
  3923. /**
  3924. * Creates a Path2 object from the starting 2D coordinates x and y.
  3925. * @param x the starting points x value
  3926. * @param y the starting points y value
  3927. */
  3928. constructor(x: number, y: number);
  3929. /**
  3930. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3931. * @param x the added points x value
  3932. * @param y the added points y value
  3933. * @returns the updated Path2.
  3934. */
  3935. addLineTo(x: number, y: number): Path2;
  3936. /**
  3937. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3938. * @param midX middle point x value
  3939. * @param midY middle point y value
  3940. * @param endX end point x value
  3941. * @param endY end point y value
  3942. * @param numberOfSegments (default: 36)
  3943. * @returns the updated Path2.
  3944. */
  3945. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3946. /**
  3947. * Closes the Path2.
  3948. * @returns the Path2.
  3949. */
  3950. close(): Path2;
  3951. /**
  3952. * Gets the sum of the distance between each sequential point in the path
  3953. * @returns the Path2 total length (float).
  3954. */
  3955. length(): number;
  3956. /**
  3957. * Gets the points which construct the path
  3958. * @returns the Path2 internal array of points.
  3959. */
  3960. getPoints(): Vector2[];
  3961. /**
  3962. * Retreives the point at the distance aways from the starting point
  3963. * @param normalizedLengthPosition the length along the path to retreive the point from
  3964. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3965. */
  3966. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3967. /**
  3968. * Creates a new path starting from an x and y position
  3969. * @param x starting x value
  3970. * @param y starting y value
  3971. * @returns a new Path2 starting at the coordinates (x, y).
  3972. */
  3973. static StartingAt(x: number, y: number): Path2;
  3974. }
  3975. /**
  3976. * Represents a 3D path made up of multiple 3D points
  3977. */
  3978. export class Path3D {
  3979. /**
  3980. * an array of Vector3, the curve axis of the Path3D
  3981. */
  3982. path: Vector3[];
  3983. private _curve;
  3984. private _distances;
  3985. private _tangents;
  3986. private _normals;
  3987. private _binormals;
  3988. private _raw;
  3989. /**
  3990. * new Path3D(path, normal, raw)
  3991. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3992. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3993. * @param path an array of Vector3, the curve axis of the Path3D
  3994. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3995. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3996. */
  3997. constructor(
  3998. /**
  3999. * an array of Vector3, the curve axis of the Path3D
  4000. */
  4001. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4002. /**
  4003. * Returns the Path3D array of successive Vector3 designing its curve.
  4004. * @returns the Path3D array of successive Vector3 designing its curve.
  4005. */
  4006. getCurve(): Vector3[];
  4007. /**
  4008. * Returns an array populated with tangent vectors on each Path3D curve point.
  4009. * @returns an array populated with tangent vectors on each Path3D curve point.
  4010. */
  4011. getTangents(): Vector3[];
  4012. /**
  4013. * Returns an array populated with normal vectors on each Path3D curve point.
  4014. * @returns an array populated with normal vectors on each Path3D curve point.
  4015. */
  4016. getNormals(): Vector3[];
  4017. /**
  4018. * Returns an array populated with binormal vectors on each Path3D curve point.
  4019. * @returns an array populated with binormal vectors on each Path3D curve point.
  4020. */
  4021. getBinormals(): Vector3[];
  4022. /**
  4023. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4024. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4025. */
  4026. getDistances(): number[];
  4027. /**
  4028. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4029. * @param path path which all values are copied into the curves points
  4030. * @param firstNormal which should be projected onto the curve
  4031. * @returns the same object updated.
  4032. */
  4033. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4034. private _compute;
  4035. private _getFirstNonNullVector;
  4036. private _getLastNonNullVector;
  4037. private _normalVector;
  4038. }
  4039. /**
  4040. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4041. * A Curve3 is designed from a series of successive Vector3.
  4042. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4043. */
  4044. export class Curve3 {
  4045. private _points;
  4046. private _length;
  4047. /**
  4048. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4049. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4050. * @param v1 (Vector3) the control point
  4051. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4052. * @param nbPoints (integer) the wanted number of points in the curve
  4053. * @returns the created Curve3
  4054. */
  4055. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4056. /**
  4057. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4058. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4059. * @param v1 (Vector3) the first control point
  4060. * @param v2 (Vector3) the second control point
  4061. * @param v3 (Vector3) the end point of the Cubic Bezier
  4062. * @param nbPoints (integer) the wanted number of points in the curve
  4063. * @returns the created Curve3
  4064. */
  4065. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4066. /**
  4067. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4068. * @param p1 (Vector3) the origin point of the Hermite Spline
  4069. * @param t1 (Vector3) the tangent vector at the origin point
  4070. * @param p2 (Vector3) the end point of the Hermite Spline
  4071. * @param t2 (Vector3) the tangent vector at the end point
  4072. * @param nbPoints (integer) the wanted number of points in the curve
  4073. * @returns the created Curve3
  4074. */
  4075. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4076. /**
  4077. * Returns a Curve3 object along a CatmullRom Spline curve :
  4078. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4079. * @param nbPoints (integer) the wanted number of points between each curve control points
  4080. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4081. * @returns the created Curve3
  4082. */
  4083. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4084. /**
  4085. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4086. * A Curve3 is designed from a series of successive Vector3.
  4087. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4088. * @param points points which make up the curve
  4089. */
  4090. constructor(points: Vector3[]);
  4091. /**
  4092. * @returns the Curve3 stored array of successive Vector3
  4093. */
  4094. getPoints(): Vector3[];
  4095. /**
  4096. * @returns the computed length (float) of the curve.
  4097. */
  4098. length(): number;
  4099. /**
  4100. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4101. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4102. * curveA and curveB keep unchanged.
  4103. * @param curve the curve to continue from this curve
  4104. * @returns the newly constructed curve
  4105. */
  4106. continue(curve: DeepImmutable<Curve3>): Curve3;
  4107. private _computeLength;
  4108. }
  4109. /**
  4110. * Contains position and normal vectors for a vertex
  4111. */
  4112. export class PositionNormalVertex {
  4113. /** the position of the vertex (defaut: 0,0,0) */
  4114. position: Vector3;
  4115. /** the normal of the vertex (defaut: 0,1,0) */
  4116. normal: Vector3;
  4117. /**
  4118. * Creates a PositionNormalVertex
  4119. * @param position the position of the vertex (defaut: 0,0,0)
  4120. * @param normal the normal of the vertex (defaut: 0,1,0)
  4121. */
  4122. constructor(
  4123. /** the position of the vertex (defaut: 0,0,0) */
  4124. position?: Vector3,
  4125. /** the normal of the vertex (defaut: 0,1,0) */
  4126. normal?: Vector3);
  4127. /**
  4128. * Clones the PositionNormalVertex
  4129. * @returns the cloned PositionNormalVertex
  4130. */
  4131. clone(): PositionNormalVertex;
  4132. }
  4133. /**
  4134. * Contains position, normal and uv vectors for a vertex
  4135. */
  4136. export class PositionNormalTextureVertex {
  4137. /** the position of the vertex (defaut: 0,0,0) */
  4138. position: Vector3;
  4139. /** the normal of the vertex (defaut: 0,1,0) */
  4140. normal: Vector3;
  4141. /** the uv of the vertex (default: 0,0) */
  4142. uv: Vector2;
  4143. /**
  4144. * Creates a PositionNormalTextureVertex
  4145. * @param position the position of the vertex (defaut: 0,0,0)
  4146. * @param normal the normal of the vertex (defaut: 0,1,0)
  4147. * @param uv the uv of the vertex (default: 0,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3,
  4154. /** the uv of the vertex (default: 0,0) */
  4155. uv?: Vector2);
  4156. /**
  4157. * Clones the PositionNormalTextureVertex
  4158. * @returns the cloned PositionNormalTextureVertex
  4159. */
  4160. clone(): PositionNormalTextureVertex;
  4161. }
  4162. /**
  4163. * @hidden
  4164. */
  4165. export class Tmp {
  4166. static Color3: Color3[];
  4167. static Color4: Color4[];
  4168. static Vector2: Vector2[];
  4169. static Vector3: Vector3[];
  4170. static Vector4: Vector4[];
  4171. static Quaternion: Quaternion[];
  4172. static Matrix: Matrix[];
  4173. }
  4174. }
  4175. declare module BABYLON {
  4176. /**
  4177. * Class used to enable access to offline support
  4178. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4179. */
  4180. export interface IOfflineProvider {
  4181. /**
  4182. * Gets a boolean indicating if scene must be saved in the database
  4183. */
  4184. enableSceneOffline: boolean;
  4185. /**
  4186. * Gets a boolean indicating if textures must be saved in the database
  4187. */
  4188. enableTexturesOffline: boolean;
  4189. /**
  4190. * Open the offline support and make it available
  4191. * @param successCallback defines the callback to call on success
  4192. * @param errorCallback defines the callback to call on error
  4193. */
  4194. open(successCallback: () => void, errorCallback: () => void): void;
  4195. /**
  4196. * Loads an image from the offline support
  4197. * @param url defines the url to load from
  4198. * @param image defines the target DOM image
  4199. */
  4200. loadImage(url: string, image: HTMLImageElement): void;
  4201. /**
  4202. * Loads a file from offline support
  4203. * @param url defines the URL to load from
  4204. * @param sceneLoaded defines a callback to call on success
  4205. * @param progressCallBack defines a callback to call when progress changed
  4206. * @param errorCallback defines a callback to call on error
  4207. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4208. */
  4209. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4210. }
  4211. }
  4212. declare module BABYLON {
  4213. /**
  4214. * A class serves as a medium between the observable and its observers
  4215. */
  4216. export class EventState {
  4217. /**
  4218. * Create a new EventState
  4219. * @param mask defines the mask associated with this state
  4220. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4221. * @param target defines the original target of the state
  4222. * @param currentTarget defines the current target of the state
  4223. */
  4224. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4225. /**
  4226. * Initialize the current event state
  4227. * @param mask defines the mask associated with this state
  4228. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4229. * @param target defines the original target of the state
  4230. * @param currentTarget defines the current target of the state
  4231. * @returns the current event state
  4232. */
  4233. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4234. /**
  4235. * An Observer can set this property to true to prevent subsequent observers of being notified
  4236. */
  4237. skipNextObservers: boolean;
  4238. /**
  4239. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4240. */
  4241. mask: number;
  4242. /**
  4243. * The object that originally notified the event
  4244. */
  4245. target?: any;
  4246. /**
  4247. * The current object in the bubbling phase
  4248. */
  4249. currentTarget?: any;
  4250. /**
  4251. * This will be populated with the return value of the last function that was executed.
  4252. * If it is the first function in the callback chain it will be the event data.
  4253. */
  4254. lastReturnValue?: any;
  4255. }
  4256. /**
  4257. * Represent an Observer registered to a given Observable object.
  4258. */
  4259. export class Observer<T> {
  4260. /**
  4261. * Defines the callback to call when the observer is notified
  4262. */
  4263. callback: (eventData: T, eventState: EventState) => void;
  4264. /**
  4265. * Defines the mask of the observer (used to filter notifications)
  4266. */
  4267. mask: number;
  4268. /**
  4269. * Defines the current scope used to restore the JS context
  4270. */
  4271. scope: any;
  4272. /** @hidden */ willBeUnregistered: boolean;
  4273. /**
  4274. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4275. */
  4276. unregisterOnNextCall: boolean;
  4277. /**
  4278. * Creates a new observer
  4279. * @param callback defines the callback to call when the observer is notified
  4280. * @param mask defines the mask of the observer (used to filter notifications)
  4281. * @param scope defines the current scope used to restore the JS context
  4282. */
  4283. constructor(
  4284. /**
  4285. * Defines the callback to call when the observer is notified
  4286. */
  4287. callback: (eventData: T, eventState: EventState) => void,
  4288. /**
  4289. * Defines the mask of the observer (used to filter notifications)
  4290. */
  4291. mask: number,
  4292. /**
  4293. * Defines the current scope used to restore the JS context
  4294. */
  4295. scope?: any);
  4296. }
  4297. /**
  4298. * Represent a list of observers registered to multiple Observables object.
  4299. */
  4300. export class MultiObserver<T> {
  4301. private _observers;
  4302. private _observables;
  4303. /**
  4304. * Release associated resources
  4305. */
  4306. dispose(): void;
  4307. /**
  4308. * Raise a callback when one of the observable will notify
  4309. * @param observables defines a list of observables to watch
  4310. * @param callback defines the callback to call on notification
  4311. * @param mask defines the mask used to filter notifications
  4312. * @param scope defines the current scope used to restore the JS context
  4313. * @returns the new MultiObserver
  4314. */
  4315. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4316. }
  4317. /**
  4318. * The Observable class is a simple implementation of the Observable pattern.
  4319. *
  4320. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4321. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4322. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4323. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4324. */
  4325. export class Observable<T> {
  4326. private _observers;
  4327. private _eventState;
  4328. private _onObserverAdded;
  4329. /**
  4330. * Creates a new observable
  4331. * @param onObserverAdded defines a callback to call when a new observer is added
  4332. */
  4333. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4334. /**
  4335. * Create a new Observer with the specified callback
  4336. * @param callback the callback that will be executed for that Observer
  4337. * @param mask the mask used to filter observers
  4338. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4339. * @param scope optional scope for the callback to be called from
  4340. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4341. * @returns the new observer created for the callback
  4342. */
  4343. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4344. /**
  4345. * Create a new Observer with the specified callback and unregisters after the next notification
  4346. * @param callback the callback that will be executed for that Observer
  4347. * @returns the new observer created for the callback
  4348. */
  4349. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4350. /**
  4351. * Remove an Observer from the Observable object
  4352. * @param observer the instance of the Observer to remove
  4353. * @returns false if it doesn't belong to this Observable
  4354. */
  4355. remove(observer: Nullable<Observer<T>>): boolean;
  4356. /**
  4357. * Remove a callback from the Observable object
  4358. * @param callback the callback to remove
  4359. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4360. * @returns false if it doesn't belong to this Observable
  4361. */
  4362. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4363. private _deferUnregister;
  4364. private _remove;
  4365. /**
  4366. * Moves the observable to the top of the observer list making it get called first when notified
  4367. * @param observer the observer to move
  4368. */
  4369. makeObserverTopPriority(observer: Observer<T>): void;
  4370. /**
  4371. * Moves the observable to the bottom of the observer list making it get called last when notified
  4372. * @param observer the observer to move
  4373. */
  4374. makeObserverBottomPriority(observer: Observer<T>): void;
  4375. /**
  4376. * Notify all Observers by calling their respective callback with the given data
  4377. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4378. * @param eventData defines the data to send to all observers
  4379. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4380. * @param target defines the original target of the state
  4381. * @param currentTarget defines the current target of the state
  4382. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4383. */
  4384. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4385. /**
  4386. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4387. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4388. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4389. * and it is crucial that all callbacks will be executed.
  4390. * The order of the callbacks is kept, callbacks are not executed parallel.
  4391. *
  4392. * @param eventData The data to be sent to each callback
  4393. * @param mask is used to filter observers defaults to -1
  4394. * @param target defines the callback target (see EventState)
  4395. * @param currentTarget defines he current object in the bubbling phase
  4396. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4397. */
  4398. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4399. /**
  4400. * Notify a specific observer
  4401. * @param observer defines the observer to notify
  4402. * @param eventData defines the data to be sent to each callback
  4403. * @param mask is used to filter observers defaults to -1
  4404. */
  4405. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4406. /**
  4407. * Gets a boolean indicating if the observable has at least one observer
  4408. * @returns true is the Observable has at least one Observer registered
  4409. */
  4410. hasObservers(): boolean;
  4411. /**
  4412. * Clear the list of observers
  4413. */
  4414. clear(): void;
  4415. /**
  4416. * Clone the current observable
  4417. * @returns a new observable
  4418. */
  4419. clone(): Observable<T>;
  4420. /**
  4421. * Does this observable handles observer registered with a given mask
  4422. * @param mask defines the mask to be tested
  4423. * @return whether or not one observer registered with the given mask is handeled
  4424. **/
  4425. hasSpecificMask(mask?: number): boolean;
  4426. }
  4427. }
  4428. declare module BABYLON {
  4429. /**
  4430. * Class used to help managing file picking and drag'n'drop
  4431. * File Storage
  4432. */
  4433. export class FilesInputStore {
  4434. /**
  4435. * List of files ready to be loaded
  4436. */
  4437. static FilesToLoad: {
  4438. [key: string]: File;
  4439. };
  4440. }
  4441. }
  4442. declare module BABYLON {
  4443. /** Defines the cross module used constants to avoid circular dependncies */
  4444. export class Constants {
  4445. /** Defines that alpha blending is disabled */
  4446. static readonly ALPHA_DISABLE: number;
  4447. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4448. static readonly ALPHA_ADD: number;
  4449. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4450. static readonly ALPHA_COMBINE: number;
  4451. /** Defines that alpha blending to DEST - SRC * DEST */
  4452. static readonly ALPHA_SUBTRACT: number;
  4453. /** Defines that alpha blending to SRC * DEST */
  4454. static readonly ALPHA_MULTIPLY: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4456. static readonly ALPHA_MAXIMIZED: number;
  4457. /** Defines that alpha blending to SRC + DEST */
  4458. static readonly ALPHA_ONEONE: number;
  4459. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4460. static readonly ALPHA_PREMULTIPLIED: number;
  4461. /**
  4462. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4463. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4464. */
  4465. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4466. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4467. static readonly ALPHA_INTERPOLATE: number;
  4468. /**
  4469. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4470. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4471. */
  4472. static readonly ALPHA_SCREENMODE: number;
  4473. /** Defines that the ressource is not delayed*/
  4474. static readonly DELAYLOADSTATE_NONE: number;
  4475. /** Defines that the ressource was successfully delay loaded */
  4476. static readonly DELAYLOADSTATE_LOADED: number;
  4477. /** Defines that the ressource is currently delay loading */
  4478. static readonly DELAYLOADSTATE_LOADING: number;
  4479. /** Defines that the ressource is delayed and has not started loading */
  4480. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4481. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4482. static readonly NEVER: number;
  4483. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4484. static readonly ALWAYS: number;
  4485. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4486. static readonly LESS: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4488. static readonly EQUAL: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4490. static readonly LEQUAL: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4492. static readonly GREATER: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4494. static readonly GEQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4496. static readonly NOTEQUAL: number;
  4497. /** Passed to stencilOperation to specify that stencil value must be kept */
  4498. static readonly KEEP: number;
  4499. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4500. static readonly REPLACE: number;
  4501. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4502. static readonly INCR: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4504. static readonly DECR: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4506. static readonly INVERT: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4508. static readonly INCR_WRAP: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4510. static readonly DECR_WRAP: number;
  4511. /** Texture is not repeating outside of 0..1 UVs */
  4512. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4513. /** Texture is repeating outside of 0..1 UVs */
  4514. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4515. /** Texture is repeating and mirrored */
  4516. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4517. /** ALPHA */
  4518. static readonly TEXTUREFORMAT_ALPHA: number;
  4519. /** LUMINANCE */
  4520. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4521. /** LUMINANCE_ALPHA */
  4522. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4523. /** RGB */
  4524. static readonly TEXTUREFORMAT_RGB: number;
  4525. /** RGBA */
  4526. static readonly TEXTUREFORMAT_RGBA: number;
  4527. /** RED */
  4528. static readonly TEXTUREFORMAT_RED: number;
  4529. /** RED (2nd reference) */
  4530. static readonly TEXTUREFORMAT_R: number;
  4531. /** RG */
  4532. static readonly TEXTUREFORMAT_RG: number;
  4533. /** RED_INTEGER */
  4534. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4535. /** RED_INTEGER (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4537. /** RG_INTEGER */
  4538. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4539. /** RGB_INTEGER */
  4540. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4541. /** RGBA_INTEGER */
  4542. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4543. /** UNSIGNED_BYTE */
  4544. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4545. /** UNSIGNED_BYTE (2nd reference) */
  4546. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4547. /** FLOAT */
  4548. static readonly TEXTURETYPE_FLOAT: number;
  4549. /** HALF_FLOAT */
  4550. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4551. /** BYTE */
  4552. static readonly TEXTURETYPE_BYTE: number;
  4553. /** SHORT */
  4554. static readonly TEXTURETYPE_SHORT: number;
  4555. /** UNSIGNED_SHORT */
  4556. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4557. /** INT */
  4558. static readonly TEXTURETYPE_INT: number;
  4559. /** UNSIGNED_INT */
  4560. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4561. /** UNSIGNED_SHORT_4_4_4_4 */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4563. /** UNSIGNED_SHORT_5_5_5_1 */
  4564. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4565. /** UNSIGNED_SHORT_5_6_5 */
  4566. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4567. /** UNSIGNED_INT_2_10_10_10_REV */
  4568. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4569. /** UNSIGNED_INT_24_8 */
  4570. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4571. /** UNSIGNED_INT_10F_11F_11F_REV */
  4572. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4573. /** UNSIGNED_INT_5_9_9_9_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4575. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4576. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4577. /** nearest is mag = nearest and min = nearest and mip = linear */
  4578. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4579. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4580. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4581. /** Trilinear is mag = linear and min = linear and mip = linear */
  4582. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4589. /** mag = nearest and min = nearest and mip = nearest */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4591. /** mag = nearest and min = linear and mip = nearest */
  4592. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4593. /** mag = nearest and min = linear and mip = linear */
  4594. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = linear and mip = none */
  4596. static readonly TEXTURE_NEAREST_LINEAR: number;
  4597. /** mag = nearest and min = nearest and mip = none */
  4598. static readonly TEXTURE_NEAREST_NEAREST: number;
  4599. /** mag = linear and min = nearest and mip = nearest */
  4600. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4601. /** mag = linear and min = nearest and mip = linear */
  4602. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4603. /** mag = linear and min = linear and mip = none */
  4604. static readonly TEXTURE_LINEAR_LINEAR: number;
  4605. /** mag = linear and min = nearest and mip = none */
  4606. static readonly TEXTURE_LINEAR_NEAREST: number;
  4607. /** Explicit coordinates mode */
  4608. static readonly TEXTURE_EXPLICIT_MODE: number;
  4609. /** Spherical coordinates mode */
  4610. static readonly TEXTURE_SPHERICAL_MODE: number;
  4611. /** Planar coordinates mode */
  4612. static readonly TEXTURE_PLANAR_MODE: number;
  4613. /** Cubic coordinates mode */
  4614. static readonly TEXTURE_CUBIC_MODE: number;
  4615. /** Projection coordinates mode */
  4616. static readonly TEXTURE_PROJECTION_MODE: number;
  4617. /** Skybox coordinates mode */
  4618. static readonly TEXTURE_SKYBOX_MODE: number;
  4619. /** Inverse Cubic coordinates mode */
  4620. static readonly TEXTURE_INVCUBIC_MODE: number;
  4621. /** Equirectangular coordinates mode */
  4622. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4623. /** Equirectangular Fixed coordinates mode */
  4624. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4625. /** Equirectangular Fixed Mirrored coordinates mode */
  4626. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4627. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4628. static readonly SCALEMODE_FLOOR: number;
  4629. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4630. static readonly SCALEMODE_NEAREST: number;
  4631. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4632. static readonly SCALEMODE_CEILING: number;
  4633. /**
  4634. * The dirty texture flag value
  4635. */
  4636. static readonly MATERIAL_TextureDirtyFlag: number;
  4637. /**
  4638. * The dirty light flag value
  4639. */
  4640. static readonly MATERIAL_LightDirtyFlag: number;
  4641. /**
  4642. * The dirty fresnel flag value
  4643. */
  4644. static readonly MATERIAL_FresnelDirtyFlag: number;
  4645. /**
  4646. * The dirty attribute flag value
  4647. */
  4648. static readonly MATERIAL_AttributesDirtyFlag: number;
  4649. /**
  4650. * The dirty misc flag value
  4651. */
  4652. static readonly MATERIAL_MiscDirtyFlag: number;
  4653. /**
  4654. * The all dirty flag value
  4655. */
  4656. static readonly MATERIAL_AllDirtyFlag: number;
  4657. /**
  4658. * Returns the triangle fill mode
  4659. */
  4660. static readonly MATERIAL_TriangleFillMode: number;
  4661. /**
  4662. * Returns the wireframe mode
  4663. */
  4664. static readonly MATERIAL_WireFrameFillMode: number;
  4665. /**
  4666. * Returns the point fill mode
  4667. */
  4668. static readonly MATERIAL_PointFillMode: number;
  4669. /**
  4670. * Returns the point list draw mode
  4671. */
  4672. static readonly MATERIAL_PointListDrawMode: number;
  4673. /**
  4674. * Returns the line list draw mode
  4675. */
  4676. static readonly MATERIAL_LineListDrawMode: number;
  4677. /**
  4678. * Returns the line loop draw mode
  4679. */
  4680. static readonly MATERIAL_LineLoopDrawMode: number;
  4681. /**
  4682. * Returns the line strip draw mode
  4683. */
  4684. static readonly MATERIAL_LineStripDrawMode: number;
  4685. /**
  4686. * Returns the triangle strip draw mode
  4687. */
  4688. static readonly MATERIAL_TriangleStripDrawMode: number;
  4689. /**
  4690. * Returns the triangle fan draw mode
  4691. */
  4692. static readonly MATERIAL_TriangleFanDrawMode: number;
  4693. /**
  4694. * Stores the clock-wise side orientation
  4695. */
  4696. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4697. /**
  4698. * Stores the counter clock-wise side orientation
  4699. */
  4700. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4701. /**
  4702. * Nothing
  4703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4704. */
  4705. static readonly ACTION_NothingTrigger: number;
  4706. /**
  4707. * On pick
  4708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4709. */
  4710. static readonly ACTION_OnPickTrigger: number;
  4711. /**
  4712. * On left pick
  4713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4714. */
  4715. static readonly ACTION_OnLeftPickTrigger: number;
  4716. /**
  4717. * On right pick
  4718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4719. */
  4720. static readonly ACTION_OnRightPickTrigger: number;
  4721. /**
  4722. * On center pick
  4723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4724. */
  4725. static readonly ACTION_OnCenterPickTrigger: number;
  4726. /**
  4727. * On pick down
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickDownTrigger: number;
  4731. /**
  4732. * On double pick
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnDoublePickTrigger: number;
  4736. /**
  4737. * On pick up
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPickUpTrigger: number;
  4741. /**
  4742. * On pick out.
  4743. * This trigger will only be raised if you also declared a OnPickDown
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickOutTrigger: number;
  4747. /**
  4748. * On long press
  4749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4750. */
  4751. static readonly ACTION_OnLongPressTrigger: number;
  4752. /**
  4753. * On pointer over
  4754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4755. */
  4756. static readonly ACTION_OnPointerOverTrigger: number;
  4757. /**
  4758. * On pointer out
  4759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4760. */
  4761. static readonly ACTION_OnPointerOutTrigger: number;
  4762. /**
  4763. * On every frame
  4764. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4765. */
  4766. static readonly ACTION_OnEveryFrameTrigger: number;
  4767. /**
  4768. * On intersection enter
  4769. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4770. */
  4771. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4772. /**
  4773. * On intersection exit
  4774. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4775. */
  4776. static readonly ACTION_OnIntersectionExitTrigger: number;
  4777. /**
  4778. * On key down
  4779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4780. */
  4781. static readonly ACTION_OnKeyDownTrigger: number;
  4782. /**
  4783. * On key up
  4784. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4785. */
  4786. static readonly ACTION_OnKeyUpTrigger: number;
  4787. /**
  4788. * Billboard mode will only apply to Y axis
  4789. */
  4790. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4791. /**
  4792. * Billboard mode will apply to all axes
  4793. */
  4794. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4795. /**
  4796. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4797. */
  4798. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4799. /**
  4800. * Gets or sets base Assets URL
  4801. */
  4802. static readonly PARTICLES_BaseAssetsUrl: string;
  4803. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4804. * Test order :
  4805. * Is the bounding sphere outside the frustum ?
  4806. * If not, are the bounding box vertices outside the frustum ?
  4807. * It not, then the cullable object is in the frustum.
  4808. */
  4809. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4810. /** Culling strategy : Bounding Sphere Only.
  4811. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4812. * It's also less accurate than the standard because some not visible objects can still be selected.
  4813. * Test : is the bounding sphere outside the frustum ?
  4814. * If not, then the cullable object is in the frustum.
  4815. */
  4816. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4817. /** Culling strategy : Optimistic Inclusion.
  4818. * This in an inclusion test first, then the standard exclusion test.
  4819. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4820. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4821. * Anyway, it's as accurate as the standard strategy.
  4822. * Test :
  4823. * Is the cullable object bounding sphere center in the frustum ?
  4824. * If not, apply the default culling strategy.
  4825. */
  4826. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4827. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4828. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4829. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4830. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4831. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4832. * Test :
  4833. * Is the cullable object bounding sphere center in the frustum ?
  4834. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4835. */
  4836. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4837. /**
  4838. * No logging while loading
  4839. */
  4840. static readonly SCENELOADER_NO_LOGGING: number;
  4841. /**
  4842. * Minimal logging while loading
  4843. */
  4844. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4845. /**
  4846. * Summary logging while loading
  4847. */
  4848. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4849. /**
  4850. * Detailled logging while loading
  4851. */
  4852. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4853. }
  4854. }
  4855. declare module BABYLON {
  4856. /**
  4857. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4858. * Babylon.js
  4859. */
  4860. export class DomManagement {
  4861. /**
  4862. * Checks if the window object exists
  4863. * @returns true if the window object exists
  4864. */
  4865. static IsWindowObjectExist(): boolean;
  4866. /**
  4867. * Extracts text content from a DOM element hierarchy
  4868. * @param element defines the root element
  4869. * @returns a string
  4870. */
  4871. static GetDOMTextContent(element: HTMLElement): string;
  4872. }
  4873. }
  4874. declare module BABYLON {
  4875. /**
  4876. * Logger used througouht the application to allow configuration of
  4877. * the log level required for the messages.
  4878. */
  4879. export class Logger {
  4880. /**
  4881. * No log
  4882. */
  4883. static readonly NoneLogLevel: number;
  4884. /**
  4885. * Only message logs
  4886. */
  4887. static readonly MessageLogLevel: number;
  4888. /**
  4889. * Only warning logs
  4890. */
  4891. static readonly WarningLogLevel: number;
  4892. /**
  4893. * Only error logs
  4894. */
  4895. static readonly ErrorLogLevel: number;
  4896. /**
  4897. * All logs
  4898. */
  4899. static readonly AllLogLevel: number;
  4900. private static _LogCache;
  4901. /**
  4902. * Gets a value indicating the number of loading errors
  4903. * @ignorenaming
  4904. */
  4905. static errorsCount: number;
  4906. /**
  4907. * Callback called when a new log is added
  4908. */
  4909. static OnNewCacheEntry: (entry: string) => void;
  4910. private static _AddLogEntry;
  4911. private static _FormatMessage;
  4912. private static _LogDisabled;
  4913. private static _LogEnabled;
  4914. private static _WarnDisabled;
  4915. private static _WarnEnabled;
  4916. private static _ErrorDisabled;
  4917. private static _ErrorEnabled;
  4918. /**
  4919. * Log a message to the console
  4920. */
  4921. static Log: (message: string) => void;
  4922. /**
  4923. * Write a warning message to the console
  4924. */
  4925. static Warn: (message: string) => void;
  4926. /**
  4927. * Write an error message to the console
  4928. */
  4929. static Error: (message: string) => void;
  4930. /**
  4931. * Gets current log cache (list of logs)
  4932. */
  4933. static readonly LogCache: string;
  4934. /**
  4935. * Clears the log cache
  4936. */
  4937. static ClearLogCache(): void;
  4938. /**
  4939. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4940. */
  4941. static LogLevels: number;
  4942. }
  4943. }
  4944. declare module BABYLON {
  4945. /** @hidden */
  4946. export class _TypeStore {
  4947. /** @hidden */
  4948. static RegisteredTypes: {
  4949. [key: string]: Object;
  4950. };
  4951. /** @hidden */
  4952. static GetClass(fqdn: string): any;
  4953. }
  4954. }
  4955. declare module BABYLON {
  4956. /**
  4957. * Class containing a set of static utilities functions for deep copy.
  4958. */
  4959. export class DeepCopier {
  4960. /**
  4961. * Tries to copy an object by duplicating every property
  4962. * @param source defines the source object
  4963. * @param destination defines the target object
  4964. * @param doNotCopyList defines a list of properties to avoid
  4965. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4966. */
  4967. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4968. }
  4969. }
  4970. declare module BABYLON {
  4971. /**
  4972. * Class containing a set of static utilities functions for precision date
  4973. */
  4974. export class PrecisionDate {
  4975. /**
  4976. * Gets either window.performance.now() if supported or Date.now() else
  4977. */
  4978. static readonly Now: number;
  4979. }
  4980. }
  4981. declare module BABYLON {
  4982. /** @hidden */
  4983. export class _DevTools {
  4984. static WarnImport(name: string): string;
  4985. }
  4986. }
  4987. declare module BABYLON {
  4988. /**
  4989. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4990. */
  4991. export class WebRequest {
  4992. private _xhr;
  4993. /**
  4994. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4995. * i.e. when loading files, where the server/service expects an Authorization header
  4996. */
  4997. static CustomRequestHeaders: {
  4998. [key: string]: string;
  4999. };
  5000. /**
  5001. * Add callback functions in this array to update all the requests before they get sent to the network
  5002. */
  5003. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5004. private _injectCustomRequestHeaders;
  5005. /**
  5006. * Gets or sets a function to be called when loading progress changes
  5007. */
  5008. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5009. /**
  5010. * Returns client's state
  5011. */
  5012. readonly readyState: number;
  5013. /**
  5014. * Returns client's status
  5015. */
  5016. readonly status: number;
  5017. /**
  5018. * Returns client's status as a text
  5019. */
  5020. readonly statusText: string;
  5021. /**
  5022. * Returns client's response
  5023. */
  5024. readonly response: any;
  5025. /**
  5026. * Returns client's response url
  5027. */
  5028. readonly responseURL: string;
  5029. /**
  5030. * Returns client's response as text
  5031. */
  5032. readonly responseText: string;
  5033. /**
  5034. * Gets or sets the expected response type
  5035. */
  5036. responseType: XMLHttpRequestResponseType;
  5037. /** @hidden */
  5038. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5039. /** @hidden */
  5040. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5041. /**
  5042. * Cancels any network activity
  5043. */
  5044. abort(): void;
  5045. /**
  5046. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5047. * @param body defines an optional request body
  5048. */
  5049. send(body?: Document | BodyInit | null): void;
  5050. /**
  5051. * Sets the request method, request URL
  5052. * @param method defines the method to use (GET, POST, etc..)
  5053. * @param url defines the url to connect with
  5054. */
  5055. open(method: string, url: string): void;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to evalaute queries containing `and` and `or` operators
  5061. */
  5062. export class AndOrNotEvaluator {
  5063. /**
  5064. * Evaluate a query
  5065. * @param query defines the query to evaluate
  5066. * @param evaluateCallback defines the callback used to filter result
  5067. * @returns true if the query matches
  5068. */
  5069. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5070. private static _HandleParenthesisContent;
  5071. private static _SimplifyNegation;
  5072. }
  5073. }
  5074. declare module BABYLON {
  5075. /**
  5076. * Class used to store custom tags
  5077. */
  5078. export class Tags {
  5079. /**
  5080. * Adds support for tags on the given object
  5081. * @param obj defines the object to use
  5082. */
  5083. static EnableFor(obj: any): void;
  5084. /**
  5085. * Removes tags support
  5086. * @param obj defines the object to use
  5087. */
  5088. static DisableFor(obj: any): void;
  5089. /**
  5090. * Gets a boolean indicating if the given object has tags
  5091. * @param obj defines the object to use
  5092. * @returns a boolean
  5093. */
  5094. static HasTags(obj: any): boolean;
  5095. /**
  5096. * Gets the tags available on a given object
  5097. * @param obj defines the object to use
  5098. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5099. * @returns the tags
  5100. */
  5101. static GetTags(obj: any, asString?: boolean): any;
  5102. /**
  5103. * Adds tags to an object
  5104. * @param obj defines the object to use
  5105. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5106. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5107. */
  5108. static AddTagsTo(obj: any, tagsString: string): void;
  5109. /**
  5110. * @hidden
  5111. */ private static _AddTagTo(obj: any, tag: string): void;
  5112. /**
  5113. * Removes specific tags from a specific object
  5114. * @param obj defines the object to use
  5115. * @param tagsString defines the tags to remove
  5116. */
  5117. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5118. /**
  5119. * @hidden
  5120. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5121. /**
  5122. * Defines if tags hosted on an object match a given query
  5123. * @param obj defines the object to use
  5124. * @param tagsQuery defines the tag query
  5125. * @returns a boolean
  5126. */
  5127. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5128. }
  5129. }
  5130. declare module BABYLON {
  5131. /**
  5132. * Manages the defines for the Material
  5133. */
  5134. export class MaterialDefines {
  5135. private _keys;
  5136. private _isDirty;
  5137. /** @hidden */ renderId: number;
  5138. /** @hidden */ areLightsDirty: boolean;
  5139. /** @hidden */ areAttributesDirty: boolean;
  5140. /** @hidden */ areTexturesDirty: boolean;
  5141. /** @hidden */ areFresnelDirty: boolean;
  5142. /** @hidden */ areMiscDirty: boolean;
  5143. /** @hidden */ areImageProcessingDirty: boolean;
  5144. /** @hidden */ normals: boolean;
  5145. /** @hidden */ uvs: boolean;
  5146. /** @hidden */ needNormals: boolean;
  5147. /** @hidden */ needUVs: boolean;
  5148. /**
  5149. * Specifies if the material needs to be re-calculated
  5150. */
  5151. readonly isDirty: boolean;
  5152. /**
  5153. * Marks the material to indicate that it has been re-calculated
  5154. */
  5155. markAsProcessed(): void;
  5156. /**
  5157. * Marks the material to indicate that it needs to be re-calculated
  5158. */
  5159. markAsUnprocessed(): void;
  5160. /**
  5161. * Marks the material to indicate all of its defines need to be re-calculated
  5162. */
  5163. markAllAsDirty(): void;
  5164. /**
  5165. * Marks the material to indicate that image processing needs to be re-calculated
  5166. */
  5167. markAsImageProcessingDirty(): void;
  5168. /**
  5169. * Marks the material to indicate the lights need to be re-calculated
  5170. */
  5171. markAsLightDirty(): void;
  5172. /**
  5173. * Marks the attribute state as changed
  5174. */
  5175. markAsAttributesDirty(): void;
  5176. /**
  5177. * Marks the texture state as changed
  5178. */
  5179. markAsTexturesDirty(): void;
  5180. /**
  5181. * Marks the fresnel state as changed
  5182. */
  5183. markAsFresnelDirty(): void;
  5184. /**
  5185. * Marks the misc state as changed
  5186. */
  5187. markAsMiscDirty(): void;
  5188. /**
  5189. * Rebuilds the material defines
  5190. */
  5191. rebuild(): void;
  5192. /**
  5193. * Specifies if two material defines are equal
  5194. * @param other - A material define instance to compare to
  5195. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5196. */
  5197. isEqual(other: MaterialDefines): boolean;
  5198. /**
  5199. * Clones this instance's defines to another instance
  5200. * @param other - material defines to clone values to
  5201. */
  5202. cloneTo(other: MaterialDefines): void;
  5203. /**
  5204. * Resets the material define values
  5205. */
  5206. reset(): void;
  5207. /**
  5208. * Converts the material define values to a string
  5209. * @returns - String of material define information
  5210. */
  5211. toString(): string;
  5212. }
  5213. }
  5214. declare module BABYLON {
  5215. /**
  5216. * Class used to store and describe the pipeline context associated with an effect
  5217. */
  5218. export interface IPipelineContext {
  5219. /**
  5220. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5221. */
  5222. isAsync: boolean;
  5223. /**
  5224. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5225. */
  5226. isReady: boolean;
  5227. /** @hidden */ handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5228. }
  5229. }
  5230. declare module BABYLON {
  5231. /**
  5232. * Class used to store gfx data (like WebGLBuffer)
  5233. */
  5234. export class DataBuffer {
  5235. /**
  5236. * Gets or sets the number of objects referencing this buffer
  5237. */
  5238. references: number;
  5239. /** Gets or sets the size of the underlying buffer */
  5240. capacity: number;
  5241. /**
  5242. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5243. */
  5244. is32Bits: boolean;
  5245. /**
  5246. * Gets the underlying buffer
  5247. */
  5248. readonly underlyingResource: any;
  5249. }
  5250. }
  5251. declare module BABYLON {
  5252. /**
  5253. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5254. */
  5255. export class PerformanceMonitor {
  5256. private _enabled;
  5257. private _rollingFrameTime;
  5258. private _lastFrameTimeMs;
  5259. /**
  5260. * constructor
  5261. * @param frameSampleSize The number of samples required to saturate the sliding window
  5262. */
  5263. constructor(frameSampleSize?: number);
  5264. /**
  5265. * Samples current frame
  5266. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5267. */
  5268. sampleFrame(timeMs?: number): void;
  5269. /**
  5270. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5271. */
  5272. readonly averageFrameTime: number;
  5273. /**
  5274. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5275. */
  5276. readonly averageFrameTimeVariance: number;
  5277. /**
  5278. * Returns the frame time of the most recent frame
  5279. */
  5280. readonly instantaneousFrameTime: number;
  5281. /**
  5282. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5283. */
  5284. readonly averageFPS: number;
  5285. /**
  5286. * Returns the average framerate in frames per second using the most recent frame time
  5287. */
  5288. readonly instantaneousFPS: number;
  5289. /**
  5290. * Returns true if enough samples have been taken to completely fill the sliding window
  5291. */
  5292. readonly isSaturated: boolean;
  5293. /**
  5294. * Enables contributions to the sliding window sample set
  5295. */
  5296. enable(): void;
  5297. /**
  5298. * Disables contributions to the sliding window sample set
  5299. * Samples will not be interpolated over the disabled period
  5300. */
  5301. disable(): void;
  5302. /**
  5303. * Returns true if sampling is enabled
  5304. */
  5305. readonly isEnabled: boolean;
  5306. /**
  5307. * Resets performance monitor
  5308. */
  5309. reset(): void;
  5310. }
  5311. /**
  5312. * RollingAverage
  5313. *
  5314. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5315. */
  5316. export class RollingAverage {
  5317. /**
  5318. * Current average
  5319. */
  5320. average: number;
  5321. /**
  5322. * Current variance
  5323. */
  5324. variance: number;
  5325. protected _samples: Array<number>;
  5326. protected _sampleCount: number;
  5327. protected _pos: number;
  5328. protected _m2: number;
  5329. /**
  5330. * constructor
  5331. * @param length The number of samples required to saturate the sliding window
  5332. */
  5333. constructor(length: number);
  5334. /**
  5335. * Adds a sample to the sample set
  5336. * @param v The sample value
  5337. */
  5338. add(v: number): void;
  5339. /**
  5340. * Returns previously added values or null if outside of history or outside the sliding window domain
  5341. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5342. * @return Value previously recorded with add() or null if outside of range
  5343. */
  5344. history(i: number): number;
  5345. /**
  5346. * Returns true if enough samples have been taken to completely fill the sliding window
  5347. * @return true if sample-set saturated
  5348. */
  5349. isSaturated(): boolean;
  5350. /**
  5351. * Resets the rolling average (equivalent to 0 samples taken so far)
  5352. */
  5353. reset(): void;
  5354. /**
  5355. * Wraps a value around the sample range boundaries
  5356. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5357. * @return Wrapped position in sample range
  5358. */
  5359. protected _wrapPosition(i: number): number;
  5360. }
  5361. }
  5362. declare module BABYLON {
  5363. /**
  5364. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5365. * The underlying implementation relies on an associative array to ensure the best performances.
  5366. * The value can be anything including 'null' but except 'undefined'
  5367. */
  5368. export class StringDictionary<T> {
  5369. /**
  5370. * This will clear this dictionary and copy the content from the 'source' one.
  5371. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5372. * @param source the dictionary to take the content from and copy to this dictionary
  5373. */
  5374. copyFrom(source: StringDictionary<T>): void;
  5375. /**
  5376. * Get a value based from its key
  5377. * @param key the given key to get the matching value from
  5378. * @return the value if found, otherwise undefined is returned
  5379. */
  5380. get(key: string): T | undefined;
  5381. /**
  5382. * Get a value from its key or add it if it doesn't exist.
  5383. * This method will ensure you that a given key/data will be present in the dictionary.
  5384. * @param key the given key to get the matching value from
  5385. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5386. * The factory will only be invoked if there's no data for the given key.
  5387. * @return the value corresponding to the key.
  5388. */
  5389. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5390. /**
  5391. * Get a value from its key if present in the dictionary otherwise add it
  5392. * @param key the key to get the value from
  5393. * @param val if there's no such key/value pair in the dictionary add it with this value
  5394. * @return the value corresponding to the key
  5395. */
  5396. getOrAdd(key: string, val: T): T;
  5397. /**
  5398. * Check if there's a given key in the dictionary
  5399. * @param key the key to check for
  5400. * @return true if the key is present, false otherwise
  5401. */
  5402. contains(key: string): boolean;
  5403. /**
  5404. * Add a new key and its corresponding value
  5405. * @param key the key to add
  5406. * @param value the value corresponding to the key
  5407. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  5408. */
  5409. add(key: string, value: T): boolean;
  5410. /**
  5411. * Update a specific value associated to a key
  5412. * @param key defines the key to use
  5413. * @param value defines the value to store
  5414. * @returns true if the value was updated (or false if the key was not found)
  5415. */
  5416. set(key: string, value: T): boolean;
  5417. /**
  5418. * Get the element of the given key and remove it from the dictionary
  5419. * @param key defines the key to search
  5420. * @returns the value associated with the key or null if not found
  5421. */
  5422. getAndRemove(key: string): Nullable<T>;
  5423. /**
  5424. * Remove a key/value from the dictionary.
  5425. * @param key the key to remove
  5426. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5427. */
  5428. remove(key: string): boolean;
  5429. /**
  5430. * Clear the whole content of the dictionary
  5431. */
  5432. clear(): void;
  5433. /**
  5434. * Gets the current count
  5435. */
  5436. readonly count: number;
  5437. /**
  5438. * Execute a callback on each key/val of the dictionary.
  5439. * Note that you can remove any element in this dictionary in the callback implementation
  5440. * @param callback the callback to execute on a given key/value pair
  5441. */
  5442. forEach(callback: (key: string, val: T) => void): void;
  5443. /**
  5444. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5445. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5446. * Note that you can remove any element in this dictionary in the callback implementation
  5447. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5448. * @returns the first item
  5449. */
  5450. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5451. private _count;
  5452. private _data;
  5453. }
  5454. }
  5455. declare module BABYLON {
  5456. /**
  5457. * Helper class that provides a small promise polyfill
  5458. */
  5459. export class PromisePolyfill {
  5460. /**
  5461. * Static function used to check if the polyfill is required
  5462. * If this is the case then the function will inject the polyfill to window.Promise
  5463. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5464. */
  5465. static Apply(force?: boolean): void;
  5466. }
  5467. }
  5468. declare module BABYLON {
  5469. /**
  5470. * Class used to store data that will be store in GPU memory
  5471. */
  5472. export class Buffer {
  5473. private _engine;
  5474. private _buffer;
  5475. /** @hidden */ data: Nullable<DataArray>;
  5476. private _updatable;
  5477. private _instanced;
  5478. /**
  5479. * Gets the byte stride.
  5480. */
  5481. readonly byteStride: number;
  5482. /**
  5483. * Constructor
  5484. * @param engine the engine
  5485. * @param data the data to use for this buffer
  5486. * @param updatable whether the data is updatable
  5487. * @param stride the stride (optional)
  5488. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5489. * @param instanced whether the buffer is instanced (optional)
  5490. * @param useBytes set to true if the stride in in bytes (optional)
  5491. */
  5492. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5493. /**
  5494. * Create a new VertexBuffer based on the current buffer
  5495. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5496. * @param offset defines offset in the buffer (0 by default)
  5497. * @param size defines the size in floats of attributes (position is 3 for instance)
  5498. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5499. * @param instanced defines if the vertex buffer contains indexed data
  5500. * @param useBytes defines if the offset and stride are in bytes
  5501. * @returns the new vertex buffer
  5502. */
  5503. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5504. /**
  5505. * Gets a boolean indicating if the Buffer is updatable?
  5506. * @returns true if the buffer is updatable
  5507. */
  5508. isUpdatable(): boolean;
  5509. /**
  5510. * Gets current buffer's data
  5511. * @returns a DataArray or null
  5512. */
  5513. getData(): Nullable<DataArray>;
  5514. /**
  5515. * Gets underlying native buffer
  5516. * @returns underlying native buffer
  5517. */
  5518. getBuffer(): Nullable<DataBuffer>;
  5519. /**
  5520. * Gets the stride in float32 units (i.e. byte stride / 4).
  5521. * May not be an integer if the byte stride is not divisible by 4.
  5522. * DEPRECATED. Use byteStride instead.
  5523. * @returns the stride in float32 units
  5524. */
  5525. getStrideSize(): number;
  5526. /**
  5527. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5528. * @param data defines the data to store
  5529. */
  5530. create(data?: Nullable<DataArray>): void;
  5531. /** @hidden */ rebuild(): void;
  5532. /**
  5533. * Update current buffer data
  5534. * @param data defines the data to store
  5535. */
  5536. update(data: DataArray): void;
  5537. /**
  5538. * Updates the data directly.
  5539. * @param data the new data
  5540. * @param offset the new offset
  5541. * @param vertexCount the vertex count (optional)
  5542. * @param useBytes set to true if the offset is in bytes
  5543. */
  5544. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5545. /**
  5546. * Release all resources
  5547. */
  5548. dispose(): void;
  5549. }
  5550. /**
  5551. * Specialized buffer used to store vertex data
  5552. */
  5553. export class VertexBuffer {
  5554. /** @hidden */ buffer: Buffer;
  5555. private _kind;
  5556. private _size;
  5557. private _ownsBuffer;
  5558. private _instanced;
  5559. private _instanceDivisor;
  5560. /**
  5561. * The byte type.
  5562. */
  5563. static readonly BYTE: number;
  5564. /**
  5565. * The unsigned byte type.
  5566. */
  5567. static readonly UNSIGNED_BYTE: number;
  5568. /**
  5569. * The short type.
  5570. */
  5571. static readonly SHORT: number;
  5572. /**
  5573. * The unsigned short type.
  5574. */
  5575. static readonly UNSIGNED_SHORT: number;
  5576. /**
  5577. * The integer type.
  5578. */
  5579. static readonly INT: number;
  5580. /**
  5581. * The unsigned integer type.
  5582. */
  5583. static readonly UNSIGNED_INT: number;
  5584. /**
  5585. * The float type.
  5586. */
  5587. static readonly FLOAT: number;
  5588. /**
  5589. * Gets or sets the instance divisor when in instanced mode
  5590. */
  5591. instanceDivisor: number;
  5592. /**
  5593. * Gets the byte stride.
  5594. */
  5595. readonly byteStride: number;
  5596. /**
  5597. * Gets the byte offset.
  5598. */
  5599. readonly byteOffset: number;
  5600. /**
  5601. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5602. */
  5603. readonly normalized: boolean;
  5604. /**
  5605. * Gets the data type of each component in the array.
  5606. */
  5607. readonly type: number;
  5608. /**
  5609. * Constructor
  5610. * @param engine the engine
  5611. * @param data the data to use for this vertex buffer
  5612. * @param kind the vertex buffer kind
  5613. * @param updatable whether the data is updatable
  5614. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5615. * @param stride the stride (optional)
  5616. * @param instanced whether the buffer is instanced (optional)
  5617. * @param offset the offset of the data (optional)
  5618. * @param size the number of components (optional)
  5619. * @param type the type of the component (optional)
  5620. * @param normalized whether the data contains normalized data (optional)
  5621. * @param useBytes set to true if stride and offset are in bytes (optional)
  5622. */
  5623. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  5624. /** @hidden */ rebuild(): void;
  5625. /**
  5626. * Returns the kind of the VertexBuffer (string)
  5627. * @returns a string
  5628. */
  5629. getKind(): string;
  5630. /**
  5631. * Gets a boolean indicating if the VertexBuffer is updatable?
  5632. * @returns true if the buffer is updatable
  5633. */
  5634. isUpdatable(): boolean;
  5635. /**
  5636. * Gets current buffer's data
  5637. * @returns a DataArray or null
  5638. */
  5639. getData(): Nullable<DataArray>;
  5640. /**
  5641. * Gets underlying native buffer
  5642. * @returns underlying native buffer
  5643. */
  5644. getBuffer(): Nullable<DataBuffer>;
  5645. /**
  5646. * Gets the stride in float32 units (i.e. byte stride / 4).
  5647. * May not be an integer if the byte stride is not divisible by 4.
  5648. * DEPRECATED. Use byteStride instead.
  5649. * @returns the stride in float32 units
  5650. */
  5651. getStrideSize(): number;
  5652. /**
  5653. * Returns the offset as a multiple of the type byte length.
  5654. * DEPRECATED. Use byteOffset instead.
  5655. * @returns the offset in bytes
  5656. */
  5657. getOffset(): number;
  5658. /**
  5659. * Returns the number of components per vertex attribute (integer)
  5660. * @returns the size in float
  5661. */
  5662. getSize(): number;
  5663. /**
  5664. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5665. * @returns true if this buffer is instanced
  5666. */
  5667. getIsInstanced(): boolean;
  5668. /**
  5669. * Returns the instancing divisor, zero for non-instanced (integer).
  5670. * @returns a number
  5671. */
  5672. getInstanceDivisor(): number;
  5673. /**
  5674. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5675. * @param data defines the data to store
  5676. */
  5677. create(data?: DataArray): void;
  5678. /**
  5679. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5680. * This function will create a new buffer if the current one is not updatable
  5681. * @param data defines the data to store
  5682. */
  5683. update(data: DataArray): void;
  5684. /**
  5685. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5686. * Returns the directly updated WebGLBuffer.
  5687. * @param data the new data
  5688. * @param offset the new offset
  5689. * @param useBytes set to true if the offset is in bytes
  5690. */
  5691. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5692. /**
  5693. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5694. */
  5695. dispose(): void;
  5696. /**
  5697. * Enumerates each value of this vertex buffer as numbers.
  5698. * @param count the number of values to enumerate
  5699. * @param callback the callback function called for each value
  5700. */
  5701. forEach(count: number, callback: (value: number, index: number) => void): void;
  5702. /**
  5703. * Positions
  5704. */
  5705. static readonly PositionKind: string;
  5706. /**
  5707. * Normals
  5708. */
  5709. static readonly NormalKind: string;
  5710. /**
  5711. * Tangents
  5712. */
  5713. static readonly TangentKind: string;
  5714. /**
  5715. * Texture coordinates
  5716. */
  5717. static readonly UVKind: string;
  5718. /**
  5719. * Texture coordinates 2
  5720. */
  5721. static readonly UV2Kind: string;
  5722. /**
  5723. * Texture coordinates 3
  5724. */
  5725. static readonly UV3Kind: string;
  5726. /**
  5727. * Texture coordinates 4
  5728. */
  5729. static readonly UV4Kind: string;
  5730. /**
  5731. * Texture coordinates 5
  5732. */
  5733. static readonly UV5Kind: string;
  5734. /**
  5735. * Texture coordinates 6
  5736. */
  5737. static readonly UV6Kind: string;
  5738. /**
  5739. * Colors
  5740. */
  5741. static readonly ColorKind: string;
  5742. /**
  5743. * Matrix indices (for bones)
  5744. */
  5745. static readonly MatricesIndicesKind: string;
  5746. /**
  5747. * Matrix weights (for bones)
  5748. */
  5749. static readonly MatricesWeightsKind: string;
  5750. /**
  5751. * Additional matrix indices (for bones)
  5752. */
  5753. static readonly MatricesIndicesExtraKind: string;
  5754. /**
  5755. * Additional matrix weights (for bones)
  5756. */
  5757. static readonly MatricesWeightsExtraKind: string;
  5758. /**
  5759. * Deduces the stride given a kind.
  5760. * @param kind The kind string to deduce
  5761. * @returns The deduced stride
  5762. */
  5763. static DeduceStride(kind: string): number;
  5764. /**
  5765. * Gets the byte length of the given type.
  5766. * @param type the type
  5767. * @returns the number of bytes
  5768. */
  5769. static GetTypeByteLength(type: number): number;
  5770. /**
  5771. * Enumerates each value of the given parameters as numbers.
  5772. * @param data the data to enumerate
  5773. * @param byteOffset the byte offset of the data
  5774. * @param byteStride the byte stride of the data
  5775. * @param componentCount the number of components per element
  5776. * @param componentType the type of the component
  5777. * @param count the total number of components
  5778. * @param normalized whether the data is normalized
  5779. * @param callback the callback function called for each value
  5780. */
  5781. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5782. private static _GetFloatValue;
  5783. }
  5784. }
  5785. declare module BABYLON {
  5786. /**
  5787. * Class representing spherical harmonics coefficients to the 3rd degree
  5788. */
  5789. export class SphericalHarmonics {
  5790. /**
  5791. * Defines whether or not the harmonics have been prescaled for rendering.
  5792. */
  5793. preScaled: boolean;
  5794. /**
  5795. * The l0,0 coefficients of the spherical harmonics
  5796. */
  5797. l00: Vector3;
  5798. /**
  5799. * The l1,-1 coefficients of the spherical harmonics
  5800. */
  5801. l1_1: Vector3;
  5802. /**
  5803. * The l1,0 coefficients of the spherical harmonics
  5804. */
  5805. l10: Vector3;
  5806. /**
  5807. * The l1,1 coefficients of the spherical harmonics
  5808. */
  5809. l11: Vector3;
  5810. /**
  5811. * The l2,-2 coefficients of the spherical harmonics
  5812. */
  5813. l2_2: Vector3;
  5814. /**
  5815. * The l2,-1 coefficients of the spherical harmonics
  5816. */
  5817. l2_1: Vector3;
  5818. /**
  5819. * The l2,0 coefficients of the spherical harmonics
  5820. */
  5821. l20: Vector3;
  5822. /**
  5823. * The l2,1 coefficients of the spherical harmonics
  5824. */
  5825. l21: Vector3;
  5826. /**
  5827. * The l2,2 coefficients of the spherical harmonics
  5828. */
  5829. l22: Vector3;
  5830. /**
  5831. * Adds a light to the spherical harmonics
  5832. * @param direction the direction of the light
  5833. * @param color the color of the light
  5834. * @param deltaSolidAngle the delta solid angle of the light
  5835. */
  5836. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5837. /**
  5838. * Scales the spherical harmonics by the given amount
  5839. * @param scale the amount to scale
  5840. */
  5841. scaleInPlace(scale: number): void;
  5842. /**
  5843. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5844. *
  5845. * ```
  5846. * E_lm = A_l * L_lm
  5847. * ```
  5848. *
  5849. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5850. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5851. * the scaling factors are given in equation 9.
  5852. */
  5853. convertIncidentRadianceToIrradiance(): void;
  5854. /**
  5855. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5856. *
  5857. * ```
  5858. * L = (1/pi) * E * rho
  5859. * ```
  5860. *
  5861. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5862. */
  5863. convertIrradianceToLambertianRadiance(): void;
  5864. /**
  5865. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5866. * required operations at run time.
  5867. *
  5868. * This is simply done by scaling back the SH with Ylm constants parameter.
  5869. * The trigonometric part being applied by the shader at run time.
  5870. */
  5871. preScaleForRendering(): void;
  5872. /**
  5873. * Constructs a spherical harmonics from an array.
  5874. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5875. * @returns the spherical harmonics
  5876. */
  5877. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5878. /**
  5879. * Gets the spherical harmonics from polynomial
  5880. * @param polynomial the spherical polynomial
  5881. * @returns the spherical harmonics
  5882. */
  5883. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5884. }
  5885. /**
  5886. * Class representing spherical polynomial coefficients to the 3rd degree
  5887. */
  5888. export class SphericalPolynomial {
  5889. private _harmonics;
  5890. /**
  5891. * The spherical harmonics used to create the polynomials.
  5892. */
  5893. readonly preScaledHarmonics: SphericalHarmonics;
  5894. /**
  5895. * The x coefficients of the spherical polynomial
  5896. */
  5897. x: Vector3;
  5898. /**
  5899. * The y coefficients of the spherical polynomial
  5900. */
  5901. y: Vector3;
  5902. /**
  5903. * The z coefficients of the spherical polynomial
  5904. */
  5905. z: Vector3;
  5906. /**
  5907. * The xx coefficients of the spherical polynomial
  5908. */
  5909. xx: Vector3;
  5910. /**
  5911. * The yy coefficients of the spherical polynomial
  5912. */
  5913. yy: Vector3;
  5914. /**
  5915. * The zz coefficients of the spherical polynomial
  5916. */
  5917. zz: Vector3;
  5918. /**
  5919. * The xy coefficients of the spherical polynomial
  5920. */
  5921. xy: Vector3;
  5922. /**
  5923. * The yz coefficients of the spherical polynomial
  5924. */
  5925. yz: Vector3;
  5926. /**
  5927. * The zx coefficients of the spherical polynomial
  5928. */
  5929. zx: Vector3;
  5930. /**
  5931. * Adds an ambient color to the spherical polynomial
  5932. * @param color the color to add
  5933. */
  5934. addAmbient(color: Color3): void;
  5935. /**
  5936. * Scales the spherical polynomial by the given amount
  5937. * @param scale the amount to scale
  5938. */
  5939. scaleInPlace(scale: number): void;
  5940. /**
  5941. * Gets the spherical polynomial from harmonics
  5942. * @param harmonics the spherical harmonics
  5943. * @returns the spherical polynomial
  5944. */
  5945. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5946. /**
  5947. * Constructs a spherical polynomial from an array.
  5948. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5949. * @returns the spherical polynomial
  5950. */
  5951. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5952. }
  5953. }
  5954. declare module BABYLON {
  5955. /**
  5956. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5957. */
  5958. export interface CubeMapInfo {
  5959. /**
  5960. * The pixel array for the front face.
  5961. * This is stored in format, left to right, up to down format.
  5962. */
  5963. front: Nullable<ArrayBufferView>;
  5964. /**
  5965. * The pixel array for the back face.
  5966. * This is stored in format, left to right, up to down format.
  5967. */
  5968. back: Nullable<ArrayBufferView>;
  5969. /**
  5970. * The pixel array for the left face.
  5971. * This is stored in format, left to right, up to down format.
  5972. */
  5973. left: Nullable<ArrayBufferView>;
  5974. /**
  5975. * The pixel array for the right face.
  5976. * This is stored in format, left to right, up to down format.
  5977. */
  5978. right: Nullable<ArrayBufferView>;
  5979. /**
  5980. * The pixel array for the up face.
  5981. * This is stored in format, left to right, up to down format.
  5982. */
  5983. up: Nullable<ArrayBufferView>;
  5984. /**
  5985. * The pixel array for the down face.
  5986. * This is stored in format, left to right, up to down format.
  5987. */
  5988. down: Nullable<ArrayBufferView>;
  5989. /**
  5990. * The size of the cubemap stored.
  5991. *
  5992. * Each faces will be size * size pixels.
  5993. */
  5994. size: number;
  5995. /**
  5996. * The format of the texture.
  5997. *
  5998. * RGBA, RGB.
  5999. */
  6000. format: number;
  6001. /**
  6002. * The type of the texture data.
  6003. *
  6004. * UNSIGNED_INT, FLOAT.
  6005. */
  6006. type: number;
  6007. /**
  6008. * Specifies whether the texture is in gamma space.
  6009. */
  6010. gammaSpace: boolean;
  6011. }
  6012. /**
  6013. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6014. */
  6015. export class PanoramaToCubeMapTools {
  6016. private static FACE_FRONT;
  6017. private static FACE_BACK;
  6018. private static FACE_RIGHT;
  6019. private static FACE_LEFT;
  6020. private static FACE_DOWN;
  6021. private static FACE_UP;
  6022. /**
  6023. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6024. *
  6025. * @param float32Array The source data.
  6026. * @param inputWidth The width of the input panorama.
  6027. * @param inputHeight The height of the input panorama.
  6028. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6029. * @return The cubemap data
  6030. */
  6031. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6032. private static CreateCubemapTexture;
  6033. private static CalcProjectionSpherical;
  6034. }
  6035. }
  6036. declare module BABYLON {
  6037. /**
  6038. * Helper class dealing with the extraction of spherical polynomial dataArray
  6039. * from a cube map.
  6040. */
  6041. export class CubeMapToSphericalPolynomialTools {
  6042. private static FileFaces;
  6043. /**
  6044. * Converts a texture to the according Spherical Polynomial data.
  6045. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6046. *
  6047. * @param texture The texture to extract the information from.
  6048. * @return The Spherical Polynomial data.
  6049. */
  6050. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6051. /**
  6052. * Converts a cubemap to the according Spherical Polynomial data.
  6053. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6054. *
  6055. * @param cubeInfo The Cube map to extract the information from.
  6056. * @return The Spherical Polynomial data.
  6057. */
  6058. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6064. * during the life time of the application.
  6065. */
  6066. export class EngineStore {
  6067. /** Gets the list of created engines */
  6068. static Instances: Engine[];
  6069. /**
  6070. * Gets the latest created engine
  6071. */
  6072. static readonly LastCreatedEngine: Nullable<Engine>;
  6073. /**
  6074. * Gets the latest created scene
  6075. */
  6076. static readonly LastCreatedScene: Nullable<Scene>;
  6077. }
  6078. }
  6079. declare module BABYLON {
  6080. /**
  6081. * Define options used to create a render target texture
  6082. */
  6083. export class RenderTargetCreationOptions {
  6084. /**
  6085. * Specifies is mipmaps must be generated
  6086. */
  6087. generateMipMaps?: boolean;
  6088. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6089. generateDepthBuffer?: boolean;
  6090. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6091. generateStencilBuffer?: boolean;
  6092. /** Defines texture type (int by default) */
  6093. type?: number;
  6094. /** Defines sampling mode (trilinear by default) */
  6095. samplingMode?: number;
  6096. /** Defines format (RGBA by default) */
  6097. format?: number;
  6098. }
  6099. }
  6100. declare module BABYLON {
  6101. /**
  6102. * @hidden
  6103. **/
  6104. export class _AlphaState {
  6105. private _isAlphaBlendDirty;
  6106. private _isBlendFunctionParametersDirty;
  6107. private _isBlendEquationParametersDirty;
  6108. private _isBlendConstantsDirty;
  6109. private _alphaBlend;
  6110. private _blendFunctionParameters;
  6111. private _blendEquationParameters;
  6112. private _blendConstants;
  6113. /**
  6114. * Initializes the state.
  6115. */
  6116. constructor();
  6117. readonly isDirty: boolean;
  6118. alphaBlend: boolean;
  6119. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6120. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6121. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6122. reset(): void;
  6123. apply(gl: WebGLRenderingContext): void;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @hidden
  6129. **/
  6130. export class _DepthCullingState {
  6131. private _isDepthTestDirty;
  6132. private _isDepthMaskDirty;
  6133. private _isDepthFuncDirty;
  6134. private _isCullFaceDirty;
  6135. private _isCullDirty;
  6136. private _isZOffsetDirty;
  6137. private _isFrontFaceDirty;
  6138. private _depthTest;
  6139. private _depthMask;
  6140. private _depthFunc;
  6141. private _cull;
  6142. private _cullFace;
  6143. private _zOffset;
  6144. private _frontFace;
  6145. /**
  6146. * Initializes the state.
  6147. */
  6148. constructor();
  6149. readonly isDirty: boolean;
  6150. zOffset: number;
  6151. cullFace: Nullable<number>;
  6152. cull: Nullable<boolean>;
  6153. depthFunc: Nullable<number>;
  6154. depthMask: boolean;
  6155. depthTest: boolean;
  6156. frontFace: Nullable<number>;
  6157. reset(): void;
  6158. apply(gl: WebGLRenderingContext): void;
  6159. }
  6160. }
  6161. declare module BABYLON {
  6162. /**
  6163. * @hidden
  6164. **/
  6165. export class _StencilState {
  6166. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  6167. static readonly ALWAYS: number;
  6168. /** Passed to stencilOperation to specify that stencil value must be kept */
  6169. static readonly KEEP: number;
  6170. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6171. static readonly REPLACE: number;
  6172. private _isStencilTestDirty;
  6173. private _isStencilMaskDirty;
  6174. private _isStencilFuncDirty;
  6175. private _isStencilOpDirty;
  6176. private _stencilTest;
  6177. private _stencilMask;
  6178. private _stencilFunc;
  6179. private _stencilFuncRef;
  6180. private _stencilFuncMask;
  6181. private _stencilOpStencilFail;
  6182. private _stencilOpDepthFail;
  6183. private _stencilOpStencilDepthPass;
  6184. readonly isDirty: boolean;
  6185. stencilFunc: number;
  6186. stencilFuncRef: number;
  6187. stencilFuncMask: number;
  6188. stencilOpStencilFail: number;
  6189. stencilOpDepthFail: number;
  6190. stencilOpStencilDepthPass: number;
  6191. stencilMask: number;
  6192. stencilTest: boolean;
  6193. constructor();
  6194. reset(): void;
  6195. apply(gl: WebGLRenderingContext): void;
  6196. }
  6197. }
  6198. declare module BABYLON {
  6199. /**
  6200. * @hidden
  6201. **/
  6202. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6203. }
  6204. }
  6205. declare module BABYLON {
  6206. /**
  6207. * Class used to store data associated with WebGL texture data for the engine
  6208. * This class should not be used directly
  6209. */
  6210. export class InternalTexture {
  6211. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6212. /**
  6213. * The source of the texture data is unknown
  6214. */
  6215. static DATASOURCE_UNKNOWN: number;
  6216. /**
  6217. * Texture data comes from an URL
  6218. */
  6219. static DATASOURCE_URL: number;
  6220. /**
  6221. * Texture data is only used for temporary storage
  6222. */
  6223. static DATASOURCE_TEMP: number;
  6224. /**
  6225. * Texture data comes from raw data (ArrayBuffer)
  6226. */
  6227. static DATASOURCE_RAW: number;
  6228. /**
  6229. * Texture content is dynamic (video or dynamic texture)
  6230. */
  6231. static DATASOURCE_DYNAMIC: number;
  6232. /**
  6233. * Texture content is generated by rendering to it
  6234. */
  6235. static DATASOURCE_RENDERTARGET: number;
  6236. /**
  6237. * Texture content is part of a multi render target process
  6238. */
  6239. static DATASOURCE_MULTIRENDERTARGET: number;
  6240. /**
  6241. * Texture data comes from a cube data file
  6242. */
  6243. static DATASOURCE_CUBE: number;
  6244. /**
  6245. * Texture data comes from a raw cube data
  6246. */
  6247. static DATASOURCE_CUBERAW: number;
  6248. /**
  6249. * Texture data come from a prefiltered cube data file
  6250. */
  6251. static DATASOURCE_CUBEPREFILTERED: number;
  6252. /**
  6253. * Texture content is raw 3D data
  6254. */
  6255. static DATASOURCE_RAW3D: number;
  6256. /**
  6257. * Texture content is a depth texture
  6258. */
  6259. static DATASOURCE_DEPTHTEXTURE: number;
  6260. /**
  6261. * Texture data comes from a raw cube data encoded with RGBD
  6262. */
  6263. static DATASOURCE_CUBERAW_RGBD: number;
  6264. /**
  6265. * Defines if the texture is ready
  6266. */
  6267. isReady: boolean;
  6268. /**
  6269. * Defines if the texture is a cube texture
  6270. */
  6271. isCube: boolean;
  6272. /**
  6273. * Defines if the texture contains 3D data
  6274. */
  6275. is3D: boolean;
  6276. /**
  6277. * Defines if the texture contains multiview data
  6278. */
  6279. isMultiview: boolean;
  6280. /**
  6281. * Gets the URL used to load this texture
  6282. */
  6283. url: string;
  6284. /**
  6285. * Gets the sampling mode of the texture
  6286. */
  6287. samplingMode: number;
  6288. /**
  6289. * Gets a boolean indicating if the texture needs mipmaps generation
  6290. */
  6291. generateMipMaps: boolean;
  6292. /**
  6293. * Gets the number of samples used by the texture (WebGL2+ only)
  6294. */
  6295. samples: number;
  6296. /**
  6297. * Gets the type of the texture (int, float...)
  6298. */
  6299. type: number;
  6300. /**
  6301. * Gets the format of the texture (RGB, RGBA...)
  6302. */
  6303. format: number;
  6304. /**
  6305. * Observable called when the texture is loaded
  6306. */
  6307. onLoadedObservable: Observable<InternalTexture>;
  6308. /**
  6309. * Gets the width of the texture
  6310. */
  6311. width: number;
  6312. /**
  6313. * Gets the height of the texture
  6314. */
  6315. height: number;
  6316. /**
  6317. * Gets the depth of the texture
  6318. */
  6319. depth: number;
  6320. /**
  6321. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseWidth: number;
  6324. /**
  6325. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseHeight: number;
  6328. /**
  6329. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6330. */
  6331. baseDepth: number;
  6332. /**
  6333. * Gets a boolean indicating if the texture is inverted on Y axis
  6334. */
  6335. invertY: boolean;
  6336. /** @hidden */ invertVScale: boolean;
  6337. /** @hidden */ associatedChannel: number;
  6338. /** @hidden */ dataSource: number;
  6339. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6341. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6342. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6343. /** @hidden */ size: number;
  6344. /** @hidden */ extension: string;
  6345. /** @hidden */ files: Nullable<string[]>;
  6346. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  6347. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  6348. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6349. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6350. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6351. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6352. /** @hidden */ attachments: Nullable<number[]>;
  6353. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6354. /** @hidden */ cachedWrapU: Nullable<number>;
  6355. /** @hidden */ cachedWrapV: Nullable<number>;
  6356. /** @hidden */ cachedWrapR: Nullable<number>;
  6357. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6358. /** @hidden */ isDisabled: boolean;
  6359. /** @hidden */ compression: Nullable<string>;
  6360. /** @hidden */ generateStencilBuffer: boolean;
  6361. /** @hidden */ generateDepthBuffer: boolean;
  6362. /** @hidden */ comparisonFunction: number;
  6363. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6364. /** @hidden */ lodGenerationScale: number;
  6365. /** @hidden */ lodGenerationOffset: number;
  6366. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6367. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6368. /** @hidden */ lodTextureHigh: Nullable<BaseTexture>;
  6369. /** @hidden */ lodTextureMid: Nullable<BaseTexture>;
  6370. /** @hidden */ lodTextureLow: Nullable<BaseTexture>;
  6371. /** @hidden */ isRGBD: boolean;
  6372. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6373. /** @hidden */ references: number;
  6374. private _engine;
  6375. /**
  6376. * Gets the Engine the texture belongs to.
  6377. * @returns The babylon engine
  6378. */
  6379. getEngine(): Engine;
  6380. /**
  6381. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6382. */
  6383. readonly dataSource: number;
  6384. /**
  6385. * Creates a new InternalTexture
  6386. * @param engine defines the engine to use
  6387. * @param dataSource defines the type of data that will be used
  6388. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6389. */
  6390. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6391. /**
  6392. * Increments the number of references (ie. the number of Texture that point to it)
  6393. */
  6394. incrementReferences(): void;
  6395. /**
  6396. * Change the size of the texture (not the size of the content)
  6397. * @param width defines the new width
  6398. * @param height defines the new height
  6399. * @param depth defines the new depth (1 by default)
  6400. */
  6401. updateSize(width: int, height: int, depth?: int): void;
  6402. /** @hidden */ rebuild(): void;
  6403. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6404. /**
  6405. * Dispose the current allocated resources
  6406. */
  6407. dispose(): void;
  6408. }
  6409. }
  6410. declare module BABYLON {
  6411. /**
  6412. * This represents the main contract an easing function should follow.
  6413. * Easing functions are used throughout the animation system.
  6414. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6415. */
  6416. export interface IEasingFunction {
  6417. /**
  6418. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6419. * of the easing function.
  6420. * The link below provides some of the most common examples of easing functions.
  6421. * @see https://easings.net/
  6422. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6423. * @returns the corresponding value on the curve defined by the easing function
  6424. */
  6425. ease(gradient: number): number;
  6426. }
  6427. /**
  6428. * Base class used for every default easing function.
  6429. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6430. */
  6431. export class EasingFunction implements IEasingFunction {
  6432. /**
  6433. * Interpolation follows the mathematical formula associated with the easing function.
  6434. */
  6435. static readonly EASINGMODE_EASEIN: number;
  6436. /**
  6437. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6438. */
  6439. static readonly EASINGMODE_EASEOUT: number;
  6440. /**
  6441. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6442. */
  6443. static readonly EASINGMODE_EASEINOUT: number;
  6444. private _easingMode;
  6445. /**
  6446. * Sets the easing mode of the current function.
  6447. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6448. */
  6449. setEasingMode(easingMode: number): void;
  6450. /**
  6451. * Gets the current easing mode.
  6452. * @returns the easing mode
  6453. */
  6454. getEasingMode(): number;
  6455. /**
  6456. * @hidden
  6457. */
  6458. easeInCore(gradient: number): number;
  6459. /**
  6460. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6461. * of the easing function.
  6462. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6463. * @returns the corresponding value on the curve defined by the easing function
  6464. */
  6465. ease(gradient: number): number;
  6466. }
  6467. /**
  6468. * Easing function with a circle shape (see link below).
  6469. * @see https://easings.net/#easeInCirc
  6470. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6471. */
  6472. export class CircleEase extends EasingFunction implements IEasingFunction {
  6473. /** @hidden */
  6474. easeInCore(gradient: number): number;
  6475. }
  6476. /**
  6477. * Easing function with a ease back shape (see link below).
  6478. * @see https://easings.net/#easeInBack
  6479. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6480. */
  6481. export class BackEase extends EasingFunction implements IEasingFunction {
  6482. /** Defines the amplitude of the function */
  6483. amplitude: number;
  6484. /**
  6485. * Instantiates a back ease easing
  6486. * @see https://easings.net/#easeInBack
  6487. * @param amplitude Defines the amplitude of the function
  6488. */
  6489. constructor(
  6490. /** Defines the amplitude of the function */
  6491. amplitude?: number);
  6492. /** @hidden */
  6493. easeInCore(gradient: number): number;
  6494. }
  6495. /**
  6496. * Easing function with a bouncing shape (see link below).
  6497. * @see https://easings.net/#easeInBounce
  6498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6499. */
  6500. export class BounceEase extends EasingFunction implements IEasingFunction {
  6501. /** Defines the number of bounces */
  6502. bounces: number;
  6503. /** Defines the amplitude of the bounce */
  6504. bounciness: number;
  6505. /**
  6506. * Instantiates a bounce easing
  6507. * @see https://easings.net/#easeInBounce
  6508. * @param bounces Defines the number of bounces
  6509. * @param bounciness Defines the amplitude of the bounce
  6510. */
  6511. constructor(
  6512. /** Defines the number of bounces */
  6513. bounces?: number,
  6514. /** Defines the amplitude of the bounce */
  6515. bounciness?: number);
  6516. /** @hidden */
  6517. easeInCore(gradient: number): number;
  6518. }
  6519. /**
  6520. * Easing function with a power of 3 shape (see link below).
  6521. * @see https://easings.net/#easeInCubic
  6522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6523. */
  6524. export class CubicEase extends EasingFunction implements IEasingFunction {
  6525. /** @hidden */
  6526. easeInCore(gradient: number): number;
  6527. }
  6528. /**
  6529. * Easing function with an elastic shape (see link below).
  6530. * @see https://easings.net/#easeInElastic
  6531. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6532. */
  6533. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6534. /** Defines the number of oscillations*/
  6535. oscillations: number;
  6536. /** Defines the amplitude of the oscillations*/
  6537. springiness: number;
  6538. /**
  6539. * Instantiates an elastic easing function
  6540. * @see https://easings.net/#easeInElastic
  6541. * @param oscillations Defines the number of oscillations
  6542. * @param springiness Defines the amplitude of the oscillations
  6543. */
  6544. constructor(
  6545. /** Defines the number of oscillations*/
  6546. oscillations?: number,
  6547. /** Defines the amplitude of the oscillations*/
  6548. springiness?: number);
  6549. /** @hidden */
  6550. easeInCore(gradient: number): number;
  6551. }
  6552. /**
  6553. * Easing function with an exponential shape (see link below).
  6554. * @see https://easings.net/#easeInExpo
  6555. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6556. */
  6557. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6558. /** Defines the exponent of the function */
  6559. exponent: number;
  6560. /**
  6561. * Instantiates an exponential easing function
  6562. * @see https://easings.net/#easeInExpo
  6563. * @param exponent Defines the exponent of the function
  6564. */
  6565. constructor(
  6566. /** Defines the exponent of the function */
  6567. exponent?: number);
  6568. /** @hidden */
  6569. easeInCore(gradient: number): number;
  6570. }
  6571. /**
  6572. * Easing function with a power shape (see link below).
  6573. * @see https://easings.net/#easeInQuad
  6574. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6575. */
  6576. export class PowerEase extends EasingFunction implements IEasingFunction {
  6577. /** Defines the power of the function */
  6578. power: number;
  6579. /**
  6580. * Instantiates an power base easing function
  6581. * @see https://easings.net/#easeInQuad
  6582. * @param power Defines the power of the function
  6583. */
  6584. constructor(
  6585. /** Defines the power of the function */
  6586. power?: number);
  6587. /** @hidden */
  6588. easeInCore(gradient: number): number;
  6589. }
  6590. /**
  6591. * Easing function with a power of 2 shape (see link below).
  6592. * @see https://easings.net/#easeInQuad
  6593. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6594. */
  6595. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6596. /** @hidden */
  6597. easeInCore(gradient: number): number;
  6598. }
  6599. /**
  6600. * Easing function with a power of 4 shape (see link below).
  6601. * @see https://easings.net/#easeInQuart
  6602. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6603. */
  6604. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6605. /** @hidden */
  6606. easeInCore(gradient: number): number;
  6607. }
  6608. /**
  6609. * Easing function with a power of 5 shape (see link below).
  6610. * @see https://easings.net/#easeInQuint
  6611. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6612. */
  6613. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6614. /** @hidden */
  6615. easeInCore(gradient: number): number;
  6616. }
  6617. /**
  6618. * Easing function with a sin shape (see link below).
  6619. * @see https://easings.net/#easeInSine
  6620. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6621. */
  6622. export class SineEase extends EasingFunction implements IEasingFunction {
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a bezier shape (see link below).
  6628. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6632. /** Defines the x component of the start tangent in the bezier curve */
  6633. x1: number;
  6634. /** Defines the y component of the start tangent in the bezier curve */
  6635. y1: number;
  6636. /** Defines the x component of the end tangent in the bezier curve */
  6637. x2: number;
  6638. /** Defines the y component of the end tangent in the bezier curve */
  6639. y2: number;
  6640. /**
  6641. * Instantiates a bezier function
  6642. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6643. * @param x1 Defines the x component of the start tangent in the bezier curve
  6644. * @param y1 Defines the y component of the start tangent in the bezier curve
  6645. * @param x2 Defines the x component of the end tangent in the bezier curve
  6646. * @param y2 Defines the y component of the end tangent in the bezier curve
  6647. */
  6648. constructor(
  6649. /** Defines the x component of the start tangent in the bezier curve */
  6650. x1?: number,
  6651. /** Defines the y component of the start tangent in the bezier curve */
  6652. y1?: number,
  6653. /** Defines the x component of the end tangent in the bezier curve */
  6654. x2?: number,
  6655. /** Defines the y component of the end tangent in the bezier curve */
  6656. y2?: number);
  6657. /** @hidden */
  6658. easeInCore(gradient: number): number;
  6659. }
  6660. }
  6661. declare module BABYLON {
  6662. /**
  6663. * Defines an interface which represents an animation key frame
  6664. */
  6665. export interface IAnimationKey {
  6666. /**
  6667. * Frame of the key frame
  6668. */
  6669. frame: number;
  6670. /**
  6671. * Value at the specifies key frame
  6672. */
  6673. value: any;
  6674. /**
  6675. * The input tangent for the cubic hermite spline
  6676. */
  6677. inTangent?: any;
  6678. /**
  6679. * The output tangent for the cubic hermite spline
  6680. */
  6681. outTangent?: any;
  6682. /**
  6683. * The animation interpolation type
  6684. */
  6685. interpolation?: AnimationKeyInterpolation;
  6686. }
  6687. /**
  6688. * Enum for the animation key frame interpolation type
  6689. */
  6690. export enum AnimationKeyInterpolation {
  6691. /**
  6692. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6693. */
  6694. STEP = 1
  6695. }
  6696. }
  6697. declare module BABYLON {
  6698. /**
  6699. * Represents the range of an animation
  6700. */
  6701. export class AnimationRange {
  6702. /**The name of the animation range**/
  6703. name: string;
  6704. /**The starting frame of the animation */
  6705. from: number;
  6706. /**The ending frame of the animation*/
  6707. to: number;
  6708. /**
  6709. * Initializes the range of an animation
  6710. * @param name The name of the animation range
  6711. * @param from The starting frame of the animation
  6712. * @param to The ending frame of the animation
  6713. */
  6714. constructor(
  6715. /**The name of the animation range**/
  6716. name: string,
  6717. /**The starting frame of the animation */
  6718. from: number,
  6719. /**The ending frame of the animation*/
  6720. to: number);
  6721. /**
  6722. * Makes a copy of the animation range
  6723. * @returns A copy of the animation range
  6724. */
  6725. clone(): AnimationRange;
  6726. }
  6727. }
  6728. declare module BABYLON {
  6729. /**
  6730. * Composed of a frame, and an action function
  6731. */
  6732. export class AnimationEvent {
  6733. /** The frame for which the event is triggered **/
  6734. frame: number;
  6735. /** The event to perform when triggered **/
  6736. action: (currentFrame: number) => void;
  6737. /** Specifies if the event should be triggered only once**/
  6738. onlyOnce?: boolean | undefined;
  6739. /**
  6740. * Specifies if the animation event is done
  6741. */
  6742. isDone: boolean;
  6743. /**
  6744. * Initializes the animation event
  6745. * @param frame The frame for which the event is triggered
  6746. * @param action The event to perform when triggered
  6747. * @param onlyOnce Specifies if the event should be triggered only once
  6748. */
  6749. constructor(
  6750. /** The frame for which the event is triggered **/
  6751. frame: number,
  6752. /** The event to perform when triggered **/
  6753. action: (currentFrame: number) => void,
  6754. /** Specifies if the event should be triggered only once**/
  6755. onlyOnce?: boolean | undefined);
  6756. /** @hidden */ clone(): AnimationEvent;
  6757. }
  6758. }
  6759. declare module BABYLON {
  6760. /**
  6761. * Interface used to define a behavior
  6762. */
  6763. export interface Behavior<T> {
  6764. /** gets or sets behavior's name */
  6765. name: string;
  6766. /**
  6767. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6768. */
  6769. init(): void;
  6770. /**
  6771. * Called when the behavior is attached to a target
  6772. * @param target defines the target where the behavior is attached to
  6773. */
  6774. attach(target: T): void;
  6775. /**
  6776. * Called when the behavior is detached from its target
  6777. */
  6778. detach(): void;
  6779. }
  6780. /**
  6781. * Interface implemented by classes supporting behaviors
  6782. */
  6783. export interface IBehaviorAware<T> {
  6784. /**
  6785. * Attach a behavior
  6786. * @param behavior defines the behavior to attach
  6787. * @returns the current host
  6788. */
  6789. addBehavior(behavior: Behavior<T>): T;
  6790. /**
  6791. * Remove a behavior from the current object
  6792. * @param behavior defines the behavior to detach
  6793. * @returns the current host
  6794. */
  6795. removeBehavior(behavior: Behavior<T>): T;
  6796. /**
  6797. * Gets a behavior using its name to search
  6798. * @param name defines the name to search
  6799. * @returns the behavior or null if not found
  6800. */
  6801. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6802. }
  6803. }
  6804. declare module BABYLON {
  6805. /**
  6806. * @hidden
  6807. */
  6808. export class IntersectionInfo {
  6809. bu: Nullable<number>;
  6810. bv: Nullable<number>;
  6811. distance: number;
  6812. faceId: number;
  6813. subMeshId: number;
  6814. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * Class used to store bounding sphere information
  6820. */
  6821. export class BoundingSphere {
  6822. /**
  6823. * Gets the center of the bounding sphere in local space
  6824. */
  6825. readonly center: Vector3;
  6826. /**
  6827. * Radius of the bounding sphere in local space
  6828. */
  6829. radius: number;
  6830. /**
  6831. * Gets the center of the bounding sphere in world space
  6832. */
  6833. readonly centerWorld: Vector3;
  6834. /**
  6835. * Radius of the bounding sphere in world space
  6836. */
  6837. radiusWorld: number;
  6838. /**
  6839. * Gets the minimum vector in local space
  6840. */
  6841. readonly minimum: Vector3;
  6842. /**
  6843. * Gets the maximum vector in local space
  6844. */
  6845. readonly maximum: Vector3;
  6846. private _worldMatrix;
  6847. private static readonly TmpVector3;
  6848. /**
  6849. * Creates a new bounding sphere
  6850. * @param min defines the minimum vector (in local space)
  6851. * @param max defines the maximum vector (in local space)
  6852. * @param worldMatrix defines the new world matrix
  6853. */
  6854. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6855. /**
  6856. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6857. * @param min defines the new minimum vector (in local space)
  6858. * @param max defines the new maximum vector (in local space)
  6859. * @param worldMatrix defines the new world matrix
  6860. */
  6861. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6862. /**
  6863. * Scale the current bounding sphere by applying a scale factor
  6864. * @param factor defines the scale factor to apply
  6865. * @returns the current bounding box
  6866. */
  6867. scale(factor: number): BoundingSphere;
  6868. /**
  6869. * Gets the world matrix of the bounding box
  6870. * @returns a matrix
  6871. */
  6872. getWorldMatrix(): DeepImmutable<Matrix>;
  6873. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6874. /**
  6875. * Tests if the bounding sphere is intersecting the frustum planes
  6876. * @param frustumPlanes defines the frustum planes to test
  6877. * @returns true if there is an intersection
  6878. */
  6879. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6880. /**
  6881. * Tests if the bounding sphere center is in between the frustum planes.
  6882. * Used for optimistic fast inclusion.
  6883. * @param frustumPlanes defines the frustum planes to test
  6884. * @returns true if the sphere center is in between the frustum planes
  6885. */
  6886. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6887. /**
  6888. * Tests if a point is inside the bounding sphere
  6889. * @param point defines the point to test
  6890. * @returns true if the point is inside the bounding sphere
  6891. */
  6892. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6893. /**
  6894. * Checks if two sphere intersct
  6895. * @param sphere0 sphere 0
  6896. * @param sphere1 sphere 1
  6897. * @returns true if the speres intersect
  6898. */
  6899. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6900. }
  6901. }
  6902. declare module BABYLON {
  6903. /**
  6904. * Class used to store bounding box information
  6905. */
  6906. export class BoundingBox implements ICullable {
  6907. /**
  6908. * Gets the 8 vectors representing the bounding box in local space
  6909. */
  6910. readonly vectors: Vector3[];
  6911. /**
  6912. * Gets the center of the bounding box in local space
  6913. */
  6914. readonly center: Vector3;
  6915. /**
  6916. * Gets the center of the bounding box in world space
  6917. */
  6918. readonly centerWorld: Vector3;
  6919. /**
  6920. * Gets the extend size in local space
  6921. */
  6922. readonly extendSize: Vector3;
  6923. /**
  6924. * Gets the extend size in world space
  6925. */
  6926. readonly extendSizeWorld: Vector3;
  6927. /**
  6928. * Gets the OBB (object bounding box) directions
  6929. */
  6930. readonly directions: Vector3[];
  6931. /**
  6932. * Gets the 8 vectors representing the bounding box in world space
  6933. */
  6934. readonly vectorsWorld: Vector3[];
  6935. /**
  6936. * Gets the minimum vector in world space
  6937. */
  6938. readonly minimumWorld: Vector3;
  6939. /**
  6940. * Gets the maximum vector in world space
  6941. */
  6942. readonly maximumWorld: Vector3;
  6943. /**
  6944. * Gets the minimum vector in local space
  6945. */
  6946. readonly minimum: Vector3;
  6947. /**
  6948. * Gets the maximum vector in local space
  6949. */
  6950. readonly maximum: Vector3;
  6951. private _worldMatrix;
  6952. private static readonly TmpVector3;
  6953. /**
  6954. * @hidden
  6955. */ tag: number;
  6956. /**
  6957. * Creates a new bounding box
  6958. * @param min defines the minimum vector (in local space)
  6959. * @param max defines the maximum vector (in local space)
  6960. * @param worldMatrix defines the new world matrix
  6961. */
  6962. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6963. /**
  6964. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6965. * @param min defines the new minimum vector (in local space)
  6966. * @param max defines the new maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6970. /**
  6971. * Scale the current bounding box by applying a scale factor
  6972. * @param factor defines the scale factor to apply
  6973. * @returns the current bounding box
  6974. */
  6975. scale(factor: number): BoundingBox;
  6976. /**
  6977. * Gets the world matrix of the bounding box
  6978. * @returns a matrix
  6979. */
  6980. getWorldMatrix(): DeepImmutable<Matrix>;
  6981. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6982. /**
  6983. * Tests if the bounding box is intersecting the frustum planes
  6984. * @param frustumPlanes defines the frustum planes to test
  6985. * @returns true if there is an intersection
  6986. */
  6987. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6988. /**
  6989. * Tests if the bounding box is entirely inside the frustum planes
  6990. * @param frustumPlanes defines the frustum planes to test
  6991. * @returns true if there is an inclusion
  6992. */
  6993. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6994. /**
  6995. * Tests if a point is inside the bounding box
  6996. * @param point defines the point to test
  6997. * @returns true if the point is inside the bounding box
  6998. */
  6999. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7000. /**
  7001. * Tests if the bounding box intersects with a bounding sphere
  7002. * @param sphere defines the sphere to test
  7003. * @returns true if there is an intersection
  7004. */
  7005. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7006. /**
  7007. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7008. * @param min defines the min vector to use
  7009. * @param max defines the max vector to use
  7010. * @returns true if there is an intersection
  7011. */
  7012. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7013. /**
  7014. * Tests if two bounding boxes are intersections
  7015. * @param box0 defines the first box to test
  7016. * @param box1 defines the second box to test
  7017. * @returns true if there is an intersection
  7018. */
  7019. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7020. /**
  7021. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7022. * @param minPoint defines the minimum vector of the bounding box
  7023. * @param maxPoint defines the maximum vector of the bounding box
  7024. * @param sphereCenter defines the sphere center
  7025. * @param sphereRadius defines the sphere radius
  7026. * @returns true if there is an intersection
  7027. */
  7028. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7029. /**
  7030. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7031. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @return true if there is an inclusion
  7034. */
  7035. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7038. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7039. * @param frustumPlanes defines the frustum planes to test
  7040. * @return true if there is an intersection
  7041. */
  7042. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7043. }
  7044. }
  7045. declare module BABYLON {
  7046. /** @hidden */
  7047. export class Collider {
  7048. /** Define if a collision was found */
  7049. collisionFound: boolean;
  7050. /**
  7051. * Define last intersection point in local space
  7052. */
  7053. intersectionPoint: Vector3;
  7054. /**
  7055. * Define last collided mesh
  7056. */
  7057. collidedMesh: Nullable<AbstractMesh>;
  7058. private _collisionPoint;
  7059. private _planeIntersectionPoint;
  7060. private _tempVector;
  7061. private _tempVector2;
  7062. private _tempVector3;
  7063. private _tempVector4;
  7064. private _edge;
  7065. private _baseToVertex;
  7066. private _destinationPoint;
  7067. private _slidePlaneNormal;
  7068. private _displacementVector;
  7069. /** @hidden */ radius: Vector3;
  7070. /** @hidden */ retry: number;
  7071. private _velocity;
  7072. private _basePoint;
  7073. private _epsilon;
  7074. /** @hidden */ velocityWorldLength: number;
  7075. /** @hidden */ basePointWorld: Vector3;
  7076. private _velocityWorld;
  7077. private _normalizedVelocity;
  7078. /** @hidden */ initialVelocity: Vector3;
  7079. /** @hidden */ initialPosition: Vector3;
  7080. private _nearestDistance;
  7081. private _collisionMask;
  7082. collisionMask: number;
  7083. /**
  7084. * Gets the plane normal used to compute the sliding response (in local space)
  7085. */
  7086. readonly slidePlaneNormal: Vector3;
  7087. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7088. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7089. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7090. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7091. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7092. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7093. }
  7094. }
  7095. declare module BABYLON {
  7096. /**
  7097. * Interface for cullable objects
  7098. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7099. */
  7100. export interface ICullable {
  7101. /**
  7102. * Checks if the object or part of the object is in the frustum
  7103. * @param frustumPlanes Camera near/planes
  7104. * @returns true if the object is in frustum otherwise false
  7105. */
  7106. isInFrustum(frustumPlanes: Plane[]): boolean;
  7107. /**
  7108. * Checks if a cullable object (mesh...) is in the camera frustum
  7109. * Unlike isInFrustum this cheks the full bounding box
  7110. * @param frustumPlanes Camera near/planes
  7111. * @returns true if the object is in frustum otherwise false
  7112. */
  7113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7114. }
  7115. /**
  7116. * Info for a bounding data of a mesh
  7117. */
  7118. export class BoundingInfo implements ICullable {
  7119. /**
  7120. * Bounding box for the mesh
  7121. */
  7122. readonly boundingBox: BoundingBox;
  7123. /**
  7124. * Bounding sphere for the mesh
  7125. */
  7126. readonly boundingSphere: BoundingSphere;
  7127. private _isLocked;
  7128. private static readonly TmpVector3;
  7129. /**
  7130. * Constructs bounding info
  7131. * @param minimum min vector of the bounding box/sphere
  7132. * @param maximum max vector of the bounding box/sphere
  7133. * @param worldMatrix defines the new world matrix
  7134. */
  7135. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7136. /**
  7137. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7138. * @param min defines the new minimum vector (in local space)
  7139. * @param max defines the new maximum vector (in local space)
  7140. * @param worldMatrix defines the new world matrix
  7141. */
  7142. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7143. /**
  7144. * min vector of the bounding box/sphere
  7145. */
  7146. readonly minimum: Vector3;
  7147. /**
  7148. * max vector of the bounding box/sphere
  7149. */
  7150. readonly maximum: Vector3;
  7151. /**
  7152. * If the info is locked and won't be updated to avoid perf overhead
  7153. */
  7154. isLocked: boolean;
  7155. /**
  7156. * Updates the bounding sphere and box
  7157. * @param world world matrix to be used to update
  7158. */
  7159. update(world: DeepImmutable<Matrix>): void;
  7160. /**
  7161. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7162. * @param center New center of the bounding info
  7163. * @param extend New extend of the bounding info
  7164. * @returns the current bounding info
  7165. */
  7166. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7167. /**
  7168. * Scale the current bounding info by applying a scale factor
  7169. * @param factor defines the scale factor to apply
  7170. * @returns the current bounding info
  7171. */
  7172. scale(factor: number): BoundingInfo;
  7173. /**
  7174. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7175. * @param frustumPlanes defines the frustum to test
  7176. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7177. * @returns true if the bounding info is in the frustum planes
  7178. */
  7179. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7180. /**
  7181. * Gets the world distance between the min and max points of the bounding box
  7182. */
  7183. readonly diagonalLength: number;
  7184. /**
  7185. * Checks if a cullable object (mesh...) is in the camera frustum
  7186. * Unlike isInFrustum this cheks the full bounding box
  7187. * @param frustumPlanes Camera near/planes
  7188. * @returns true if the object is in frustum otherwise false
  7189. */
  7190. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7191. /** @hidden */ checkCollision(collider: Collider): boolean;
  7192. /**
  7193. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7194. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7195. * @param point the point to check intersection with
  7196. * @returns if the point intersects
  7197. */
  7198. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7199. /**
  7200. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7201. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7202. * @param boundingInfo the bounding info to check intersection with
  7203. * @param precise if the intersection should be done using OBB
  7204. * @returns if the bounding info intersects
  7205. */
  7206. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7207. }
  7208. }
  7209. declare module BABYLON {
  7210. /**
  7211. * Defines an array and its length.
  7212. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7213. */
  7214. export interface ISmartArrayLike<T> {
  7215. /**
  7216. * The data of the array.
  7217. */
  7218. data: Array<T>;
  7219. /**
  7220. * The active length of the array.
  7221. */
  7222. length: number;
  7223. }
  7224. /**
  7225. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7226. */
  7227. export class SmartArray<T> implements ISmartArrayLike<T> {
  7228. /**
  7229. * The full set of data from the array.
  7230. */
  7231. data: Array<T>;
  7232. /**
  7233. * The active length of the array.
  7234. */
  7235. length: number;
  7236. protected _id: number;
  7237. /**
  7238. * Instantiates a Smart Array.
  7239. * @param capacity defines the default capacity of the array.
  7240. */
  7241. constructor(capacity: number);
  7242. /**
  7243. * Pushes a value at the end of the active data.
  7244. * @param value defines the object to push in the array.
  7245. */
  7246. push(value: T): void;
  7247. /**
  7248. * Iterates over the active data and apply the lambda to them.
  7249. * @param func defines the action to apply on each value.
  7250. */
  7251. forEach(func: (content: T) => void): void;
  7252. /**
  7253. * Sorts the full sets of data.
  7254. * @param compareFn defines the comparison function to apply.
  7255. */
  7256. sort(compareFn: (a: T, b: T) => number): void;
  7257. /**
  7258. * Resets the active data to an empty array.
  7259. */
  7260. reset(): void;
  7261. /**
  7262. * Releases all the data from the array as well as the array.
  7263. */
  7264. dispose(): void;
  7265. /**
  7266. * Concats the active data with a given array.
  7267. * @param array defines the data to concatenate with.
  7268. */
  7269. concat(array: any): void;
  7270. /**
  7271. * Returns the position of a value in the active data.
  7272. * @param value defines the value to find the index for
  7273. * @returns the index if found in the active data otherwise -1
  7274. */
  7275. indexOf(value: T): number;
  7276. /**
  7277. * Returns whether an element is part of the active data.
  7278. * @param value defines the value to look for
  7279. * @returns true if found in the active data otherwise false
  7280. */
  7281. contains(value: T): boolean;
  7282. private static _GlobalId;
  7283. }
  7284. /**
  7285. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7286. * The data in this array can only be present once
  7287. */
  7288. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7289. private _duplicateId;
  7290. /**
  7291. * Pushes a value at the end of the active data.
  7292. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7293. * @param value defines the object to push in the array.
  7294. */
  7295. push(value: T): void;
  7296. /**
  7297. * Pushes a value at the end of the active data.
  7298. * If the data is already present, it won t be added again
  7299. * @param value defines the object to push in the array.
  7300. * @returns true if added false if it was already present
  7301. */
  7302. pushNoDuplicate(value: T): boolean;
  7303. /**
  7304. * Resets the active data to an empty array.
  7305. */
  7306. reset(): void;
  7307. /**
  7308. * Concats the active data with a given array.
  7309. * This ensures no dupplicate will be present in the result.
  7310. * @param array defines the data to concatenate with.
  7311. */
  7312. concatWithNoDuplicate(array: any): void;
  7313. }
  7314. }
  7315. declare module BABYLON {
  7316. /**
  7317. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7318. * separate meshes. This can be use to improve performances.
  7319. * @see http://doc.babylonjs.com/how_to/multi_materials
  7320. */
  7321. export class MultiMaterial extends Material {
  7322. private _subMaterials;
  7323. /**
  7324. * Gets or Sets the list of Materials used within the multi material.
  7325. * They need to be ordered according to the submeshes order in the associated mesh
  7326. */
  7327. subMaterials: Nullable<Material>[];
  7328. /**
  7329. * Function used to align with Node.getChildren()
  7330. * @returns the list of Materials used within the multi material
  7331. */
  7332. getChildren(): Nullable<Material>[];
  7333. /**
  7334. * Instantiates a new Multi Material
  7335. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7336. * separate meshes. This can be use to improve performances.
  7337. * @see http://doc.babylonjs.com/how_to/multi_materials
  7338. * @param name Define the name in the scene
  7339. * @param scene Define the scene the material belongs to
  7340. */
  7341. constructor(name: string, scene: Scene);
  7342. private _hookArray;
  7343. /**
  7344. * Get one of the submaterial by its index in the submaterials array
  7345. * @param index The index to look the sub material at
  7346. * @returns The Material if the index has been defined
  7347. */
  7348. getSubMaterial(index: number): Nullable<Material>;
  7349. /**
  7350. * Get the list of active textures for the whole sub materials list.
  7351. * @returns All the textures that will be used during the rendering
  7352. */
  7353. getActiveTextures(): BaseTexture[];
  7354. /**
  7355. * Gets the current class name of the material e.g. "MultiMaterial"
  7356. * Mainly use in serialization.
  7357. * @returns the class name
  7358. */
  7359. getClassName(): string;
  7360. /**
  7361. * Checks if the material is ready to render the requested sub mesh
  7362. * @param mesh Define the mesh the submesh belongs to
  7363. * @param subMesh Define the sub mesh to look readyness for
  7364. * @param useInstances Define whether or not the material is used with instances
  7365. * @returns true if ready, otherwise false
  7366. */
  7367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7368. /**
  7369. * Clones the current material and its related sub materials
  7370. * @param name Define the name of the newly cloned material
  7371. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7372. * @returns the cloned material
  7373. */
  7374. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7375. /**
  7376. * Serializes the materials into a JSON representation.
  7377. * @returns the JSON representation
  7378. */
  7379. serialize(): any;
  7380. /**
  7381. * Dispose the material and release its associated resources
  7382. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  7383. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  7384. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  7385. */
  7386. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7387. /**
  7388. * Creates a MultiMaterial from parsed MultiMaterial data.
  7389. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7390. * @param scene defines the hosting scene
  7391. * @returns a new MultiMaterial
  7392. */
  7393. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7394. }
  7395. }
  7396. declare module BABYLON {
  7397. /**
  7398. * Class used to represent data loading progression
  7399. */
  7400. export class SceneLoaderFlags {
  7401. private static _ForceFullSceneLoadingForIncremental;
  7402. private static _ShowLoadingScreen;
  7403. private static _CleanBoneMatrixWeights;
  7404. private static _loggingLevel;
  7405. /**
  7406. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7407. */
  7408. static ForceFullSceneLoadingForIncremental: boolean;
  7409. /**
  7410. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7411. */
  7412. static ShowLoadingScreen: boolean;
  7413. /**
  7414. * Defines the current logging level (while loading the scene)
  7415. * @ignorenaming
  7416. */
  7417. static loggingLevel: number;
  7418. /**
  7419. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7420. */
  7421. static CleanBoneMatrixWeights: boolean;
  7422. }
  7423. }
  7424. declare module BABYLON {
  7425. /**
  7426. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  7427. * @see https://doc.babylonjs.com/how_to/transformnode
  7428. */
  7429. export class TransformNode extends Node {
  7430. /**
  7431. * Object will not rotate to face the camera
  7432. */
  7433. static BILLBOARDMODE_NONE: number;
  7434. /**
  7435. * Object will rotate to face the camera but only on the x axis
  7436. */
  7437. static BILLBOARDMODE_X: number;
  7438. /**
  7439. * Object will rotate to face the camera but only on the y axis
  7440. */
  7441. static BILLBOARDMODE_Y: number;
  7442. /**
  7443. * Object will rotate to face the camera but only on the z axis
  7444. */
  7445. static BILLBOARDMODE_Z: number;
  7446. /**
  7447. * Object will rotate to face the camera
  7448. */
  7449. static BILLBOARDMODE_ALL: number;
  7450. private _forward;
  7451. private _forwardInverted;
  7452. private _up;
  7453. private _right;
  7454. private _rightInverted;
  7455. private _position;
  7456. private _rotation;
  7457. private _rotationQuaternion;
  7458. protected _scaling: Vector3;
  7459. protected _isDirty: boolean;
  7460. private _transformToBoneReferal;
  7461. private _billboardMode;
  7462. /**
  7463. * Gets or sets the billboard mode. Default is 0.
  7464. *
  7465. * | Value | Type | Description |
  7466. * | --- | --- | --- |
  7467. * | 0 | BILLBOARDMODE_NONE | |
  7468. * | 1 | BILLBOARDMODE_X | |
  7469. * | 2 | BILLBOARDMODE_Y | |
  7470. * | 4 | BILLBOARDMODE_Z | |
  7471. * | 7 | BILLBOARDMODE_ALL | |
  7472. *
  7473. */
  7474. billboardMode: number;
  7475. private _preserveParentRotationForBillboard;
  7476. /**
  7477. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7478. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7479. */
  7480. preserveParentRotationForBillboard: boolean;
  7481. /**
  7482. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  7483. */
  7484. scalingDeterminant: number;
  7485. private _infiniteDistance;
  7486. /**
  7487. * Gets or sets the distance of the object to max, often used by skybox
  7488. */
  7489. infiniteDistance: boolean;
  7490. /**
  7491. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7492. * By default the system will update normals to compensate
  7493. */
  7494. ignoreNonUniformScaling: boolean;
  7495. /**
  7496. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7497. */
  7498. reIntegrateRotationIntoRotationQuaternion: boolean;
  7499. /** @hidden */ poseMatrix: Nullable<Matrix>;
  7500. /** @hidden */ localMatrix: Matrix;
  7501. private _usePivotMatrix;
  7502. private _absolutePosition;
  7503. private _pivotMatrix;
  7504. private _pivotMatrixInverse;
  7505. protected _postMultiplyPivotMatrix: boolean;
  7506. protected _isWorldMatrixFrozen: boolean;
  7507. /** @hidden */ indexInSceneTransformNodesArray: number;
  7508. /**
  7509. * An event triggered after the world matrix is updated
  7510. */
  7511. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7512. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7513. /**
  7514. * Gets a string identifying the name of the class
  7515. * @returns "TransformNode" string
  7516. */
  7517. getClassName(): string;
  7518. /**
  7519. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7520. */
  7521. position: Vector3;
  7522. /**
  7523. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7524. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7525. */
  7526. rotation: Vector3;
  7527. /**
  7528. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  7529. */
  7530. scaling: Vector3;
  7531. /**
  7532. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  7533. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7534. */
  7535. rotationQuaternion: Nullable<Quaternion>;
  7536. /**
  7537. * The forward direction of that transform in world space.
  7538. */
  7539. readonly forward: Vector3;
  7540. /**
  7541. * The up direction of that transform in world space.
  7542. */
  7543. readonly up: Vector3;
  7544. /**
  7545. * The right direction of that transform in world space.
  7546. */
  7547. readonly right: Vector3;
  7548. /**
  7549. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7550. * @param matrix the matrix to copy the pose from
  7551. * @returns this TransformNode.
  7552. */
  7553. updatePoseMatrix(matrix: Matrix): TransformNode;
  7554. /**
  7555. * Returns the mesh Pose matrix.
  7556. * @returns the pose matrix
  7557. */
  7558. getPoseMatrix(): Matrix;
  7559. /** @hidden */ isSynchronized(): boolean;
  7560. /** @hidden */ initCache(): void;
  7561. /**
  7562. * Flag the transform node as dirty (Forcing it to update everything)
  7563. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7564. * @returns this transform node
  7565. */
  7566. markAsDirty(property: string): TransformNode;
  7567. /**
  7568. * Returns the current mesh absolute position.
  7569. * Returns a Vector3.
  7570. */
  7571. readonly absolutePosition: Vector3;
  7572. /**
  7573. * Sets a new matrix to apply before all other transformation
  7574. * @param matrix defines the transform matrix
  7575. * @returns the current TransformNode
  7576. */
  7577. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7578. /**
  7579. * Sets a new pivot matrix to the current node
  7580. * @param matrix defines the new pivot matrix to use
  7581. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  7582. * @returns the current TransformNode
  7583. */
  7584. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7585. /**
  7586. * Returns the mesh pivot matrix.
  7587. * Default : Identity.
  7588. * @returns the matrix
  7589. */
  7590. getPivotMatrix(): Matrix;
  7591. /**
  7592. * Prevents the World matrix to be computed any longer.
  7593. * @returns the TransformNode.
  7594. */
  7595. freezeWorldMatrix(): TransformNode;
  7596. /**
  7597. * Allows back the World matrix computation.
  7598. * @returns the TransformNode.
  7599. */
  7600. unfreezeWorldMatrix(): this;
  7601. /**
  7602. * True if the World matrix has been frozen.
  7603. */
  7604. readonly isWorldMatrixFrozen: boolean;
  7605. /**
  7606. * Retuns the mesh absolute position in the World.
  7607. * @returns a Vector3.
  7608. */
  7609. getAbsolutePosition(): Vector3;
  7610. /**
  7611. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7612. * @param absolutePosition the absolute position to set
  7613. * @returns the TransformNode.
  7614. */
  7615. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7616. /**
  7617. * Sets the mesh position in its local space.
  7618. * @param vector3 the position to set in localspace
  7619. * @returns the TransformNode.
  7620. */
  7621. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7622. /**
  7623. * Returns the mesh position in the local space from the current World matrix values.
  7624. * @returns a new Vector3.
  7625. */
  7626. getPositionExpressedInLocalSpace(): Vector3;
  7627. /**
  7628. * Translates the mesh along the passed Vector3 in its local space.
  7629. * @param vector3 the distance to translate in localspace
  7630. * @returns the TransformNode.
  7631. */
  7632. locallyTranslate(vector3: Vector3): TransformNode;
  7633. private static _lookAtVectorCache;
  7634. /**
  7635. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7636. * @param targetPoint the position (must be in same space as current mesh) to look at
  7637. * @param yawCor optional yaw (y-axis) correction in radians
  7638. * @param pitchCor optional pitch (x-axis) correction in radians
  7639. * @param rollCor optional roll (z-axis) correction in radians
  7640. * @param space the choosen space of the target
  7641. * @returns the TransformNode.
  7642. */
  7643. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7644. /**
  7645. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7646. * This Vector3 is expressed in the World space.
  7647. * @param localAxis axis to rotate
  7648. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7649. */
  7650. getDirection(localAxis: Vector3): Vector3;
  7651. /**
  7652. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7653. * localAxis is expressed in the mesh local space.
  7654. * result is computed in the Wordl space from the mesh World matrix.
  7655. * @param localAxis axis to rotate
  7656. * @param result the resulting transformnode
  7657. * @returns this TransformNode.
  7658. */
  7659. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7660. /**
  7661. * Sets this transform node rotation to the given local axis.
  7662. * @param localAxis the axis in local space
  7663. * @param yawCor optional yaw (y-axis) correction in radians
  7664. * @param pitchCor optional pitch (x-axis) correction in radians
  7665. * @param rollCor optional roll (z-axis) correction in radians
  7666. * @returns this TransformNode
  7667. */
  7668. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7669. /**
  7670. * Sets a new pivot point to the current node
  7671. * @param point defines the new pivot point to use
  7672. * @param space defines if the point is in world or local space (local by default)
  7673. * @returns the current TransformNode
  7674. */
  7675. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7676. /**
  7677. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7678. * @returns the pivot point
  7679. */
  7680. getPivotPoint(): Vector3;
  7681. /**
  7682. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7683. * @param result the vector3 to store the result
  7684. * @returns this TransformNode.
  7685. */
  7686. getPivotPointToRef(result: Vector3): TransformNode;
  7687. /**
  7688. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7689. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7690. */
  7691. getAbsolutePivotPoint(): Vector3;
  7692. /**
  7693. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7694. * @param result vector3 to store the result
  7695. * @returns this TransformNode.
  7696. */
  7697. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7698. /**
  7699. * Defines the passed node as the parent of the current node.
  7700. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7701. * @see https://doc.babylonjs.com/how_to/parenting
  7702. * @param node the node ot set as the parent
  7703. * @returns this TransformNode.
  7704. */
  7705. setParent(node: Nullable<Node>): TransformNode;
  7706. private _nonUniformScaling;
  7707. /**
  7708. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7709. */
  7710. readonly nonUniformScaling: boolean;
  7711. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7712. /**
  7713. * Attach the current TransformNode to another TransformNode associated with a bone
  7714. * @param bone Bone affecting the TransformNode
  7715. * @param affectedTransformNode TransformNode associated with the bone
  7716. * @returns this object
  7717. */
  7718. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7719. /**
  7720. * Detach the transform node if its associated with a bone
  7721. * @returns this object
  7722. */
  7723. detachFromBone(): TransformNode;
  7724. private static _rotationAxisCache;
  7725. /**
  7726. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7727. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7728. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7729. * The passed axis is also normalized.
  7730. * @param axis the axis to rotate around
  7731. * @param amount the amount to rotate in radians
  7732. * @param space Space to rotate in (Default: local)
  7733. * @returns the TransformNode.
  7734. */
  7735. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7736. /**
  7737. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7738. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7739. * The passed axis is also normalized. .
  7740. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7741. * @param point the point to rotate around
  7742. * @param axis the axis to rotate around
  7743. * @param amount the amount to rotate in radians
  7744. * @returns the TransformNode
  7745. */
  7746. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7747. /**
  7748. * Translates the mesh along the axis vector for the passed distance in the given space.
  7749. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7750. * @param axis the axis to translate in
  7751. * @param distance the distance to translate
  7752. * @param space Space to rotate in (Default: local)
  7753. * @returns the TransformNode.
  7754. */
  7755. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7756. /**
  7757. * Adds a rotation step to the mesh current rotation.
  7758. * x, y, z are Euler angles expressed in radians.
  7759. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7760. * This means this rotation is made in the mesh local space only.
  7761. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7762. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7763. * ```javascript
  7764. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7765. * ```
  7766. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7767. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  7768. * @param x Rotation to add
  7769. * @param y Rotation to add
  7770. * @param z Rotation to add
  7771. * @returns the TransformNode.
  7772. */
  7773. addRotation(x: number, y: number, z: number): TransformNode;
  7774. /**
  7775. * @hidden
  7776. */
  7777. protected _getEffectiveParent(): Nullable<Node>;
  7778. /**
  7779. * Computes the world matrix of the node
  7780. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7781. * @returns the world matrix
  7782. */
  7783. computeWorldMatrix(force?: boolean): Matrix;
  7784. protected _afterComputeWorldMatrix(): void;
  7785. /**
  7786. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7787. * @param func callback function to add
  7788. *
  7789. * @returns the TransformNode.
  7790. */
  7791. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7792. /**
  7793. * Removes a registered callback function.
  7794. * @param func callback function to remove
  7795. * @returns the TransformNode.
  7796. */
  7797. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7798. /**
  7799. * Gets the position of the current mesh in camera space
  7800. * @param camera defines the camera to use
  7801. * @returns a position
  7802. */
  7803. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7804. /**
  7805. * Returns the distance from the mesh to the active camera
  7806. * @param camera defines the camera to use
  7807. * @returns the distance
  7808. */
  7809. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7810. /**
  7811. * Clone the current transform node
  7812. * @param name Name of the new clone
  7813. * @param newParent New parent for the clone
  7814. * @param doNotCloneChildren Do not clone children hierarchy
  7815. * @returns the new transform node
  7816. */
  7817. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7818. /**
  7819. * Serializes the objects information.
  7820. * @param currentSerializationObject defines the object to serialize in
  7821. * @returns the serialized object
  7822. */
  7823. serialize(currentSerializationObject?: any): any;
  7824. /**
  7825. * Returns a new TransformNode object parsed from the source provided.
  7826. * @param parsedTransformNode is the source.
  7827. * @param scene the scne the object belongs to
  7828. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7829. * @returns a new TransformNode object parsed from the source provided.
  7830. */
  7831. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7832. /**
  7833. * Get all child-transformNodes of this node
  7834. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  7835. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  7836. * @returns an array of TransformNode
  7837. */
  7838. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7839. /**
  7840. * Releases resources associated with this transform node.
  7841. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7842. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7843. */
  7844. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7845. }
  7846. }
  7847. declare module BABYLON {
  7848. /**
  7849. * Class used to override all child animations of a given target
  7850. */
  7851. export class AnimationPropertiesOverride {
  7852. /**
  7853. * Gets or sets a value indicating if animation blending must be used
  7854. */
  7855. enableBlending: boolean;
  7856. /**
  7857. * Gets or sets the blending speed to use when enableBlending is true
  7858. */
  7859. blendingSpeed: number;
  7860. /**
  7861. * Gets or sets the default loop mode to use
  7862. */
  7863. loopMode: number;
  7864. }
  7865. }
  7866. declare module BABYLON {
  7867. /**
  7868. * Class used to store bone information
  7869. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7870. */
  7871. export class Bone extends Node {
  7872. /**
  7873. * defines the bone name
  7874. */
  7875. name: string;
  7876. private static _tmpVecs;
  7877. private static _tmpQuat;
  7878. private static _tmpMats;
  7879. /**
  7880. * Gets the list of child bones
  7881. */
  7882. children: Bone[];
  7883. /** Gets the animations associated with this bone */
  7884. animations: Animation[];
  7885. /**
  7886. * Gets or sets bone length
  7887. */
  7888. length: number;
  7889. /**
  7890. * @hidden Internal only
  7891. * Set this value to map this bone to a different index in the transform matrices
  7892. * Set this value to -1 to exclude the bone from the transform matrices
  7893. */ index: Nullable<number>;
  7894. private _skeleton;
  7895. private _localMatrix;
  7896. private _restPose;
  7897. private _baseMatrix;
  7898. private _absoluteTransform;
  7899. private _invertedAbsoluteTransform;
  7900. private _parent;
  7901. private _scalingDeterminant;
  7902. private _worldTransform;
  7903. private _localScaling;
  7904. private _localRotation;
  7905. private _localPosition;
  7906. private _needToDecompose;
  7907. private _needToCompose;
  7908. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7909. /** @hidden */ waitingTransformNodeId: Nullable<string>;
  7910. /** @hidden */
  7911. /** @hidden */ matrix: Matrix;
  7912. /**
  7913. * Create a new bone
  7914. * @param name defines the bone name
  7915. * @param skeleton defines the parent skeleton
  7916. * @param parentBone defines the parent (can be null if the bone is the root)
  7917. * @param localMatrix defines the local matrix
  7918. * @param restPose defines the rest pose matrix
  7919. * @param baseMatrix defines the base matrix
  7920. * @param index defines index of the bone in the hiearchy
  7921. */
  7922. constructor(
  7923. /**
  7924. * defines the bone name
  7925. */
  7926. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7927. /**
  7928. * Gets the current object class name.
  7929. * @return the class name
  7930. */
  7931. getClassName(): string;
  7932. /**
  7933. * Gets the parent skeleton
  7934. * @returns a skeleton
  7935. */
  7936. getSkeleton(): Skeleton;
  7937. /**
  7938. * Gets parent bone
  7939. * @returns a bone or null if the bone is the root of the bone hierarchy
  7940. */
  7941. getParent(): Nullable<Bone>;
  7942. /**
  7943. * Returns an array containing the root bones
  7944. * @returns an array containing the root bones
  7945. */
  7946. getChildren(): Array<Bone>;
  7947. /**
  7948. * Sets the parent bone
  7949. * @param parent defines the parent (can be null if the bone is the root)
  7950. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7951. */
  7952. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7953. /**
  7954. * Gets the local matrix
  7955. * @returns a matrix
  7956. */
  7957. getLocalMatrix(): Matrix;
  7958. /**
  7959. * Gets the base matrix (initial matrix which remains unchanged)
  7960. * @returns a matrix
  7961. */
  7962. getBaseMatrix(): Matrix;
  7963. /**
  7964. * Gets the rest pose matrix
  7965. * @returns a matrix
  7966. */
  7967. getRestPose(): Matrix;
  7968. /**
  7969. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7970. */
  7971. getWorldMatrix(): Matrix;
  7972. /**
  7973. * Sets the local matrix to rest pose matrix
  7974. */
  7975. returnToRest(): void;
  7976. /**
  7977. * Gets the inverse of the absolute transform matrix.
  7978. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7979. * @returns a matrix
  7980. */
  7981. getInvertedAbsoluteTransform(): Matrix;
  7982. /**
  7983. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7984. * @returns a matrix
  7985. */
  7986. getAbsoluteTransform(): Matrix;
  7987. /**
  7988. * Links with the given transform node.
  7989. * The local matrix of this bone is copied from the transform node every frame.
  7990. * @param transformNode defines the transform node to link to
  7991. */
  7992. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7993. /** Gets or sets current position (in local space) */
  7994. position: Vector3;
  7995. /** Gets or sets current rotation (in local space) */
  7996. rotation: Vector3;
  7997. /** Gets or sets current rotation quaternion (in local space) */
  7998. rotationQuaternion: Quaternion;
  7999. /** Gets or sets current scaling (in local space) */
  8000. scaling: Vector3;
  8001. /**
  8002. * Gets the animation properties override
  8003. */
  8004. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8005. private _decompose;
  8006. private _compose;
  8007. /**
  8008. * Update the base and local matrices
  8009. * @param matrix defines the new base or local matrix
  8010. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8011. * @param updateLocalMatrix defines if the local matrix should be updated
  8012. */
  8013. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8014. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8015. /**
  8016. * Flag the bone as dirty (Forcing it to update everything)
  8017. */
  8018. markAsDirty(): void;
  8019. private _markAsDirtyAndCompose;
  8020. private _markAsDirtyAndDecompose;
  8021. /**
  8022. * Translate the bone in local or world space
  8023. * @param vec The amount to translate the bone
  8024. * @param space The space that the translation is in
  8025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8026. */
  8027. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8028. /**
  8029. * Set the postion of the bone in local or world space
  8030. * @param position The position to set the bone
  8031. * @param space The space that the position is in
  8032. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8033. */
  8034. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8035. /**
  8036. * Set the absolute position of the bone (world space)
  8037. * @param position The position to set the bone
  8038. * @param mesh The mesh that this bone is attached to
  8039. */
  8040. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8041. /**
  8042. * Scale the bone on the x, y and z axes (in local space)
  8043. * @param x The amount to scale the bone on the x axis
  8044. * @param y The amount to scale the bone on the y axis
  8045. * @param z The amount to scale the bone on the z axis
  8046. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8047. */
  8048. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8049. /**
  8050. * Set the bone scaling in local space
  8051. * @param scale defines the scaling vector
  8052. */
  8053. setScale(scale: Vector3): void;
  8054. /**
  8055. * Gets the current scaling in local space
  8056. * @returns the current scaling vector
  8057. */
  8058. getScale(): Vector3;
  8059. /**
  8060. * Gets the current scaling in local space and stores it in a target vector
  8061. * @param result defines the target vector
  8062. */
  8063. getScaleToRef(result: Vector3): void;
  8064. /**
  8065. * Set the yaw, pitch, and roll of the bone in local or world space
  8066. * @param yaw The rotation of the bone on the y axis
  8067. * @param pitch The rotation of the bone on the x axis
  8068. * @param roll The rotation of the bone on the z axis
  8069. * @param space The space that the axes of rotation are in
  8070. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8071. */
  8072. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8073. /**
  8074. * Add a rotation to the bone on an axis in local or world space
  8075. * @param axis The axis to rotate the bone on
  8076. * @param amount The amount to rotate the bone
  8077. * @param space The space that the axis is in
  8078. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8079. */
  8080. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8081. /**
  8082. * Set the rotation of the bone to a particular axis angle in local or world space
  8083. * @param axis The axis to rotate the bone on
  8084. * @param angle The angle that the bone should be rotated to
  8085. * @param space The space that the axis is in
  8086. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8087. */
  8088. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8089. /**
  8090. * Set the euler rotation of the bone in local of world space
  8091. * @param rotation The euler rotation that the bone should be set to
  8092. * @param space The space that the rotation is in
  8093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8094. */
  8095. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8096. /**
  8097. * Set the quaternion rotation of the bone in local of world space
  8098. * @param quat The quaternion rotation that the bone should be set to
  8099. * @param space The space that the rotation is in
  8100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8101. */
  8102. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8103. /**
  8104. * Set the rotation matrix of the bone in local of world space
  8105. * @param rotMat The rotation matrix that the bone should be set to
  8106. * @param space The space that the rotation is in
  8107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8108. */
  8109. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8110. private _rotateWithMatrix;
  8111. private _getNegativeRotationToRef;
  8112. /**
  8113. * Get the position of the bone in local or world space
  8114. * @param space The space that the returned position is in
  8115. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8116. * @returns The position of the bone
  8117. */
  8118. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8119. /**
  8120. * Copy the position of the bone to a vector3 in local or world space
  8121. * @param space The space that the returned position is in
  8122. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8123. * @param result The vector3 to copy the position to
  8124. */
  8125. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8126. /**
  8127. * Get the absolute position of the bone (world space)
  8128. * @param mesh The mesh that this bone is attached to
  8129. * @returns The absolute position of the bone
  8130. */
  8131. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8132. /**
  8133. * Copy the absolute position of the bone (world space) to the result param
  8134. * @param mesh The mesh that this bone is attached to
  8135. * @param result The vector3 to copy the absolute position to
  8136. */
  8137. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8138. /**
  8139. * Compute the absolute transforms of this bone and its children
  8140. */
  8141. computeAbsoluteTransforms(): void;
  8142. /**
  8143. * Get the world direction from an axis that is in the local space of the bone
  8144. * @param localAxis The local direction that is used to compute the world direction
  8145. * @param mesh The mesh that this bone is attached to
  8146. * @returns The world direction
  8147. */
  8148. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8149. /**
  8150. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8151. * @param localAxis The local direction that is used to compute the world direction
  8152. * @param mesh The mesh that this bone is attached to
  8153. * @param result The vector3 that the world direction will be copied to
  8154. */
  8155. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8156. /**
  8157. * Get the euler rotation of the bone in local or world space
  8158. * @param space The space that the rotation should be in
  8159. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8160. * @returns The euler rotation
  8161. */
  8162. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8163. /**
  8164. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8165. * @param space The space that the rotation should be in
  8166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8167. * @param result The vector3 that the rotation should be copied to
  8168. */
  8169. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8170. /**
  8171. * Get the quaternion rotation of the bone in either local or world space
  8172. * @param space The space that the rotation should be in
  8173. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8174. * @returns The quaternion rotation
  8175. */
  8176. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8177. /**
  8178. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8179. * @param space The space that the rotation should be in
  8180. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8181. * @param result The quaternion that the rotation should be copied to
  8182. */
  8183. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8184. /**
  8185. * Get the rotation matrix of the bone in local or world space
  8186. * @param space The space that the rotation should be in
  8187. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8188. * @returns The rotation matrix
  8189. */
  8190. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8191. /**
  8192. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8193. * @param space The space that the rotation should be in
  8194. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8195. * @param result The quaternion that the rotation should be copied to
  8196. */
  8197. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8198. /**
  8199. * Get the world position of a point that is in the local space of the bone
  8200. * @param position The local position
  8201. * @param mesh The mesh that this bone is attached to
  8202. * @returns The world position
  8203. */
  8204. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8205. /**
  8206. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8207. * @param position The local position
  8208. * @param mesh The mesh that this bone is attached to
  8209. * @param result The vector3 that the world position should be copied to
  8210. */
  8211. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8212. /**
  8213. * Get the local position of a point that is in world space
  8214. * @param position The world position
  8215. * @param mesh The mesh that this bone is attached to
  8216. * @returns The local position
  8217. */
  8218. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8219. /**
  8220. * Get the local position of a point that is in world space and copy it to the result param
  8221. * @param position The world position
  8222. * @param mesh The mesh that this bone is attached to
  8223. * @param result The vector3 that the local position should be copied to
  8224. */
  8225. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8226. }
  8227. }
  8228. declare module BABYLON {
  8229. /**
  8230. * Enum that determines the text-wrapping mode to use.
  8231. */
  8232. export enum InspectableType {
  8233. /**
  8234. * Checkbox for booleans
  8235. */
  8236. Checkbox = 0,
  8237. /**
  8238. * Sliders for numbers
  8239. */
  8240. Slider = 1,
  8241. /**
  8242. * Vector3
  8243. */
  8244. Vector3 = 2,
  8245. /**
  8246. * Quaternions
  8247. */
  8248. Quaternion = 3,
  8249. /**
  8250. * Color3
  8251. */
  8252. Color3 = 4
  8253. }
  8254. /**
  8255. * Interface used to define custom inspectable properties.
  8256. * This interface is used by the inspector to display custom property grids
  8257. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8258. */
  8259. export interface IInspectable {
  8260. /**
  8261. * Gets the label to display
  8262. */
  8263. label: string;
  8264. /**
  8265. * Gets the name of the property to edit
  8266. */
  8267. propertyName: string;
  8268. /**
  8269. * Gets the type of the editor to use
  8270. */
  8271. type: InspectableType;
  8272. /**
  8273. * Gets the minimum value of the property when using in "slider" mode
  8274. */
  8275. min?: number;
  8276. /**
  8277. * Gets the maximum value of the property when using in "slider" mode
  8278. */
  8279. max?: number;
  8280. /**
  8281. * Gets the setp to use when using in "slider" mode
  8282. */
  8283. step?: number;
  8284. }
  8285. }
  8286. declare module BABYLON {
  8287. /**
  8288. * This represents the required contract to create a new type of texture loader.
  8289. */
  8290. export interface IInternalTextureLoader {
  8291. /**
  8292. * Defines wether the loader supports cascade loading the different faces.
  8293. */
  8294. supportCascades: boolean;
  8295. /**
  8296. * This returns if the loader support the current file information.
  8297. * @param extension defines the file extension of the file being loaded
  8298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8299. * @param fallback defines the fallback internal texture if any
  8300. * @param isBase64 defines whether the texture is encoded as a base64
  8301. * @param isBuffer defines whether the texture data are stored as a buffer
  8302. * @returns true if the loader can load the specified file
  8303. */
  8304. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8305. /**
  8306. * Transform the url before loading if required.
  8307. * @param rootUrl the url of the texture
  8308. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8309. * @returns the transformed texture
  8310. */
  8311. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8312. /**
  8313. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8314. * @param rootUrl the url of the texture
  8315. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8316. * @returns the fallback texture
  8317. */
  8318. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8319. /**
  8320. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8321. * @param data contains the texture data
  8322. * @param texture defines the BabylonJS internal texture
  8323. * @param createPolynomials will be true if polynomials have been requested
  8324. * @param onLoad defines the callback to trigger once the texture is ready
  8325. * @param onError defines the callback to trigger in case of error
  8326. */
  8327. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8328. /**
  8329. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8330. * @param data contains the texture data
  8331. * @param texture defines the BabylonJS internal texture
  8332. * @param callback defines the method to call once ready to upload
  8333. */
  8334. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8335. }
  8336. }
  8337. declare module BABYLON {
  8338. interface Engine {
  8339. /**
  8340. * Creates a depth stencil cube texture.
  8341. * This is only available in WebGL 2.
  8342. * @param size The size of face edge in the cube texture.
  8343. * @param options The options defining the cube texture.
  8344. * @returns The cube texture
  8345. */ createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8346. /**
  8347. * Creates a cube texture
  8348. * @param rootUrl defines the url where the files to load is located
  8349. * @param scene defines the current scene
  8350. * @param files defines the list of files to load (1 per face)
  8351. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8352. * @param onLoad defines an optional callback raised when the texture is loaded
  8353. * @param onError defines an optional callback raised if there is an issue to load the texture
  8354. * @param format defines the format of the data
  8355. * @param forcedExtension defines the extension to use to pick the right loader
  8356. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8357. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8358. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8359. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8360. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8361. * @returns the cube texture as an InternalTexture
  8362. */
  8363. 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;
  8364. /**
  8365. * Creates a cube texture
  8366. * @param rootUrl defines the url where the files to load is located
  8367. * @param scene defines the current scene
  8368. * @param files defines the list of files to load (1 per face)
  8369. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8370. * @param onLoad defines an optional callback raised when the texture is loaded
  8371. * @param onError defines an optional callback raised if there is an issue to load the texture
  8372. * @param format defines the format of the data
  8373. * @param forcedExtension defines the extension to use to pick the right loader
  8374. * @returns the cube texture as an InternalTexture
  8375. */
  8376. 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;
  8377. /**
  8378. * Creates a cube texture
  8379. * @param rootUrl defines the url where the files to load is located
  8380. * @param scene defines the current scene
  8381. * @param files defines the list of files to load (1 per face)
  8382. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8383. * @param onLoad defines an optional callback raised when the texture is loaded
  8384. * @param onError defines an optional callback raised if there is an issue to load the texture
  8385. * @param format defines the format of the data
  8386. * @param forcedExtension defines the extension to use to pick the right loader
  8387. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8388. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8389. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8390. * @returns the cube texture as an InternalTexture
  8391. */
  8392. 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;
  8393. /** @hidden */ partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8394. /** @hidden */ cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8395. /** @hidden */ cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8396. /** @hidden */ partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8397. }
  8398. }
  8399. declare module BABYLON {
  8400. /**
  8401. * Class for creating a cube texture
  8402. */
  8403. export class CubeTexture extends BaseTexture {
  8404. private _delayedOnLoad;
  8405. /**
  8406. * The url of the texture
  8407. */
  8408. url: string;
  8409. /**
  8410. * Gets or sets the center of the bounding box associated with the cube texture.
  8411. * It must define where the camera used to render the texture was set
  8412. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8413. */
  8414. boundingBoxPosition: Vector3;
  8415. private _boundingBoxSize;
  8416. /**
  8417. * Gets or sets the size of the bounding box associated with the cube texture
  8418. * When defined, the cubemap will switch to local mode
  8419. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8420. * @example https://www.babylonjs-playground.com/#RNASML
  8421. */
  8422. /**
  8423. * Returns the bounding box size
  8424. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8425. */
  8426. boundingBoxSize: Vector3;
  8427. protected _rotationY: number;
  8428. /**
  8429. * Sets texture matrix rotation angle around Y axis in radians.
  8430. */
  8431. /**
  8432. * Gets texture matrix rotation angle around Y axis radians.
  8433. */
  8434. rotationY: number;
  8435. /**
  8436. * Are mip maps generated for this texture or not.
  8437. */
  8438. readonly noMipmap: boolean;
  8439. private _noMipmap;
  8440. private _files;
  8441. private _extensions;
  8442. private _textureMatrix;
  8443. private _format;
  8444. private _createPolynomials;
  8445. /** @hidden */ prefiltered: boolean;
  8446. /**
  8447. * Creates a cube texture from an array of image urls
  8448. * @param files defines an array of image urls
  8449. * @param scene defines the hosting scene
  8450. * @param noMipmap specifies if mip maps are not used
  8451. * @returns a cube texture
  8452. */
  8453. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8454. /**
  8455. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8456. * @param url defines the url of the prefiltered texture
  8457. * @param scene defines the scene the texture is attached to
  8458. * @param forcedExtension defines the extension of the file if different from the url
  8459. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8460. * @return the prefiltered texture
  8461. */
  8462. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8463. /**
  8464. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8465. * as prefiltered data.
  8466. * @param rootUrl defines the url of the texture or the root name of the six images
  8467. * @param scene defines the scene the texture is attached to
  8468. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8469. * @param noMipmap defines if mipmaps should be created or not
  8470. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8471. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8472. * @param onError defines a callback triggered in case of error during load
  8473. * @param format defines the internal format to use for the texture once loaded
  8474. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8475. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8476. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8477. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8478. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8479. * @return the cube texture
  8480. */
  8481. 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);
  8482. /**
  8483. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8484. */
  8485. readonly isPrefiltered: boolean;
  8486. /**
  8487. * Get the current class name of the texture useful for serialization or dynamic coding.
  8488. * @returns "CubeTexture"
  8489. */
  8490. getClassName(): string;
  8491. /**
  8492. * Update the url (and optional buffer) of this texture if url was null during construction.
  8493. * @param url the url of the texture
  8494. * @param forcedExtension defines the extension to use
  8495. * @param onLoad callback called when the texture is loaded (defaults to null)
  8496. */
  8497. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8498. /**
  8499. * Delays loading of the cube texture
  8500. * @param forcedExtension defines the extension to use
  8501. */
  8502. delayLoad(forcedExtension?: string): void;
  8503. /**
  8504. * Returns the reflection texture matrix
  8505. * @returns the reflection texture matrix
  8506. */
  8507. getReflectionTextureMatrix(): Matrix;
  8508. /**
  8509. * Sets the reflection texture matrix
  8510. * @param value Reflection texture matrix
  8511. */
  8512. setReflectionTextureMatrix(value: Matrix): void;
  8513. /**
  8514. * Parses text to create a cube texture
  8515. * @param parsedTexture define the serialized text to read from
  8516. * @param scene defines the hosting scene
  8517. * @param rootUrl defines the root url of the cube texture
  8518. * @returns a cube texture
  8519. */
  8520. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8521. /**
  8522. * Makes a clone, or deep copy, of the cube texture
  8523. * @returns a new cube texture
  8524. */
  8525. clone(): CubeTexture;
  8526. }
  8527. }
  8528. declare module BABYLON {
  8529. /** @hidden */
  8530. export var postprocessVertexShader: {
  8531. name: string;
  8532. shader: string;
  8533. };
  8534. }
  8535. declare module BABYLON {
  8536. /**
  8537. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8538. * This is the base of the follow, arc rotate cameras and Free camera
  8539. * @see http://doc.babylonjs.com/features/cameras
  8540. */
  8541. export class TargetCamera extends Camera {
  8542. private static _RigCamTransformMatrix;
  8543. private static _TargetTransformMatrix;
  8544. private static _TargetFocalPoint;
  8545. /**
  8546. * Define the current direction the camera is moving to
  8547. */
  8548. cameraDirection: Vector3;
  8549. /**
  8550. * Define the current rotation the camera is rotating to
  8551. */
  8552. cameraRotation: Vector2;
  8553. /**
  8554. * When set, the up vector of the camera will be updated by the rotation of the camera
  8555. */
  8556. updateUpVectorFromRotation: boolean;
  8557. private _tmpQuaternion;
  8558. /**
  8559. * Define the current rotation of the camera
  8560. */
  8561. rotation: Vector3;
  8562. /**
  8563. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8564. */
  8565. rotationQuaternion: Quaternion;
  8566. /**
  8567. * Define the current speed of the camera
  8568. */
  8569. speed: number;
  8570. /**
  8571. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8572. * around all axis.
  8573. */
  8574. noRotationConstraint: boolean;
  8575. /**
  8576. * Define the current target of the camera as an object or a position.
  8577. */
  8578. lockedTarget: any;
  8579. /** @hidden */ currentTarget: Vector3;
  8580. /** @hidden */ initialFocalDistance: number;
  8581. /** @hidden */ viewMatrix: Matrix;
  8582. /** @hidden */ camMatrix: Matrix;
  8583. /** @hidden */ cameraTransformMatrix: Matrix;
  8584. /** @hidden */ cameraRotationMatrix: Matrix;
  8585. /** @hidden */ referencePoint: Vector3;
  8586. /** @hidden */ transformedReferencePoint: Vector3;
  8587. protected _globalCurrentTarget: Vector3;
  8588. protected _globalCurrentUpVector: Vector3;
  8589. /** @hidden */ reset: () => void;
  8590. private _defaultUp;
  8591. /**
  8592. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8593. * This is the base of the follow, arc rotate cameras and Free camera
  8594. * @see http://doc.babylonjs.com/features/cameras
  8595. * @param name Defines the name of the camera in the scene
  8596. * @param position Defines the start position of the camera in the scene
  8597. * @param scene Defines the scene the camera belongs to
  8598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8599. */
  8600. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8601. /**
  8602. * Gets the position in front of the camera at a given distance.
  8603. * @param distance The distance from the camera we want the position to be
  8604. * @returns the position
  8605. */
  8606. getFrontPosition(distance: number): Vector3;
  8607. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8608. private _storedPosition;
  8609. private _storedRotation;
  8610. private _storedRotationQuaternion;
  8611. /**
  8612. * Store current camera state of the camera (fov, position, rotation, etc..)
  8613. * @returns the camera
  8614. */
  8615. storeState(): Camera;
  8616. /**
  8617. * Restored camera state. You must call storeState() first
  8618. * @returns whether it was successful or not
  8619. * @hidden
  8620. */ restoreStateValues(): boolean;
  8621. /** @hidden */ initCache(): void;
  8622. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8623. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8624. /** @hidden */ computeLocalCameraSpeed(): number;
  8625. /**
  8626. * Defines the target the camera should look at.
  8627. * This will automatically adapt alpha beta and radius to fit within the new target.
  8628. * @param target Defines the new target as a Vector or a mesh
  8629. */
  8630. setTarget(target: Vector3): void;
  8631. /**
  8632. * Return the current target position of the camera. This value is expressed in local space.
  8633. * @returns the target position
  8634. */
  8635. getTarget(): Vector3;
  8636. /** @hidden */ decideIfNeedsToMove(): boolean;
  8637. /** @hidden */ updatePosition(): void;
  8638. /** @hidden */ checkInputs(): void;
  8639. protected _updateCameraRotationMatrix(): void;
  8640. /**
  8641. * 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)
  8642. * @returns the current camera
  8643. */
  8644. private _rotateUpVectorWithCameraRotationMatrix;
  8645. private _cachedRotationZ;
  8646. private _cachedQuaternionRotationZ;
  8647. /** @hidden */ getViewMatrix(): Matrix;
  8648. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8649. /**
  8650. * @hidden
  8651. */
  8652. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8653. /**
  8654. * @hidden
  8655. */ updateRigCameras(): void;
  8656. private _getRigCamPositionAndTarget;
  8657. /**
  8658. * Gets the current object class name.
  8659. * @return the class name
  8660. */
  8661. getClassName(): string;
  8662. }
  8663. }
  8664. declare module BABYLON {
  8665. /**
  8666. * @ignore
  8667. * This is a list of all the different input types that are available in the application.
  8668. * Fo instance: ArcRotateCameraGamepadInput...
  8669. */
  8670. export var CameraInputTypes: {};
  8671. /**
  8672. * This is the contract to implement in order to create a new input class.
  8673. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8674. */
  8675. export interface ICameraInput<TCamera extends Camera> {
  8676. /**
  8677. * Defines the camera the input is attached to.
  8678. */
  8679. camera: Nullable<TCamera>;
  8680. /**
  8681. * Gets the class name of the current intput.
  8682. * @returns the class name
  8683. */
  8684. getClassName(): string;
  8685. /**
  8686. * Get the friendly name associated with the input class.
  8687. * @returns the input friendly name
  8688. */
  8689. getSimpleName(): string;
  8690. /**
  8691. * Attach the input controls to a specific dom element to get the input from.
  8692. * @param element Defines the element the controls should be listened from
  8693. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8694. */
  8695. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8696. /**
  8697. * Detach the current controls from the specified dom element.
  8698. * @param element Defines the element to stop listening the inputs from
  8699. */
  8700. detachControl(element: Nullable<HTMLElement>): void;
  8701. /**
  8702. * Update the current camera state depending on the inputs that have been used this frame.
  8703. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8704. */
  8705. checkInputs?: () => void;
  8706. }
  8707. /**
  8708. * Represents a map of input types to input instance or input index to input instance.
  8709. */
  8710. export interface CameraInputsMap<TCamera extends Camera> {
  8711. /**
  8712. * Accessor to the input by input type.
  8713. */
  8714. [name: string]: ICameraInput<TCamera>;
  8715. /**
  8716. * Accessor to the input by input index.
  8717. */
  8718. [idx: number]: ICameraInput<TCamera>;
  8719. }
  8720. /**
  8721. * This represents the input manager used within a camera.
  8722. * It helps dealing with all the different kind of input attached to a camera.
  8723. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8724. */
  8725. export class CameraInputsManager<TCamera extends Camera> {
  8726. /**
  8727. * Defines the list of inputs attahed to the camera.
  8728. */
  8729. attached: CameraInputsMap<TCamera>;
  8730. /**
  8731. * Defines the dom element the camera is collecting inputs from.
  8732. * This is null if the controls have not been attached.
  8733. */
  8734. attachedElement: Nullable<HTMLElement>;
  8735. /**
  8736. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8737. */
  8738. noPreventDefault: boolean;
  8739. /**
  8740. * Defined the camera the input manager belongs to.
  8741. */
  8742. camera: TCamera;
  8743. /**
  8744. * Update the current camera state depending on the inputs that have been used this frame.
  8745. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8746. */
  8747. checkInputs: () => void;
  8748. /**
  8749. * Instantiate a new Camera Input Manager.
  8750. * @param camera Defines the camera the input manager blongs to
  8751. */
  8752. constructor(camera: TCamera);
  8753. /**
  8754. * Add an input method to a camera
  8755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8756. * @param input camera input method
  8757. */
  8758. add(input: ICameraInput<TCamera>): void;
  8759. /**
  8760. * Remove a specific input method from a camera
  8761. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8762. * @param inputToRemove camera input method
  8763. */
  8764. remove(inputToRemove: ICameraInput<TCamera>): void;
  8765. /**
  8766. * Remove a specific input type from a camera
  8767. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8768. * @param inputType the type of the input to remove
  8769. */
  8770. removeByType(inputType: string): void;
  8771. private _addCheckInputs;
  8772. /**
  8773. * Attach the input controls to the currently attached dom element to listen the events from.
  8774. * @param input Defines the input to attach
  8775. */
  8776. attachInput(input: ICameraInput<TCamera>): void;
  8777. /**
  8778. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8779. * @param element Defines the dom element to collect the events from
  8780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8781. */
  8782. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8783. /**
  8784. * Detach the current manager inputs controls from a specific dom element.
  8785. * @param element Defines the dom element to collect the events from
  8786. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8787. */
  8788. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8789. /**
  8790. * Rebuild the dynamic inputCheck function from the current list of
  8791. * defined inputs in the manager.
  8792. */
  8793. rebuildInputCheck(): void;
  8794. /**
  8795. * Remove all attached input methods from a camera
  8796. */
  8797. clear(): void;
  8798. /**
  8799. * Serialize the current input manager attached to a camera.
  8800. * This ensures than once parsed,
  8801. * the input associated to the camera will be identical to the current ones
  8802. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8803. */
  8804. serialize(serializedCamera: any): void;
  8805. /**
  8806. * Parses an input manager serialized JSON to restore the previous list of inputs
  8807. * and states associated to a camera.
  8808. * @param parsedCamera Defines the JSON to parse
  8809. */
  8810. parse(parsedCamera: any): void;
  8811. }
  8812. }
  8813. declare module BABYLON {
  8814. /**
  8815. * Gather the list of keyboard event types as constants.
  8816. */
  8817. export class KeyboardEventTypes {
  8818. /**
  8819. * The keydown event is fired when a key becomes active (pressed).
  8820. */
  8821. static readonly KEYDOWN: number;
  8822. /**
  8823. * The keyup event is fired when a key has been released.
  8824. */
  8825. static readonly KEYUP: number;
  8826. }
  8827. /**
  8828. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8829. */
  8830. export class KeyboardInfo {
  8831. /**
  8832. * Defines the type of event (KeyboardEventTypes)
  8833. */
  8834. type: number;
  8835. /**
  8836. * Defines the related dom event
  8837. */
  8838. event: KeyboardEvent;
  8839. /**
  8840. * Instantiates a new keyboard info.
  8841. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8842. * @param type Defines the type of event (KeyboardEventTypes)
  8843. * @param event Defines the related dom event
  8844. */
  8845. constructor(
  8846. /**
  8847. * Defines the type of event (KeyboardEventTypes)
  8848. */
  8849. type: number,
  8850. /**
  8851. * Defines the related dom event
  8852. */
  8853. event: KeyboardEvent);
  8854. }
  8855. /**
  8856. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8857. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8858. */
  8859. export class KeyboardInfoPre extends KeyboardInfo {
  8860. /**
  8861. * Defines the type of event (KeyboardEventTypes)
  8862. */
  8863. type: number;
  8864. /**
  8865. * Defines the related dom event
  8866. */
  8867. event: KeyboardEvent;
  8868. /**
  8869. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8870. */
  8871. skipOnPointerObservable: boolean;
  8872. /**
  8873. * Instantiates a new keyboard pre info.
  8874. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8875. * @param type Defines the type of event (KeyboardEventTypes)
  8876. * @param event Defines the related dom event
  8877. */
  8878. constructor(
  8879. /**
  8880. * Defines the type of event (KeyboardEventTypes)
  8881. */
  8882. type: number,
  8883. /**
  8884. * Defines the related dom event
  8885. */
  8886. event: KeyboardEvent);
  8887. }
  8888. }
  8889. declare module BABYLON {
  8890. /**
  8891. * Manage the keyboard inputs to control the movement of a free camera.
  8892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8893. */
  8894. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8895. /**
  8896. * Defines the camera the input is attached to.
  8897. */
  8898. camera: FreeCamera;
  8899. /**
  8900. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8901. */
  8902. keysUp: number[];
  8903. /**
  8904. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8905. */
  8906. keysDown: number[];
  8907. /**
  8908. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8909. */
  8910. keysLeft: number[];
  8911. /**
  8912. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8913. */
  8914. keysRight: number[];
  8915. private _keys;
  8916. private _onCanvasBlurObserver;
  8917. private _onKeyboardObserver;
  8918. private _engine;
  8919. private _scene;
  8920. /**
  8921. * Attach the input controls to a specific dom element to get the input from.
  8922. * @param element Defines the element the controls should be listened from
  8923. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8924. */
  8925. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8926. /**
  8927. * Detach the current controls from the specified dom element.
  8928. * @param element Defines the element to stop listening the inputs from
  8929. */
  8930. detachControl(element: Nullable<HTMLElement>): void;
  8931. /**
  8932. * Update the current camera state depending on the inputs that have been used this frame.
  8933. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8934. */
  8935. checkInputs(): void;
  8936. /**
  8937. * Gets the class name of the current intput.
  8938. * @returns the class name
  8939. */
  8940. getClassName(): string;
  8941. /** @hidden */ onLostFocus(): void;
  8942. /**
  8943. * Get the friendly name associated with the input class.
  8944. * @returns the input friendly name
  8945. */
  8946. getSimpleName(): string;
  8947. }
  8948. }
  8949. declare module BABYLON {
  8950. /**
  8951. * Interface describing all the common properties and methods a shadow light needs to implement.
  8952. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8953. * as well as binding the different shadow properties to the effects.
  8954. */
  8955. export interface IShadowLight extends Light {
  8956. /**
  8957. * The light id in the scene (used in scene.findLighById for instance)
  8958. */
  8959. id: string;
  8960. /**
  8961. * The position the shdow will be casted from.
  8962. */
  8963. position: Vector3;
  8964. /**
  8965. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8966. */
  8967. direction: Vector3;
  8968. /**
  8969. * The transformed position. Position of the light in world space taking parenting in account.
  8970. */
  8971. transformedPosition: Vector3;
  8972. /**
  8973. * The transformed direction. Direction of the light in world space taking parenting in account.
  8974. */
  8975. transformedDirection: Vector3;
  8976. /**
  8977. * The friendly name of the light in the scene.
  8978. */
  8979. name: string;
  8980. /**
  8981. * Defines the shadow projection clipping minimum z value.
  8982. */
  8983. shadowMinZ: number;
  8984. /**
  8985. * Defines the shadow projection clipping maximum z value.
  8986. */
  8987. shadowMaxZ: number;
  8988. /**
  8989. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8990. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8991. */
  8992. computeTransformedInformation(): boolean;
  8993. /**
  8994. * Gets the scene the light belongs to.
  8995. * @returns The scene
  8996. */
  8997. getScene(): Scene;
  8998. /**
  8999. * Callback defining a custom Projection Matrix Builder.
  9000. * This can be used to override the default projection matrix computation.
  9001. */
  9002. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9003. /**
  9004. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9005. * @param matrix The materix to updated with the projection information
  9006. * @param viewMatrix The transform matrix of the light
  9007. * @param renderList The list of mesh to render in the map
  9008. * @returns The current light
  9009. */
  9010. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9011. /**
  9012. * Gets the current depth scale used in ESM.
  9013. * @returns The scale
  9014. */
  9015. getDepthScale(): number;
  9016. /**
  9017. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9018. * @returns true if a cube texture needs to be use
  9019. */
  9020. needCube(): boolean;
  9021. /**
  9022. * Detects if the projection matrix requires to be recomputed this frame.
  9023. * @returns true if it requires to be recomputed otherwise, false.
  9024. */
  9025. needProjectionMatrixCompute(): boolean;
  9026. /**
  9027. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9028. */
  9029. forceProjectionMatrixCompute(): void;
  9030. /**
  9031. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9032. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9033. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9034. */
  9035. getShadowDirection(faceIndex?: number): Vector3;
  9036. /**
  9037. * Gets the minZ used for shadow according to both the scene and the light.
  9038. * @param activeCamera The camera we are returning the min for
  9039. * @returns the depth min z
  9040. */
  9041. getDepthMinZ(activeCamera: Camera): number;
  9042. /**
  9043. * Gets the maxZ used for shadow according to both the scene and the light.
  9044. * @param activeCamera The camera we are returning the max for
  9045. * @returns the depth max z
  9046. */
  9047. getDepthMaxZ(activeCamera: Camera): number;
  9048. }
  9049. /**
  9050. * Base implementation IShadowLight
  9051. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9052. */
  9053. export abstract class ShadowLight extends Light implements IShadowLight {
  9054. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9055. protected _position: Vector3;
  9056. protected _setPosition(value: Vector3): void;
  9057. /**
  9058. * Sets the position the shadow will be casted from. Also use as the light position for both
  9059. * point and spot lights.
  9060. */
  9061. /**
  9062. * Sets the position the shadow will be casted from. Also use as the light position for both
  9063. * point and spot lights.
  9064. */
  9065. position: Vector3;
  9066. protected _direction: Vector3;
  9067. protected _setDirection(value: Vector3): void;
  9068. /**
  9069. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9070. * Also use as the light direction on spot and directional lights.
  9071. */
  9072. /**
  9073. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9074. * Also use as the light direction on spot and directional lights.
  9075. */
  9076. direction: Vector3;
  9077. private _shadowMinZ;
  9078. /**
  9079. * Gets the shadow projection clipping minimum z value.
  9080. */
  9081. /**
  9082. * Sets the shadow projection clipping minimum z value.
  9083. */
  9084. shadowMinZ: number;
  9085. private _shadowMaxZ;
  9086. /**
  9087. * Sets the shadow projection clipping maximum z value.
  9088. */
  9089. /**
  9090. * Gets the shadow projection clipping maximum z value.
  9091. */
  9092. shadowMaxZ: number;
  9093. /**
  9094. * Callback defining a custom Projection Matrix Builder.
  9095. * This can be used to override the default projection matrix computation.
  9096. */
  9097. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9098. /**
  9099. * The transformed position. Position of the light in world space taking parenting in account.
  9100. */
  9101. transformedPosition: Vector3;
  9102. /**
  9103. * The transformed direction. Direction of the light in world space taking parenting in account.
  9104. */
  9105. transformedDirection: Vector3;
  9106. private _needProjectionMatrixCompute;
  9107. /**
  9108. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9109. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9110. */
  9111. computeTransformedInformation(): boolean;
  9112. /**
  9113. * Return the depth scale used for the shadow map.
  9114. * @returns the depth scale.
  9115. */
  9116. getDepthScale(): number;
  9117. /**
  9118. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9119. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9120. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9121. */
  9122. getShadowDirection(faceIndex?: number): Vector3;
  9123. /**
  9124. * Returns the ShadowLight absolute position in the World.
  9125. * @returns the position vector in world space
  9126. */
  9127. getAbsolutePosition(): Vector3;
  9128. /**
  9129. * Sets the ShadowLight direction toward the passed target.
  9130. * @param target The point to target in local space
  9131. * @returns the updated ShadowLight direction
  9132. */
  9133. setDirectionToTarget(target: Vector3): Vector3;
  9134. /**
  9135. * Returns the light rotation in euler definition.
  9136. * @returns the x y z rotation in local space.
  9137. */
  9138. getRotation(): Vector3;
  9139. /**
  9140. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9141. * @returns true if a cube texture needs to be use
  9142. */
  9143. needCube(): boolean;
  9144. /**
  9145. * Detects if the projection matrix requires to be recomputed this frame.
  9146. * @returns true if it requires to be recomputed otherwise, false.
  9147. */
  9148. needProjectionMatrixCompute(): boolean;
  9149. /**
  9150. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9151. */
  9152. forceProjectionMatrixCompute(): void;
  9153. /** @hidden */ initCache(): void;
  9154. /** @hidden */ isSynchronized(): boolean;
  9155. /**
  9156. * Computes the world matrix of the node
  9157. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9158. * @returns the world matrix
  9159. */
  9160. computeWorldMatrix(force?: boolean): Matrix;
  9161. /**
  9162. * Gets the minZ used for shadow according to both the scene and the light.
  9163. * @param activeCamera The camera we are returning the min for
  9164. * @returns the depth min z
  9165. */
  9166. getDepthMinZ(activeCamera: Camera): number;
  9167. /**
  9168. * Gets the maxZ used for shadow according to both the scene and the light.
  9169. * @param activeCamera The camera we are returning the max for
  9170. * @returns the depth max z
  9171. */
  9172. getDepthMaxZ(activeCamera: Camera): number;
  9173. /**
  9174. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9175. * @param matrix The materix to updated with the projection information
  9176. * @param viewMatrix The transform matrix of the light
  9177. * @param renderList The list of mesh to render in the map
  9178. * @returns The current light
  9179. */
  9180. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9181. }
  9182. }
  9183. declare module BABYLON {
  9184. /**
  9185. * "Static Class" containing the most commonly used helper while dealing with material for
  9186. * rendering purpose.
  9187. *
  9188. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9189. *
  9190. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9191. */
  9192. export class MaterialHelper {
  9193. /**
  9194. * Bind the current view position to an effect.
  9195. * @param effect The effect to be bound
  9196. * @param scene The scene the eyes position is used from
  9197. */
  9198. static BindEyePosition(effect: Effect, scene: Scene): void;
  9199. /**
  9200. * Helps preparing the defines values about the UVs in used in the effect.
  9201. * UVs are shared as much as we can accross channels in the shaders.
  9202. * @param texture The texture we are preparing the UVs for
  9203. * @param defines The defines to update
  9204. * @param key The channel key "diffuse", "specular"... used in the shader
  9205. */
  9206. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9207. /**
  9208. * Binds a texture matrix value to its corrsponding uniform
  9209. * @param texture The texture to bind the matrix for
  9210. * @param uniformBuffer The uniform buffer receivin the data
  9211. * @param key The channel key "diffuse", "specular"... used in the shader
  9212. */
  9213. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9214. /**
  9215. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9216. * @param mesh defines the current mesh
  9217. * @param scene defines the current scene
  9218. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9219. * @param pointsCloud defines if point cloud rendering has to be turned on
  9220. * @param fogEnabled defines if fog has to be turned on
  9221. * @param alphaTest defines if alpha testing has to be turned on
  9222. * @param defines defines the current list of defines
  9223. */
  9224. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9225. /**
  9226. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9227. * @param scene defines the current scene
  9228. * @param engine defines the current engine
  9229. * @param defines specifies the list of active defines
  9230. * @param useInstances defines if instances have to be turned on
  9231. * @param useClipPlane defines if clip plane have to be turned on
  9232. */
  9233. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9234. /**
  9235. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9236. * @param mesh The mesh containing the geometry data we will draw
  9237. * @param defines The defines to update
  9238. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9239. * @param useBones Precise whether bones should be used or not (override mesh info)
  9240. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9241. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9242. * @returns false if defines are considered not dirty and have not been checked
  9243. */
  9244. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9245. /**
  9246. * Prepares the defines related to multiview
  9247. * @param scene The scene we are intending to draw
  9248. * @param defines The defines to update
  9249. */
  9250. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9251. /**
  9252. * Prepares the defines related to the light information passed in parameter
  9253. * @param scene The scene we are intending to draw
  9254. * @param mesh The mesh the effect is compiling for
  9255. * @param defines The defines to update
  9256. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9257. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9258. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9259. * @returns true if normals will be required for the rest of the effect
  9260. */
  9261. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9262. /**
  9263. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9264. * that won t be acctive due to defines being turned off.
  9265. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9266. * @param samplersList The samplers list
  9267. * @param defines The defines helping in the list generation
  9268. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9269. */
  9270. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9271. /**
  9272. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9273. * @param defines The defines to update while falling back
  9274. * @param fallbacks The authorized effect fallbacks
  9275. * @param maxSimultaneousLights The maximum number of lights allowed
  9276. * @param rank the current rank of the Effect
  9277. * @returns The newly affected rank
  9278. */
  9279. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9280. /**
  9281. * Prepares the list of attributes required for morph targets according to the effect defines.
  9282. * @param attribs The current list of supported attribs
  9283. * @param mesh The mesh to prepare the morph targets attributes for
  9284. * @param defines The current Defines of the effect
  9285. */
  9286. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9287. /**
  9288. * Prepares the list of attributes required for bones according to the effect defines.
  9289. * @param attribs The current list of supported attribs
  9290. * @param mesh The mesh to prepare the bones attributes for
  9291. * @param defines The current Defines of the effect
  9292. * @param fallbacks The current efffect fallback strategy
  9293. */
  9294. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9295. /**
  9296. * Prepares the list of attributes required for instances according to the effect defines.
  9297. * @param attribs The current list of supported attribs
  9298. * @param defines The current Defines of the effect
  9299. */
  9300. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9301. /**
  9302. * Binds the light shadow information to the effect for the given mesh.
  9303. * @param light The light containing the generator
  9304. * @param scene The scene the lights belongs to
  9305. * @param mesh The mesh we are binding the information to render
  9306. * @param lightIndex The light index in the effect used to render the mesh
  9307. * @param effect The effect we are binding the data to
  9308. */
  9309. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9310. /**
  9311. * Binds the light information to the effect.
  9312. * @param light The light containing the generator
  9313. * @param effect The effect we are binding the data to
  9314. * @param lightIndex The light index in the effect used to render
  9315. */
  9316. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9317. /**
  9318. * Binds the lights information from the scene to the effect for the given mesh.
  9319. * @param scene The scene the lights belongs to
  9320. * @param mesh The mesh we are binding the information to render
  9321. * @param effect The effect we are binding the data to
  9322. * @param defines The generated defines for the effect
  9323. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9324. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9325. */
  9326. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9327. private static _tempFogColor;
  9328. /**
  9329. * Binds the fog information from the scene to the effect for the given mesh.
  9330. * @param scene The scene the lights belongs to
  9331. * @param mesh The mesh we are binding the information to render
  9332. * @param effect The effect we are binding the data to
  9333. * @param linearSpace Defines if the fog effect is applied in linear space
  9334. */
  9335. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9336. /**
  9337. * Binds the bones information from the mesh to the effect.
  9338. * @param mesh The mesh we are binding the information to render
  9339. * @param effect The effect we are binding the data to
  9340. */
  9341. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9342. /**
  9343. * Binds the morph targets information from the mesh to the effect.
  9344. * @param abstractMesh The mesh we are binding the information to render
  9345. * @param effect The effect we are binding the data to
  9346. */
  9347. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9348. /**
  9349. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9350. * @param defines The generated defines used in the effect
  9351. * @param effect The effect we are binding the data to
  9352. * @param scene The scene we are willing to render with logarithmic scale for
  9353. */
  9354. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9355. /**
  9356. * Binds the clip plane information from the scene to the effect.
  9357. * @param scene The scene the clip plane information are extracted from
  9358. * @param effect The effect we are binding the data to
  9359. */
  9360. static BindClipPlane(effect: Effect, scene: Scene): void;
  9361. }
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var kernelBlurVaryingDeclaration: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var kernelBlurFragment: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var kernelBlurFragment2: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var kernelBlurPixelShader: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var kernelBlurVertex: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var kernelBlurVertexShader: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /**
  9407. * The Blur Post Process which blurs an image based on a kernel and direction.
  9408. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9409. */
  9410. export class BlurPostProcess extends PostProcess {
  9411. /** The direction in which to blur the image. */
  9412. direction: Vector2;
  9413. private blockCompilation;
  9414. protected _kernel: number;
  9415. protected _idealKernel: number;
  9416. protected _packedFloat: boolean;
  9417. private _staticDefines;
  9418. /**
  9419. * Sets the length in pixels of the blur sample region
  9420. */
  9421. /**
  9422. * Gets the length in pixels of the blur sample region
  9423. */
  9424. kernel: number;
  9425. /**
  9426. * Sets wether or not the blur needs to unpack/repack floats
  9427. */
  9428. /**
  9429. * Gets wether or not the blur is unpacking/repacking floats
  9430. */
  9431. packedFloat: boolean;
  9432. /**
  9433. * Creates a new instance BlurPostProcess
  9434. * @param name The name of the effect.
  9435. * @param direction The direction in which to blur the image.
  9436. * @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.
  9437. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9438. * @param camera The camera to apply the render pass to.
  9439. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9440. * @param engine The engine which the post process will be applied. (default: current engine)
  9441. * @param reusable If the post process can be reused on the same frame. (default: false)
  9442. * @param textureType Type of textures used when performing the post process. (default: 0)
  9443. * @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)
  9444. */
  9445. constructor(name: string,
  9446. /** The direction in which to blur the image. */
  9447. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9448. /**
  9449. * Updates the effect with the current post process compile time values and recompiles the shader.
  9450. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9451. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9452. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9453. * @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
  9454. * @param onCompiled Called when the shader has been compiled.
  9455. * @param onError Called if there is an error when compiling a shader.
  9456. */
  9457. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9458. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9459. /**
  9460. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9461. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9462. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9463. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9464. * The gaps between physical kernels are compensated for in the weighting of the samples
  9465. * @param idealKernel Ideal blur kernel.
  9466. * @return Nearest best kernel.
  9467. */
  9468. protected _nearestBestKernel(idealKernel: number): number;
  9469. /**
  9470. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9471. * @param x The point on the Gaussian distribution to sample.
  9472. * @return the value of the Gaussian function at x.
  9473. */
  9474. protected _gaussianWeight(x: number): number;
  9475. /**
  9476. * Generates a string that can be used as a floating point number in GLSL.
  9477. * @param x Value to print.
  9478. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9479. * @return GLSL float string.
  9480. */
  9481. protected _glslFloat(x: number, decimalFigures?: number): string;
  9482. }
  9483. }
  9484. declare module BABYLON {
  9485. /** @hidden */
  9486. export var shadowMapPixelShader: {
  9487. name: string;
  9488. shader: string;
  9489. };
  9490. }
  9491. declare module BABYLON {
  9492. /** @hidden */
  9493. export var bonesDeclaration: {
  9494. name: string;
  9495. shader: string;
  9496. };
  9497. }
  9498. declare module BABYLON {
  9499. /** @hidden */
  9500. export var morphTargetsVertexGlobalDeclaration: {
  9501. name: string;
  9502. shader: string;
  9503. };
  9504. }
  9505. declare module BABYLON {
  9506. /** @hidden */
  9507. export var morphTargetsVertexDeclaration: {
  9508. name: string;
  9509. shader: string;
  9510. };
  9511. }
  9512. declare module BABYLON {
  9513. /** @hidden */
  9514. export var instancesDeclaration: {
  9515. name: string;
  9516. shader: string;
  9517. };
  9518. }
  9519. declare module BABYLON {
  9520. /** @hidden */
  9521. export var helperFunctions: {
  9522. name: string;
  9523. shader: string;
  9524. };
  9525. }
  9526. declare module BABYLON {
  9527. /** @hidden */
  9528. export var morphTargetsVertex: {
  9529. name: string;
  9530. shader: string;
  9531. };
  9532. }
  9533. declare module BABYLON {
  9534. /** @hidden */
  9535. export var instancesVertex: {
  9536. name: string;
  9537. shader: string;
  9538. };
  9539. }
  9540. declare module BABYLON {
  9541. /** @hidden */
  9542. export var bonesVertex: {
  9543. name: string;
  9544. shader: string;
  9545. };
  9546. }
  9547. declare module BABYLON {
  9548. /** @hidden */
  9549. export var shadowMapVertexShader: {
  9550. name: string;
  9551. shader: string;
  9552. };
  9553. }
  9554. declare module BABYLON {
  9555. /** @hidden */
  9556. export var depthBoxBlurPixelShader: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module BABYLON {
  9562. /**
  9563. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9564. */
  9565. export interface ICustomShaderOptions {
  9566. /**
  9567. * Gets or sets the custom shader name to use
  9568. */
  9569. shaderName: string;
  9570. /**
  9571. * The list of attribute names used in the shader
  9572. */
  9573. attributes?: string[];
  9574. /**
  9575. * The list of unifrom names used in the shader
  9576. */
  9577. uniforms?: string[];
  9578. /**
  9579. * The list of sampler names used in the shader
  9580. */
  9581. samplers?: string[];
  9582. /**
  9583. * The list of defines used in the shader
  9584. */
  9585. defines?: string[];
  9586. }
  9587. /**
  9588. * Interface to implement to create a shadow generator compatible with BJS.
  9589. */
  9590. export interface IShadowGenerator {
  9591. /**
  9592. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9593. * @returns The render target texture if present otherwise, null
  9594. */
  9595. getShadowMap(): Nullable<RenderTargetTexture>;
  9596. /**
  9597. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9598. * @returns The render target texture if the shadow map is present otherwise, null
  9599. */
  9600. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9601. /**
  9602. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9603. * @param subMesh The submesh we want to render in the shadow map
  9604. * @param useInstances Defines wether will draw in the map using instances
  9605. * @returns true if ready otherwise, false
  9606. */
  9607. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9608. /**
  9609. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9610. * @param defines Defines of the material we want to update
  9611. * @param lightIndex Index of the light in the enabled light list of the material
  9612. */
  9613. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9614. /**
  9615. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9616. * defined in the generator but impacting the effect).
  9617. * It implies the unifroms available on the materials are the standard BJS ones.
  9618. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9619. * @param effect The effect we are binfing the information for
  9620. */
  9621. bindShadowLight(lightIndex: string, effect: Effect): void;
  9622. /**
  9623. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9624. * (eq to shadow prjection matrix * light transform matrix)
  9625. * @returns The transform matrix used to create the shadow map
  9626. */
  9627. getTransformMatrix(): Matrix;
  9628. /**
  9629. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9630. * Cube and 2D textures for instance.
  9631. */
  9632. recreateShadowMap(): void;
  9633. /**
  9634. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9635. * @param onCompiled Callback triggered at the and of the effects compilation
  9636. * @param options Sets of optional options forcing the compilation with different modes
  9637. */
  9638. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9639. useInstances: boolean;
  9640. }>): void;
  9641. /**
  9642. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9643. * @param options Sets of optional options forcing the compilation with different modes
  9644. * @returns A promise that resolves when the compilation completes
  9645. */
  9646. forceCompilationAsync(options?: Partial<{
  9647. useInstances: boolean;
  9648. }>): Promise<void>;
  9649. /**
  9650. * Serializes the shadow generator setup to a json object.
  9651. * @returns The serialized JSON object
  9652. */
  9653. serialize(): any;
  9654. /**
  9655. * Disposes the Shadow map and related Textures and effects.
  9656. */
  9657. dispose(): void;
  9658. }
  9659. /**
  9660. * Default implementation IShadowGenerator.
  9661. * This is the main object responsible of generating shadows in the framework.
  9662. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9663. */
  9664. export class ShadowGenerator implements IShadowGenerator {
  9665. /**
  9666. * Shadow generator mode None: no filtering applied.
  9667. */
  9668. static readonly FILTER_NONE: number;
  9669. /**
  9670. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9671. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9672. */
  9673. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9674. /**
  9675. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9676. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9677. */
  9678. static readonly FILTER_POISSONSAMPLING: number;
  9679. /**
  9680. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9681. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9682. */
  9683. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9684. /**
  9685. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9686. * edge artifacts on steep falloff.
  9687. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9688. */
  9689. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9690. /**
  9691. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9692. * edge artifacts on steep falloff.
  9693. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9694. */
  9695. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9696. /**
  9697. * Shadow generator mode PCF: Percentage Closer Filtering
  9698. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9699. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9700. */
  9701. static readonly FILTER_PCF: number;
  9702. /**
  9703. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9704. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9705. * Contact Hardening
  9706. */
  9707. static readonly FILTER_PCSS: number;
  9708. /**
  9709. * Reserved for PCF and PCSS
  9710. * Highest Quality.
  9711. *
  9712. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9713. *
  9714. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9715. */
  9716. static readonly QUALITY_HIGH: number;
  9717. /**
  9718. * Reserved for PCF and PCSS
  9719. * Good tradeoff for quality/perf cross devices
  9720. *
  9721. * Execute PCF on a 3*3 kernel.
  9722. *
  9723. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9724. */
  9725. static readonly QUALITY_MEDIUM: number;
  9726. /**
  9727. * Reserved for PCF and PCSS
  9728. * The lowest quality but the fastest.
  9729. *
  9730. * Execute PCF on a 1*1 kernel.
  9731. *
  9732. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9733. */
  9734. static readonly QUALITY_LOW: number;
  9735. /** Gets or sets the custom shader name to use */
  9736. customShaderOptions: ICustomShaderOptions;
  9737. /**
  9738. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9739. */
  9740. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9741. /**
  9742. * Observable triggered before a mesh is rendered in the shadow map.
  9743. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9744. */
  9745. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9746. private _bias;
  9747. /**
  9748. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9749. */
  9750. /**
  9751. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9752. */
  9753. bias: number;
  9754. private _normalBias;
  9755. /**
  9756. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9757. */
  9758. /**
  9759. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9760. */
  9761. normalBias: number;
  9762. private _blurBoxOffset;
  9763. /**
  9764. * Gets the blur box offset: offset applied during the blur pass.
  9765. * Only useful if useKernelBlur = false
  9766. */
  9767. /**
  9768. * Sets the blur box offset: offset applied during the blur pass.
  9769. * Only useful if useKernelBlur = false
  9770. */
  9771. blurBoxOffset: number;
  9772. private _blurScale;
  9773. /**
  9774. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9775. * 2 means half of the size.
  9776. */
  9777. /**
  9778. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9779. * 2 means half of the size.
  9780. */
  9781. blurScale: number;
  9782. private _blurKernel;
  9783. /**
  9784. * Gets the blur kernel: kernel size of the blur pass.
  9785. * Only useful if useKernelBlur = true
  9786. */
  9787. /**
  9788. * Sets the blur kernel: kernel size of the blur pass.
  9789. * Only useful if useKernelBlur = true
  9790. */
  9791. blurKernel: number;
  9792. private _useKernelBlur;
  9793. /**
  9794. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9795. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9796. */
  9797. /**
  9798. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9799. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9800. */
  9801. useKernelBlur: boolean;
  9802. private _depthScale;
  9803. /**
  9804. * Gets the depth scale used in ESM mode.
  9805. */
  9806. /**
  9807. * Sets the depth scale used in ESM mode.
  9808. * This can override the scale stored on the light.
  9809. */
  9810. depthScale: number;
  9811. private _filter;
  9812. /**
  9813. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9814. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9815. */
  9816. /**
  9817. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9818. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9819. */
  9820. filter: number;
  9821. /**
  9822. * Gets if the current filter is set to Poisson Sampling.
  9823. */
  9824. /**
  9825. * Sets the current filter to Poisson Sampling.
  9826. */
  9827. usePoissonSampling: boolean;
  9828. /**
  9829. * Gets if the current filter is set to ESM.
  9830. */
  9831. /**
  9832. * Sets the current filter is to ESM.
  9833. */
  9834. useExponentialShadowMap: boolean;
  9835. /**
  9836. * Gets if the current filter is set to filtered ESM.
  9837. */
  9838. /**
  9839. * Gets if the current filter is set to filtered ESM.
  9840. */
  9841. useBlurExponentialShadowMap: boolean;
  9842. /**
  9843. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9844. * exponential to prevent steep falloff artifacts).
  9845. */
  9846. /**
  9847. * Sets the current filter to "close ESM" (using the inverse of the
  9848. * exponential to prevent steep falloff artifacts).
  9849. */
  9850. useCloseExponentialShadowMap: boolean;
  9851. /**
  9852. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9853. * exponential to prevent steep falloff artifacts).
  9854. */
  9855. /**
  9856. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9857. * exponential to prevent steep falloff artifacts).
  9858. */
  9859. useBlurCloseExponentialShadowMap: boolean;
  9860. /**
  9861. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9862. */
  9863. /**
  9864. * Sets the current filter to "PCF" (percentage closer filtering).
  9865. */
  9866. usePercentageCloserFiltering: boolean;
  9867. private _filteringQuality;
  9868. /**
  9869. * Gets the PCF or PCSS Quality.
  9870. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9871. */
  9872. /**
  9873. * Sets the PCF or PCSS Quality.
  9874. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9875. */
  9876. filteringQuality: number;
  9877. /**
  9878. * Gets if the current filter is set to "PCSS" (contact hardening).
  9879. */
  9880. /**
  9881. * Sets the current filter to "PCSS" (contact hardening).
  9882. */
  9883. useContactHardeningShadow: boolean;
  9884. private _contactHardeningLightSizeUVRatio;
  9885. /**
  9886. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9887. * Using a ratio helps keeping shape stability independently of the map size.
  9888. *
  9889. * It does not account for the light projection as it was having too much
  9890. * instability during the light setup or during light position changes.
  9891. *
  9892. * Only valid if useContactHardeningShadow is true.
  9893. */
  9894. /**
  9895. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9896. * Using a ratio helps keeping shape stability independently of the map size.
  9897. *
  9898. * It does not account for the light projection as it was having too much
  9899. * instability during the light setup or during light position changes.
  9900. *
  9901. * Only valid if useContactHardeningShadow is true.
  9902. */
  9903. contactHardeningLightSizeUVRatio: number;
  9904. private _darkness;
  9905. /**
  9906. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9907. * 0 means strongest and 1 would means no shadow.
  9908. * @returns the darkness.
  9909. */
  9910. getDarkness(): number;
  9911. /**
  9912. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9913. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9914. * @returns the shadow generator allowing fluent coding.
  9915. */
  9916. setDarkness(darkness: number): ShadowGenerator;
  9917. private _transparencyShadow;
  9918. /**
  9919. * Sets the ability to have transparent shadow (boolean).
  9920. * @param transparent True if transparent else False
  9921. * @returns the shadow generator allowing fluent coding
  9922. */
  9923. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9924. private _shadowMap;
  9925. private _shadowMap2;
  9926. /**
  9927. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9928. * @returns The render target texture if present otherwise, null
  9929. */
  9930. getShadowMap(): Nullable<RenderTargetTexture>;
  9931. /**
  9932. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9933. * @returns The render target texture if the shadow map is present otherwise, null
  9934. */
  9935. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9936. /**
  9937. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9938. * @param mesh Mesh to add
  9939. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9940. * @returns the Shadow Generator itself
  9941. */
  9942. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9943. /**
  9944. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9945. * @param mesh Mesh to remove
  9946. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9947. * @returns the Shadow Generator itself
  9948. */
  9949. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9950. /**
  9951. * Controls the extent to which the shadows fade out at the edge of the frustum
  9952. * Used only by directionals and spots
  9953. */
  9954. frustumEdgeFalloff: number;
  9955. private _light;
  9956. /**
  9957. * Returns the associated light object.
  9958. * @returns the light generating the shadow
  9959. */
  9960. getLight(): IShadowLight;
  9961. /**
  9962. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9963. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9964. * It might on the other hand introduce peter panning.
  9965. */
  9966. forceBackFacesOnly: boolean;
  9967. private _scene;
  9968. private _lightDirection;
  9969. private _effect;
  9970. private _viewMatrix;
  9971. private _projectionMatrix;
  9972. private _transformMatrix;
  9973. private _cachedPosition;
  9974. private _cachedDirection;
  9975. private _cachedDefines;
  9976. private _currentRenderID;
  9977. private _boxBlurPostprocess;
  9978. private _kernelBlurXPostprocess;
  9979. private _kernelBlurYPostprocess;
  9980. private _blurPostProcesses;
  9981. private _mapSize;
  9982. private _currentFaceIndex;
  9983. private _currentFaceIndexCache;
  9984. private _textureType;
  9985. private _defaultTextureMatrix;
  9986. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9987. /**
  9988. * Creates a ShadowGenerator object.
  9989. * A ShadowGenerator is the required tool to use the shadows.
  9990. * Each light casting shadows needs to use its own ShadowGenerator.
  9991. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9992. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9993. * @param light The light object generating the shadows.
  9994. * @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.
  9995. */
  9996. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9997. private _initializeGenerator;
  9998. private _initializeShadowMap;
  9999. private _initializeBlurRTTAndPostProcesses;
  10000. private _renderForShadowMap;
  10001. private _renderSubMeshForShadowMap;
  10002. private _applyFilterValues;
  10003. /**
  10004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10005. * @param onCompiled Callback triggered at the and of the effects compilation
  10006. * @param options Sets of optional options forcing the compilation with different modes
  10007. */
  10008. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10009. useInstances: boolean;
  10010. }>): void;
  10011. /**
  10012. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10013. * @param options Sets of optional options forcing the compilation with different modes
  10014. * @returns A promise that resolves when the compilation completes
  10015. */
  10016. forceCompilationAsync(options?: Partial<{
  10017. useInstances: boolean;
  10018. }>): Promise<void>;
  10019. /**
  10020. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10021. * @param subMesh The submesh we want to render in the shadow map
  10022. * @param useInstances Defines wether will draw in the map using instances
  10023. * @returns true if ready otherwise, false
  10024. */
  10025. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10026. /**
  10027. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10028. * @param defines Defines of the material we want to update
  10029. * @param lightIndex Index of the light in the enabled light list of the material
  10030. */
  10031. prepareDefines(defines: any, lightIndex: number): void;
  10032. /**
  10033. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10034. * defined in the generator but impacting the effect).
  10035. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10036. * @param effect The effect we are binfing the information for
  10037. */
  10038. bindShadowLight(lightIndex: string, effect: Effect): void;
  10039. /**
  10040. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10041. * (eq to shadow prjection matrix * light transform matrix)
  10042. * @returns The transform matrix used to create the shadow map
  10043. */
  10044. getTransformMatrix(): Matrix;
  10045. /**
  10046. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10047. * Cube and 2D textures for instance.
  10048. */
  10049. recreateShadowMap(): void;
  10050. private _disposeBlurPostProcesses;
  10051. private _disposeRTTandPostProcesses;
  10052. /**
  10053. * Disposes the ShadowGenerator.
  10054. * Returns nothing.
  10055. */
  10056. dispose(): void;
  10057. /**
  10058. * Serializes the shadow generator setup to a json object.
  10059. * @returns The serialized JSON object
  10060. */
  10061. serialize(): any;
  10062. /**
  10063. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10064. * @param parsedShadowGenerator The JSON object to parse
  10065. * @param scene The scene to create the shadow map for
  10066. * @returns The parsed shadow generator
  10067. */
  10068. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10069. }
  10070. }
  10071. declare module BABYLON {
  10072. /**
  10073. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10074. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10075. * 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.
  10076. */
  10077. export abstract class Light extends Node {
  10078. /**
  10079. * Falloff Default: light is falling off following the material specification:
  10080. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10081. */
  10082. static readonly FALLOFF_DEFAULT: number;
  10083. /**
  10084. * Falloff Physical: light is falling off following the inverse squared distance law.
  10085. */
  10086. static readonly FALLOFF_PHYSICAL: number;
  10087. /**
  10088. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10089. * to enhance interoperability with other engines.
  10090. */
  10091. static readonly FALLOFF_GLTF: number;
  10092. /**
  10093. * Falloff Standard: light is falling off like in the standard material
  10094. * to enhance interoperability with other materials.
  10095. */
  10096. static readonly FALLOFF_STANDARD: number;
  10097. /**
  10098. * If every light affecting the material is in this lightmapMode,
  10099. * material.lightmapTexture adds or multiplies
  10100. * (depends on material.useLightmapAsShadowmap)
  10101. * after every other light calculations.
  10102. */
  10103. static readonly LIGHTMAP_DEFAULT: number;
  10104. /**
  10105. * material.lightmapTexture as only diffuse lighting from this light
  10106. * adds only specular lighting from this light
  10107. * adds dynamic shadows
  10108. */
  10109. static readonly LIGHTMAP_SPECULAR: number;
  10110. /**
  10111. * material.lightmapTexture as only lighting
  10112. * no light calculation from this light
  10113. * only adds dynamic shadows from this light
  10114. */
  10115. static readonly LIGHTMAP_SHADOWSONLY: number;
  10116. /**
  10117. * Each light type uses the default quantity according to its type:
  10118. * point/spot lights use luminous intensity
  10119. * directional lights use illuminance
  10120. */
  10121. static readonly INTENSITYMODE_AUTOMATIC: number;
  10122. /**
  10123. * lumen (lm)
  10124. */
  10125. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10126. /**
  10127. * candela (lm/sr)
  10128. */
  10129. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10130. /**
  10131. * lux (lm/m^2)
  10132. */
  10133. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10134. /**
  10135. * nit (cd/m^2)
  10136. */
  10137. static readonly INTENSITYMODE_LUMINANCE: number;
  10138. /**
  10139. * Light type const id of the point light.
  10140. */
  10141. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10142. /**
  10143. * Light type const id of the directional light.
  10144. */
  10145. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10146. /**
  10147. * Light type const id of the spot light.
  10148. */
  10149. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10150. /**
  10151. * Light type const id of the hemispheric light.
  10152. */
  10153. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10154. /**
  10155. * Diffuse gives the basic color to an object.
  10156. */
  10157. diffuse: Color3;
  10158. /**
  10159. * Specular produces a highlight color on an object.
  10160. * Note: This is note affecting PBR materials.
  10161. */
  10162. specular: Color3;
  10163. /**
  10164. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10165. * falling off base on range or angle.
  10166. * This can be set to any values in Light.FALLOFF_x.
  10167. *
  10168. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10169. * other types of materials.
  10170. */
  10171. falloffType: number;
  10172. /**
  10173. * Strength of the light.
  10174. * Note: By default it is define in the framework own unit.
  10175. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10176. */
  10177. intensity: number;
  10178. private _range;
  10179. protected _inverseSquaredRange: number;
  10180. /**
  10181. * Defines how far from the source the light is impacting in scene units.
  10182. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10183. */
  10184. /**
  10185. * Defines how far from the source the light is impacting in scene units.
  10186. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10187. */
  10188. range: number;
  10189. /**
  10190. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10191. * of light.
  10192. */
  10193. private _photometricScale;
  10194. private _intensityMode;
  10195. /**
  10196. * Gets the photometric scale used to interpret the intensity.
  10197. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10198. */
  10199. /**
  10200. * Sets the photometric scale used to interpret the intensity.
  10201. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10202. */
  10203. intensityMode: number;
  10204. private _radius;
  10205. /**
  10206. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10207. */
  10208. /**
  10209. * sets the light radius used by PBR Materials to simulate soft area lights.
  10210. */
  10211. radius: number;
  10212. private _renderPriority;
  10213. /**
  10214. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10215. * exceeding the number allowed of the materials.
  10216. */
  10217. renderPriority: number;
  10218. private _shadowEnabled;
  10219. /**
  10220. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10221. * the current shadow generator.
  10222. */
  10223. /**
  10224. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10225. * the current shadow generator.
  10226. */
  10227. shadowEnabled: boolean;
  10228. private _includedOnlyMeshes;
  10229. /**
  10230. * Gets the only meshes impacted by this light.
  10231. */
  10232. /**
  10233. * Sets the only meshes impacted by this light.
  10234. */
  10235. includedOnlyMeshes: AbstractMesh[];
  10236. private _excludedMeshes;
  10237. /**
  10238. * Gets the meshes not impacted by this light.
  10239. */
  10240. /**
  10241. * Sets the meshes not impacted by this light.
  10242. */
  10243. excludedMeshes: AbstractMesh[];
  10244. private _excludeWithLayerMask;
  10245. /**
  10246. * Gets the layer id use to find what meshes are not impacted by the light.
  10247. * Inactive if 0
  10248. */
  10249. /**
  10250. * Sets the layer id use to find what meshes are not impacted by the light.
  10251. * Inactive if 0
  10252. */
  10253. excludeWithLayerMask: number;
  10254. private _includeOnlyWithLayerMask;
  10255. /**
  10256. * Gets the layer id use to find what meshes are impacted by the light.
  10257. * Inactive if 0
  10258. */
  10259. /**
  10260. * Sets the layer id use to find what meshes are impacted by the light.
  10261. * Inactive if 0
  10262. */
  10263. includeOnlyWithLayerMask: number;
  10264. private _lightmapMode;
  10265. /**
  10266. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10267. */
  10268. /**
  10269. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10270. */
  10271. lightmapMode: number;
  10272. /**
  10273. * Shadow generator associted to the light.
  10274. * @hidden Internal use only.
  10275. */ shadowGenerator: Nullable<IShadowGenerator>;
  10276. /**
  10277. * @hidden Internal use only.
  10278. */ excludedMeshesIds: string[];
  10279. /**
  10280. * @hidden Internal use only.
  10281. */ includedOnlyMeshesIds: string[];
  10282. /**
  10283. * The current light unifom buffer.
  10284. * @hidden Internal use only.
  10285. */ uniformBuffer: UniformBuffer;
  10286. /**
  10287. * Creates a Light object in the scene.
  10288. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10289. * @param name The firendly name of the light
  10290. * @param scene The scene the light belongs too
  10291. */
  10292. constructor(name: string, scene: Scene);
  10293. protected abstract _buildUniformLayout(): void;
  10294. /**
  10295. * Sets the passed Effect "effect" with the Light information.
  10296. * @param effect The effect to update
  10297. * @param lightIndex The index of the light in the effect to update
  10298. * @returns The light
  10299. */
  10300. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10301. /**
  10302. * Returns the string "Light".
  10303. * @returns the class name
  10304. */
  10305. getClassName(): string;
  10306. /** @hidden */ protected readonly _isLight: boolean;
  10307. /**
  10308. * Converts the light information to a readable string for debug purpose.
  10309. * @param fullDetails Supports for multiple levels of logging within scene loading
  10310. * @returns the human readable light info
  10311. */
  10312. toString(fullDetails?: boolean): string;
  10313. /** @hidden */
  10314. protected _syncParentEnabledState(): void;
  10315. /**
  10316. * Set the enabled state of this node.
  10317. * @param value - the new enabled state
  10318. */
  10319. setEnabled(value: boolean): void;
  10320. /**
  10321. * Returns the Light associated shadow generator if any.
  10322. * @return the associated shadow generator.
  10323. */
  10324. getShadowGenerator(): Nullable<IShadowGenerator>;
  10325. /**
  10326. * Returns a Vector3, the absolute light position in the World.
  10327. * @returns the world space position of the light
  10328. */
  10329. getAbsolutePosition(): Vector3;
  10330. /**
  10331. * Specifies if the light will affect the passed mesh.
  10332. * @param mesh The mesh to test against the light
  10333. * @return true the mesh is affected otherwise, false.
  10334. */
  10335. canAffectMesh(mesh: AbstractMesh): boolean;
  10336. /**
  10337. * Sort function to order lights for rendering.
  10338. * @param a First Light object to compare to second.
  10339. * @param b Second Light object to compare first.
  10340. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10341. */
  10342. static CompareLightsPriority(a: Light, b: Light): number;
  10343. /**
  10344. * Releases resources associated with this node.
  10345. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10346. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10347. */
  10348. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10349. /**
  10350. * Returns the light type ID (integer).
  10351. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10352. */
  10353. getTypeID(): number;
  10354. /**
  10355. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10356. * @returns the scaled intensity in intensity mode unit
  10357. */
  10358. getScaledIntensity(): number;
  10359. /**
  10360. * Returns a new Light object, named "name", from the current one.
  10361. * @param name The name of the cloned light
  10362. * @returns the new created light
  10363. */
  10364. clone(name: string): Nullable<Light>;
  10365. /**
  10366. * Serializes the current light into a Serialization object.
  10367. * @returns the serialized object.
  10368. */
  10369. serialize(): any;
  10370. /**
  10371. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10372. * This new light is named "name" and added to the passed scene.
  10373. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10374. * @param name The friendly name of the light
  10375. * @param scene The scene the new light will belong to
  10376. * @returns the constructor function
  10377. */
  10378. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10379. /**
  10380. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10381. * @param parsedLight The JSON representation of the light
  10382. * @param scene The scene to create the parsed light in
  10383. * @returns the created light after parsing
  10384. */
  10385. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10386. private _hookArrayForExcluded;
  10387. private _hookArrayForIncludedOnly;
  10388. private _resyncMeshes;
  10389. /**
  10390. * Forces the meshes to update their light related information in their rendering used effects
  10391. * @hidden Internal Use Only
  10392. */ markMeshesAsLightDirty(): void;
  10393. /**
  10394. * Recomputes the cached photometric scale if needed.
  10395. */
  10396. private _computePhotometricScale;
  10397. /**
  10398. * Returns the Photometric Scale according to the light type and intensity mode.
  10399. */
  10400. private _getPhotometricScale;
  10401. /**
  10402. * Reorder the light in the scene according to their defined priority.
  10403. * @hidden Internal Use Only
  10404. */ reorderLightsInScene(): void;
  10405. /**
  10406. * Prepares the list of defines specific to the light type.
  10407. * @param defines the list of defines
  10408. * @param lightIndex defines the index of the light for the effect
  10409. */
  10410. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10411. }
  10412. }
  10413. declare module BABYLON {
  10414. /**
  10415. * Interface used to define Action
  10416. */
  10417. export interface IAction {
  10418. /**
  10419. * Trigger for the action
  10420. */
  10421. trigger: number;
  10422. /** Options of the trigger */
  10423. triggerOptions: any;
  10424. /**
  10425. * Gets the trigger parameters
  10426. * @returns the trigger parameters
  10427. */
  10428. getTriggerParameter(): any;
  10429. /**
  10430. * Internal only - executes current action event
  10431. * @hidden
  10432. */ executeCurrent(evt?: ActionEvent): void;
  10433. /**
  10434. * Serialize placeholder for child classes
  10435. * @param parent of child
  10436. * @returns the serialized object
  10437. */
  10438. serialize(parent: any): any;
  10439. /**
  10440. * Internal only
  10441. * @hidden
  10442. */ prepare(): void;
  10443. /**
  10444. * Internal only - manager for action
  10445. * @hidden
  10446. */ actionManager: AbstractActionManager;
  10447. }
  10448. /**
  10449. * The action to be carried out following a trigger
  10450. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10451. */
  10452. export class Action implements IAction {
  10453. /** the trigger, with or without parameters, for the action */
  10454. triggerOptions: any;
  10455. /**
  10456. * Trigger for the action
  10457. */
  10458. trigger: number;
  10459. /**
  10460. * Internal only - manager for action
  10461. * @hidden
  10462. */ actionManager: ActionManager;
  10463. private _nextActiveAction;
  10464. private _child;
  10465. private _condition?;
  10466. private _triggerParameter;
  10467. /**
  10468. * An event triggered prior to action being executed.
  10469. */
  10470. onBeforeExecuteObservable: Observable<Action>;
  10471. /**
  10472. * Creates a new Action
  10473. * @param triggerOptions the trigger, with or without parameters, for the action
  10474. * @param condition an optional determinant of action
  10475. */
  10476. constructor(
  10477. /** the trigger, with or without parameters, for the action */
  10478. triggerOptions: any, condition?: Condition);
  10479. /**
  10480. * Internal only
  10481. * @hidden
  10482. */ prepare(): void;
  10483. /**
  10484. * Gets the trigger parameters
  10485. * @returns the trigger parameters
  10486. */
  10487. getTriggerParameter(): any;
  10488. /**
  10489. * Internal only - executes current action event
  10490. * @hidden
  10491. */ executeCurrent(evt?: ActionEvent): void;
  10492. /**
  10493. * Execute placeholder for child classes
  10494. * @param evt optional action event
  10495. */
  10496. execute(evt?: ActionEvent): void;
  10497. /**
  10498. * Skips to next active action
  10499. */
  10500. skipToNextActiveAction(): void;
  10501. /**
  10502. * Adds action to chain of actions, may be a DoNothingAction
  10503. * @param action defines the next action to execute
  10504. * @returns The action passed in
  10505. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10506. */
  10507. then(action: Action): Action;
  10508. /**
  10509. * Internal only
  10510. * @hidden
  10511. */ getProperty(propertyPath: string): string;
  10512. /**
  10513. * Internal only
  10514. * @hidden
  10515. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10516. /**
  10517. * Serialize placeholder for child classes
  10518. * @param parent of child
  10519. * @returns the serialized object
  10520. */
  10521. serialize(parent: any): any;
  10522. /**
  10523. * Internal only called by serialize
  10524. * @hidden
  10525. */
  10526. protected _serialize(serializedAction: any, parent?: any): any;
  10527. /**
  10528. * Internal only
  10529. * @hidden
  10530. */ private static _SerializeValueAsString: (value: any) => string;
  10531. /**
  10532. * Internal only
  10533. * @hidden
  10534. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10535. name: string;
  10536. targetType: string;
  10537. value: string;
  10538. };
  10539. }
  10540. }
  10541. declare module BABYLON {
  10542. /**
  10543. * A Condition applied to an Action
  10544. */
  10545. export class Condition {
  10546. /**
  10547. * Internal only - manager for action
  10548. * @hidden
  10549. */ actionManager: ActionManager;
  10550. /**
  10551. * Internal only
  10552. * @hidden
  10553. */ evaluationId: number;
  10554. /**
  10555. * Internal only
  10556. * @hidden
  10557. */ currentResult: boolean;
  10558. /**
  10559. * Creates a new Condition
  10560. * @param actionManager the manager of the action the condition is applied to
  10561. */
  10562. constructor(actionManager: ActionManager);
  10563. /**
  10564. * Check if the current condition is valid
  10565. * @returns a boolean
  10566. */
  10567. isValid(): boolean;
  10568. /**
  10569. * Internal only
  10570. * @hidden
  10571. */ getProperty(propertyPath: string): string;
  10572. /**
  10573. * Internal only
  10574. * @hidden
  10575. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10576. /**
  10577. * Serialize placeholder for child classes
  10578. * @returns the serialized object
  10579. */
  10580. serialize(): any;
  10581. /**
  10582. * Internal only
  10583. * @hidden
  10584. */
  10585. protected _serialize(serializedCondition: any): any;
  10586. }
  10587. /**
  10588. * Defines specific conditional operators as extensions of Condition
  10589. */
  10590. export class ValueCondition extends Condition {
  10591. /** path to specify the property of the target the conditional operator uses */
  10592. propertyPath: string;
  10593. /** the value compared by the conditional operator against the current value of the property */
  10594. value: any;
  10595. /** the conditional operator, default ValueCondition.IsEqual */
  10596. operator: number;
  10597. /**
  10598. * Internal only
  10599. * @hidden
  10600. */
  10601. private static _IsEqual;
  10602. /**
  10603. * Internal only
  10604. * @hidden
  10605. */
  10606. private static _IsDifferent;
  10607. /**
  10608. * Internal only
  10609. * @hidden
  10610. */
  10611. private static _IsGreater;
  10612. /**
  10613. * Internal only
  10614. * @hidden
  10615. */
  10616. private static _IsLesser;
  10617. /**
  10618. * returns the number for IsEqual
  10619. */
  10620. static readonly IsEqual: number;
  10621. /**
  10622. * Returns the number for IsDifferent
  10623. */
  10624. static readonly IsDifferent: number;
  10625. /**
  10626. * Returns the number for IsGreater
  10627. */
  10628. static readonly IsGreater: number;
  10629. /**
  10630. * Returns the number for IsLesser
  10631. */
  10632. static readonly IsLesser: number;
  10633. /**
  10634. * Internal only The action manager for the condition
  10635. * @hidden
  10636. */ actionManager: ActionManager;
  10637. /**
  10638. * Internal only
  10639. * @hidden
  10640. */
  10641. private _target;
  10642. /**
  10643. * Internal only
  10644. * @hidden
  10645. */
  10646. private _effectiveTarget;
  10647. /**
  10648. * Internal only
  10649. * @hidden
  10650. */
  10651. private _property;
  10652. /**
  10653. * Creates a new ValueCondition
  10654. * @param actionManager manager for the action the condition applies to
  10655. * @param target for the action
  10656. * @param propertyPath path to specify the property of the target the conditional operator uses
  10657. * @param value the value compared by the conditional operator against the current value of the property
  10658. * @param operator the conditional operator, default ValueCondition.IsEqual
  10659. */
  10660. constructor(actionManager: ActionManager, target: any,
  10661. /** path to specify the property of the target the conditional operator uses */
  10662. propertyPath: string,
  10663. /** the value compared by the conditional operator against the current value of the property */
  10664. value: any,
  10665. /** the conditional operator, default ValueCondition.IsEqual */
  10666. operator?: number);
  10667. /**
  10668. * Compares the given value with the property value for the specified conditional operator
  10669. * @returns the result of the comparison
  10670. */
  10671. isValid(): boolean;
  10672. /**
  10673. * Serialize the ValueCondition into a JSON compatible object
  10674. * @returns serialization object
  10675. */
  10676. serialize(): any;
  10677. /**
  10678. * Gets the name of the conditional operator for the ValueCondition
  10679. * @param operator the conditional operator
  10680. * @returns the name
  10681. */
  10682. static GetOperatorName(operator: number): string;
  10683. }
  10684. /**
  10685. * Defines a predicate condition as an extension of Condition
  10686. */
  10687. export class PredicateCondition extends Condition {
  10688. /** defines the predicate function used to validate the condition */
  10689. predicate: () => boolean;
  10690. /**
  10691. * Internal only - manager for action
  10692. * @hidden
  10693. */ actionManager: ActionManager;
  10694. /**
  10695. * Creates a new PredicateCondition
  10696. * @param actionManager manager for the action the condition applies to
  10697. * @param predicate defines the predicate function used to validate the condition
  10698. */
  10699. constructor(actionManager: ActionManager,
  10700. /** defines the predicate function used to validate the condition */
  10701. predicate: () => boolean);
  10702. /**
  10703. * @returns the validity of the predicate condition
  10704. */
  10705. isValid(): boolean;
  10706. }
  10707. /**
  10708. * Defines a state condition as an extension of Condition
  10709. */
  10710. export class StateCondition extends Condition {
  10711. /** Value to compare with target state */
  10712. value: string;
  10713. /**
  10714. * Internal only - manager for action
  10715. * @hidden
  10716. */ actionManager: ActionManager;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. private _target;
  10722. /**
  10723. * Creates a new StateCondition
  10724. * @param actionManager manager for the action the condition applies to
  10725. * @param target of the condition
  10726. * @param value to compare with target state
  10727. */
  10728. constructor(actionManager: ActionManager, target: any,
  10729. /** Value to compare with target state */
  10730. value: string);
  10731. /**
  10732. * Gets a boolean indicating if the current condition is met
  10733. * @returns the validity of the state
  10734. */
  10735. isValid(): boolean;
  10736. /**
  10737. * Serialize the StateCondition into a JSON compatible object
  10738. * @returns serialization object
  10739. */
  10740. serialize(): any;
  10741. }
  10742. }
  10743. declare module BABYLON {
  10744. /**
  10745. * This defines an action responsible to toggle a boolean once triggered.
  10746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10747. */
  10748. export class SwitchBooleanAction extends Action {
  10749. /**
  10750. * The path to the boolean property in the target object
  10751. */
  10752. propertyPath: string;
  10753. private _target;
  10754. private _effectiveTarget;
  10755. private _property;
  10756. /**
  10757. * Instantiate the action
  10758. * @param triggerOptions defines the trigger options
  10759. * @param target defines the object containing the boolean
  10760. * @param propertyPath defines the path to the boolean property in the target object
  10761. * @param condition defines the trigger related conditions
  10762. */
  10763. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10764. /** @hidden */ prepare(): void;
  10765. /**
  10766. * Execute the action toggle the boolean value.
  10767. */
  10768. execute(): void;
  10769. /**
  10770. * Serializes the actions and its related information.
  10771. * @param parent defines the object to serialize in
  10772. * @returns the serialized object
  10773. */
  10774. serialize(parent: any): any;
  10775. }
  10776. /**
  10777. * This defines an action responsible to set a the state field of the target
  10778. * to a desired value once triggered.
  10779. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10780. */
  10781. export class SetStateAction extends Action {
  10782. /**
  10783. * The value to store in the state field.
  10784. */
  10785. value: string;
  10786. private _target;
  10787. /**
  10788. * Instantiate the action
  10789. * @param triggerOptions defines the trigger options
  10790. * @param target defines the object containing the state property
  10791. * @param value defines the value to store in the state field
  10792. * @param condition defines the trigger related conditions
  10793. */
  10794. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10795. /**
  10796. * Execute the action and store the value on the target state property.
  10797. */
  10798. execute(): void;
  10799. /**
  10800. * Serializes the actions and its related information.
  10801. * @param parent defines the object to serialize in
  10802. * @returns the serialized object
  10803. */
  10804. serialize(parent: any): any;
  10805. }
  10806. /**
  10807. * This defines an action responsible to set a property of the target
  10808. * to a desired value once triggered.
  10809. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10810. */
  10811. export class SetValueAction extends Action {
  10812. /**
  10813. * The path of the property to set in the target.
  10814. */
  10815. propertyPath: string;
  10816. /**
  10817. * The value to set in the property
  10818. */
  10819. value: any;
  10820. private _target;
  10821. private _effectiveTarget;
  10822. private _property;
  10823. /**
  10824. * Instantiate the action
  10825. * @param triggerOptions defines the trigger options
  10826. * @param target defines the object containing the property
  10827. * @param propertyPath defines the path of the property to set in the target
  10828. * @param value defines the value to set in the property
  10829. * @param condition defines the trigger related conditions
  10830. */
  10831. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10832. /** @hidden */ prepare(): void;
  10833. /**
  10834. * Execute the action and set the targetted property to the desired value.
  10835. */
  10836. execute(): void;
  10837. /**
  10838. * Serializes the actions and its related information.
  10839. * @param parent defines the object to serialize in
  10840. * @returns the serialized object
  10841. */
  10842. serialize(parent: any): any;
  10843. }
  10844. /**
  10845. * This defines an action responsible to increment the target value
  10846. * to a desired value once triggered.
  10847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10848. */
  10849. export class IncrementValueAction extends Action {
  10850. /**
  10851. * The path of the property to increment in the target.
  10852. */
  10853. propertyPath: string;
  10854. /**
  10855. * The value we should increment the property by.
  10856. */
  10857. value: any;
  10858. private _target;
  10859. private _effectiveTarget;
  10860. private _property;
  10861. /**
  10862. * Instantiate the action
  10863. * @param triggerOptions defines the trigger options
  10864. * @param target defines the object containing the property
  10865. * @param propertyPath defines the path of the property to increment in the target
  10866. * @param value defines the value value we should increment the property by
  10867. * @param condition defines the trigger related conditions
  10868. */
  10869. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10870. /** @hidden */ prepare(): void;
  10871. /**
  10872. * Execute the action and increment the target of the value amount.
  10873. */
  10874. execute(): void;
  10875. /**
  10876. * Serializes the actions and its related information.
  10877. * @param parent defines the object to serialize in
  10878. * @returns the serialized object
  10879. */
  10880. serialize(parent: any): any;
  10881. }
  10882. /**
  10883. * This defines an action responsible to start an animation once triggered.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class PlayAnimationAction extends Action {
  10887. /**
  10888. * Where the animation should start (animation frame)
  10889. */
  10890. from: number;
  10891. /**
  10892. * Where the animation should stop (animation frame)
  10893. */
  10894. to: number;
  10895. /**
  10896. * Define if the animation should loop or stop after the first play.
  10897. */
  10898. loop?: boolean;
  10899. private _target;
  10900. /**
  10901. * Instantiate the action
  10902. * @param triggerOptions defines the trigger options
  10903. * @param target defines the target animation or animation name
  10904. * @param from defines from where the animation should start (animation frame)
  10905. * @param end defines where the animation should stop (animation frame)
  10906. * @param loop defines if the animation should loop or stop after the first play
  10907. * @param condition defines the trigger related conditions
  10908. */
  10909. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10910. /** @hidden */ prepare(): void;
  10911. /**
  10912. * Execute the action and play the animation.
  10913. */
  10914. execute(): void;
  10915. /**
  10916. * Serializes the actions and its related information.
  10917. * @param parent defines the object to serialize in
  10918. * @returns the serialized object
  10919. */
  10920. serialize(parent: any): any;
  10921. }
  10922. /**
  10923. * This defines an action responsible to stop an animation once triggered.
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10925. */
  10926. export class StopAnimationAction extends Action {
  10927. private _target;
  10928. /**
  10929. * Instantiate the action
  10930. * @param triggerOptions defines the trigger options
  10931. * @param target defines the target animation or animation name
  10932. * @param condition defines the trigger related conditions
  10933. */
  10934. constructor(triggerOptions: any, target: any, condition?: Condition);
  10935. /** @hidden */ prepare(): void;
  10936. /**
  10937. * Execute the action and stop the animation.
  10938. */
  10939. execute(): void;
  10940. /**
  10941. * Serializes the actions and its related information.
  10942. * @param parent defines the object to serialize in
  10943. * @returns the serialized object
  10944. */
  10945. serialize(parent: any): any;
  10946. }
  10947. /**
  10948. * This defines an action responsible that does nothing once triggered.
  10949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10950. */
  10951. export class DoNothingAction extends Action {
  10952. /**
  10953. * Instantiate the action
  10954. * @param triggerOptions defines the trigger options
  10955. * @param condition defines the trigger related conditions
  10956. */
  10957. constructor(triggerOptions?: any, condition?: Condition);
  10958. /**
  10959. * Execute the action and do nothing.
  10960. */
  10961. execute(): void;
  10962. /**
  10963. * Serializes the actions and its related information.
  10964. * @param parent defines the object to serialize in
  10965. * @returns the serialized object
  10966. */
  10967. serialize(parent: any): any;
  10968. }
  10969. /**
  10970. * This defines an action responsible to trigger several actions once triggered.
  10971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10972. */
  10973. export class CombineAction extends Action {
  10974. /**
  10975. * The list of aggregated animations to run.
  10976. */
  10977. children: Action[];
  10978. /**
  10979. * Instantiate the action
  10980. * @param triggerOptions defines the trigger options
  10981. * @param children defines the list of aggregated animations to run
  10982. * @param condition defines the trigger related conditions
  10983. */
  10984. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10985. /** @hidden */ prepare(): void;
  10986. /**
  10987. * Execute the action and executes all the aggregated actions.
  10988. */
  10989. execute(evt: ActionEvent): void;
  10990. /**
  10991. * Serializes the actions and its related information.
  10992. * @param parent defines the object to serialize in
  10993. * @returns the serialized object
  10994. */
  10995. serialize(parent: any): any;
  10996. }
  10997. /**
  10998. * This defines an action responsible to run code (external event) once triggered.
  10999. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11000. */
  11001. export class ExecuteCodeAction extends Action {
  11002. /**
  11003. * The callback function to run.
  11004. */
  11005. func: (evt: ActionEvent) => void;
  11006. /**
  11007. * Instantiate the action
  11008. * @param triggerOptions defines the trigger options
  11009. * @param func defines the callback function to run
  11010. * @param condition defines the trigger related conditions
  11011. */
  11012. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11013. /**
  11014. * Execute the action and run the attached code.
  11015. */
  11016. execute(evt: ActionEvent): void;
  11017. }
  11018. /**
  11019. * This defines an action responsible to set the parent property of the target once triggered.
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11021. */
  11022. export class SetParentAction extends Action {
  11023. private _parent;
  11024. private _target;
  11025. /**
  11026. * Instantiate the action
  11027. * @param triggerOptions defines the trigger options
  11028. * @param target defines the target containing the parent property
  11029. * @param parent defines from where the animation should start (animation frame)
  11030. * @param condition defines the trigger related conditions
  11031. */
  11032. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11033. /** @hidden */ prepare(): void;
  11034. /**
  11035. * Execute the action and set the parent property.
  11036. */
  11037. execute(): void;
  11038. /**
  11039. * Serializes the actions and its related information.
  11040. * @param parent defines the object to serialize in
  11041. * @returns the serialized object
  11042. */
  11043. serialize(parent: any): any;
  11044. }
  11045. }
  11046. declare module BABYLON {
  11047. /**
  11048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11050. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11051. */
  11052. export class ActionManager extends AbstractActionManager {
  11053. /**
  11054. * Nothing
  11055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11056. */
  11057. static readonly NothingTrigger: number;
  11058. /**
  11059. * On pick
  11060. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11061. */
  11062. static readonly OnPickTrigger: number;
  11063. /**
  11064. * On left pick
  11065. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11066. */
  11067. static readonly OnLeftPickTrigger: number;
  11068. /**
  11069. * On right pick
  11070. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11071. */
  11072. static readonly OnRightPickTrigger: number;
  11073. /**
  11074. * On center pick
  11075. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11076. */
  11077. static readonly OnCenterPickTrigger: number;
  11078. /**
  11079. * On pick down
  11080. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11081. */
  11082. static readonly OnPickDownTrigger: number;
  11083. /**
  11084. * On double pick
  11085. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11086. */
  11087. static readonly OnDoublePickTrigger: number;
  11088. /**
  11089. * On pick up
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11091. */
  11092. static readonly OnPickUpTrigger: number;
  11093. /**
  11094. * On pick out.
  11095. * This trigger will only be raised if you also declared a OnPickDown
  11096. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11097. */
  11098. static readonly OnPickOutTrigger: number;
  11099. /**
  11100. * On long press
  11101. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11102. */
  11103. static readonly OnLongPressTrigger: number;
  11104. /**
  11105. * On pointer over
  11106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11107. */
  11108. static readonly OnPointerOverTrigger: number;
  11109. /**
  11110. * On pointer out
  11111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11112. */
  11113. static readonly OnPointerOutTrigger: number;
  11114. /**
  11115. * On every frame
  11116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11117. */
  11118. static readonly OnEveryFrameTrigger: number;
  11119. /**
  11120. * On intersection enter
  11121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11122. */
  11123. static readonly OnIntersectionEnterTrigger: number;
  11124. /**
  11125. * On intersection exit
  11126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11127. */
  11128. static readonly OnIntersectionExitTrigger: number;
  11129. /**
  11130. * On key down
  11131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11132. */
  11133. static readonly OnKeyDownTrigger: number;
  11134. /**
  11135. * On key up
  11136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11137. */
  11138. static readonly OnKeyUpTrigger: number;
  11139. private _scene;
  11140. /**
  11141. * Creates a new action manager
  11142. * @param scene defines the hosting scene
  11143. */
  11144. constructor(scene: Scene);
  11145. /**
  11146. * Releases all associated resources
  11147. */
  11148. dispose(): void;
  11149. /**
  11150. * Gets hosting scene
  11151. * @returns the hosting scene
  11152. */
  11153. getScene(): Scene;
  11154. /**
  11155. * Does this action manager handles actions of any of the given triggers
  11156. * @param triggers defines the triggers to be tested
  11157. * @return a boolean indicating whether one (or more) of the triggers is handled
  11158. */
  11159. hasSpecificTriggers(triggers: number[]): boolean;
  11160. /**
  11161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11162. * speed.
  11163. * @param triggerA defines the trigger to be tested
  11164. * @param triggerB defines the trigger to be tested
  11165. * @return a boolean indicating whether one (or more) of the triggers is handled
  11166. */
  11167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11168. /**
  11169. * Does this action manager handles actions of a given trigger
  11170. * @param trigger defines the trigger to be tested
  11171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11172. * @return whether the trigger is handled
  11173. */
  11174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11175. /**
  11176. * Does this action manager has pointer triggers
  11177. */
  11178. readonly hasPointerTriggers: boolean;
  11179. /**
  11180. * Does this action manager has pick triggers
  11181. */
  11182. readonly hasPickTriggers: boolean;
  11183. /**
  11184. * Registers an action to this action manager
  11185. * @param action defines the action to be registered
  11186. * @return the action amended (prepared) after registration
  11187. */
  11188. registerAction(action: IAction): Nullable<IAction>;
  11189. /**
  11190. * Unregisters an action to this action manager
  11191. * @param action defines the action to be unregistered
  11192. * @return a boolean indicating whether the action has been unregistered
  11193. */
  11194. unregisterAction(action: IAction): Boolean;
  11195. /**
  11196. * Process a specific trigger
  11197. * @param trigger defines the trigger to process
  11198. * @param evt defines the event details to be processed
  11199. */
  11200. processTrigger(trigger: number, evt?: IActionEvent): void;
  11201. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11202. /** @hidden */ getProperty(propertyPath: string): string;
  11203. /**
  11204. * Serialize this manager to a JSON object
  11205. * @param name defines the property name to store this manager
  11206. * @returns a JSON representation of this manager
  11207. */
  11208. serialize(name: string): any;
  11209. /**
  11210. * Creates a new ActionManager from a JSON data
  11211. * @param parsedActions defines the JSON data to read from
  11212. * @param object defines the hosting mesh
  11213. * @param scene defines the hosting scene
  11214. */
  11215. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11216. /**
  11217. * Get a trigger name by index
  11218. * @param trigger defines the trigger index
  11219. * @returns a trigger name
  11220. */
  11221. static GetTriggerName(trigger: number): string;
  11222. }
  11223. }
  11224. declare module BABYLON {
  11225. /**
  11226. * Class representing a ray with position and direction
  11227. */
  11228. export class Ray {
  11229. /** origin point */
  11230. origin: Vector3;
  11231. /** direction */
  11232. direction: Vector3;
  11233. /** length of the ray */
  11234. length: number;
  11235. private static readonly TmpVector3;
  11236. private _tmpRay;
  11237. /**
  11238. * Creates a new ray
  11239. * @param origin origin point
  11240. * @param direction direction
  11241. * @param length length of the ray
  11242. */
  11243. constructor(
  11244. /** origin point */
  11245. origin: Vector3,
  11246. /** direction */
  11247. direction: Vector3,
  11248. /** length of the ray */
  11249. length?: number);
  11250. /**
  11251. * Checks if the ray intersects a box
  11252. * @param minimum bound of the box
  11253. * @param maximum bound of the box
  11254. * @param intersectionTreshold extra extend to be added to the box in all direction
  11255. * @returns if the box was hit
  11256. */
  11257. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11258. /**
  11259. * Checks if the ray intersects a box
  11260. * @param box the bounding box to check
  11261. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11262. * @returns if the box was hit
  11263. */
  11264. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11265. /**
  11266. * If the ray hits a sphere
  11267. * @param sphere the bounding sphere to check
  11268. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11269. * @returns true if it hits the sphere
  11270. */
  11271. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11272. /**
  11273. * If the ray hits a triange
  11274. * @param vertex0 triangle vertex
  11275. * @param vertex1 triangle vertex
  11276. * @param vertex2 triangle vertex
  11277. * @returns intersection information if hit
  11278. */
  11279. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11280. /**
  11281. * Checks if ray intersects a plane
  11282. * @param plane the plane to check
  11283. * @returns the distance away it was hit
  11284. */
  11285. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11286. /**
  11287. * Checks if ray intersects a mesh
  11288. * @param mesh the mesh to check
  11289. * @param fastCheck if only the bounding box should checked
  11290. * @returns picking info of the intersecton
  11291. */
  11292. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11293. /**
  11294. * Checks if ray intersects a mesh
  11295. * @param meshes the meshes to check
  11296. * @param fastCheck if only the bounding box should checked
  11297. * @param results array to store result in
  11298. * @returns Array of picking infos
  11299. */
  11300. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11301. private _comparePickingInfo;
  11302. private static smallnum;
  11303. private static rayl;
  11304. /**
  11305. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11306. * @param sega the first point of the segment to test the intersection against
  11307. * @param segb the second point of the segment to test the intersection against
  11308. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11309. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11310. */
  11311. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11312. /**
  11313. * Update the ray from viewport position
  11314. * @param x position
  11315. * @param y y position
  11316. * @param viewportWidth viewport width
  11317. * @param viewportHeight viewport height
  11318. * @param world world matrix
  11319. * @param view view matrix
  11320. * @param projection projection matrix
  11321. * @returns this ray updated
  11322. */
  11323. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11324. /**
  11325. * Creates a ray with origin and direction of 0,0,0
  11326. * @returns the new ray
  11327. */
  11328. static Zero(): Ray;
  11329. /**
  11330. * Creates a new ray from screen space and viewport
  11331. * @param x position
  11332. * @param y y position
  11333. * @param viewportWidth viewport width
  11334. * @param viewportHeight viewport height
  11335. * @param world world matrix
  11336. * @param view view matrix
  11337. * @param projection projection matrix
  11338. * @returns new ray
  11339. */
  11340. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11341. /**
  11342. * 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
  11343. * transformed to the given world matrix.
  11344. * @param origin The origin point
  11345. * @param end The end point
  11346. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11347. * @returns the new ray
  11348. */
  11349. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11350. /**
  11351. * Transforms a ray by a matrix
  11352. * @param ray ray to transform
  11353. * @param matrix matrix to apply
  11354. * @returns the resulting new ray
  11355. */
  11356. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11357. /**
  11358. * Transforms a ray by a matrix
  11359. * @param ray ray to transform
  11360. * @param matrix matrix to apply
  11361. * @param result ray to store result in
  11362. */
  11363. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11364. /**
  11365. * Unproject a ray from screen space to object space
  11366. * @param sourceX defines the screen space x coordinate to use
  11367. * @param sourceY defines the screen space y coordinate to use
  11368. * @param viewportWidth defines the current width of the viewport
  11369. * @param viewportHeight defines the current height of the viewport
  11370. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11371. * @param view defines the view matrix to use
  11372. * @param projection defines the projection matrix to use
  11373. */
  11374. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11375. }
  11376. /**
  11377. * Type used to define predicate used to select faces when a mesh intersection is detected
  11378. */
  11379. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11380. interface Scene {
  11381. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11382. /** @hidden */ cachedRayForTransform: Ray;
  11383. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11384. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11385. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11386. }
  11387. }
  11388. declare module BABYLON {
  11389. /**
  11390. * Groups all the scene component constants in one place to ease maintenance.
  11391. * @hidden
  11392. */
  11393. export class SceneComponentConstants {
  11394. static readonly NAME_EFFECTLAYER: string;
  11395. static readonly NAME_LAYER: string;
  11396. static readonly NAME_LENSFLARESYSTEM: string;
  11397. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11398. static readonly NAME_PARTICLESYSTEM: string;
  11399. static readonly NAME_GAMEPAD: string;
  11400. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11401. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11402. static readonly NAME_DEPTHRENDERER: string;
  11403. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11404. static readonly NAME_SPRITE: string;
  11405. static readonly NAME_OUTLINERENDERER: string;
  11406. static readonly NAME_PROCEDURALTEXTURE: string;
  11407. static readonly NAME_SHADOWGENERATOR: string;
  11408. static readonly NAME_OCTREE: string;
  11409. static readonly NAME_PHYSICSENGINE: string;
  11410. static readonly NAME_AUDIO: string;
  11411. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11412. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11413. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11414. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11415. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11416. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11417. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11418. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11419. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11420. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11421. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11422. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11423. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11424. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11425. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11426. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11427. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11428. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11429. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11430. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11431. static readonly STEP_AFTERRENDER_AUDIO: number;
  11432. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11433. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11434. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11435. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11436. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11437. static readonly STEP_POINTERMOVE_SPRITE: number;
  11438. static readonly STEP_POINTERDOWN_SPRITE: number;
  11439. static readonly STEP_POINTERUP_SPRITE: number;
  11440. }
  11441. /**
  11442. * This represents a scene component.
  11443. *
  11444. * This is used to decouple the dependency the scene is having on the different workloads like
  11445. * layers, post processes...
  11446. */
  11447. export interface ISceneComponent {
  11448. /**
  11449. * The name of the component. Each component must have a unique name.
  11450. */
  11451. name: string;
  11452. /**
  11453. * The scene the component belongs to.
  11454. */
  11455. scene: Scene;
  11456. /**
  11457. * Register the component to one instance of a scene.
  11458. */
  11459. register(): void;
  11460. /**
  11461. * Rebuilds the elements related to this component in case of
  11462. * context lost for instance.
  11463. */
  11464. rebuild(): void;
  11465. /**
  11466. * Disposes the component and the associated ressources.
  11467. */
  11468. dispose(): void;
  11469. }
  11470. /**
  11471. * This represents a SERIALIZABLE scene component.
  11472. *
  11473. * This extends Scene Component to add Serialization methods on top.
  11474. */
  11475. export interface ISceneSerializableComponent extends ISceneComponent {
  11476. /**
  11477. * Adds all the element from the container to the scene
  11478. * @param container the container holding the elements
  11479. */
  11480. addFromContainer(container: AbstractScene): void;
  11481. /**
  11482. * Removes all the elements in the container from the scene
  11483. * @param container contains the elements to remove
  11484. * @param dispose if the removed element should be disposed (default: false)
  11485. */
  11486. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11487. /**
  11488. * Serializes the component data to the specified json object
  11489. * @param serializationObject The object to serialize to
  11490. */
  11491. serialize(serializationObject: any): void;
  11492. }
  11493. /**
  11494. * Strong typing of a Mesh related stage step action
  11495. */
  11496. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11497. /**
  11498. * Strong typing of a Evaluate Sub Mesh related stage step action
  11499. */
  11500. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11501. /**
  11502. * Strong typing of a Active Mesh related stage step action
  11503. */
  11504. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11505. /**
  11506. * Strong typing of a Camera related stage step action
  11507. */
  11508. export type CameraStageAction = (camera: Camera) => void;
  11509. /**
  11510. * Strong typing of a Camera Frame buffer related stage step action
  11511. */
  11512. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11513. /**
  11514. * Strong typing of a Render Target related stage step action
  11515. */
  11516. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11517. /**
  11518. * Strong typing of a RenderingGroup related stage step action
  11519. */
  11520. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11521. /**
  11522. * Strong typing of a Mesh Render related stage step action
  11523. */
  11524. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11525. /**
  11526. * Strong typing of a simple stage step action
  11527. */
  11528. export type SimpleStageAction = () => void;
  11529. /**
  11530. * Strong typing of a render target action.
  11531. */
  11532. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11533. /**
  11534. * Strong typing of a pointer move action.
  11535. */
  11536. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11537. /**
  11538. * Strong typing of a pointer up/down action.
  11539. */
  11540. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11541. /**
  11542. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11543. * @hidden
  11544. */
  11545. export class Stage<T extends Function> extends Array<{
  11546. index: number;
  11547. component: ISceneComponent;
  11548. action: T;
  11549. }> {
  11550. /**
  11551. * Hide ctor from the rest of the world.
  11552. * @param items The items to add.
  11553. */
  11554. private constructor();
  11555. /**
  11556. * Creates a new Stage.
  11557. * @returns A new instance of a Stage
  11558. */
  11559. static Create<T extends Function>(): Stage<T>;
  11560. /**
  11561. * Registers a step in an ordered way in the targeted stage.
  11562. * @param index Defines the position to register the step in
  11563. * @param component Defines the component attached to the step
  11564. * @param action Defines the action to launch during the step
  11565. */
  11566. registerStep(index: number, component: ISceneComponent, action: T): void;
  11567. /**
  11568. * Clears all the steps from the stage.
  11569. */
  11570. clear(): void;
  11571. }
  11572. }
  11573. declare module BABYLON {
  11574. interface Scene {
  11575. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11576. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11577. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11578. /**
  11579. * All of the sprite managers added to this scene
  11580. * @see http://doc.babylonjs.com/babylon101/sprites
  11581. */
  11582. spriteManagers: Array<ISpriteManager>;
  11583. /**
  11584. * An event triggered when sprites rendering is about to start
  11585. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11586. */
  11587. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11588. /**
  11589. * An event triggered when sprites rendering is done
  11590. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11591. */
  11592. onAfterSpritesRenderingObservable: Observable<Scene>;
  11593. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11594. /** Launch a ray to try to pick a sprite in the scene
  11595. * @param x position on screen
  11596. * @param y position on screen
  11597. * @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
  11598. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11599. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11600. * @returns a PickingInfo
  11601. */
  11602. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11603. /** Use the given ray to pick a sprite in the scene
  11604. * @param ray The ray (in world space) to use to pick meshes
  11605. * @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
  11606. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11607. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11608. * @returns a PickingInfo
  11609. */
  11610. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11611. /**
  11612. * Force the sprite under the pointer
  11613. * @param sprite defines the sprite to use
  11614. */
  11615. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11616. /**
  11617. * Gets the sprite under the pointer
  11618. * @returns a Sprite or null if no sprite is under the pointer
  11619. */
  11620. getPointerOverSprite(): Nullable<Sprite>;
  11621. }
  11622. /**
  11623. * Defines the sprite scene component responsible to manage sprites
  11624. * in a given scene.
  11625. */
  11626. export class SpriteSceneComponent implements ISceneComponent {
  11627. /**
  11628. * The component name helpfull to identify the component in the list of scene components.
  11629. */
  11630. readonly name: string;
  11631. /**
  11632. * The scene the component belongs to.
  11633. */
  11634. scene: Scene;
  11635. /** @hidden */
  11636. private _spritePredicate;
  11637. /**
  11638. * Creates a new instance of the component for the given scene
  11639. * @param scene Defines the scene to register the component in
  11640. */
  11641. constructor(scene: Scene);
  11642. /**
  11643. * Registers the component in a given scene
  11644. */
  11645. register(): void;
  11646. /**
  11647. * Rebuilds the elements related to this component in case of
  11648. * context lost for instance.
  11649. */
  11650. rebuild(): void;
  11651. /**
  11652. * Disposes the component and the associated ressources.
  11653. */
  11654. dispose(): void;
  11655. private _pickSpriteButKeepRay;
  11656. private _pointerMove;
  11657. private _pointerDown;
  11658. private _pointerUp;
  11659. }
  11660. }
  11661. declare module BABYLON {
  11662. /** @hidden */
  11663. export var fogFragmentDeclaration: {
  11664. name: string;
  11665. shader: string;
  11666. };
  11667. }
  11668. declare module BABYLON {
  11669. /** @hidden */
  11670. export var fogFragment: {
  11671. name: string;
  11672. shader: string;
  11673. };
  11674. }
  11675. declare module BABYLON {
  11676. /** @hidden */
  11677. export var spritesPixelShader: {
  11678. name: string;
  11679. shader: string;
  11680. };
  11681. }
  11682. declare module BABYLON {
  11683. /** @hidden */
  11684. export var fogVertexDeclaration: {
  11685. name: string;
  11686. shader: string;
  11687. };
  11688. }
  11689. declare module BABYLON {
  11690. /** @hidden */
  11691. export var spritesVertexShader: {
  11692. name: string;
  11693. shader: string;
  11694. };
  11695. }
  11696. declare module BABYLON {
  11697. /**
  11698. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11699. */
  11700. export interface ISpriteManager extends IDisposable {
  11701. /**
  11702. * Restricts the camera to viewing objects with the same layerMask.
  11703. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11704. */
  11705. layerMask: number;
  11706. /**
  11707. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11708. */
  11709. isPickable: boolean;
  11710. /**
  11711. * Specifies the rendering group id for this mesh (0 by default)
  11712. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11713. */
  11714. renderingGroupId: number;
  11715. /**
  11716. * Defines the list of sprites managed by the manager.
  11717. */
  11718. sprites: Array<Sprite>;
  11719. /**
  11720. * Tests the intersection of a sprite with a specific ray.
  11721. * @param ray The ray we are sending to test the collision
  11722. * @param camera The camera space we are sending rays in
  11723. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11724. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11725. * @returns picking info or null.
  11726. */
  11727. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11728. /**
  11729. * Renders the list of sprites on screen.
  11730. */
  11731. render(): void;
  11732. }
  11733. /**
  11734. * Class used to manage multiple sprites on the same spritesheet
  11735. * @see http://doc.babylonjs.com/babylon101/sprites
  11736. */
  11737. export class SpriteManager implements ISpriteManager {
  11738. /** defines the manager's name */
  11739. name: string;
  11740. /** Gets the list of sprites */
  11741. sprites: Sprite[];
  11742. /** Gets or sets the rendering group id (0 by default) */
  11743. renderingGroupId: number;
  11744. /** Gets or sets camera layer mask */
  11745. layerMask: number;
  11746. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11747. fogEnabled: boolean;
  11748. /** Gets or sets a boolean indicating if the sprites are pickable */
  11749. isPickable: boolean;
  11750. /** Defines the default width of a cell in the spritesheet */
  11751. cellWidth: number;
  11752. /** Defines the default height of a cell in the spritesheet */
  11753. cellHeight: number;
  11754. /**
  11755. * An event triggered when the manager is disposed.
  11756. */
  11757. onDisposeObservable: Observable<SpriteManager>;
  11758. private _onDisposeObserver;
  11759. /**
  11760. * Callback called when the manager is disposed
  11761. */
  11762. onDispose: () => void;
  11763. private _capacity;
  11764. private _spriteTexture;
  11765. private _epsilon;
  11766. private _scene;
  11767. private _vertexData;
  11768. private _buffer;
  11769. private _vertexBuffers;
  11770. private _indexBuffer;
  11771. private _effectBase;
  11772. private _effectFog;
  11773. /**
  11774. * Gets or sets the spritesheet texture
  11775. */
  11776. texture: Texture;
  11777. /**
  11778. * Creates a new sprite manager
  11779. * @param name defines the manager's name
  11780. * @param imgUrl defines the sprite sheet url
  11781. * @param capacity defines the maximum allowed number of sprites
  11782. * @param cellSize defines the size of a sprite cell
  11783. * @param scene defines the hosting scene
  11784. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11785. * @param samplingMode defines the smapling mode to use with spritesheet
  11786. */
  11787. constructor(
  11788. /** defines the manager's name */
  11789. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11790. private _appendSpriteVertex;
  11791. /**
  11792. * Intersects the sprites with a ray
  11793. * @param ray defines the ray to intersect with
  11794. * @param camera defines the current active camera
  11795. * @param predicate defines a predicate used to select candidate sprites
  11796. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11797. * @returns null if no hit or a PickingInfo
  11798. */
  11799. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11800. /**
  11801. * Render all child sprites
  11802. */
  11803. render(): void;
  11804. /**
  11805. * Release associated resources
  11806. */
  11807. dispose(): void;
  11808. }
  11809. }
  11810. declare module BABYLON {
  11811. /**
  11812. * Class used to represent a sprite
  11813. * @see http://doc.babylonjs.com/babylon101/sprites
  11814. */
  11815. export class Sprite {
  11816. /** defines the name */
  11817. name: string;
  11818. /** Gets or sets the current world position */
  11819. position: Vector3;
  11820. /** Gets or sets the main color */
  11821. color: Color4;
  11822. /** Gets or sets the width */
  11823. width: number;
  11824. /** Gets or sets the height */
  11825. height: number;
  11826. /** Gets or sets rotation angle */
  11827. angle: number;
  11828. /** Gets or sets the cell index in the sprite sheet */
  11829. cellIndex: number;
  11830. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11831. invertU: number;
  11832. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11833. invertV: number;
  11834. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11835. disposeWhenFinishedAnimating: boolean;
  11836. /** Gets the list of attached animations */
  11837. animations: Animation[];
  11838. /** Gets or sets a boolean indicating if the sprite can be picked */
  11839. isPickable: boolean;
  11840. /**
  11841. * Gets or sets the associated action manager
  11842. */
  11843. actionManager: Nullable<ActionManager>;
  11844. private _animationStarted;
  11845. private _loopAnimation;
  11846. private _fromIndex;
  11847. private _toIndex;
  11848. private _delay;
  11849. private _direction;
  11850. private _manager;
  11851. private _time;
  11852. private _onAnimationEnd;
  11853. /**
  11854. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11855. */
  11856. isVisible: boolean;
  11857. /**
  11858. * Gets or sets the sprite size
  11859. */
  11860. size: number;
  11861. /**
  11862. * Creates a new Sprite
  11863. * @param name defines the name
  11864. * @param manager defines the manager
  11865. */
  11866. constructor(
  11867. /** defines the name */
  11868. name: string, manager: ISpriteManager);
  11869. /**
  11870. * Starts an animation
  11871. * @param from defines the initial key
  11872. * @param to defines the end key
  11873. * @param loop defines if the animation must loop
  11874. * @param delay defines the start delay (in ms)
  11875. * @param onAnimationEnd defines a callback to call when animation ends
  11876. */
  11877. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11878. /** Stops current animation (if any) */
  11879. stopAnimation(): void;
  11880. /** @hidden */ animate(deltaTime: number): void;
  11881. /** Release associated resources */
  11882. dispose(): void;
  11883. }
  11884. }
  11885. declare module BABYLON {
  11886. /**
  11887. * Information about the result of picking within a scene
  11888. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11889. */
  11890. export class PickingInfo {
  11891. /** @hidden */ pickingUnavailable: boolean;
  11892. /**
  11893. * If the pick collided with an object
  11894. */
  11895. hit: boolean;
  11896. /**
  11897. * Distance away where the pick collided
  11898. */
  11899. distance: number;
  11900. /**
  11901. * The location of pick collision
  11902. */
  11903. pickedPoint: Nullable<Vector3>;
  11904. /**
  11905. * The mesh corresponding the the pick collision
  11906. */
  11907. pickedMesh: Nullable<AbstractMesh>;
  11908. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11909. bu: number;
  11910. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11911. bv: number;
  11912. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11913. faceId: number;
  11914. /** Id of the the submesh that was picked */
  11915. subMeshId: number;
  11916. /** If a sprite was picked, this will be the sprite the pick collided with */
  11917. pickedSprite: Nullable<Sprite>;
  11918. /**
  11919. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11920. */
  11921. originMesh: Nullable<AbstractMesh>;
  11922. /**
  11923. * The ray that was used to perform the picking.
  11924. */
  11925. ray: Nullable<Ray>;
  11926. /**
  11927. * Gets the normal correspodning to the face the pick collided with
  11928. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11929. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11930. * @returns The normal correspodning to the face the pick collided with
  11931. */
  11932. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11933. /**
  11934. * Gets the texture coordinates of where the pick occured
  11935. * @returns the vector containing the coordnates of the texture
  11936. */
  11937. getTextureCoordinates(): Nullable<Vector2>;
  11938. }
  11939. }
  11940. declare module BABYLON {
  11941. /**
  11942. * Gather the list of pointer event types as constants.
  11943. */
  11944. export class PointerEventTypes {
  11945. /**
  11946. * 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.
  11947. */
  11948. static readonly POINTERDOWN: number;
  11949. /**
  11950. * The pointerup event is fired when a pointer is no longer active.
  11951. */
  11952. static readonly POINTERUP: number;
  11953. /**
  11954. * The pointermove event is fired when a pointer changes coordinates.
  11955. */
  11956. static readonly POINTERMOVE: number;
  11957. /**
  11958. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11959. */
  11960. static readonly POINTERWHEEL: number;
  11961. /**
  11962. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11963. */
  11964. static readonly POINTERPICK: number;
  11965. /**
  11966. * The pointertap event is fired when a the object has been touched and released without drag.
  11967. */
  11968. static readonly POINTERTAP: number;
  11969. /**
  11970. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11971. */
  11972. static readonly POINTERDOUBLETAP: number;
  11973. }
  11974. /**
  11975. * Base class of pointer info types.
  11976. */
  11977. export class PointerInfoBase {
  11978. /**
  11979. * Defines the type of event (PointerEventTypes)
  11980. */
  11981. type: number;
  11982. /**
  11983. * Defines the related dom event
  11984. */
  11985. event: PointerEvent | MouseWheelEvent;
  11986. /**
  11987. * Instantiates the base class of pointers info.
  11988. * @param type Defines the type of event (PointerEventTypes)
  11989. * @param event Defines the related dom event
  11990. */
  11991. constructor(
  11992. /**
  11993. * Defines the type of event (PointerEventTypes)
  11994. */
  11995. type: number,
  11996. /**
  11997. * Defines the related dom event
  11998. */
  11999. event: PointerEvent | MouseWheelEvent);
  12000. }
  12001. /**
  12002. * This class is used to store pointer related info for the onPrePointerObservable event.
  12003. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12004. */
  12005. export class PointerInfoPre extends PointerInfoBase {
  12006. /**
  12007. * Ray from a pointer if availible (eg. 6dof controller)
  12008. */
  12009. ray: Nullable<Ray>;
  12010. /**
  12011. * Defines the local position of the pointer on the canvas.
  12012. */
  12013. localPosition: Vector2;
  12014. /**
  12015. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12016. */
  12017. skipOnPointerObservable: boolean;
  12018. /**
  12019. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12020. * @param type Defines the type of event (PointerEventTypes)
  12021. * @param event Defines the related dom event
  12022. * @param localX Defines the local x coordinates of the pointer when the event occured
  12023. * @param localY Defines the local y coordinates of the pointer when the event occured
  12024. */
  12025. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12026. }
  12027. /**
  12028. * This type contains all the data related to a pointer event in Babylon.js.
  12029. * 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.
  12030. */
  12031. export class PointerInfo extends PointerInfoBase {
  12032. /**
  12033. * Defines the picking info associated to the info (if any)\
  12034. */
  12035. pickInfo: Nullable<PickingInfo>;
  12036. /**
  12037. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12038. * @param type Defines the type of event (PointerEventTypes)
  12039. * @param event Defines the related dom event
  12040. * @param pickInfo Defines the picking info associated to the info (if any)\
  12041. */
  12042. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12043. /**
  12044. * Defines the picking info associated to the info (if any)\
  12045. */
  12046. pickInfo: Nullable<PickingInfo>);
  12047. }
  12048. /**
  12049. * Data relating to a touch event on the screen.
  12050. */
  12051. export interface PointerTouch {
  12052. /**
  12053. * X coordinate of touch.
  12054. */
  12055. x: number;
  12056. /**
  12057. * Y coordinate of touch.
  12058. */
  12059. y: number;
  12060. /**
  12061. * Id of touch. Unique for each finger.
  12062. */
  12063. pointerId: number;
  12064. /**
  12065. * Event type passed from DOM.
  12066. */
  12067. type: any;
  12068. }
  12069. }
  12070. declare module BABYLON {
  12071. /**
  12072. * Manage the mouse inputs to control the movement of a free camera.
  12073. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12074. */
  12075. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12076. /**
  12077. * Define if touch is enabled in the mouse input
  12078. */
  12079. touchEnabled: boolean;
  12080. /**
  12081. * Defines the camera the input is attached to.
  12082. */
  12083. camera: FreeCamera;
  12084. /**
  12085. * Defines the buttons associated with the input to handle camera move.
  12086. */
  12087. buttons: number[];
  12088. /**
  12089. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12090. */
  12091. angularSensibility: number;
  12092. private _pointerInput;
  12093. private _onMouseMove;
  12094. private _observer;
  12095. private previousPosition;
  12096. /**
  12097. * Observable for when a pointer move event occurs containing the move offset
  12098. */
  12099. onPointerMovedObservable: Observable<{
  12100. offsetX: number;
  12101. offsetY: number;
  12102. }>;
  12103. /**
  12104. * @hidden
  12105. * If the camera should be rotated automatically based on pointer movement
  12106. */ allowCameraRotation: boolean;
  12107. /**
  12108. * Manage the mouse inputs to control the movement of a free camera.
  12109. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12110. * @param touchEnabled Defines if touch is enabled or not
  12111. */
  12112. constructor(
  12113. /**
  12114. * Define if touch is enabled in the mouse input
  12115. */
  12116. touchEnabled?: boolean);
  12117. /**
  12118. * Attach the input controls to a specific dom element to get the input from.
  12119. * @param element Defines the element the controls should be listened from
  12120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12121. */
  12122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12123. /**
  12124. * Called on JS contextmenu event.
  12125. * Override this method to provide functionality.
  12126. */
  12127. protected onContextMenu(evt: PointerEvent): void;
  12128. /**
  12129. * Detach the current controls from the specified dom element.
  12130. * @param element Defines the element to stop listening the inputs from
  12131. */
  12132. detachControl(element: Nullable<HTMLElement>): void;
  12133. /**
  12134. * Gets the class name of the current intput.
  12135. * @returns the class name
  12136. */
  12137. getClassName(): string;
  12138. /**
  12139. * Get the friendly name associated with the input class.
  12140. * @returns the input friendly name
  12141. */
  12142. getSimpleName(): string;
  12143. }
  12144. }
  12145. declare module BABYLON {
  12146. /**
  12147. * Manage the touch inputs to control the movement of a free camera.
  12148. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12149. */
  12150. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12151. /**
  12152. * Defines the camera the input is attached to.
  12153. */
  12154. camera: FreeCamera;
  12155. /**
  12156. * Defines the touch sensibility for rotation.
  12157. * The higher the faster.
  12158. */
  12159. touchAngularSensibility: number;
  12160. /**
  12161. * Defines the touch sensibility for move.
  12162. * The higher the faster.
  12163. */
  12164. touchMoveSensibility: number;
  12165. private _offsetX;
  12166. private _offsetY;
  12167. private _pointerPressed;
  12168. private _pointerInput;
  12169. private _observer;
  12170. private _onLostFocus;
  12171. /**
  12172. * Attach the input controls to a specific dom element to get the input from.
  12173. * @param element Defines the element the controls should be listened from
  12174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12175. */
  12176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12177. /**
  12178. * Detach the current controls from the specified dom element.
  12179. * @param element Defines the element to stop listening the inputs from
  12180. */
  12181. detachControl(element: Nullable<HTMLElement>): void;
  12182. /**
  12183. * Update the current camera state depending on the inputs that have been used this frame.
  12184. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12185. */
  12186. checkInputs(): void;
  12187. /**
  12188. * Gets the class name of the current intput.
  12189. * @returns the class name
  12190. */
  12191. getClassName(): string;
  12192. /**
  12193. * Get the friendly name associated with the input class.
  12194. * @returns the input friendly name
  12195. */
  12196. getSimpleName(): string;
  12197. }
  12198. }
  12199. declare module BABYLON {
  12200. /**
  12201. * Default Inputs manager for the FreeCamera.
  12202. * It groups all the default supported inputs for ease of use.
  12203. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12204. */
  12205. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12206. /**
  12207. * @hidden
  12208. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12209. /**
  12210. * @hidden
  12211. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12212. /**
  12213. * Instantiates a new FreeCameraInputsManager.
  12214. * @param camera Defines the camera the inputs belong to
  12215. */
  12216. constructor(camera: FreeCamera);
  12217. /**
  12218. * Add keyboard input support to the input manager.
  12219. * @returns the current input manager
  12220. */
  12221. addKeyboard(): FreeCameraInputsManager;
  12222. /**
  12223. * Add mouse input support to the input manager.
  12224. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12225. * @returns the current input manager
  12226. */
  12227. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12228. /**
  12229. * Removes the mouse input support from the manager
  12230. * @returns the current input manager
  12231. */
  12232. removeMouse(): FreeCameraInputsManager;
  12233. /**
  12234. * Add touch input support to the input manager.
  12235. * @returns the current input manager
  12236. */
  12237. addTouch(): FreeCameraInputsManager;
  12238. }
  12239. }
  12240. declare module BABYLON {
  12241. /**
  12242. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12243. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12244. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12245. */
  12246. export class FreeCamera extends TargetCamera {
  12247. /**
  12248. * Define the collision ellipsoid of the camera.
  12249. * This is helpful to simulate a camera body like the player body around the camera
  12250. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12251. */
  12252. ellipsoid: Vector3;
  12253. /**
  12254. * Define an offset for the position of the ellipsoid around the camera.
  12255. * This can be helpful to determine the center of the body near the gravity center of the body
  12256. * instead of its head.
  12257. */
  12258. ellipsoidOffset: Vector3;
  12259. /**
  12260. * Enable or disable collisions of the camera with the rest of the scene objects.
  12261. */
  12262. checkCollisions: boolean;
  12263. /**
  12264. * Enable or disable gravity on the camera.
  12265. */
  12266. applyGravity: boolean;
  12267. /**
  12268. * Define the input manager associated to the camera.
  12269. */
  12270. inputs: FreeCameraInputsManager;
  12271. /**
  12272. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12273. * Higher values reduce sensitivity.
  12274. */
  12275. /**
  12276. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12277. * Higher values reduce sensitivity.
  12278. */
  12279. angularSensibility: number;
  12280. /**
  12281. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12282. */
  12283. keysUp: number[];
  12284. /**
  12285. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12286. */
  12287. keysDown: number[];
  12288. /**
  12289. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12290. */
  12291. keysLeft: number[];
  12292. /**
  12293. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12294. */
  12295. keysRight: number[];
  12296. /**
  12297. * Event raised when the camera collide with a mesh in the scene.
  12298. */
  12299. onCollide: (collidedMesh: AbstractMesh) => void;
  12300. private _collider;
  12301. private _needMoveForGravity;
  12302. private _oldPosition;
  12303. private _diffPosition;
  12304. private _newPosition;
  12305. /** @hidden */ localDirection: Vector3;
  12306. /** @hidden */ transformedDirection: Vector3;
  12307. /**
  12308. * Instantiates a Free Camera.
  12309. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12310. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12311. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12312. * @param name Define the name of the camera in the scene
  12313. * @param position Define the start position of the camera in the scene
  12314. * @param scene Define the scene the camera belongs to
  12315. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12316. */
  12317. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12318. /**
  12319. * Attached controls to the current camera.
  12320. * @param element Defines the element the controls should be listened from
  12321. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12322. */
  12323. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12324. /**
  12325. * Detach the current controls from the camera.
  12326. * The camera will stop reacting to inputs.
  12327. * @param element Defines the element to stop listening the inputs from
  12328. */
  12329. detachControl(element: HTMLElement): void;
  12330. private _collisionMask;
  12331. /**
  12332. * Define a collision mask to limit the list of object the camera can collide with
  12333. */
  12334. collisionMask: number;
  12335. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12336. private _onCollisionPositionChange;
  12337. /** @hidden */ checkInputs(): void;
  12338. /** @hidden */ decideIfNeedsToMove(): boolean;
  12339. /** @hidden */ updatePosition(): void;
  12340. /**
  12341. * Destroy the camera and release the current resources hold by it.
  12342. */
  12343. dispose(): void;
  12344. /**
  12345. * Gets the current object class name.
  12346. * @return the class name
  12347. */
  12348. getClassName(): string;
  12349. }
  12350. }
  12351. declare module BABYLON {
  12352. /**
  12353. * Represents a gamepad control stick position
  12354. */
  12355. export class StickValues {
  12356. /**
  12357. * The x component of the control stick
  12358. */
  12359. x: number;
  12360. /**
  12361. * The y component of the control stick
  12362. */
  12363. y: number;
  12364. /**
  12365. * Initializes the gamepad x and y control stick values
  12366. * @param x The x component of the gamepad control stick value
  12367. * @param y The y component of the gamepad control stick value
  12368. */
  12369. constructor(
  12370. /**
  12371. * The x component of the control stick
  12372. */
  12373. x: number,
  12374. /**
  12375. * The y component of the control stick
  12376. */
  12377. y: number);
  12378. }
  12379. /**
  12380. * An interface which manages callbacks for gamepad button changes
  12381. */
  12382. export interface GamepadButtonChanges {
  12383. /**
  12384. * Called when a gamepad has been changed
  12385. */
  12386. changed: boolean;
  12387. /**
  12388. * Called when a gamepad press event has been triggered
  12389. */
  12390. pressChanged: boolean;
  12391. /**
  12392. * Called when a touch event has been triggered
  12393. */
  12394. touchChanged: boolean;
  12395. /**
  12396. * Called when a value has changed
  12397. */
  12398. valueChanged: boolean;
  12399. }
  12400. /**
  12401. * Represents a gamepad
  12402. */
  12403. export class Gamepad {
  12404. /**
  12405. * The id of the gamepad
  12406. */
  12407. id: string;
  12408. /**
  12409. * The index of the gamepad
  12410. */
  12411. index: number;
  12412. /**
  12413. * The browser gamepad
  12414. */
  12415. browserGamepad: any;
  12416. /**
  12417. * Specifies what type of gamepad this represents
  12418. */
  12419. type: number;
  12420. private _leftStick;
  12421. private _rightStick;
  12422. /** @hidden */ isConnected: boolean;
  12423. private _leftStickAxisX;
  12424. private _leftStickAxisY;
  12425. private _rightStickAxisX;
  12426. private _rightStickAxisY;
  12427. /**
  12428. * Triggered when the left control stick has been changed
  12429. */
  12430. private _onleftstickchanged;
  12431. /**
  12432. * Triggered when the right control stick has been changed
  12433. */
  12434. private _onrightstickchanged;
  12435. /**
  12436. * Represents a gamepad controller
  12437. */
  12438. static GAMEPAD: number;
  12439. /**
  12440. * Represents a generic controller
  12441. */
  12442. static GENERIC: number;
  12443. /**
  12444. * Represents an XBox controller
  12445. */
  12446. static XBOX: number;
  12447. /**
  12448. * Represents a pose-enabled controller
  12449. */
  12450. static POSE_ENABLED: number;
  12451. /**
  12452. * Specifies whether the left control stick should be Y-inverted
  12453. */
  12454. protected _invertLeftStickY: boolean;
  12455. /**
  12456. * Specifies if the gamepad has been connected
  12457. */
  12458. readonly isConnected: boolean;
  12459. /**
  12460. * Initializes the gamepad
  12461. * @param id The id of the gamepad
  12462. * @param index The index of the gamepad
  12463. * @param browserGamepad The browser gamepad
  12464. * @param leftStickX The x component of the left joystick
  12465. * @param leftStickY The y component of the left joystick
  12466. * @param rightStickX The x component of the right joystick
  12467. * @param rightStickY The y component of the right joystick
  12468. */
  12469. constructor(
  12470. /**
  12471. * The id of the gamepad
  12472. */
  12473. id: string,
  12474. /**
  12475. * The index of the gamepad
  12476. */
  12477. index: number,
  12478. /**
  12479. * The browser gamepad
  12480. */
  12481. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12482. /**
  12483. * Callback triggered when the left joystick has changed
  12484. * @param callback
  12485. */
  12486. onleftstickchanged(callback: (values: StickValues) => void): void;
  12487. /**
  12488. * Callback triggered when the right joystick has changed
  12489. * @param callback
  12490. */
  12491. onrightstickchanged(callback: (values: StickValues) => void): void;
  12492. /**
  12493. * Gets the left joystick
  12494. */
  12495. /**
  12496. * Sets the left joystick values
  12497. */
  12498. leftStick: StickValues;
  12499. /**
  12500. * Gets the right joystick
  12501. */
  12502. /**
  12503. * Sets the right joystick value
  12504. */
  12505. rightStick: StickValues;
  12506. /**
  12507. * Updates the gamepad joystick positions
  12508. */
  12509. update(): void;
  12510. /**
  12511. * Disposes the gamepad
  12512. */
  12513. dispose(): void;
  12514. }
  12515. /**
  12516. * Represents a generic gamepad
  12517. */
  12518. export class GenericPad extends Gamepad {
  12519. private _buttons;
  12520. private _onbuttondown;
  12521. private _onbuttonup;
  12522. /**
  12523. * Observable triggered when a button has been pressed
  12524. */
  12525. onButtonDownObservable: Observable<number>;
  12526. /**
  12527. * Observable triggered when a button has been released
  12528. */
  12529. onButtonUpObservable: Observable<number>;
  12530. /**
  12531. * Callback triggered when a button has been pressed
  12532. * @param callback Called when a button has been pressed
  12533. */
  12534. onbuttondown(callback: (buttonPressed: number) => void): void;
  12535. /**
  12536. * Callback triggered when a button has been released
  12537. * @param callback Called when a button has been released
  12538. */
  12539. onbuttonup(callback: (buttonReleased: number) => void): void;
  12540. /**
  12541. * Initializes the generic gamepad
  12542. * @param id The id of the generic gamepad
  12543. * @param index The index of the generic gamepad
  12544. * @param browserGamepad The browser gamepad
  12545. */
  12546. constructor(id: string, index: number, browserGamepad: any);
  12547. private _setButtonValue;
  12548. /**
  12549. * Updates the generic gamepad
  12550. */
  12551. update(): void;
  12552. /**
  12553. * Disposes the generic gamepad
  12554. */
  12555. dispose(): void;
  12556. }
  12557. }
  12558. declare module BABYLON {
  12559. /**
  12560. * Defines the types of pose enabled controllers that are supported
  12561. */
  12562. export enum PoseEnabledControllerType {
  12563. /**
  12564. * HTC Vive
  12565. */
  12566. VIVE = 0,
  12567. /**
  12568. * Oculus Rift
  12569. */
  12570. OCULUS = 1,
  12571. /**
  12572. * Windows mixed reality
  12573. */
  12574. WINDOWS = 2,
  12575. /**
  12576. * Samsung gear VR
  12577. */
  12578. GEAR_VR = 3,
  12579. /**
  12580. * Google Daydream
  12581. */
  12582. DAYDREAM = 4,
  12583. /**
  12584. * Generic
  12585. */
  12586. GENERIC = 5
  12587. }
  12588. /**
  12589. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12590. */
  12591. export interface MutableGamepadButton {
  12592. /**
  12593. * Value of the button/trigger
  12594. */
  12595. value: number;
  12596. /**
  12597. * If the button/trigger is currently touched
  12598. */
  12599. touched: boolean;
  12600. /**
  12601. * If the button/trigger is currently pressed
  12602. */
  12603. pressed: boolean;
  12604. }
  12605. /**
  12606. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12607. * @hidden
  12608. */
  12609. export interface ExtendedGamepadButton extends GamepadButton {
  12610. /**
  12611. * If the button/trigger is currently pressed
  12612. */
  12613. readonly pressed: boolean;
  12614. /**
  12615. * If the button/trigger is currently touched
  12616. */
  12617. readonly touched: boolean;
  12618. /**
  12619. * Value of the button/trigger
  12620. */
  12621. readonly value: number;
  12622. }
  12623. /** @hidden */
  12624. export interface _GamePadFactory {
  12625. /**
  12626. * Returns wether or not the current gamepad can be created for this type of controller.
  12627. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12628. * @returns true if it can be created, otherwise false
  12629. */
  12630. canCreate(gamepadInfo: any): boolean;
  12631. /**
  12632. * Creates a new instance of the Gamepad.
  12633. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12634. * @returns the new gamepad instance
  12635. */
  12636. create(gamepadInfo: any): Gamepad;
  12637. }
  12638. /**
  12639. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12640. */
  12641. export class PoseEnabledControllerHelper {
  12642. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12643. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12644. /**
  12645. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12646. * @param vrGamepad the gamepad to initialized
  12647. * @returns a vr controller of the type the gamepad identified as
  12648. */
  12649. static InitiateController(vrGamepad: any): Gamepad;
  12650. }
  12651. /**
  12652. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12653. */
  12654. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12655. private _deviceRoomPosition;
  12656. private _deviceRoomRotationQuaternion;
  12657. /**
  12658. * The device position in babylon space
  12659. */
  12660. devicePosition: Vector3;
  12661. /**
  12662. * The device rotation in babylon space
  12663. */
  12664. deviceRotationQuaternion: Quaternion;
  12665. /**
  12666. * The scale factor of the device in babylon space
  12667. */
  12668. deviceScaleFactor: number;
  12669. /**
  12670. * (Likely devicePosition should be used instead) The device position in its room space
  12671. */
  12672. position: Vector3;
  12673. /**
  12674. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12675. */
  12676. rotationQuaternion: Quaternion;
  12677. /**
  12678. * The type of controller (Eg. Windows mixed reality)
  12679. */
  12680. controllerType: PoseEnabledControllerType;
  12681. protected _calculatedPosition: Vector3;
  12682. private _calculatedRotation;
  12683. /**
  12684. * The raw pose from the device
  12685. */
  12686. rawPose: DevicePose;
  12687. private _trackPosition;
  12688. private _maxRotationDistFromHeadset;
  12689. private _draggedRoomRotation;
  12690. /**
  12691. * @hidden
  12692. */ disableTrackPosition(fixedPosition: Vector3): void;
  12693. /**
  12694. * Internal, the mesh attached to the controller
  12695. * @hidden
  12696. */ mesh: Nullable<AbstractMesh>;
  12697. private _poseControlledCamera;
  12698. private _leftHandSystemQuaternion;
  12699. /**
  12700. * Internal, matrix used to convert room space to babylon space
  12701. * @hidden
  12702. */ deviceToWorld: Matrix;
  12703. /**
  12704. * Node to be used when casting a ray from the controller
  12705. * @hidden
  12706. */ pointingPoseNode: Nullable<TransformNode>;
  12707. /**
  12708. * Name of the child mesh that can be used to cast a ray from the controller
  12709. */
  12710. static readonly POINTING_POSE: string;
  12711. /**
  12712. * Creates a new PoseEnabledController from a gamepad
  12713. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12714. */
  12715. constructor(browserGamepad: any);
  12716. private _workingMatrix;
  12717. /**
  12718. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12719. */
  12720. update(): void;
  12721. /**
  12722. * Updates only the pose device and mesh without doing any button event checking
  12723. */
  12724. protected _updatePoseAndMesh(): void;
  12725. /**
  12726. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12727. * @param poseData raw pose fromthe device
  12728. */
  12729. updateFromDevice(poseData: DevicePose): void;
  12730. /**
  12731. * @hidden
  12732. */ meshAttachedObservable: Observable<AbstractMesh>;
  12733. /**
  12734. * Attaches a mesh to the controller
  12735. * @param mesh the mesh to be attached
  12736. */
  12737. attachToMesh(mesh: AbstractMesh): void;
  12738. /**
  12739. * Attaches the controllers mesh to a camera
  12740. * @param camera the camera the mesh should be attached to
  12741. */
  12742. attachToPoseControlledCamera(camera: TargetCamera): void;
  12743. /**
  12744. * Disposes of the controller
  12745. */
  12746. dispose(): void;
  12747. /**
  12748. * The mesh that is attached to the controller
  12749. */
  12750. readonly mesh: Nullable<AbstractMesh>;
  12751. /**
  12752. * Gets the ray of the controller in the direction the controller is pointing
  12753. * @param length the length the resulting ray should be
  12754. * @returns a ray in the direction the controller is pointing
  12755. */
  12756. getForwardRay(length?: number): Ray;
  12757. }
  12758. }
  12759. declare module BABYLON {
  12760. /**
  12761. * Defines the WebVRController object that represents controllers tracked in 3D space
  12762. */
  12763. export abstract class WebVRController extends PoseEnabledController {
  12764. /**
  12765. * Internal, the default controller model for the controller
  12766. */
  12767. protected _defaultModel: AbstractMesh;
  12768. /**
  12769. * Fired when the trigger state has changed
  12770. */
  12771. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12772. /**
  12773. * Fired when the main button state has changed
  12774. */
  12775. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12776. /**
  12777. * Fired when the secondary button state has changed
  12778. */
  12779. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12780. /**
  12781. * Fired when the pad state has changed
  12782. */
  12783. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12784. /**
  12785. * Fired when controllers stick values have changed
  12786. */
  12787. onPadValuesChangedObservable: Observable<StickValues>;
  12788. /**
  12789. * Array of button availible on the controller
  12790. */
  12791. protected _buttons: Array<MutableGamepadButton>;
  12792. private _onButtonStateChange;
  12793. /**
  12794. * Fired when a controller button's state has changed
  12795. * @param callback the callback containing the button that was modified
  12796. */
  12797. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12798. /**
  12799. * X and Y axis corrisponding to the controllers joystick
  12800. */
  12801. pad: StickValues;
  12802. /**
  12803. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12804. */
  12805. hand: string;
  12806. /**
  12807. * The default controller model for the controller
  12808. */
  12809. readonly defaultModel: AbstractMesh;
  12810. /**
  12811. * Creates a new WebVRController from a gamepad
  12812. * @param vrGamepad the gamepad that the WebVRController should be created from
  12813. */
  12814. constructor(vrGamepad: any);
  12815. /**
  12816. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12817. */
  12818. update(): void;
  12819. /**
  12820. * Function to be called when a button is modified
  12821. */
  12822. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12823. /**
  12824. * Loads a mesh and attaches it to the controller
  12825. * @param scene the scene the mesh should be added to
  12826. * @param meshLoaded callback for when the mesh has been loaded
  12827. */
  12828. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12829. private _setButtonValue;
  12830. private _changes;
  12831. private _checkChanges;
  12832. /**
  12833. * Disposes of th webVRCOntroller
  12834. */
  12835. dispose(): void;
  12836. }
  12837. }
  12838. declare module BABYLON {
  12839. /**
  12840. * The HemisphericLight simulates the ambient environment light,
  12841. * so the passed direction is the light reflection direction, not the incoming direction.
  12842. */
  12843. export class HemisphericLight extends Light {
  12844. /**
  12845. * The groundColor is the light in the opposite direction to the one specified during creation.
  12846. * 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.
  12847. */
  12848. groundColor: Color3;
  12849. /**
  12850. * The light reflection direction, not the incoming direction.
  12851. */
  12852. direction: Vector3;
  12853. /**
  12854. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12855. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12856. * The HemisphericLight can't cast shadows.
  12857. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12858. * @param name The friendly name of the light
  12859. * @param direction The direction of the light reflection
  12860. * @param scene The scene the light belongs to
  12861. */
  12862. constructor(name: string, direction: Vector3, scene: Scene);
  12863. protected _buildUniformLayout(): void;
  12864. /**
  12865. * Returns the string "HemisphericLight".
  12866. * @return The class name
  12867. */
  12868. getClassName(): string;
  12869. /**
  12870. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12871. * Returns the updated direction.
  12872. * @param target The target the direction should point to
  12873. * @return The computed direction
  12874. */
  12875. setDirectionToTarget(target: Vector3): Vector3;
  12876. /**
  12877. * Returns the shadow generator associated to the light.
  12878. * @returns Always null for hemispheric lights because it does not support shadows.
  12879. */
  12880. getShadowGenerator(): Nullable<IShadowGenerator>;
  12881. /**
  12882. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12883. * @param effect The effect to update
  12884. * @param lightIndex The index of the light in the effect to update
  12885. * @returns The hemispheric light
  12886. */
  12887. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12888. /**
  12889. * Computes the world matrix of the node
  12890. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12891. * @param useWasUpdatedFlag defines a reserved property
  12892. * @returns the world matrix
  12893. */
  12894. computeWorldMatrix(): Matrix;
  12895. /**
  12896. * Returns the integer 3.
  12897. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12898. */
  12899. getTypeID(): number;
  12900. /**
  12901. * Prepares the list of defines specific to the light type.
  12902. * @param defines the list of defines
  12903. * @param lightIndex defines the index of the light for the effect
  12904. */
  12905. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12906. }
  12907. }
  12908. declare module BABYLON {
  12909. /** @hidden */
  12910. export var vrMultiviewToSingleviewPixelShader: {
  12911. name: string;
  12912. shader: string;
  12913. };
  12914. }
  12915. declare module BABYLON {
  12916. /**
  12917. * Renders to multiple views with a single draw call
  12918. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12919. */
  12920. export class MultiviewRenderTarget extends RenderTargetTexture {
  12921. /**
  12922. * Creates a multiview render target
  12923. * @param scene scene used with the render target
  12924. * @param size the size of the render target (used for each view)
  12925. */
  12926. constructor(scene: Scene, size?: number | {
  12927. width: number;
  12928. height: number;
  12929. } | {
  12930. ratio: number;
  12931. });
  12932. /**
  12933. * @hidden
  12934. * @param faceIndex the face index, if its a cube texture
  12935. */ bindFrameBuffer(faceIndex?: number): void;
  12936. /**
  12937. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12938. * @returns the view count
  12939. */
  12940. getViewCount(): number;
  12941. }
  12942. }
  12943. declare module BABYLON {
  12944. interface Engine {
  12945. /**
  12946. * Creates a new multiview render target
  12947. * @param width defines the width of the texture
  12948. * @param height defines the height of the texture
  12949. * @returns the created multiview texture
  12950. */
  12951. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12952. /**
  12953. * Binds a multiview framebuffer to be drawn to
  12954. * @param multiviewTexture texture to bind
  12955. */
  12956. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12957. }
  12958. interface Camera {
  12959. /**
  12960. * @hidden
  12961. * 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)
  12962. */ useMultiviewToSingleView: boolean;
  12963. /**
  12964. * @hidden
  12965. * 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)
  12966. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12967. /**
  12968. * @hidden
  12969. * ensures the multiview texture of the camera exists and has the specified width/height
  12970. * @param width height to set on the multiview texture
  12971. * @param height width to set on the multiview texture
  12972. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12973. }
  12974. interface Scene {
  12975. /** @hidden */ transformMatrixR: Matrix;
  12976. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12977. /** @hidden */ createMultiviewUbo(): void;
  12978. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12979. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12980. }
  12981. }
  12982. declare module BABYLON {
  12983. /**
  12984. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12985. * This will not be used for webXR as it supports displaying texture arrays directly
  12986. */
  12987. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12988. /**
  12989. * Initializes a VRMultiviewToSingleview
  12990. * @param name name of the post process
  12991. * @param camera camera to be applied to
  12992. * @param scaleFactor scaling factor to the size of the output texture
  12993. */
  12994. constructor(name: string, camera: Camera, scaleFactor: number);
  12995. }
  12996. }
  12997. declare module BABYLON {
  12998. /**
  12999. * Defines the interface used by display changed events
  13000. */
  13001. interface IDisplayChangedEventArgs {
  13002. /** Gets the vrDisplay object (if any) */
  13003. vrDisplay: Nullable<any>;
  13004. /** Gets a boolean indicating if webVR is supported */
  13005. vrSupported: boolean;
  13006. }
  13007. interface Engine {
  13008. /** @hidden */ vrDisplay: any;
  13009. /** @hidden */ vrSupported: boolean;
  13010. /** @hidden */ oldSize: Size;
  13011. /** @hidden */ oldHardwareScaleFactor: number;
  13012. /** @hidden */ vrExclusivePointerMode: boolean;
  13013. /** @hidden */ webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13014. /** @hidden */ onVRDisplayPointerRestricted: () => void;
  13015. /** @hidden */ onVRDisplayPointerUnrestricted: () => void;
  13016. /** @hidden */ onVrDisplayConnect: Nullable<(display: any) => void>;
  13017. /** @hidden */ onVrDisplayDisconnect: Nullable<() => void>;
  13018. /** @hidden */ onVrDisplayPresentChange: Nullable<() => void>;
  13019. /**
  13020. * Observable signaled when VR display mode changes
  13021. */
  13022. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13023. /**
  13024. * Observable signaled when VR request present is complete
  13025. */
  13026. onVRRequestPresentComplete: Observable<boolean>;
  13027. /**
  13028. * Observable signaled when VR request present starts
  13029. */
  13030. onVRRequestPresentStart: Observable<Engine>;
  13031. /**
  13032. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13033. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13034. */
  13035. isInVRExclusivePointerMode: boolean;
  13036. /**
  13037. * Gets a boolean indicating if a webVR device was detected
  13038. * @returns true if a webVR device was detected
  13039. */
  13040. isVRDevicePresent(): boolean;
  13041. /**
  13042. * Gets the current webVR device
  13043. * @returns the current webVR device (or null)
  13044. */
  13045. getVRDevice(): any;
  13046. /**
  13047. * Initializes a webVR display and starts listening to display change events
  13048. * The onVRDisplayChangedObservable will be notified upon these changes
  13049. * @returns A promise containing a VRDisplay and if vr is supported
  13050. */
  13051. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13052. /** @hidden */ getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13053. /**
  13054. * Call this function to switch to webVR mode
  13055. * Will do nothing if webVR is not supported or if there is no webVR device
  13056. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13057. */
  13058. enableVR(): void;
  13059. /** @hidden */ onVRFullScreenTriggered(): void;
  13060. }
  13061. }
  13062. declare module BABYLON {
  13063. /**
  13064. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13065. * IMPORTANT!! The data is right-hand data.
  13066. * @export
  13067. * @interface DevicePose
  13068. */
  13069. export interface DevicePose {
  13070. /**
  13071. * The position of the device, values in array are [x,y,z].
  13072. */
  13073. readonly position: Nullable<Float32Array>;
  13074. /**
  13075. * The linearVelocity of the device, values in array are [x,y,z].
  13076. */
  13077. readonly linearVelocity: Nullable<Float32Array>;
  13078. /**
  13079. * The linearAcceleration of the device, values in array are [x,y,z].
  13080. */
  13081. readonly linearAcceleration: Nullable<Float32Array>;
  13082. /**
  13083. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13084. */
  13085. readonly orientation: Nullable<Float32Array>;
  13086. /**
  13087. * The angularVelocity of the device, values in array are [x,y,z].
  13088. */
  13089. readonly angularVelocity: Nullable<Float32Array>;
  13090. /**
  13091. * The angularAcceleration of the device, values in array are [x,y,z].
  13092. */
  13093. readonly angularAcceleration: Nullable<Float32Array>;
  13094. }
  13095. /**
  13096. * Interface representing a pose controlled object in Babylon.
  13097. * A pose controlled object has both regular pose values as well as pose values
  13098. * from an external device such as a VR head mounted display
  13099. */
  13100. export interface PoseControlled {
  13101. /**
  13102. * The position of the object in babylon space.
  13103. */
  13104. position: Vector3;
  13105. /**
  13106. * The rotation quaternion of the object in babylon space.
  13107. */
  13108. rotationQuaternion: Quaternion;
  13109. /**
  13110. * The position of the device in babylon space.
  13111. */
  13112. devicePosition?: Vector3;
  13113. /**
  13114. * The rotation quaternion of the device in babylon space.
  13115. */
  13116. deviceRotationQuaternion: Quaternion;
  13117. /**
  13118. * The raw pose coming from the device.
  13119. */
  13120. rawPose: Nullable<DevicePose>;
  13121. /**
  13122. * The scale of the device to be used when translating from device space to babylon space.
  13123. */
  13124. deviceScaleFactor: number;
  13125. /**
  13126. * Updates the poseControlled values based on the input device pose.
  13127. * @param poseData the pose data to update the object with
  13128. */
  13129. updateFromDevice(poseData: DevicePose): void;
  13130. }
  13131. /**
  13132. * Set of options to customize the webVRCamera
  13133. */
  13134. export interface WebVROptions {
  13135. /**
  13136. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13137. */
  13138. trackPosition?: boolean;
  13139. /**
  13140. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13141. */
  13142. positionScale?: number;
  13143. /**
  13144. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13145. */
  13146. displayName?: string;
  13147. /**
  13148. * Should the native controller meshes be initialized. (default: true)
  13149. */
  13150. controllerMeshes?: boolean;
  13151. /**
  13152. * Creating a default HemiLight only on controllers. (default: true)
  13153. */
  13154. defaultLightingOnControllers?: boolean;
  13155. /**
  13156. * If you don't want to use the default VR button of the helper. (default: false)
  13157. */
  13158. useCustomVRButton?: boolean;
  13159. /**
  13160. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13161. */
  13162. customVRButton?: HTMLButtonElement;
  13163. /**
  13164. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13165. */
  13166. rayLength?: number;
  13167. /**
  13168. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13169. */
  13170. defaultHeight?: number;
  13171. /**
  13172. * If multiview should be used if availible (default: false)
  13173. */
  13174. useMultiview?: boolean;
  13175. }
  13176. /**
  13177. * This represents a WebVR camera.
  13178. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13179. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13180. */
  13181. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13182. private webVROptions;
  13183. /**
  13184. * @hidden
  13185. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13186. */ vrDevice: any;
  13187. /**
  13188. * The rawPose of the vrDevice.
  13189. */
  13190. rawPose: Nullable<DevicePose>;
  13191. private _onVREnabled;
  13192. private _specsVersion;
  13193. private _attached;
  13194. private _frameData;
  13195. protected _descendants: Array<Node>;
  13196. private _deviceRoomPosition;
  13197. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  13198. private _standingMatrix;
  13199. /**
  13200. * Represents device position in babylon space.
  13201. */
  13202. devicePosition: Vector3;
  13203. /**
  13204. * Represents device rotation in babylon space.
  13205. */
  13206. deviceRotationQuaternion: Quaternion;
  13207. /**
  13208. * The scale of the device to be used when translating from device space to babylon space.
  13209. */
  13210. deviceScaleFactor: number;
  13211. private _deviceToWorld;
  13212. private _worldToDevice;
  13213. /**
  13214. * References to the webVR controllers for the vrDevice.
  13215. */
  13216. controllers: Array<WebVRController>;
  13217. /**
  13218. * Emits an event when a controller is attached.
  13219. */
  13220. onControllersAttachedObservable: Observable<WebVRController[]>;
  13221. /**
  13222. * Emits an event when a controller's mesh has been loaded;
  13223. */
  13224. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13225. /**
  13226. * Emits an event when the HMD's pose has been updated.
  13227. */
  13228. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13229. private _poseSet;
  13230. /**
  13231. * If the rig cameras be used as parent instead of this camera.
  13232. */
  13233. rigParenting: boolean;
  13234. private _lightOnControllers;
  13235. private _defaultHeight?;
  13236. /**
  13237. * Instantiates a WebVRFreeCamera.
  13238. * @param name The name of the WebVRFreeCamera
  13239. * @param position The starting anchor position for the camera
  13240. * @param scene The scene the camera belongs to
  13241. * @param webVROptions a set of customizable options for the webVRCamera
  13242. */
  13243. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13244. /**
  13245. * Gets the device distance from the ground in meters.
  13246. * @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.
  13247. */
  13248. deviceDistanceToRoomGround(): number;
  13249. /**
  13250. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13251. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13252. */
  13253. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13254. /**
  13255. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13256. * @returns A promise with a boolean set to if the standing matrix is supported.
  13257. */
  13258. useStandingMatrixAsync(): Promise<boolean>;
  13259. /**
  13260. * Disposes the camera
  13261. */
  13262. dispose(): void;
  13263. /**
  13264. * Gets a vrController by name.
  13265. * @param name The name of the controller to retreive
  13266. * @returns the controller matching the name specified or null if not found
  13267. */
  13268. getControllerByName(name: string): Nullable<WebVRController>;
  13269. private _leftController;
  13270. /**
  13271. * The controller corrisponding to the users left hand.
  13272. */
  13273. readonly leftController: Nullable<WebVRController>;
  13274. private _rightController;
  13275. /**
  13276. * The controller corrisponding to the users right hand.
  13277. */
  13278. readonly rightController: Nullable<WebVRController>;
  13279. /**
  13280. * Casts a ray forward from the vrCamera's gaze.
  13281. * @param length Length of the ray (default: 100)
  13282. * @returns the ray corrisponding to the gaze
  13283. */
  13284. getForwardRay(length?: number): Ray;
  13285. /**
  13286. * @hidden
  13287. * Updates the camera based on device's frame data
  13288. */ checkInputs(): void;
  13289. /**
  13290. * Updates the poseControlled values based on the input device pose.
  13291. * @param poseData Pose coming from the device
  13292. */
  13293. updateFromDevice(poseData: DevicePose): void;
  13294. private _htmlElementAttached;
  13295. private _detachIfAttached;
  13296. /**
  13297. * WebVR's attach control will start broadcasting frames to the device.
  13298. * Note that in certain browsers (chrome for example) this function must be called
  13299. * within a user-interaction callback. Example:
  13300. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13301. *
  13302. * @param element html element to attach the vrDevice to
  13303. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13304. */
  13305. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13306. /**
  13307. * Detaches the camera from the html element and disables VR
  13308. *
  13309. * @param element html element to detach from
  13310. */
  13311. detachControl(element: HTMLElement): void;
  13312. /**
  13313. * @returns the name of this class
  13314. */
  13315. getClassName(): string;
  13316. /**
  13317. * Calls resetPose on the vrDisplay
  13318. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13319. */
  13320. resetToCurrentRotation(): void;
  13321. /**
  13322. * @hidden
  13323. * Updates the rig cameras (left and right eye)
  13324. */ updateRigCameras(): void;
  13325. private _workingVector;
  13326. private _oneVector;
  13327. private _workingMatrix;
  13328. private updateCacheCalled;
  13329. private _correctPositionIfNotTrackPosition;
  13330. /**
  13331. * @hidden
  13332. * Updates the cached values of the camera
  13333. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13334. */ updateCache(ignoreParentClass?: boolean): void;
  13335. /**
  13336. * @hidden
  13337. * Get current device position in babylon world
  13338. */ computeDevicePosition(): void;
  13339. /**
  13340. * Updates the current device position and rotation in the babylon world
  13341. */
  13342. update(): void;
  13343. /**
  13344. * @hidden
  13345. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13346. * @returns an identity matrix
  13347. */ getViewMatrix(): Matrix;
  13348. private _tmpMatrix;
  13349. /**
  13350. * This function is called by the two RIG cameras.
  13351. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13352. * @hidden
  13353. */ getWebVRViewMatrix(): Matrix;
  13354. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13355. private _onGamepadConnectedObserver;
  13356. private _onGamepadDisconnectedObserver;
  13357. private _updateCacheWhenTrackingDisabledObserver;
  13358. /**
  13359. * Initializes the controllers and their meshes
  13360. */
  13361. initControllers(): void;
  13362. }
  13363. }
  13364. declare module BABYLON {
  13365. /**
  13366. * Size options for a post process
  13367. */
  13368. export type PostProcessOptions = {
  13369. width: number;
  13370. height: number;
  13371. };
  13372. /**
  13373. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13374. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13375. */
  13376. export class PostProcess {
  13377. /** Name of the PostProcess. */
  13378. name: string;
  13379. /**
  13380. * Gets or sets the unique id of the post process
  13381. */
  13382. uniqueId: number;
  13383. /**
  13384. * Width of the texture to apply the post process on
  13385. */
  13386. width: number;
  13387. /**
  13388. * Height of the texture to apply the post process on
  13389. */
  13390. height: number;
  13391. /**
  13392. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13393. * @hidden
  13394. */ outputTexture: Nullable<InternalTexture>;
  13395. /**
  13396. * Sampling mode used by the shader
  13397. * See https://doc.babylonjs.com/classes/3.1/texture
  13398. */
  13399. renderTargetSamplingMode: number;
  13400. /**
  13401. * Clear color to use when screen clearing
  13402. */
  13403. clearColor: Color4;
  13404. /**
  13405. * If the buffer needs to be cleared before applying the post process. (default: true)
  13406. * Should be set to false if shader will overwrite all previous pixels.
  13407. */
  13408. autoClear: boolean;
  13409. /**
  13410. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13411. */
  13412. alphaMode: number;
  13413. /**
  13414. * Sets the setAlphaBlendConstants of the babylon engine
  13415. */
  13416. alphaConstants: Color4;
  13417. /**
  13418. * Animations to be used for the post processing
  13419. */
  13420. animations: Animation[];
  13421. /**
  13422. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13423. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13424. */
  13425. enablePixelPerfectMode: boolean;
  13426. /**
  13427. * Force the postprocess to be applied without taking in account viewport
  13428. */
  13429. forceFullscreenViewport: boolean;
  13430. /**
  13431. * List of inspectable custom properties (used by the Inspector)
  13432. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13433. */
  13434. inspectableCustomProperties: IInspectable[];
  13435. /**
  13436. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13437. *
  13438. * | Value | Type | Description |
  13439. * | ----- | ----------------------------------- | ----------- |
  13440. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13441. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13442. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13443. *
  13444. */
  13445. scaleMode: number;
  13446. /**
  13447. * Force textures to be a power of two (default: false)
  13448. */
  13449. alwaysForcePOT: boolean;
  13450. private _samples;
  13451. /**
  13452. * Number of sample textures (default: 1)
  13453. */
  13454. samples: number;
  13455. /**
  13456. * Modify the scale of the post process to be the same as the viewport (default: false)
  13457. */
  13458. adaptScaleToCurrentViewport: boolean;
  13459. private _camera;
  13460. private _scene;
  13461. private _engine;
  13462. private _options;
  13463. private _reusable;
  13464. private _textureType;
  13465. /**
  13466. * Smart array of input and output textures for the post process.
  13467. * @hidden
  13468. */ textures: SmartArray<InternalTexture>;
  13469. /**
  13470. * The index in _textures that corresponds to the output texture.
  13471. * @hidden
  13472. */ currentRenderTextureInd: number;
  13473. private _effect;
  13474. private _samplers;
  13475. private _fragmentUrl;
  13476. private _vertexUrl;
  13477. private _parameters;
  13478. private _scaleRatio;
  13479. protected _indexParameters: any;
  13480. private _shareOutputWithPostProcess;
  13481. private _texelSize;
  13482. private _forcedOutputTexture;
  13483. /**
  13484. * Returns the fragment url or shader name used in the post process.
  13485. * @returns the fragment url or name in the shader store.
  13486. */
  13487. getEffectName(): string;
  13488. /**
  13489. * An event triggered when the postprocess is activated.
  13490. */
  13491. onActivateObservable: Observable<Camera>;
  13492. private _onActivateObserver;
  13493. /**
  13494. * A function that is added to the onActivateObservable
  13495. */
  13496. onActivate: Nullable<(camera: Camera) => void>;
  13497. /**
  13498. * An event triggered when the postprocess changes its size.
  13499. */
  13500. onSizeChangedObservable: Observable<PostProcess>;
  13501. private _onSizeChangedObserver;
  13502. /**
  13503. * A function that is added to the onSizeChangedObservable
  13504. */
  13505. onSizeChanged: (postProcess: PostProcess) => void;
  13506. /**
  13507. * An event triggered when the postprocess applies its effect.
  13508. */
  13509. onApplyObservable: Observable<Effect>;
  13510. private _onApplyObserver;
  13511. /**
  13512. * A function that is added to the onApplyObservable
  13513. */
  13514. onApply: (effect: Effect) => void;
  13515. /**
  13516. * An event triggered before rendering the postprocess
  13517. */
  13518. onBeforeRenderObservable: Observable<Effect>;
  13519. private _onBeforeRenderObserver;
  13520. /**
  13521. * A function that is added to the onBeforeRenderObservable
  13522. */
  13523. onBeforeRender: (effect: Effect) => void;
  13524. /**
  13525. * An event triggered after rendering the postprocess
  13526. */
  13527. onAfterRenderObservable: Observable<Effect>;
  13528. private _onAfterRenderObserver;
  13529. /**
  13530. * A function that is added to the onAfterRenderObservable
  13531. */
  13532. onAfterRender: (efect: Effect) => void;
  13533. /**
  13534. * 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
  13535. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13536. */
  13537. inputTexture: InternalTexture;
  13538. /**
  13539. * Gets the camera which post process is applied to.
  13540. * @returns The camera the post process is applied to.
  13541. */
  13542. getCamera(): Camera;
  13543. /**
  13544. * Gets the texel size of the postprocess.
  13545. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13546. */
  13547. readonly texelSize: Vector2;
  13548. /**
  13549. * Creates a new instance PostProcess
  13550. * @param name The name of the PostProcess.
  13551. * @param fragmentUrl The url of the fragment shader to be used.
  13552. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13553. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13554. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13555. * @param camera The camera to apply the render pass to.
  13556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13557. * @param engine The engine which the post process will be applied. (default: current engine)
  13558. * @param reusable If the post process can be reused on the same frame. (default: false)
  13559. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13560. * @param textureType Type of textures used when performing the post process. (default: 0)
  13561. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13562. * @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
  13563. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13564. */
  13565. constructor(
  13566. /** Name of the PostProcess. */
  13567. 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);
  13568. /**
  13569. * Gets a string idenfifying the name of the class
  13570. * @returns "PostProcess" string
  13571. */
  13572. getClassName(): string;
  13573. /**
  13574. * Gets the engine which this post process belongs to.
  13575. * @returns The engine the post process was enabled with.
  13576. */
  13577. getEngine(): Engine;
  13578. /**
  13579. * The effect that is created when initializing the post process.
  13580. * @returns The created effect corrisponding the the postprocess.
  13581. */
  13582. getEffect(): Effect;
  13583. /**
  13584. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13585. * @param postProcess The post process to share the output with.
  13586. * @returns This post process.
  13587. */
  13588. shareOutputWith(postProcess: PostProcess): PostProcess;
  13589. /**
  13590. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13591. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13592. */
  13593. useOwnOutput(): void;
  13594. /**
  13595. * Updates the effect with the current post process compile time values and recompiles the shader.
  13596. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13597. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13598. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13599. * @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
  13600. * @param onCompiled Called when the shader has been compiled.
  13601. * @param onError Called if there is an error when compiling a shader.
  13602. */
  13603. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13604. /**
  13605. * The post process is reusable if it can be used multiple times within one frame.
  13606. * @returns If the post process is reusable
  13607. */
  13608. isReusable(): boolean;
  13609. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13610. markTextureDirty(): void;
  13611. /**
  13612. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13613. * 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.
  13614. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13615. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13616. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13617. * @returns The target texture that was bound to be written to.
  13618. */
  13619. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13620. /**
  13621. * If the post process is supported.
  13622. */
  13623. readonly isSupported: boolean;
  13624. /**
  13625. * The aspect ratio of the output texture.
  13626. */
  13627. readonly aspectRatio: number;
  13628. /**
  13629. * Get a value indicating if the post-process is ready to be used
  13630. * @returns true if the post-process is ready (shader is compiled)
  13631. */
  13632. isReady(): boolean;
  13633. /**
  13634. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13635. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13636. */
  13637. apply(): Nullable<Effect>;
  13638. private _disposeTextures;
  13639. /**
  13640. * Disposes the post process.
  13641. * @param camera The camera to dispose the post process on.
  13642. */
  13643. dispose(camera?: Camera): void;
  13644. }
  13645. }
  13646. declare module BABYLON {
  13647. /**
  13648. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13649. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13650. */
  13651. export class PostProcessManager {
  13652. private _scene;
  13653. private _indexBuffer;
  13654. private _vertexBuffers;
  13655. /**
  13656. * Creates a new instance PostProcess
  13657. * @param scene The scene that the post process is associated with.
  13658. */
  13659. constructor(scene: Scene);
  13660. private _prepareBuffers;
  13661. private _buildIndexBuffer;
  13662. /**
  13663. * Rebuilds the vertex buffers of the manager.
  13664. * @hidden
  13665. */ rebuild(): void;
  13666. /**
  13667. * Prepares a frame to be run through a post process.
  13668. * @param sourceTexture The input texture to the post procesess. (default: null)
  13669. * @param postProcesses An array of post processes to be run. (default: null)
  13670. * @returns True if the post processes were able to be run.
  13671. * @hidden
  13672. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13673. /**
  13674. * Manually render a set of post processes to a texture.
  13675. * @param postProcesses An array of post processes to be run.
  13676. * @param targetTexture The target texture to render to.
  13677. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13678. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13679. * @param lodLevel defines which lod of the texture to render to
  13680. */
  13681. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13682. /**
  13683. * Finalize the result of the output of the postprocesses.
  13684. * @param doNotPresent If true the result will not be displayed to the screen.
  13685. * @param targetTexture The target texture to render to.
  13686. * @param faceIndex The index of the face to bind the target texture to.
  13687. * @param postProcesses The array of post processes to render.
  13688. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13689. * @hidden
  13690. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13691. /**
  13692. * Disposes of the post process manager.
  13693. */
  13694. dispose(): void;
  13695. }
  13696. }
  13697. declare module BABYLON {
  13698. interface AbstractScene {
  13699. /**
  13700. * The list of layers (background and foreground) of the scene
  13701. */
  13702. layers: Array<Layer>;
  13703. }
  13704. /**
  13705. * Defines the layer scene component responsible to manage any layers
  13706. * in a given scene.
  13707. */
  13708. export class LayerSceneComponent implements ISceneComponent {
  13709. /**
  13710. * The component name helpfull to identify the component in the list of scene components.
  13711. */
  13712. readonly name: string;
  13713. /**
  13714. * The scene the component belongs to.
  13715. */
  13716. scene: Scene;
  13717. private _engine;
  13718. /**
  13719. * Creates a new instance of the component for the given scene
  13720. * @param scene Defines the scene to register the component in
  13721. */
  13722. constructor(scene: Scene);
  13723. /**
  13724. * Registers the component in a given scene
  13725. */
  13726. register(): void;
  13727. /**
  13728. * Rebuilds the elements related to this component in case of
  13729. * context lost for instance.
  13730. */
  13731. rebuild(): void;
  13732. /**
  13733. * Disposes the component and the associated ressources.
  13734. */
  13735. dispose(): void;
  13736. private _draw;
  13737. private _drawCameraPredicate;
  13738. private _drawCameraBackground;
  13739. private _drawCameraForeground;
  13740. private _drawRenderTargetPredicate;
  13741. private _drawRenderTargetBackground;
  13742. private _drawRenderTargetForeground;
  13743. }
  13744. }
  13745. declare module BABYLON {
  13746. /** @hidden */
  13747. export var layerPixelShader: {
  13748. name: string;
  13749. shader: string;
  13750. };
  13751. }
  13752. declare module BABYLON {
  13753. /** @hidden */
  13754. export var layerVertexShader: {
  13755. name: string;
  13756. shader: string;
  13757. };
  13758. }
  13759. declare module BABYLON {
  13760. /**
  13761. * This represents a full screen 2d layer.
  13762. * This can be useful to display a picture in the background of your scene for instance.
  13763. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13764. */
  13765. export class Layer {
  13766. /**
  13767. * Define the name of the layer.
  13768. */
  13769. name: string;
  13770. /**
  13771. * Define the texture the layer should display.
  13772. */
  13773. texture: Nullable<Texture>;
  13774. /**
  13775. * Is the layer in background or foreground.
  13776. */
  13777. isBackground: boolean;
  13778. /**
  13779. * Define the color of the layer (instead of texture).
  13780. */
  13781. color: Color4;
  13782. /**
  13783. * Define the scale of the layer in order to zoom in out of the texture.
  13784. */
  13785. scale: Vector2;
  13786. /**
  13787. * Define an offset for the layer in order to shift the texture.
  13788. */
  13789. offset: Vector2;
  13790. /**
  13791. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13792. */
  13793. alphaBlendingMode: number;
  13794. /**
  13795. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13796. * Alpha test will not mix with the background color in case of transparency.
  13797. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13798. */
  13799. alphaTest: boolean;
  13800. /**
  13801. * Define a mask to restrict the layer to only some of the scene cameras.
  13802. */
  13803. layerMask: number;
  13804. /**
  13805. * Define the list of render target the layer is visible into.
  13806. */
  13807. renderTargetTextures: RenderTargetTexture[];
  13808. /**
  13809. * Define if the layer is only used in renderTarget or if it also
  13810. * renders in the main frame buffer of the canvas.
  13811. */
  13812. renderOnlyInRenderTargetTextures: boolean;
  13813. private _scene;
  13814. private _vertexBuffers;
  13815. private _indexBuffer;
  13816. private _effect;
  13817. private _alphaTestEffect;
  13818. /**
  13819. * An event triggered when the layer is disposed.
  13820. */
  13821. onDisposeObservable: Observable<Layer>;
  13822. private _onDisposeObserver;
  13823. /**
  13824. * Back compatibility with callback before the onDisposeObservable existed.
  13825. * The set callback will be triggered when the layer has been disposed.
  13826. */
  13827. onDispose: () => void;
  13828. /**
  13829. * An event triggered before rendering the scene
  13830. */
  13831. onBeforeRenderObservable: Observable<Layer>;
  13832. private _onBeforeRenderObserver;
  13833. /**
  13834. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13835. * The set callback will be triggered just before rendering the layer.
  13836. */
  13837. onBeforeRender: () => void;
  13838. /**
  13839. * An event triggered after rendering the scene
  13840. */
  13841. onAfterRenderObservable: Observable<Layer>;
  13842. private _onAfterRenderObserver;
  13843. /**
  13844. * Back compatibility with callback before the onAfterRenderObservable existed.
  13845. * The set callback will be triggered just after rendering the layer.
  13846. */
  13847. onAfterRender: () => void;
  13848. /**
  13849. * Instantiates a new layer.
  13850. * This represents a full screen 2d layer.
  13851. * This can be useful to display a picture in the background of your scene for instance.
  13852. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13853. * @param name Define the name of the layer in the scene
  13854. * @param imgUrl Define the url of the texture to display in the layer
  13855. * @param scene Define the scene the layer belongs to
  13856. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13857. * @param color Defines a color for the layer
  13858. */
  13859. constructor(
  13860. /**
  13861. * Define the name of the layer.
  13862. */
  13863. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13864. private _createIndexBuffer;
  13865. /** @hidden */ rebuild(): void;
  13866. /**
  13867. * Renders the layer in the scene.
  13868. */
  13869. render(): void;
  13870. /**
  13871. * Disposes and releases the associated ressources.
  13872. */
  13873. dispose(): void;
  13874. }
  13875. }
  13876. declare module BABYLON {
  13877. interface AbstractScene {
  13878. /**
  13879. * The list of procedural textures added to the scene
  13880. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13881. */
  13882. proceduralTextures: Array<ProceduralTexture>;
  13883. }
  13884. /**
  13885. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13886. * in a given scene.
  13887. */
  13888. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13889. /**
  13890. * The component name helpfull to identify the component in the list of scene components.
  13891. */
  13892. readonly name: string;
  13893. /**
  13894. * The scene the component belongs to.
  13895. */
  13896. scene: Scene;
  13897. /**
  13898. * Creates a new instance of the component for the given scene
  13899. * @param scene Defines the scene to register the component in
  13900. */
  13901. constructor(scene: Scene);
  13902. /**
  13903. * Registers the component in a given scene
  13904. */
  13905. register(): void;
  13906. /**
  13907. * Rebuilds the elements related to this component in case of
  13908. * context lost for instance.
  13909. */
  13910. rebuild(): void;
  13911. /**
  13912. * Disposes the component and the associated ressources.
  13913. */
  13914. dispose(): void;
  13915. private _beforeClear;
  13916. }
  13917. }
  13918. declare module BABYLON {
  13919. interface Engine {
  13920. /**
  13921. * Creates a new render target cube texture
  13922. * @param size defines the size of the texture
  13923. * @param options defines the options used to create the texture
  13924. * @returns a new render target cube texture stored in an InternalTexture
  13925. */
  13926. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13927. }
  13928. }
  13929. declare module BABYLON {
  13930. /** @hidden */
  13931. export var proceduralVertexShader: {
  13932. name: string;
  13933. shader: string;
  13934. };
  13935. }
  13936. declare module BABYLON {
  13937. /**
  13938. * 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.
  13939. * This is the base class of any Procedural texture and contains most of the shareable code.
  13940. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13941. */
  13942. export class ProceduralTexture extends Texture {
  13943. isCube: boolean;
  13944. /**
  13945. * Define if the texture is enabled or not (disabled texture will not render)
  13946. */
  13947. isEnabled: boolean;
  13948. /**
  13949. * Define if the texture must be cleared before rendering (default is true)
  13950. */
  13951. autoClear: boolean;
  13952. /**
  13953. * Callback called when the texture is generated
  13954. */
  13955. onGenerated: () => void;
  13956. /**
  13957. * Event raised when the texture is generated
  13958. */
  13959. onGeneratedObservable: Observable<ProceduralTexture>;
  13960. /** @hidden */ generateMipMaps: boolean;
  13961. /** @hidden **/ effect: Effect;
  13962. /** @hidden */ textures: {
  13963. [key: string]: Texture;
  13964. };
  13965. private _size;
  13966. private _currentRefreshId;
  13967. private _refreshRate;
  13968. private _vertexBuffers;
  13969. private _indexBuffer;
  13970. private _uniforms;
  13971. private _samplers;
  13972. private _fragment;
  13973. private _floats;
  13974. private _ints;
  13975. private _floatsArrays;
  13976. private _colors3;
  13977. private _colors4;
  13978. private _vectors2;
  13979. private _vectors3;
  13980. private _matrices;
  13981. private _fallbackTexture;
  13982. private _fallbackTextureUsed;
  13983. private _engine;
  13984. private _cachedDefines;
  13985. private _contentUpdateId;
  13986. private _contentData;
  13987. /**
  13988. * Instantiates a new procedural texture.
  13989. * 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.
  13990. * This is the base class of any Procedural texture and contains most of the shareable code.
  13991. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13992. * @param name Define the name of the texture
  13993. * @param size Define the size of the texture to create
  13994. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13995. * @param scene Define the scene the texture belongs to
  13996. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13997. * @param generateMipMaps Define if the texture should creates mip maps or not
  13998. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13999. */
  14000. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14001. /**
  14002. * The effect that is created when initializing the post process.
  14003. * @returns The created effect corrisponding the the postprocess.
  14004. */
  14005. getEffect(): Effect;
  14006. /**
  14007. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14008. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14009. */
  14010. getContent(): Nullable<ArrayBufferView>;
  14011. private _createIndexBuffer;
  14012. /** @hidden */ rebuild(): void;
  14013. /**
  14014. * Resets the texture in order to recreate its associated resources.
  14015. * This can be called in case of context loss
  14016. */
  14017. reset(): void;
  14018. protected _getDefines(): string;
  14019. /**
  14020. * Is the texture ready to be used ? (rendered at least once)
  14021. * @returns true if ready, otherwise, false.
  14022. */
  14023. isReady(): boolean;
  14024. /**
  14025. * Resets the refresh counter of the texture and start bak from scratch.
  14026. * Could be useful to regenerate the texture if it is setup to render only once.
  14027. */
  14028. resetRefreshCounter(): void;
  14029. /**
  14030. * Set the fragment shader to use in order to render the texture.
  14031. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14032. */
  14033. setFragment(fragment: any): void;
  14034. /**
  14035. * Define the refresh rate of the texture or the rendering frequency.
  14036. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14037. */
  14038. refreshRate: number;
  14039. /** @hidden */ shouldRender(): boolean;
  14040. /**
  14041. * Get the size the texture is rendering at.
  14042. * @returns the size (texture is always squared)
  14043. */
  14044. getRenderSize(): number;
  14045. /**
  14046. * Resize the texture to new value.
  14047. * @param size Define the new size the texture should have
  14048. * @param generateMipMaps Define whether the new texture should create mip maps
  14049. */
  14050. resize(size: number, generateMipMaps: boolean): void;
  14051. private _checkUniform;
  14052. /**
  14053. * Set a texture in the shader program used to render.
  14054. * @param name Define the name of the uniform samplers as defined in the shader
  14055. * @param texture Define the texture to bind to this sampler
  14056. * @return the texture itself allowing "fluent" like uniform updates
  14057. */
  14058. setTexture(name: string, texture: Texture): ProceduralTexture;
  14059. /**
  14060. * Set a float in the shader.
  14061. * @param name Define the name of the uniform as defined in the shader
  14062. * @param value Define the value to give to the uniform
  14063. * @return the texture itself allowing "fluent" like uniform updates
  14064. */
  14065. setFloat(name: string, value: number): ProceduralTexture;
  14066. /**
  14067. * Set a int in the shader.
  14068. * @param name Define the name of the uniform as defined in the shader
  14069. * @param value Define the value to give to the uniform
  14070. * @return the texture itself allowing "fluent" like uniform updates
  14071. */
  14072. setInt(name: string, value: number): ProceduralTexture;
  14073. /**
  14074. * Set an array of floats in the shader.
  14075. * @param name Define the name of the uniform as defined in the shader
  14076. * @param value Define the value to give to the uniform
  14077. * @return the texture itself allowing "fluent" like uniform updates
  14078. */
  14079. setFloats(name: string, value: number[]): ProceduralTexture;
  14080. /**
  14081. * Set a vec3 in the shader from a Color3.
  14082. * @param name Define the name of the uniform as defined in the shader
  14083. * @param value Define the value to give to the uniform
  14084. * @return the texture itself allowing "fluent" like uniform updates
  14085. */
  14086. setColor3(name: string, value: Color3): ProceduralTexture;
  14087. /**
  14088. * Set a vec4 in the shader from a Color4.
  14089. * @param name Define the name of the uniform as defined in the shader
  14090. * @param value Define the value to give to the uniform
  14091. * @return the texture itself allowing "fluent" like uniform updates
  14092. */
  14093. setColor4(name: string, value: Color4): ProceduralTexture;
  14094. /**
  14095. * Set a vec2 in the shader from a Vector2.
  14096. * @param name Define the name of the uniform as defined in the shader
  14097. * @param value Define the value to give to the uniform
  14098. * @return the texture itself allowing "fluent" like uniform updates
  14099. */
  14100. setVector2(name: string, value: Vector2): ProceduralTexture;
  14101. /**
  14102. * Set a vec3 in the shader from a Vector3.
  14103. * @param name Define the name of the uniform as defined in the shader
  14104. * @param value Define the value to give to the uniform
  14105. * @return the texture itself allowing "fluent" like uniform updates
  14106. */
  14107. setVector3(name: string, value: Vector3): ProceduralTexture;
  14108. /**
  14109. * Set a mat4 in the shader from a MAtrix.
  14110. * @param name Define the name of the uniform as defined in the shader
  14111. * @param value Define the value to give to the uniform
  14112. * @return the texture itself allowing "fluent" like uniform updates
  14113. */
  14114. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14115. /**
  14116. * Render the texture to its associated render target.
  14117. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14118. */
  14119. render(useCameraPostProcess?: boolean): void;
  14120. /**
  14121. * Clone the texture.
  14122. * @returns the cloned texture
  14123. */
  14124. clone(): ProceduralTexture;
  14125. /**
  14126. * Dispose the texture and release its asoociated resources.
  14127. */
  14128. dispose(): void;
  14129. }
  14130. }
  14131. declare module BABYLON {
  14132. /**
  14133. * This represents the base class for particle system in Babylon.
  14134. * 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.
  14135. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14136. * @example https://doc.babylonjs.com/babylon101/particles
  14137. */
  14138. export class BaseParticleSystem {
  14139. /**
  14140. * Source color is added to the destination color without alpha affecting the result
  14141. */
  14142. static BLENDMODE_ONEONE: number;
  14143. /**
  14144. * Blend current color and particle color using particle’s alpha
  14145. */
  14146. static BLENDMODE_STANDARD: number;
  14147. /**
  14148. * Add current color and particle color multiplied by particle’s alpha
  14149. */
  14150. static BLENDMODE_ADD: number;
  14151. /**
  14152. * Multiply current color with particle color
  14153. */
  14154. static BLENDMODE_MULTIPLY: number;
  14155. /**
  14156. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14157. */
  14158. static BLENDMODE_MULTIPLYADD: number;
  14159. /**
  14160. * List of animations used by the particle system.
  14161. */
  14162. animations: Animation[];
  14163. /**
  14164. * The id of the Particle system.
  14165. */
  14166. id: string;
  14167. /**
  14168. * The friendly name of the Particle system.
  14169. */
  14170. name: string;
  14171. /**
  14172. * The rendering group used by the Particle system to chose when to render.
  14173. */
  14174. renderingGroupId: number;
  14175. /**
  14176. * The emitter represents the Mesh or position we are attaching the particle system to.
  14177. */
  14178. emitter: Nullable<AbstractMesh | Vector3>;
  14179. /**
  14180. * The maximum number of particles to emit per frame
  14181. */
  14182. emitRate: number;
  14183. /**
  14184. * If you want to launch only a few particles at once, that can be done, as well.
  14185. */
  14186. manualEmitCount: number;
  14187. /**
  14188. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14189. */
  14190. updateSpeed: number;
  14191. /**
  14192. * The amount of time the particle system is running (depends of the overall update speed).
  14193. */
  14194. targetStopDuration: number;
  14195. /**
  14196. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14197. */
  14198. disposeOnStop: boolean;
  14199. /**
  14200. * Minimum power of emitting particles.
  14201. */
  14202. minEmitPower: number;
  14203. /**
  14204. * Maximum power of emitting particles.
  14205. */
  14206. maxEmitPower: number;
  14207. /**
  14208. * Minimum life time of emitting particles.
  14209. */
  14210. minLifeTime: number;
  14211. /**
  14212. * Maximum life time of emitting particles.
  14213. */
  14214. maxLifeTime: number;
  14215. /**
  14216. * Minimum Size of emitting particles.
  14217. */
  14218. minSize: number;
  14219. /**
  14220. * Maximum Size of emitting particles.
  14221. */
  14222. maxSize: number;
  14223. /**
  14224. * Minimum scale of emitting particles on X axis.
  14225. */
  14226. minScaleX: number;
  14227. /**
  14228. * Maximum scale of emitting particles on X axis.
  14229. */
  14230. maxScaleX: number;
  14231. /**
  14232. * Minimum scale of emitting particles on Y axis.
  14233. */
  14234. minScaleY: number;
  14235. /**
  14236. * Maximum scale of emitting particles on Y axis.
  14237. */
  14238. maxScaleY: number;
  14239. /**
  14240. * Gets or sets the minimal initial rotation in radians.
  14241. */
  14242. minInitialRotation: number;
  14243. /**
  14244. * Gets or sets the maximal initial rotation in radians.
  14245. */
  14246. maxInitialRotation: number;
  14247. /**
  14248. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14249. */
  14250. minAngularSpeed: number;
  14251. /**
  14252. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14253. */
  14254. maxAngularSpeed: number;
  14255. /**
  14256. * The texture used to render each particle. (this can be a spritesheet)
  14257. */
  14258. particleTexture: Nullable<Texture>;
  14259. /**
  14260. * The layer mask we are rendering the particles through.
  14261. */
  14262. layerMask: number;
  14263. /**
  14264. * This can help using your own shader to render the particle system.
  14265. * The according effect will be created
  14266. */
  14267. customShader: any;
  14268. /**
  14269. * By default particle system starts as soon as they are created. This prevents the
  14270. * automatic start to happen and let you decide when to start emitting particles.
  14271. */
  14272. preventAutoStart: boolean;
  14273. private _noiseTexture;
  14274. /**
  14275. * Gets or sets a texture used to add random noise to particle positions
  14276. */
  14277. noiseTexture: Nullable<ProceduralTexture>;
  14278. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14279. noiseStrength: Vector3;
  14280. /**
  14281. * Callback triggered when the particle animation is ending.
  14282. */
  14283. onAnimationEnd: Nullable<() => void>;
  14284. /**
  14285. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14286. */
  14287. blendMode: number;
  14288. /**
  14289. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14290. * to override the particles.
  14291. */
  14292. forceDepthWrite: boolean;
  14293. /** 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 */
  14294. preWarmCycles: number;
  14295. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14296. preWarmStepOffset: number;
  14297. /**
  14298. * 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)
  14299. */
  14300. spriteCellChangeSpeed: number;
  14301. /**
  14302. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14303. */
  14304. startSpriteCellID: number;
  14305. /**
  14306. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14307. */
  14308. endSpriteCellID: number;
  14309. /**
  14310. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14311. */
  14312. spriteCellWidth: number;
  14313. /**
  14314. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14315. */
  14316. spriteCellHeight: number;
  14317. /**
  14318. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14319. */
  14320. spriteRandomStartCell: boolean;
  14321. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14322. translationPivot: Vector2;
  14323. /** @hidden */
  14324. protected _isAnimationSheetEnabled: boolean;
  14325. /**
  14326. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14327. */
  14328. beginAnimationOnStart: boolean;
  14329. /**
  14330. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14331. */
  14332. beginAnimationFrom: number;
  14333. /**
  14334. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14335. */
  14336. beginAnimationTo: number;
  14337. /**
  14338. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14339. */
  14340. beginAnimationLoop: boolean;
  14341. /**
  14342. * Gets or sets a world offset applied to all particles
  14343. */
  14344. worldOffset: Vector3;
  14345. /**
  14346. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14347. */
  14348. isAnimationSheetEnabled: boolean;
  14349. /**
  14350. * Get hosting scene
  14351. * @returns the scene
  14352. */
  14353. getScene(): Scene;
  14354. /**
  14355. * You can use gravity if you want to give an orientation to your particles.
  14356. */
  14357. gravity: Vector3;
  14358. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14359. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14360. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14361. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14362. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14363. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14364. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14365. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14366. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14367. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14368. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14369. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14370. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14371. /**
  14372. * Defines the delay in milliseconds before starting the system (0 by default)
  14373. */
  14374. startDelay: number;
  14375. /**
  14376. * Gets the current list of drag gradients.
  14377. * You must use addDragGradient and removeDragGradient to udpate this list
  14378. * @returns the list of drag gradients
  14379. */
  14380. getDragGradients(): Nullable<Array<FactorGradient>>;
  14381. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14382. limitVelocityDamping: number;
  14383. /**
  14384. * Gets the current list of limit velocity gradients.
  14385. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14386. * @returns the list of limit velocity gradients
  14387. */
  14388. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14389. /**
  14390. * Gets the current list of color gradients.
  14391. * You must use addColorGradient and removeColorGradient to udpate this list
  14392. * @returns the list of color gradients
  14393. */
  14394. getColorGradients(): Nullable<Array<ColorGradient>>;
  14395. /**
  14396. * Gets the current list of size gradients.
  14397. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14398. * @returns the list of size gradients
  14399. */
  14400. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14401. /**
  14402. * Gets the current list of color remap gradients.
  14403. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14404. * @returns the list of color remap gradients
  14405. */
  14406. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14407. /**
  14408. * Gets the current list of alpha remap gradients.
  14409. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14410. * @returns the list of alpha remap gradients
  14411. */
  14412. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14413. /**
  14414. * Gets the current list of life time gradients.
  14415. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14416. * @returns the list of life time gradients
  14417. */
  14418. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14419. /**
  14420. * Gets the current list of angular speed gradients.
  14421. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14422. * @returns the list of angular speed gradients
  14423. */
  14424. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14425. /**
  14426. * Gets the current list of velocity gradients.
  14427. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14428. * @returns the list of velocity gradients
  14429. */
  14430. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14431. /**
  14432. * Gets the current list of start size gradients.
  14433. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14434. * @returns the list of start size gradients
  14435. */
  14436. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14437. /**
  14438. * Gets the current list of emit rate gradients.
  14439. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14440. * @returns the list of emit rate gradients
  14441. */
  14442. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14443. /**
  14444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14445. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14446. */
  14447. direction1: Vector3;
  14448. /**
  14449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14450. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14451. */
  14452. direction2: Vector3;
  14453. /**
  14454. * 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.
  14455. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14456. */
  14457. minEmitBox: Vector3;
  14458. /**
  14459. * 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.
  14460. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14461. */
  14462. maxEmitBox: Vector3;
  14463. /**
  14464. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14465. */
  14466. color1: Color4;
  14467. /**
  14468. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14469. */
  14470. color2: Color4;
  14471. /**
  14472. * Color the particle will have at the end of its lifetime
  14473. */
  14474. colorDead: Color4;
  14475. /**
  14476. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14477. */
  14478. textureMask: Color4;
  14479. /**
  14480. * The particle emitter type defines the emitter used by the particle system.
  14481. * It can be for example box, sphere, or cone...
  14482. */
  14483. particleEmitterType: IParticleEmitterType;
  14484. /** @hidden */ isSubEmitter: boolean;
  14485. /**
  14486. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14487. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14488. */
  14489. billboardMode: number;
  14490. protected _isBillboardBased: boolean;
  14491. /**
  14492. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14493. */
  14494. isBillboardBased: boolean;
  14495. /**
  14496. * The scene the particle system belongs to.
  14497. */
  14498. protected _scene: Scene;
  14499. /**
  14500. * Local cache of defines for image processing.
  14501. */
  14502. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14503. /**
  14504. * Default configuration related to image processing available in the standard Material.
  14505. */
  14506. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14507. /**
  14508. * Gets the image processing configuration used either in this material.
  14509. */
  14510. /**
  14511. * Sets the Default image processing configuration used either in the this material.
  14512. *
  14513. * If sets to null, the scene one is in use.
  14514. */
  14515. imageProcessingConfiguration: ImageProcessingConfiguration;
  14516. /**
  14517. * Attaches a new image processing configuration to the Standard Material.
  14518. * @param configuration
  14519. */
  14520. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14521. /** @hidden */
  14522. protected _reset(): void;
  14523. /** @hidden */
  14524. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14525. /**
  14526. * Instantiates a particle system.
  14527. * 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.
  14528. * @param name The name of the particle system
  14529. */
  14530. constructor(name: string);
  14531. /**
  14532. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14533. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14534. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14535. * @returns the emitter
  14536. */
  14537. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14538. /**
  14539. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14540. * @param radius The radius of the hemisphere to emit from
  14541. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14542. * @returns the emitter
  14543. */
  14544. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14545. /**
  14546. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14547. * @param radius The radius of the sphere to emit from
  14548. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14549. * @returns the emitter
  14550. */
  14551. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14552. /**
  14553. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14554. * @param radius The radius of the sphere to emit from
  14555. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14556. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14557. * @returns the emitter
  14558. */
  14559. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14560. /**
  14561. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14562. * @param radius The radius of the emission cylinder
  14563. * @param height The height of the emission cylinder
  14564. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14565. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14566. * @returns the emitter
  14567. */
  14568. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14569. /**
  14570. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14571. * @param radius The radius of the cylinder to emit from
  14572. * @param height The height of the emission cylinder
  14573. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14574. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14575. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14576. * @returns the emitter
  14577. */
  14578. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14579. /**
  14580. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14581. * @param radius The radius of the cone to emit from
  14582. * @param angle The base angle of the cone
  14583. * @returns the emitter
  14584. */
  14585. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14586. /**
  14587. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14588. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14589. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14590. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14591. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14592. * @returns the emitter
  14593. */
  14594. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14595. }
  14596. }
  14597. declare module BABYLON {
  14598. /**
  14599. * Type of sub emitter
  14600. */
  14601. export enum SubEmitterType {
  14602. /**
  14603. * Attached to the particle over it's lifetime
  14604. */
  14605. ATTACHED = 0,
  14606. /**
  14607. * Created when the particle dies
  14608. */
  14609. END = 1
  14610. }
  14611. /**
  14612. * Sub emitter class used to emit particles from an existing particle
  14613. */
  14614. export class SubEmitter {
  14615. /**
  14616. * the particle system to be used by the sub emitter
  14617. */
  14618. particleSystem: ParticleSystem;
  14619. /**
  14620. * Type of the submitter (Default: END)
  14621. */
  14622. type: SubEmitterType;
  14623. /**
  14624. * 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)
  14625. * Note: This only is supported when using an emitter of type Mesh
  14626. */
  14627. inheritDirection: boolean;
  14628. /**
  14629. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14630. */
  14631. inheritedVelocityAmount: number;
  14632. /**
  14633. * Creates a sub emitter
  14634. * @param particleSystem the particle system to be used by the sub emitter
  14635. */
  14636. constructor(
  14637. /**
  14638. * the particle system to be used by the sub emitter
  14639. */
  14640. particleSystem: ParticleSystem);
  14641. /**
  14642. * Clones the sub emitter
  14643. * @returns the cloned sub emitter
  14644. */
  14645. clone(): SubEmitter;
  14646. /**
  14647. * Serialize current object to a JSON object
  14648. * @returns the serialized object
  14649. */
  14650. serialize(): any;
  14651. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14652. /**
  14653. * Creates a new SubEmitter from a serialized JSON version
  14654. * @param serializationObject defines the JSON object to read from
  14655. * @param scene defines the hosting scene
  14656. * @param rootUrl defines the rootUrl for data loading
  14657. * @returns a new SubEmitter
  14658. */
  14659. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14660. /** Release associated resources */
  14661. dispose(): void;
  14662. }
  14663. }
  14664. declare module BABYLON {
  14665. /** @hidden */
  14666. export var clipPlaneFragmentDeclaration: {
  14667. name: string;
  14668. shader: string;
  14669. };
  14670. }
  14671. declare module BABYLON {
  14672. /** @hidden */
  14673. export var imageProcessingDeclaration: {
  14674. name: string;
  14675. shader: string;
  14676. };
  14677. }
  14678. declare module BABYLON {
  14679. /** @hidden */
  14680. export var imageProcessingFunctions: {
  14681. name: string;
  14682. shader: string;
  14683. };
  14684. }
  14685. declare module BABYLON {
  14686. /** @hidden */
  14687. export var clipPlaneFragment: {
  14688. name: string;
  14689. shader: string;
  14690. };
  14691. }
  14692. declare module BABYLON {
  14693. /** @hidden */
  14694. export var particlesPixelShader: {
  14695. name: string;
  14696. shader: string;
  14697. };
  14698. }
  14699. declare module BABYLON {
  14700. /** @hidden */
  14701. export var clipPlaneVertexDeclaration: {
  14702. name: string;
  14703. shader: string;
  14704. };
  14705. }
  14706. declare module BABYLON {
  14707. /** @hidden */
  14708. export var clipPlaneVertex: {
  14709. name: string;
  14710. shader: string;
  14711. };
  14712. }
  14713. declare module BABYLON {
  14714. /** @hidden */
  14715. export var particlesVertexShader: {
  14716. name: string;
  14717. shader: string;
  14718. };
  14719. }
  14720. declare module BABYLON {
  14721. /**
  14722. * This represents a particle system in Babylon.
  14723. * 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.
  14724. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14725. * @example https://doc.babylonjs.com/babylon101/particles
  14726. */
  14727. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14728. /**
  14729. * Billboard mode will only apply to Y axis
  14730. */
  14731. static readonly BILLBOARDMODE_Y: number;
  14732. /**
  14733. * Billboard mode will apply to all axes
  14734. */
  14735. static readonly BILLBOARDMODE_ALL: number;
  14736. /**
  14737. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14738. */
  14739. static readonly BILLBOARDMODE_STRETCHED: number;
  14740. /**
  14741. * This function can be defined to provide custom update for active particles.
  14742. * This function will be called instead of regular update (age, position, color, etc.).
  14743. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14744. */
  14745. updateFunction: (particles: Particle[]) => void;
  14746. private _emitterWorldMatrix;
  14747. /**
  14748. * This function can be defined to specify initial direction for every new particle.
  14749. * It by default use the emitterType defined function
  14750. */
  14751. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14752. /**
  14753. * This function can be defined to specify initial position for every new particle.
  14754. * It by default use the emitterType defined function
  14755. */
  14756. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14757. /**
  14758. * @hidden
  14759. */ inheritedVelocityOffset: Vector3;
  14760. /**
  14761. * An event triggered when the system is disposed
  14762. */
  14763. onDisposeObservable: Observable<ParticleSystem>;
  14764. private _onDisposeObserver;
  14765. /**
  14766. * Sets a callback that will be triggered when the system is disposed
  14767. */
  14768. onDispose: () => void;
  14769. private _particles;
  14770. private _epsilon;
  14771. private _capacity;
  14772. private _stockParticles;
  14773. private _newPartsExcess;
  14774. private _vertexData;
  14775. private _vertexBuffer;
  14776. private _vertexBuffers;
  14777. private _spriteBuffer;
  14778. private _indexBuffer;
  14779. private _effect;
  14780. private _customEffect;
  14781. private _cachedDefines;
  14782. private _scaledColorStep;
  14783. private _colorDiff;
  14784. private _scaledDirection;
  14785. private _scaledGravity;
  14786. private _currentRenderId;
  14787. private _alive;
  14788. private _useInstancing;
  14789. private _started;
  14790. private _stopped;
  14791. private _actualFrame;
  14792. private _scaledUpdateSpeed;
  14793. private _vertexBufferSize;
  14794. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14795. /** @hidden */ currentEmitRate1: number;
  14796. /** @hidden */ currentEmitRate2: number;
  14797. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14798. /** @hidden */ currentStartSize1: number;
  14799. /** @hidden */ currentStartSize2: number;
  14800. private readonly _rawTextureWidth;
  14801. private _rampGradientsTexture;
  14802. private _useRampGradients;
  14803. /** Gets or sets a boolean indicating that ramp gradients must be used
  14804. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14805. */
  14806. useRampGradients: boolean;
  14807. /**
  14808. * 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.
  14809. * 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: [])
  14810. */
  14811. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14812. private _subEmitters;
  14813. /**
  14814. * @hidden
  14815. * If the particle systems emitter should be disposed when the particle system is disposed
  14816. */ disposeEmitterOnDispose: boolean;
  14817. /**
  14818. * The current active Sub-systems, this property is used by the root particle system only.
  14819. */
  14820. activeSubSystems: Array<ParticleSystem>;
  14821. private _rootParticleSystem;
  14822. /**
  14823. * Gets the current list of active particles
  14824. */
  14825. readonly particles: Particle[];
  14826. /**
  14827. * Returns the string "ParticleSystem"
  14828. * @returns a string containing the class name
  14829. */
  14830. getClassName(): string;
  14831. /**
  14832. * Instantiates a particle system.
  14833. * 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.
  14834. * @param name The name of the particle system
  14835. * @param capacity The max number of particles alive at the same time
  14836. * @param scene The scene the particle system belongs to
  14837. * @param customEffect a custom effect used to change the way particles are rendered by default
  14838. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14839. * @param epsilon Offset used to render the particles
  14840. */
  14841. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14842. private _addFactorGradient;
  14843. private _removeFactorGradient;
  14844. /**
  14845. * Adds a new life time gradient
  14846. * @param gradient defines the gradient to use (between 0 and 1)
  14847. * @param factor defines the life time factor to affect to the specified gradient
  14848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14849. * @returns the current particle system
  14850. */
  14851. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14852. /**
  14853. * Remove a specific life time gradient
  14854. * @param gradient defines the gradient to remove
  14855. * @returns the current particle system
  14856. */
  14857. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14858. /**
  14859. * Adds a new size gradient
  14860. * @param gradient defines the gradient to use (between 0 and 1)
  14861. * @param factor defines the size factor to affect to the specified gradient
  14862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14863. * @returns the current particle system
  14864. */
  14865. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14866. /**
  14867. * Remove a specific size gradient
  14868. * @param gradient defines the gradient to remove
  14869. * @returns the current particle system
  14870. */
  14871. removeSizeGradient(gradient: number): IParticleSystem;
  14872. /**
  14873. * Adds a new color remap gradient
  14874. * @param gradient defines the gradient to use (between 0 and 1)
  14875. * @param min defines the color remap minimal range
  14876. * @param max defines the color remap maximal range
  14877. * @returns the current particle system
  14878. */
  14879. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14880. /**
  14881. * Remove a specific color remap gradient
  14882. * @param gradient defines the gradient to remove
  14883. * @returns the current particle system
  14884. */
  14885. removeColorRemapGradient(gradient: number): IParticleSystem;
  14886. /**
  14887. * Adds a new alpha remap gradient
  14888. * @param gradient defines the gradient to use (between 0 and 1)
  14889. * @param min defines the alpha remap minimal range
  14890. * @param max defines the alpha remap maximal range
  14891. * @returns the current particle system
  14892. */
  14893. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14894. /**
  14895. * Remove a specific alpha remap gradient
  14896. * @param gradient defines the gradient to remove
  14897. * @returns the current particle system
  14898. */
  14899. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14900. /**
  14901. * Adds a new angular speed gradient
  14902. * @param gradient defines the gradient to use (between 0 and 1)
  14903. * @param factor defines the angular speed to affect to the specified gradient
  14904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14905. * @returns the current particle system
  14906. */
  14907. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14908. /**
  14909. * Remove a specific angular speed gradient
  14910. * @param gradient defines the gradient to remove
  14911. * @returns the current particle system
  14912. */
  14913. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14914. /**
  14915. * Adds a new velocity gradient
  14916. * @param gradient defines the gradient to use (between 0 and 1)
  14917. * @param factor defines the velocity to affect to the specified gradient
  14918. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14919. * @returns the current particle system
  14920. */
  14921. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14922. /**
  14923. * Remove a specific velocity gradient
  14924. * @param gradient defines the gradient to remove
  14925. * @returns the current particle system
  14926. */
  14927. removeVelocityGradient(gradient: number): IParticleSystem;
  14928. /**
  14929. * Adds a new limit velocity gradient
  14930. * @param gradient defines the gradient to use (between 0 and 1)
  14931. * @param factor defines the limit velocity value to affect to the specified gradient
  14932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14933. * @returns the current particle system
  14934. */
  14935. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14936. /**
  14937. * Remove a specific limit velocity gradient
  14938. * @param gradient defines the gradient to remove
  14939. * @returns the current particle system
  14940. */
  14941. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14942. /**
  14943. * Adds a new drag gradient
  14944. * @param gradient defines the gradient to use (between 0 and 1)
  14945. * @param factor defines the drag value to affect to the specified gradient
  14946. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14947. * @returns the current particle system
  14948. */
  14949. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14950. /**
  14951. * Remove a specific drag gradient
  14952. * @param gradient defines the gradient to remove
  14953. * @returns the current particle system
  14954. */
  14955. removeDragGradient(gradient: number): IParticleSystem;
  14956. /**
  14957. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14958. * @param gradient defines the gradient to use (between 0 and 1)
  14959. * @param factor defines the emit rate value to affect to the specified gradient
  14960. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14961. * @returns the current particle system
  14962. */
  14963. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14964. /**
  14965. * Remove a specific emit rate gradient
  14966. * @param gradient defines the gradient to remove
  14967. * @returns the current particle system
  14968. */
  14969. removeEmitRateGradient(gradient: number): IParticleSystem;
  14970. /**
  14971. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14972. * @param gradient defines the gradient to use (between 0 and 1)
  14973. * @param factor defines the start size value to affect to the specified gradient
  14974. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14975. * @returns the current particle system
  14976. */
  14977. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14978. /**
  14979. * Remove a specific start size gradient
  14980. * @param gradient defines the gradient to remove
  14981. * @returns the current particle system
  14982. */
  14983. removeStartSizeGradient(gradient: number): IParticleSystem;
  14984. private _createRampGradientTexture;
  14985. /**
  14986. * Gets the current list of ramp gradients.
  14987. * You must use addRampGradient and removeRampGradient to udpate this list
  14988. * @returns the list of ramp gradients
  14989. */
  14990. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14991. /**
  14992. * Adds a new ramp gradient used to remap particle colors
  14993. * @param gradient defines the gradient to use (between 0 and 1)
  14994. * @param color defines the color to affect to the specified gradient
  14995. * @returns the current particle system
  14996. */
  14997. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14998. /**
  14999. * Remove a specific ramp gradient
  15000. * @param gradient defines the gradient to remove
  15001. * @returns the current particle system
  15002. */
  15003. removeRampGradient(gradient: number): ParticleSystem;
  15004. /**
  15005. * Adds a new color gradient
  15006. * @param gradient defines the gradient to use (between 0 and 1)
  15007. * @param color1 defines the color to affect to the specified gradient
  15008. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15009. * @returns this particle system
  15010. */
  15011. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15012. /**
  15013. * Remove a specific color gradient
  15014. * @param gradient defines the gradient to remove
  15015. * @returns this particle system
  15016. */
  15017. removeColorGradient(gradient: number): IParticleSystem;
  15018. private _fetchR;
  15019. protected _reset(): void;
  15020. private _resetEffect;
  15021. private _createVertexBuffers;
  15022. private _createIndexBuffer;
  15023. /**
  15024. * Gets the maximum number of particles active at the same time.
  15025. * @returns The max number of active particles.
  15026. */
  15027. getCapacity(): number;
  15028. /**
  15029. * Gets whether there are still active particles in the system.
  15030. * @returns True if it is alive, otherwise false.
  15031. */
  15032. isAlive(): boolean;
  15033. /**
  15034. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15035. * @returns True if it has been started, otherwise false.
  15036. */
  15037. isStarted(): boolean;
  15038. private _prepareSubEmitterInternalArray;
  15039. /**
  15040. * Starts the particle system and begins to emit
  15041. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15042. */
  15043. start(delay?: number): void;
  15044. /**
  15045. * Stops the particle system.
  15046. * @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.
  15047. */
  15048. stop(stopSubEmitters?: boolean): void;
  15049. /**
  15050. * Remove all active particles
  15051. */
  15052. reset(): void;
  15053. /**
  15054. * @hidden (for internal use only)
  15055. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15056. /**
  15057. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15058. * Its lifetime will start back at 0.
  15059. */
  15060. recycleParticle: (particle: Particle) => void;
  15061. private _stopSubEmitters;
  15062. private _createParticle;
  15063. private _removeFromRoot;
  15064. private _emitFromParticle;
  15065. private _update;
  15066. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15067. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15068. /** @hidden */
  15069. private _getEffect;
  15070. /**
  15071. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15072. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15073. */
  15074. animate(preWarmOnly?: boolean): void;
  15075. private _appendParticleVertices;
  15076. /**
  15077. * Rebuilds the particle system.
  15078. */
  15079. rebuild(): void;
  15080. /**
  15081. * Is this system ready to be used/rendered
  15082. * @return true if the system is ready
  15083. */
  15084. isReady(): boolean;
  15085. private _render;
  15086. /**
  15087. * Renders the particle system in its current state.
  15088. * @returns the current number of particles
  15089. */
  15090. render(): number;
  15091. /**
  15092. * Disposes the particle system and free the associated resources
  15093. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15094. */
  15095. dispose(disposeTexture?: boolean): void;
  15096. /**
  15097. * Clones the particle system.
  15098. * @param name The name of the cloned object
  15099. * @param newEmitter The new emitter to use
  15100. * @returns the cloned particle system
  15101. */
  15102. clone(name: string, newEmitter: any): ParticleSystem;
  15103. /**
  15104. * Serializes the particle system to a JSON object.
  15105. * @returns the JSON object
  15106. */
  15107. serialize(): any;
  15108. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15109. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15110. /**
  15111. * Parses a JSON object to create a particle system.
  15112. * @param parsedParticleSystem The JSON object to parse
  15113. * @param scene The scene to create the particle system in
  15114. * @param rootUrl The root url to use to load external dependencies like texture
  15115. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15116. * @returns the Parsed particle system
  15117. */
  15118. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15119. }
  15120. }
  15121. declare module BABYLON {
  15122. /**
  15123. * A particle represents one of the element emitted by a particle system.
  15124. * This is mainly define by its coordinates, direction, velocity and age.
  15125. */
  15126. export class Particle {
  15127. /**
  15128. * The particle system the particle belongs to.
  15129. */
  15130. particleSystem: ParticleSystem;
  15131. private static _Count;
  15132. /**
  15133. * Unique ID of the particle
  15134. */
  15135. id: number;
  15136. /**
  15137. * The world position of the particle in the scene.
  15138. */
  15139. position: Vector3;
  15140. /**
  15141. * The world direction of the particle in the scene.
  15142. */
  15143. direction: Vector3;
  15144. /**
  15145. * The color of the particle.
  15146. */
  15147. color: Color4;
  15148. /**
  15149. * The color change of the particle per step.
  15150. */
  15151. colorStep: Color4;
  15152. /**
  15153. * Defines how long will the life of the particle be.
  15154. */
  15155. lifeTime: number;
  15156. /**
  15157. * The current age of the particle.
  15158. */
  15159. age: number;
  15160. /**
  15161. * The current size of the particle.
  15162. */
  15163. size: number;
  15164. /**
  15165. * The current scale of the particle.
  15166. */
  15167. scale: Vector2;
  15168. /**
  15169. * The current angle of the particle.
  15170. */
  15171. angle: number;
  15172. /**
  15173. * Defines how fast is the angle changing.
  15174. */
  15175. angularSpeed: number;
  15176. /**
  15177. * Defines the cell index used by the particle to be rendered from a sprite.
  15178. */
  15179. cellIndex: number;
  15180. /**
  15181. * The information required to support color remapping
  15182. */
  15183. remapData: Vector4;
  15184. /** @hidden */ randomCellOffset?: number;
  15185. /** @hidden */ initialDirection: Nullable<Vector3>;
  15186. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15187. /** @hidden */ initialStartSpriteCellID: number;
  15188. /** @hidden */ initialEndSpriteCellID: number;
  15189. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  15190. /** @hidden */ currentColor1: Color4;
  15191. /** @hidden */ currentColor2: Color4;
  15192. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  15193. /** @hidden */ currentSize1: number;
  15194. /** @hidden */ currentSize2: number;
  15195. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  15196. /** @hidden */ currentAngularSpeed1: number;
  15197. /** @hidden */ currentAngularSpeed2: number;
  15198. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  15199. /** @hidden */ currentVelocity1: number;
  15200. /** @hidden */ currentVelocity2: number;
  15201. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  15202. /** @hidden */ currentLimitVelocity1: number;
  15203. /** @hidden */ currentLimitVelocity2: number;
  15204. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  15205. /** @hidden */ currentDrag1: number;
  15206. /** @hidden */ currentDrag2: number;
  15207. /** @hidden */ randomNoiseCoordinates1: Vector3;
  15208. /** @hidden */ randomNoiseCoordinates2: Vector3;
  15209. /**
  15210. * Creates a new instance Particle
  15211. * @param particleSystem the particle system the particle belongs to
  15212. */
  15213. constructor(
  15214. /**
  15215. * The particle system the particle belongs to.
  15216. */
  15217. particleSystem: ParticleSystem);
  15218. private updateCellInfoFromSystem;
  15219. /**
  15220. * Defines how the sprite cell index is updated for the particle
  15221. */
  15222. updateCellIndex(): void;
  15223. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15224. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  15225. /** @hidden */ reset(): void;
  15226. /**
  15227. * Copy the properties of particle to another one.
  15228. * @param other the particle to copy the information to.
  15229. */
  15230. copyTo(other: Particle): void;
  15231. }
  15232. }
  15233. declare module BABYLON {
  15234. /**
  15235. * Particle emitter represents a volume emitting particles.
  15236. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15237. */
  15238. export interface IParticleEmitterType {
  15239. /**
  15240. * Called by the particle System when the direction is computed for the created particle.
  15241. * @param worldMatrix is the world matrix of the particle system
  15242. * @param directionToUpdate is the direction vector to update with the result
  15243. * @param particle is the particle we are computed the direction for
  15244. */
  15245. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15246. /**
  15247. * Called by the particle System when the position is computed for the created particle.
  15248. * @param worldMatrix is the world matrix of the particle system
  15249. * @param positionToUpdate is the position vector to update with the result
  15250. * @param particle is the particle we are computed the position for
  15251. */
  15252. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15253. /**
  15254. * Clones the current emitter and returns a copy of it
  15255. * @returns the new emitter
  15256. */
  15257. clone(): IParticleEmitterType;
  15258. /**
  15259. * Called by the GPUParticleSystem to setup the update shader
  15260. * @param effect defines the update shader
  15261. */
  15262. applyToShader(effect: Effect): void;
  15263. /**
  15264. * Returns a string to use to update the GPU particles update shader
  15265. * @returns the effect defines string
  15266. */
  15267. getEffectDefines(): string;
  15268. /**
  15269. * Returns a string representing the class name
  15270. * @returns a string containing the class name
  15271. */
  15272. getClassName(): string;
  15273. /**
  15274. * Serializes the particle system to a JSON object.
  15275. * @returns the JSON object
  15276. */
  15277. serialize(): any;
  15278. /**
  15279. * Parse properties from a JSON object
  15280. * @param serializationObject defines the JSON object
  15281. */
  15282. parse(serializationObject: any): void;
  15283. }
  15284. }
  15285. declare module BABYLON {
  15286. /**
  15287. * Particle emitter emitting particles from the inside of a box.
  15288. * It emits the particles randomly between 2 given directions.
  15289. */
  15290. export class BoxParticleEmitter implements IParticleEmitterType {
  15291. /**
  15292. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15293. */
  15294. direction1: Vector3;
  15295. /**
  15296. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15297. */
  15298. direction2: Vector3;
  15299. /**
  15300. * 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.
  15301. */
  15302. minEmitBox: Vector3;
  15303. /**
  15304. * 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.
  15305. */
  15306. maxEmitBox: Vector3;
  15307. /**
  15308. * Creates a new instance BoxParticleEmitter
  15309. */
  15310. constructor();
  15311. /**
  15312. * Called by the particle System when the direction is computed for the created particle.
  15313. * @param worldMatrix is the world matrix of the particle system
  15314. * @param directionToUpdate is the direction vector to update with the result
  15315. * @param particle is the particle we are computed the direction for
  15316. */
  15317. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15318. /**
  15319. * Called by the particle System when the position is computed for the created particle.
  15320. * @param worldMatrix is the world matrix of the particle system
  15321. * @param positionToUpdate is the position vector to update with the result
  15322. * @param particle is the particle we are computed the position for
  15323. */
  15324. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15325. /**
  15326. * Clones the current emitter and returns a copy of it
  15327. * @returns the new emitter
  15328. */
  15329. clone(): BoxParticleEmitter;
  15330. /**
  15331. * Called by the GPUParticleSystem to setup the update shader
  15332. * @param effect defines the update shader
  15333. */
  15334. applyToShader(effect: Effect): void;
  15335. /**
  15336. * Returns a string to use to update the GPU particles update shader
  15337. * @returns a string containng the defines string
  15338. */
  15339. getEffectDefines(): string;
  15340. /**
  15341. * Returns the string "BoxParticleEmitter"
  15342. * @returns a string containing the class name
  15343. */
  15344. getClassName(): string;
  15345. /**
  15346. * Serializes the particle system to a JSON object.
  15347. * @returns the JSON object
  15348. */
  15349. serialize(): any;
  15350. /**
  15351. * Parse properties from a JSON object
  15352. * @param serializationObject defines the JSON object
  15353. */
  15354. parse(serializationObject: any): void;
  15355. }
  15356. }
  15357. declare module BABYLON {
  15358. /**
  15359. * Particle emitter emitting particles from the inside of a cone.
  15360. * It emits the particles alongside the cone volume from the base to the particle.
  15361. * The emission direction might be randomized.
  15362. */
  15363. export class ConeParticleEmitter implements IParticleEmitterType {
  15364. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15365. directionRandomizer: number;
  15366. private _radius;
  15367. private _angle;
  15368. private _height;
  15369. /**
  15370. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15371. */
  15372. radiusRange: number;
  15373. /**
  15374. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15375. */
  15376. heightRange: number;
  15377. /**
  15378. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15379. */
  15380. emitFromSpawnPointOnly: boolean;
  15381. /**
  15382. * Gets or sets the radius of the emission cone
  15383. */
  15384. radius: number;
  15385. /**
  15386. * Gets or sets the angle of the emission cone
  15387. */
  15388. angle: number;
  15389. private _buildHeight;
  15390. /**
  15391. * Creates a new instance ConeParticleEmitter
  15392. * @param radius the radius of the emission cone (1 by default)
  15393. * @param angle the cone base angle (PI by default)
  15394. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15395. */
  15396. constructor(radius?: number, angle?: number,
  15397. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15398. directionRandomizer?: number);
  15399. /**
  15400. * Called by the particle System when the direction is computed for the created particle.
  15401. * @param worldMatrix is the world matrix of the particle system
  15402. * @param directionToUpdate is the direction vector to update with the result
  15403. * @param particle is the particle we are computed the direction for
  15404. */
  15405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15406. /**
  15407. * Called by the particle System when the position is computed for the created particle.
  15408. * @param worldMatrix is the world matrix of the particle system
  15409. * @param positionToUpdate is the position vector to update with the result
  15410. * @param particle is the particle we are computed the position for
  15411. */
  15412. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15413. /**
  15414. * Clones the current emitter and returns a copy of it
  15415. * @returns the new emitter
  15416. */
  15417. clone(): ConeParticleEmitter;
  15418. /**
  15419. * Called by the GPUParticleSystem to setup the update shader
  15420. * @param effect defines the update shader
  15421. */
  15422. applyToShader(effect: Effect): void;
  15423. /**
  15424. * Returns a string to use to update the GPU particles update shader
  15425. * @returns a string containng the defines string
  15426. */
  15427. getEffectDefines(): string;
  15428. /**
  15429. * Returns the string "ConeParticleEmitter"
  15430. * @returns a string containing the class name
  15431. */
  15432. getClassName(): string;
  15433. /**
  15434. * Serializes the particle system to a JSON object.
  15435. * @returns the JSON object
  15436. */
  15437. serialize(): any;
  15438. /**
  15439. * Parse properties from a JSON object
  15440. * @param serializationObject defines the JSON object
  15441. */
  15442. parse(serializationObject: any): void;
  15443. }
  15444. }
  15445. declare module BABYLON {
  15446. /**
  15447. * Particle emitter emitting particles from the inside of a cylinder.
  15448. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15449. */
  15450. export class CylinderParticleEmitter implements IParticleEmitterType {
  15451. /**
  15452. * The radius of the emission cylinder.
  15453. */
  15454. radius: number;
  15455. /**
  15456. * The height of the emission cylinder.
  15457. */
  15458. height: number;
  15459. /**
  15460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15461. */
  15462. radiusRange: number;
  15463. /**
  15464. * How much to randomize the particle direction [0-1].
  15465. */
  15466. directionRandomizer: number;
  15467. /**
  15468. * Creates a new instance CylinderParticleEmitter
  15469. * @param radius the radius of the emission cylinder (1 by default)
  15470. * @param height the height of the emission cylinder (1 by default)
  15471. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15472. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15473. */
  15474. constructor(
  15475. /**
  15476. * The radius of the emission cylinder.
  15477. */
  15478. radius?: number,
  15479. /**
  15480. * The height of the emission cylinder.
  15481. */
  15482. height?: number,
  15483. /**
  15484. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15485. */
  15486. radiusRange?: number,
  15487. /**
  15488. * How much to randomize the particle direction [0-1].
  15489. */
  15490. directionRandomizer?: number);
  15491. /**
  15492. * Called by the particle System when the direction is computed for the created particle.
  15493. * @param worldMatrix is the world matrix of the particle system
  15494. * @param directionToUpdate is the direction vector to update with the result
  15495. * @param particle is the particle we are computed the direction for
  15496. */
  15497. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15498. /**
  15499. * Called by the particle System when the position is computed for the created particle.
  15500. * @param worldMatrix is the world matrix of the particle system
  15501. * @param positionToUpdate is the position vector to update with the result
  15502. * @param particle is the particle we are computed the position for
  15503. */
  15504. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15505. /**
  15506. * Clones the current emitter and returns a copy of it
  15507. * @returns the new emitter
  15508. */
  15509. clone(): CylinderParticleEmitter;
  15510. /**
  15511. * Called by the GPUParticleSystem to setup the update shader
  15512. * @param effect defines the update shader
  15513. */
  15514. applyToShader(effect: Effect): void;
  15515. /**
  15516. * Returns a string to use to update the GPU particles update shader
  15517. * @returns a string containng the defines string
  15518. */
  15519. getEffectDefines(): string;
  15520. /**
  15521. * Returns the string "CylinderParticleEmitter"
  15522. * @returns a string containing the class name
  15523. */
  15524. getClassName(): string;
  15525. /**
  15526. * Serializes the particle system to a JSON object.
  15527. * @returns the JSON object
  15528. */
  15529. serialize(): any;
  15530. /**
  15531. * Parse properties from a JSON object
  15532. * @param serializationObject defines the JSON object
  15533. */
  15534. parse(serializationObject: any): void;
  15535. }
  15536. /**
  15537. * Particle emitter emitting particles from the inside of a cylinder.
  15538. * It emits the particles randomly between two vectors.
  15539. */
  15540. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15541. /**
  15542. * The min limit of the emission direction.
  15543. */
  15544. direction1: Vector3;
  15545. /**
  15546. * The max limit of the emission direction.
  15547. */
  15548. direction2: Vector3;
  15549. /**
  15550. * Creates a new instance CylinderDirectedParticleEmitter
  15551. * @param radius the radius of the emission cylinder (1 by default)
  15552. * @param height the height of the emission cylinder (1 by default)
  15553. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15554. * @param direction1 the min limit of the emission direction (up vector by default)
  15555. * @param direction2 the max limit of the emission direction (up vector by default)
  15556. */
  15557. constructor(radius?: number, height?: number, radiusRange?: number,
  15558. /**
  15559. * The min limit of the emission direction.
  15560. */
  15561. direction1?: Vector3,
  15562. /**
  15563. * The max limit of the emission direction.
  15564. */
  15565. direction2?: Vector3);
  15566. /**
  15567. * Called by the particle System when the direction is computed for the created particle.
  15568. * @param worldMatrix is the world matrix of the particle system
  15569. * @param directionToUpdate is the direction vector to update with the result
  15570. * @param particle is the particle we are computed the direction for
  15571. */
  15572. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15573. /**
  15574. * Clones the current emitter and returns a copy of it
  15575. * @returns the new emitter
  15576. */
  15577. clone(): CylinderDirectedParticleEmitter;
  15578. /**
  15579. * Called by the GPUParticleSystem to setup the update shader
  15580. * @param effect defines the update shader
  15581. */
  15582. applyToShader(effect: Effect): void;
  15583. /**
  15584. * Returns a string to use to update the GPU particles update shader
  15585. * @returns a string containng the defines string
  15586. */
  15587. getEffectDefines(): string;
  15588. /**
  15589. * Returns the string "CylinderDirectedParticleEmitter"
  15590. * @returns a string containing the class name
  15591. */
  15592. getClassName(): string;
  15593. /**
  15594. * Serializes the particle system to a JSON object.
  15595. * @returns the JSON object
  15596. */
  15597. serialize(): any;
  15598. /**
  15599. * Parse properties from a JSON object
  15600. * @param serializationObject defines the JSON object
  15601. */
  15602. parse(serializationObject: any): void;
  15603. }
  15604. }
  15605. declare module BABYLON {
  15606. /**
  15607. * Particle emitter emitting particles from the inside of a hemisphere.
  15608. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15609. */
  15610. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15611. /**
  15612. * The radius of the emission hemisphere.
  15613. */
  15614. radius: number;
  15615. /**
  15616. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15617. */
  15618. radiusRange: number;
  15619. /**
  15620. * How much to randomize the particle direction [0-1].
  15621. */
  15622. directionRandomizer: number;
  15623. /**
  15624. * Creates a new instance HemisphericParticleEmitter
  15625. * @param radius the radius of the emission hemisphere (1 by default)
  15626. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15627. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15628. */
  15629. constructor(
  15630. /**
  15631. * The radius of the emission hemisphere.
  15632. */
  15633. radius?: number,
  15634. /**
  15635. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15636. */
  15637. radiusRange?: number,
  15638. /**
  15639. * How much to randomize the particle direction [0-1].
  15640. */
  15641. directionRandomizer?: number);
  15642. /**
  15643. * Called by the particle System when the direction is computed for the created particle.
  15644. * @param worldMatrix is the world matrix of the particle system
  15645. * @param directionToUpdate is the direction vector to update with the result
  15646. * @param particle is the particle we are computed the direction for
  15647. */
  15648. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15649. /**
  15650. * Called by the particle System when the position is computed for the created particle.
  15651. * @param worldMatrix is the world matrix of the particle system
  15652. * @param positionToUpdate is the position vector to update with the result
  15653. * @param particle is the particle we are computed the position for
  15654. */
  15655. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15656. /**
  15657. * Clones the current emitter and returns a copy of it
  15658. * @returns the new emitter
  15659. */
  15660. clone(): HemisphericParticleEmitter;
  15661. /**
  15662. * Called by the GPUParticleSystem to setup the update shader
  15663. * @param effect defines the update shader
  15664. */
  15665. applyToShader(effect: Effect): void;
  15666. /**
  15667. * Returns a string to use to update the GPU particles update shader
  15668. * @returns a string containng the defines string
  15669. */
  15670. getEffectDefines(): string;
  15671. /**
  15672. * Returns the string "HemisphericParticleEmitter"
  15673. * @returns a string containing the class name
  15674. */
  15675. getClassName(): string;
  15676. /**
  15677. * Serializes the particle system to a JSON object.
  15678. * @returns the JSON object
  15679. */
  15680. serialize(): any;
  15681. /**
  15682. * Parse properties from a JSON object
  15683. * @param serializationObject defines the JSON object
  15684. */
  15685. parse(serializationObject: any): void;
  15686. }
  15687. }
  15688. declare module BABYLON {
  15689. /**
  15690. * Particle emitter emitting particles from a point.
  15691. * It emits the particles randomly between 2 given directions.
  15692. */
  15693. export class PointParticleEmitter implements IParticleEmitterType {
  15694. /**
  15695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15696. */
  15697. direction1: Vector3;
  15698. /**
  15699. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15700. */
  15701. direction2: Vector3;
  15702. /**
  15703. * Creates a new instance PointParticleEmitter
  15704. */
  15705. constructor();
  15706. /**
  15707. * Called by the particle System when the direction is computed for the created particle.
  15708. * @param worldMatrix is the world matrix of the particle system
  15709. * @param directionToUpdate is the direction vector to update with the result
  15710. * @param particle is the particle we are computed the direction for
  15711. */
  15712. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15713. /**
  15714. * Called by the particle System when the position is computed for the created particle.
  15715. * @param worldMatrix is the world matrix of the particle system
  15716. * @param positionToUpdate is the position vector to update with the result
  15717. * @param particle is the particle we are computed the position for
  15718. */
  15719. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15720. /**
  15721. * Clones the current emitter and returns a copy of it
  15722. * @returns the new emitter
  15723. */
  15724. clone(): PointParticleEmitter;
  15725. /**
  15726. * Called by the GPUParticleSystem to setup the update shader
  15727. * @param effect defines the update shader
  15728. */
  15729. applyToShader(effect: Effect): void;
  15730. /**
  15731. * Returns a string to use to update the GPU particles update shader
  15732. * @returns a string containng the defines string
  15733. */
  15734. getEffectDefines(): string;
  15735. /**
  15736. * Returns the string "PointParticleEmitter"
  15737. * @returns a string containing the class name
  15738. */
  15739. getClassName(): string;
  15740. /**
  15741. * Serializes the particle system to a JSON object.
  15742. * @returns the JSON object
  15743. */
  15744. serialize(): any;
  15745. /**
  15746. * Parse properties from a JSON object
  15747. * @param serializationObject defines the JSON object
  15748. */
  15749. parse(serializationObject: any): void;
  15750. }
  15751. }
  15752. declare module BABYLON {
  15753. /**
  15754. * Particle emitter emitting particles from the inside of a sphere.
  15755. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15756. */
  15757. export class SphereParticleEmitter implements IParticleEmitterType {
  15758. /**
  15759. * The radius of the emission sphere.
  15760. */
  15761. radius: number;
  15762. /**
  15763. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15764. */
  15765. radiusRange: number;
  15766. /**
  15767. * How much to randomize the particle direction [0-1].
  15768. */
  15769. directionRandomizer: number;
  15770. /**
  15771. * Creates a new instance SphereParticleEmitter
  15772. * @param radius the radius of the emission sphere (1 by default)
  15773. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15774. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15775. */
  15776. constructor(
  15777. /**
  15778. * The radius of the emission sphere.
  15779. */
  15780. radius?: number,
  15781. /**
  15782. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15783. */
  15784. radiusRange?: number,
  15785. /**
  15786. * How much to randomize the particle direction [0-1].
  15787. */
  15788. directionRandomizer?: number);
  15789. /**
  15790. * Called by the particle System when the direction is computed for the created particle.
  15791. * @param worldMatrix is the world matrix of the particle system
  15792. * @param directionToUpdate is the direction vector to update with the result
  15793. * @param particle is the particle we are computed the direction for
  15794. */
  15795. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15796. /**
  15797. * Called by the particle System when the position is computed for the created particle.
  15798. * @param worldMatrix is the world matrix of the particle system
  15799. * @param positionToUpdate is the position vector to update with the result
  15800. * @param particle is the particle we are computed the position for
  15801. */
  15802. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15803. /**
  15804. * Clones the current emitter and returns a copy of it
  15805. * @returns the new emitter
  15806. */
  15807. clone(): SphereParticleEmitter;
  15808. /**
  15809. * Called by the GPUParticleSystem to setup the update shader
  15810. * @param effect defines the update shader
  15811. */
  15812. applyToShader(effect: Effect): void;
  15813. /**
  15814. * Returns a string to use to update the GPU particles update shader
  15815. * @returns a string containng the defines string
  15816. */
  15817. getEffectDefines(): string;
  15818. /**
  15819. * Returns the string "SphereParticleEmitter"
  15820. * @returns a string containing the class name
  15821. */
  15822. getClassName(): string;
  15823. /**
  15824. * Serializes the particle system to a JSON object.
  15825. * @returns the JSON object
  15826. */
  15827. serialize(): any;
  15828. /**
  15829. * Parse properties from a JSON object
  15830. * @param serializationObject defines the JSON object
  15831. */
  15832. parse(serializationObject: any): void;
  15833. }
  15834. /**
  15835. * Particle emitter emitting particles from the inside of a sphere.
  15836. * It emits the particles randomly between two vectors.
  15837. */
  15838. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15839. /**
  15840. * The min limit of the emission direction.
  15841. */
  15842. direction1: Vector3;
  15843. /**
  15844. * The max limit of the emission direction.
  15845. */
  15846. direction2: Vector3;
  15847. /**
  15848. * Creates a new instance SphereDirectedParticleEmitter
  15849. * @param radius the radius of the emission sphere (1 by default)
  15850. * @param direction1 the min limit of the emission direction (up vector by default)
  15851. * @param direction2 the max limit of the emission direction (up vector by default)
  15852. */
  15853. constructor(radius?: number,
  15854. /**
  15855. * The min limit of the emission direction.
  15856. */
  15857. direction1?: Vector3,
  15858. /**
  15859. * The max limit of the emission direction.
  15860. */
  15861. direction2?: Vector3);
  15862. /**
  15863. * Called by the particle System when the direction is computed for the created particle.
  15864. * @param worldMatrix is the world matrix of the particle system
  15865. * @param directionToUpdate is the direction vector to update with the result
  15866. * @param particle is the particle we are computed the direction for
  15867. */
  15868. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15869. /**
  15870. * Clones the current emitter and returns a copy of it
  15871. * @returns the new emitter
  15872. */
  15873. clone(): SphereDirectedParticleEmitter;
  15874. /**
  15875. * Called by the GPUParticleSystem to setup the update shader
  15876. * @param effect defines the update shader
  15877. */
  15878. applyToShader(effect: Effect): void;
  15879. /**
  15880. * Returns a string to use to update the GPU particles update shader
  15881. * @returns a string containng the defines string
  15882. */
  15883. getEffectDefines(): string;
  15884. /**
  15885. * Returns the string "SphereDirectedParticleEmitter"
  15886. * @returns a string containing the class name
  15887. */
  15888. getClassName(): string;
  15889. /**
  15890. * Serializes the particle system to a JSON object.
  15891. * @returns the JSON object
  15892. */
  15893. serialize(): any;
  15894. /**
  15895. * Parse properties from a JSON object
  15896. * @param serializationObject defines the JSON object
  15897. */
  15898. parse(serializationObject: any): void;
  15899. }
  15900. }
  15901. declare module BABYLON {
  15902. /**
  15903. * Interface representing a particle system in Babylon.js.
  15904. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15905. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15906. */
  15907. export interface IParticleSystem {
  15908. /**
  15909. * List of animations used by the particle system.
  15910. */
  15911. animations: Animation[];
  15912. /**
  15913. * The id of the Particle system.
  15914. */
  15915. id: string;
  15916. /**
  15917. * The name of the Particle system.
  15918. */
  15919. name: string;
  15920. /**
  15921. * The emitter represents the Mesh or position we are attaching the particle system to.
  15922. */
  15923. emitter: Nullable<AbstractMesh | Vector3>;
  15924. /**
  15925. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15926. */
  15927. isBillboardBased: boolean;
  15928. /**
  15929. * The rendering group used by the Particle system to chose when to render.
  15930. */
  15931. renderingGroupId: number;
  15932. /**
  15933. * The layer mask we are rendering the particles through.
  15934. */
  15935. layerMask: number;
  15936. /**
  15937. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15938. */
  15939. updateSpeed: number;
  15940. /**
  15941. * The amount of time the particle system is running (depends of the overall update speed).
  15942. */
  15943. targetStopDuration: number;
  15944. /**
  15945. * The texture used to render each particle. (this can be a spritesheet)
  15946. */
  15947. particleTexture: Nullable<Texture>;
  15948. /**
  15949. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15950. */
  15951. blendMode: number;
  15952. /**
  15953. * Minimum life time of emitting particles.
  15954. */
  15955. minLifeTime: number;
  15956. /**
  15957. * Maximum life time of emitting particles.
  15958. */
  15959. maxLifeTime: number;
  15960. /**
  15961. * Minimum Size of emitting particles.
  15962. */
  15963. minSize: number;
  15964. /**
  15965. * Maximum Size of emitting particles.
  15966. */
  15967. maxSize: number;
  15968. /**
  15969. * Minimum scale of emitting particles on X axis.
  15970. */
  15971. minScaleX: number;
  15972. /**
  15973. * Maximum scale of emitting particles on X axis.
  15974. */
  15975. maxScaleX: number;
  15976. /**
  15977. * Minimum scale of emitting particles on Y axis.
  15978. */
  15979. minScaleY: number;
  15980. /**
  15981. * Maximum scale of emitting particles on Y axis.
  15982. */
  15983. maxScaleY: number;
  15984. /**
  15985. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15986. */
  15987. color1: Color4;
  15988. /**
  15989. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15990. */
  15991. color2: Color4;
  15992. /**
  15993. * Color the particle will have at the end of its lifetime.
  15994. */
  15995. colorDead: Color4;
  15996. /**
  15997. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15998. */
  15999. emitRate: number;
  16000. /**
  16001. * You can use gravity if you want to give an orientation to your particles.
  16002. */
  16003. gravity: Vector3;
  16004. /**
  16005. * Minimum power of emitting particles.
  16006. */
  16007. minEmitPower: number;
  16008. /**
  16009. * Maximum power of emitting particles.
  16010. */
  16011. maxEmitPower: number;
  16012. /**
  16013. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16014. */
  16015. minAngularSpeed: number;
  16016. /**
  16017. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16018. */
  16019. maxAngularSpeed: number;
  16020. /**
  16021. * Gets or sets the minimal initial rotation in radians.
  16022. */
  16023. minInitialRotation: number;
  16024. /**
  16025. * Gets or sets the maximal initial rotation in radians.
  16026. */
  16027. maxInitialRotation: number;
  16028. /**
  16029. * The particle emitter type defines the emitter used by the particle system.
  16030. * It can be for example box, sphere, or cone...
  16031. */
  16032. particleEmitterType: Nullable<IParticleEmitterType>;
  16033. /**
  16034. * Defines the delay in milliseconds before starting the system (0 by default)
  16035. */
  16036. startDelay: number;
  16037. /**
  16038. * 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
  16039. */
  16040. preWarmCycles: number;
  16041. /**
  16042. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16043. */
  16044. preWarmStepOffset: number;
  16045. /**
  16046. * 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)
  16047. */
  16048. spriteCellChangeSpeed: number;
  16049. /**
  16050. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16051. */
  16052. startSpriteCellID: number;
  16053. /**
  16054. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16055. */
  16056. endSpriteCellID: number;
  16057. /**
  16058. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16059. */
  16060. spriteCellWidth: number;
  16061. /**
  16062. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16063. */
  16064. spriteCellHeight: number;
  16065. /**
  16066. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16067. */
  16068. spriteRandomStartCell: boolean;
  16069. /**
  16070. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16071. */
  16072. isAnimationSheetEnabled: boolean;
  16073. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16074. translationPivot: Vector2;
  16075. /**
  16076. * Gets or sets a texture used to add random noise to particle positions
  16077. */
  16078. noiseTexture: Nullable<BaseTexture>;
  16079. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16080. noiseStrength: Vector3;
  16081. /**
  16082. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16083. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16084. */
  16085. billboardMode: number;
  16086. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16087. limitVelocityDamping: number;
  16088. /**
  16089. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16090. */
  16091. beginAnimationOnStart: boolean;
  16092. /**
  16093. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16094. */
  16095. beginAnimationFrom: number;
  16096. /**
  16097. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16098. */
  16099. beginAnimationTo: number;
  16100. /**
  16101. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16102. */
  16103. beginAnimationLoop: boolean;
  16104. /**
  16105. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16106. */
  16107. disposeOnStop: boolean;
  16108. /**
  16109. * Gets the maximum number of particles active at the same time.
  16110. * @returns The max number of active particles.
  16111. */
  16112. getCapacity(): number;
  16113. /**
  16114. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16115. * @returns True if it has been started, otherwise false.
  16116. */
  16117. isStarted(): boolean;
  16118. /**
  16119. * Animates the particle system for this frame.
  16120. */
  16121. animate(): void;
  16122. /**
  16123. * Renders the particle system in its current state.
  16124. * @returns the current number of particles
  16125. */
  16126. render(): number;
  16127. /**
  16128. * Dispose the particle system and frees its associated resources.
  16129. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16130. */
  16131. dispose(disposeTexture?: boolean): void;
  16132. /**
  16133. * Clones the particle system.
  16134. * @param name The name of the cloned object
  16135. * @param newEmitter The new emitter to use
  16136. * @returns the cloned particle system
  16137. */
  16138. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16139. /**
  16140. * Serializes the particle system to a JSON object.
  16141. * @returns the JSON object
  16142. */
  16143. serialize(): any;
  16144. /**
  16145. * Rebuild the particle system
  16146. */
  16147. rebuild(): void;
  16148. /**
  16149. * Starts the particle system and begins to emit
  16150. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16151. */
  16152. start(delay?: number): void;
  16153. /**
  16154. * Stops the particle system.
  16155. */
  16156. stop(): void;
  16157. /**
  16158. * Remove all active particles
  16159. */
  16160. reset(): void;
  16161. /**
  16162. * Is this system ready to be used/rendered
  16163. * @return true if the system is ready
  16164. */
  16165. isReady(): boolean;
  16166. /**
  16167. * Adds a new color gradient
  16168. * @param gradient defines the gradient to use (between 0 and 1)
  16169. * @param color1 defines the color to affect to the specified gradient
  16170. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16171. * @returns the current particle system
  16172. */
  16173. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16174. /**
  16175. * Remove a specific color gradient
  16176. * @param gradient defines the gradient to remove
  16177. * @returns the current particle system
  16178. */
  16179. removeColorGradient(gradient: number): IParticleSystem;
  16180. /**
  16181. * Adds a new size gradient
  16182. * @param gradient defines the gradient to use (between 0 and 1)
  16183. * @param factor defines the size factor to affect to the specified gradient
  16184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16185. * @returns the current particle system
  16186. */
  16187. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16188. /**
  16189. * Remove a specific size gradient
  16190. * @param gradient defines the gradient to remove
  16191. * @returns the current particle system
  16192. */
  16193. removeSizeGradient(gradient: number): IParticleSystem;
  16194. /**
  16195. * Gets the current list of color gradients.
  16196. * You must use addColorGradient and removeColorGradient to udpate this list
  16197. * @returns the list of color gradients
  16198. */
  16199. getColorGradients(): Nullable<Array<ColorGradient>>;
  16200. /**
  16201. * Gets the current list of size gradients.
  16202. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16203. * @returns the list of size gradients
  16204. */
  16205. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16206. /**
  16207. * Gets the current list of angular speed gradients.
  16208. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16209. * @returns the list of angular speed gradients
  16210. */
  16211. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16212. /**
  16213. * Adds a new angular speed gradient
  16214. * @param gradient defines the gradient to use (between 0 and 1)
  16215. * @param factor defines the angular speed to affect to the specified gradient
  16216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16217. * @returns the current particle system
  16218. */
  16219. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16220. /**
  16221. * Remove a specific angular speed gradient
  16222. * @param gradient defines the gradient to remove
  16223. * @returns the current particle system
  16224. */
  16225. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16226. /**
  16227. * Gets the current list of velocity gradients.
  16228. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16229. * @returns the list of velocity gradients
  16230. */
  16231. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16232. /**
  16233. * Adds a new velocity gradient
  16234. * @param gradient defines the gradient to use (between 0 and 1)
  16235. * @param factor defines the velocity to affect to the specified gradient
  16236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16237. * @returns the current particle system
  16238. */
  16239. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16240. /**
  16241. * Remove a specific velocity gradient
  16242. * @param gradient defines the gradient to remove
  16243. * @returns the current particle system
  16244. */
  16245. removeVelocityGradient(gradient: number): IParticleSystem;
  16246. /**
  16247. * Gets the current list of limit velocity gradients.
  16248. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16249. * @returns the list of limit velocity gradients
  16250. */
  16251. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16252. /**
  16253. * Adds a new limit velocity gradient
  16254. * @param gradient defines the gradient to use (between 0 and 1)
  16255. * @param factor defines the limit velocity to affect to the specified gradient
  16256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16257. * @returns the current particle system
  16258. */
  16259. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16260. /**
  16261. * Remove a specific limit velocity gradient
  16262. * @param gradient defines the gradient to remove
  16263. * @returns the current particle system
  16264. */
  16265. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16266. /**
  16267. * Adds a new drag gradient
  16268. * @param gradient defines the gradient to use (between 0 and 1)
  16269. * @param factor defines the drag to affect to the specified gradient
  16270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16271. * @returns the current particle system
  16272. */
  16273. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16274. /**
  16275. * Remove a specific drag gradient
  16276. * @param gradient defines the gradient to remove
  16277. * @returns the current particle system
  16278. */
  16279. removeDragGradient(gradient: number): IParticleSystem;
  16280. /**
  16281. * Gets the current list of drag gradients.
  16282. * You must use addDragGradient and removeDragGradient to udpate this list
  16283. * @returns the list of drag gradients
  16284. */
  16285. getDragGradients(): Nullable<Array<FactorGradient>>;
  16286. /**
  16287. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16288. * @param gradient defines the gradient to use (between 0 and 1)
  16289. * @param factor defines the emit rate to affect to the specified gradient
  16290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16291. * @returns the current particle system
  16292. */
  16293. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16294. /**
  16295. * Remove a specific emit rate gradient
  16296. * @param gradient defines the gradient to remove
  16297. * @returns the current particle system
  16298. */
  16299. removeEmitRateGradient(gradient: number): IParticleSystem;
  16300. /**
  16301. * Gets the current list of emit rate gradients.
  16302. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16303. * @returns the list of emit rate gradients
  16304. */
  16305. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16306. /**
  16307. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16308. * @param gradient defines the gradient to use (between 0 and 1)
  16309. * @param factor defines the start size to affect to the specified gradient
  16310. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16311. * @returns the current particle system
  16312. */
  16313. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16314. /**
  16315. * Remove a specific start size gradient
  16316. * @param gradient defines the gradient to remove
  16317. * @returns the current particle system
  16318. */
  16319. removeStartSizeGradient(gradient: number): IParticleSystem;
  16320. /**
  16321. * Gets the current list of start size gradients.
  16322. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16323. * @returns the list of start size gradients
  16324. */
  16325. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16326. /**
  16327. * Adds a new life time gradient
  16328. * @param gradient defines the gradient to use (between 0 and 1)
  16329. * @param factor defines the life time factor to affect to the specified gradient
  16330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16331. * @returns the current particle system
  16332. */
  16333. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16334. /**
  16335. * Remove a specific life time gradient
  16336. * @param gradient defines the gradient to remove
  16337. * @returns the current particle system
  16338. */
  16339. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16340. /**
  16341. * Gets the current list of life time gradients.
  16342. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16343. * @returns the list of life time gradients
  16344. */
  16345. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16346. /**
  16347. * Gets the current list of color gradients.
  16348. * You must use addColorGradient and removeColorGradient to udpate this list
  16349. * @returns the list of color gradients
  16350. */
  16351. getColorGradients(): Nullable<Array<ColorGradient>>;
  16352. /**
  16353. * Adds a new ramp gradient used to remap particle colors
  16354. * @param gradient defines the gradient to use (between 0 and 1)
  16355. * @param color defines the color to affect to the specified gradient
  16356. * @returns the current particle system
  16357. */
  16358. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16359. /**
  16360. * Gets the current list of ramp gradients.
  16361. * You must use addRampGradient and removeRampGradient to udpate this list
  16362. * @returns the list of ramp gradients
  16363. */
  16364. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16365. /** Gets or sets a boolean indicating that ramp gradients must be used
  16366. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16367. */
  16368. useRampGradients: boolean;
  16369. /**
  16370. * Adds a new color remap gradient
  16371. * @param gradient defines the gradient to use (between 0 and 1)
  16372. * @param min defines the color remap minimal range
  16373. * @param max defines the color remap maximal range
  16374. * @returns the current particle system
  16375. */
  16376. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16377. /**
  16378. * Gets the current list of color remap gradients.
  16379. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16380. * @returns the list of color remap gradients
  16381. */
  16382. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16383. /**
  16384. * Adds a new alpha remap gradient
  16385. * @param gradient defines the gradient to use (between 0 and 1)
  16386. * @param min defines the alpha remap minimal range
  16387. * @param max defines the alpha remap maximal range
  16388. * @returns the current particle system
  16389. */
  16390. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16391. /**
  16392. * Gets the current list of alpha remap gradients.
  16393. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16394. * @returns the list of alpha remap gradients
  16395. */
  16396. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16397. /**
  16398. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16399. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16400. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16401. * @returns the emitter
  16402. */
  16403. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16404. /**
  16405. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16406. * @param radius The radius of the hemisphere to emit from
  16407. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16408. * @returns the emitter
  16409. */
  16410. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16411. /**
  16412. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16413. * @param radius The radius of the sphere to emit from
  16414. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16415. * @returns the emitter
  16416. */
  16417. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16418. /**
  16419. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16420. * @param radius The radius of the sphere to emit from
  16421. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16422. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16423. * @returns the emitter
  16424. */
  16425. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16426. /**
  16427. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16428. * @param radius The radius of the emission cylinder
  16429. * @param height The height of the emission cylinder
  16430. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16431. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16432. * @returns the emitter
  16433. */
  16434. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16435. /**
  16436. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16437. * @param radius The radius of the cylinder to emit from
  16438. * @param height The height of the emission cylinder
  16439. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16440. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16441. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16442. * @returns the emitter
  16443. */
  16444. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16445. /**
  16446. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16447. * @param radius The radius of the cone to emit from
  16448. * @param angle The base angle of the cone
  16449. * @returns the emitter
  16450. */
  16451. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16452. /**
  16453. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16454. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16455. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16456. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16457. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16458. * @returns the emitter
  16459. */
  16460. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16461. /**
  16462. * Get hosting scene
  16463. * @returns the scene
  16464. */
  16465. getScene(): Scene;
  16466. }
  16467. }
  16468. declare module BABYLON {
  16469. /**
  16470. * Creates an instance based on a source mesh.
  16471. */
  16472. export class InstancedMesh extends AbstractMesh {
  16473. private _sourceMesh;
  16474. private _currentLOD;
  16475. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16476. constructor(name: string, source: Mesh);
  16477. /**
  16478. * Returns the string "InstancedMesh".
  16479. */
  16480. getClassName(): string;
  16481. /** Gets the list of lights affecting that mesh */
  16482. readonly lightSources: Light[]; resyncLightSources(): void; resyncLighSource(light: Light): void; removeLightSource(light: Light): void;
  16483. /**
  16484. * If the source mesh receives shadows
  16485. */
  16486. readonly receiveShadows: boolean;
  16487. /**
  16488. * The material of the source mesh
  16489. */
  16490. readonly material: Nullable<Material>;
  16491. /**
  16492. * Visibility of the source mesh
  16493. */
  16494. readonly visibility: number;
  16495. /**
  16496. * Skeleton of the source mesh
  16497. */
  16498. readonly skeleton: Nullable<Skeleton>;
  16499. /**
  16500. * Rendering ground id of the source mesh
  16501. */
  16502. renderingGroupId: number;
  16503. /**
  16504. * Returns the total number of vertices (integer).
  16505. */
  16506. getTotalVertices(): number;
  16507. /**
  16508. * Returns a positive integer : the total number of indices in this mesh geometry.
  16509. * @returns the numner of indices or zero if the mesh has no geometry.
  16510. */
  16511. getTotalIndices(): number;
  16512. /**
  16513. * The source mesh of the instance
  16514. */
  16515. readonly sourceMesh: Mesh;
  16516. /**
  16517. * Is this node ready to be used/rendered
  16518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16519. * @return {boolean} is it ready
  16520. */
  16521. isReady(completeCheck?: boolean): boolean;
  16522. /**
  16523. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16524. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16525. * @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.
  16526. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16527. */
  16528. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16529. /**
  16530. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16531. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16532. * The `data` are either a numeric array either a Float32Array.
  16533. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16534. * 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).
  16535. * Note that a new underlying VertexBuffer object is created each call.
  16536. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16537. *
  16538. * Possible `kind` values :
  16539. * - VertexBuffer.PositionKind
  16540. * - VertexBuffer.UVKind
  16541. * - VertexBuffer.UV2Kind
  16542. * - VertexBuffer.UV3Kind
  16543. * - VertexBuffer.UV4Kind
  16544. * - VertexBuffer.UV5Kind
  16545. * - VertexBuffer.UV6Kind
  16546. * - VertexBuffer.ColorKind
  16547. * - VertexBuffer.MatricesIndicesKind
  16548. * - VertexBuffer.MatricesIndicesExtraKind
  16549. * - VertexBuffer.MatricesWeightsKind
  16550. * - VertexBuffer.MatricesWeightsExtraKind
  16551. *
  16552. * Returns the Mesh.
  16553. */
  16554. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16555. /**
  16556. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16557. * If the mesh has no geometry, it is simply returned as it is.
  16558. * The `data` are either a numeric array either a Float32Array.
  16559. * No new underlying VertexBuffer object is created.
  16560. * 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.
  16561. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16562. *
  16563. * Possible `kind` values :
  16564. * - VertexBuffer.PositionKind
  16565. * - VertexBuffer.UVKind
  16566. * - VertexBuffer.UV2Kind
  16567. * - VertexBuffer.UV3Kind
  16568. * - VertexBuffer.UV4Kind
  16569. * - VertexBuffer.UV5Kind
  16570. * - VertexBuffer.UV6Kind
  16571. * - VertexBuffer.ColorKind
  16572. * - VertexBuffer.MatricesIndicesKind
  16573. * - VertexBuffer.MatricesIndicesExtraKind
  16574. * - VertexBuffer.MatricesWeightsKind
  16575. * - VertexBuffer.MatricesWeightsExtraKind
  16576. *
  16577. * Returns the Mesh.
  16578. */
  16579. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16580. /**
  16581. * Sets the mesh indices.
  16582. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16583. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16584. * This method creates a new index buffer each call.
  16585. * Returns the Mesh.
  16586. */
  16587. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16588. /**
  16589. * Boolean : True if the mesh owns the requested kind of data.
  16590. */
  16591. isVerticesDataPresent(kind: string): boolean;
  16592. /**
  16593. * Returns an array of indices (IndicesArray).
  16594. */
  16595. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16596. /**
  16597. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16598. * This means the mesh underlying bounding box and sphere are recomputed.
  16599. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16600. * @returns the current mesh
  16601. */
  16602. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16603. /** @hidden */ preActivate(): InstancedMesh;
  16604. /** @hidden */ activate(renderId: number): boolean;
  16605. /** @hidden */ postActivate(): void;
  16606. getWorldMatrix(): Matrix;
  16607. readonly isAnInstance: boolean;
  16608. /**
  16609. * Returns the current associated LOD AbstractMesh.
  16610. */
  16611. getLOD(camera: Camera): AbstractMesh;
  16612. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16613. /** @hidden */ generatePointsArray(): boolean;
  16614. /**
  16615. * Creates a new InstancedMesh from the current mesh.
  16616. * - name (string) : the cloned mesh name
  16617. * - newParent (optional Node) : the optional Node to parent the clone to.
  16618. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16619. *
  16620. * Returns the clone.
  16621. */
  16622. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16623. /**
  16624. * Disposes the InstancedMesh.
  16625. * Returns nothing.
  16626. */
  16627. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16628. }
  16629. }
  16630. declare module BABYLON {
  16631. /**
  16632. * Defines the options associated with the creation of a shader material.
  16633. */
  16634. export interface IShaderMaterialOptions {
  16635. /**
  16636. * Does the material work in alpha blend mode
  16637. */
  16638. needAlphaBlending: boolean;
  16639. /**
  16640. * Does the material work in alpha test mode
  16641. */
  16642. needAlphaTesting: boolean;
  16643. /**
  16644. * The list of attribute names used in the shader
  16645. */
  16646. attributes: string[];
  16647. /**
  16648. * The list of unifrom names used in the shader
  16649. */
  16650. uniforms: string[];
  16651. /**
  16652. * The list of UBO names used in the shader
  16653. */
  16654. uniformBuffers: string[];
  16655. /**
  16656. * The list of sampler names used in the shader
  16657. */
  16658. samplers: string[];
  16659. /**
  16660. * The list of defines used in the shader
  16661. */
  16662. defines: string[];
  16663. }
  16664. /**
  16665. * 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.
  16666. *
  16667. * This returned material effects how the mesh will look based on the code in the shaders.
  16668. *
  16669. * @see http://doc.babylonjs.com/how_to/shader_material
  16670. */
  16671. export class ShaderMaterial extends Material {
  16672. private _shaderPath;
  16673. private _options;
  16674. private _textures;
  16675. private _textureArrays;
  16676. private _floats;
  16677. private _ints;
  16678. private _floatsArrays;
  16679. private _colors3;
  16680. private _colors3Arrays;
  16681. private _colors4;
  16682. private _vectors2;
  16683. private _vectors3;
  16684. private _vectors4;
  16685. private _matrices;
  16686. private _matrices3x3;
  16687. private _matrices2x2;
  16688. private _vectors2Arrays;
  16689. private _vectors3Arrays;
  16690. private _cachedWorldViewMatrix;
  16691. private _renderId;
  16692. /**
  16693. * Instantiate a new shader material.
  16694. * 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.
  16695. * This returned material effects how the mesh will look based on the code in the shaders.
  16696. * @see http://doc.babylonjs.com/how_to/shader_material
  16697. * @param name Define the name of the material in the scene
  16698. * @param scene Define the scene the material belongs to
  16699. * @param shaderPath Defines the route to the shader code in one of three ways:
  16700. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16701. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16702. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16703. * @param options Define the options used to create the shader
  16704. */
  16705. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16706. /**
  16707. * Gets the options used to compile the shader.
  16708. * They can be modified to trigger a new compilation
  16709. */
  16710. readonly options: IShaderMaterialOptions;
  16711. /**
  16712. * Gets the current class name of the material e.g. "ShaderMaterial"
  16713. * Mainly use in serialization.
  16714. * @returns the class name
  16715. */
  16716. getClassName(): string;
  16717. /**
  16718. * Specifies if the material will require alpha blending
  16719. * @returns a boolean specifying if alpha blending is needed
  16720. */
  16721. needAlphaBlending(): boolean;
  16722. /**
  16723. * Specifies if this material should be rendered in alpha test mode
  16724. * @returns a boolean specifying if an alpha test is needed.
  16725. */
  16726. needAlphaTesting(): boolean;
  16727. private _checkUniform;
  16728. /**
  16729. * Set a texture in the shader.
  16730. * @param name Define the name of the uniform samplers as defined in the shader
  16731. * @param texture Define the texture to bind to this sampler
  16732. * @return the material itself allowing "fluent" like uniform updates
  16733. */
  16734. setTexture(name: string, texture: Texture): ShaderMaterial;
  16735. /**
  16736. * Set a texture array in the shader.
  16737. * @param name Define the name of the uniform sampler array as defined in the shader
  16738. * @param textures Define the list of textures to bind to this sampler
  16739. * @return the material itself allowing "fluent" like uniform updates
  16740. */
  16741. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16742. /**
  16743. * Set a float in the shader.
  16744. * @param name Define the name of the uniform as defined in the shader
  16745. * @param value Define the value to give to the uniform
  16746. * @return the material itself allowing "fluent" like uniform updates
  16747. */
  16748. setFloat(name: string, value: number): ShaderMaterial;
  16749. /**
  16750. * Set a int in the shader.
  16751. * @param name Define the name of the uniform as defined in the shader
  16752. * @param value Define the value to give to the uniform
  16753. * @return the material itself allowing "fluent" like uniform updates
  16754. */
  16755. setInt(name: string, value: number): ShaderMaterial;
  16756. /**
  16757. * Set an array of floats in the shader.
  16758. * @param name Define the name of the uniform as defined in the shader
  16759. * @param value Define the value to give to the uniform
  16760. * @return the material itself allowing "fluent" like uniform updates
  16761. */
  16762. setFloats(name: string, value: number[]): ShaderMaterial;
  16763. /**
  16764. * Set a vec3 in the shader from a Color3.
  16765. * @param name Define the name of the uniform as defined in the shader
  16766. * @param value Define the value to give to the uniform
  16767. * @return the material itself allowing "fluent" like uniform updates
  16768. */
  16769. setColor3(name: string, value: Color3): ShaderMaterial;
  16770. /**
  16771. * Set a vec3 array in the shader from a Color3 array.
  16772. * @param name Define the name of the uniform as defined in the shader
  16773. * @param value Define the value to give to the uniform
  16774. * @return the material itself allowing "fluent" like uniform updates
  16775. */
  16776. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16777. /**
  16778. * Set a vec4 in the shader from a Color4.
  16779. * @param name Define the name of the uniform as defined in the shader
  16780. * @param value Define the value to give to the uniform
  16781. * @return the material itself allowing "fluent" like uniform updates
  16782. */
  16783. setColor4(name: string, value: Color4): ShaderMaterial;
  16784. /**
  16785. * Set a vec2 in the shader from a Vector2.
  16786. * @param name Define the name of the uniform as defined in the shader
  16787. * @param value Define the value to give to the uniform
  16788. * @return the material itself allowing "fluent" like uniform updates
  16789. */
  16790. setVector2(name: string, value: Vector2): ShaderMaterial;
  16791. /**
  16792. * Set a vec3 in the shader from a Vector3.
  16793. * @param name Define the name of the uniform as defined in the shader
  16794. * @param value Define the value to give to the uniform
  16795. * @return the material itself allowing "fluent" like uniform updates
  16796. */
  16797. setVector3(name: string, value: Vector3): ShaderMaterial;
  16798. /**
  16799. * Set a vec4 in the shader from a Vector4.
  16800. * @param name Define the name of the uniform as defined in the shader
  16801. * @param value Define the value to give to the uniform
  16802. * @return the material itself allowing "fluent" like uniform updates
  16803. */
  16804. setVector4(name: string, value: Vector4): ShaderMaterial;
  16805. /**
  16806. * Set a mat4 in the shader from a Matrix.
  16807. * @param name Define the name of the uniform as defined in the shader
  16808. * @param value Define the value to give to the uniform
  16809. * @return the material itself allowing "fluent" like uniform updates
  16810. */
  16811. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16812. /**
  16813. * Set a mat3 in the shader from a Float32Array.
  16814. * @param name Define the name of the uniform as defined in the shader
  16815. * @param value Define the value to give to the uniform
  16816. * @return the material itself allowing "fluent" like uniform updates
  16817. */
  16818. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16819. /**
  16820. * Set a mat2 in the shader from a Float32Array.
  16821. * @param name Define the name of the uniform as defined in the shader
  16822. * @param value Define the value to give to the uniform
  16823. * @return the material itself allowing "fluent" like uniform updates
  16824. */
  16825. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16826. /**
  16827. * Set a vec2 array in the shader from a number array.
  16828. * @param name Define the name of the uniform as defined in the shader
  16829. * @param value Define the value to give to the uniform
  16830. * @return the material itself allowing "fluent" like uniform updates
  16831. */
  16832. setArray2(name: string, value: number[]): ShaderMaterial;
  16833. /**
  16834. * Set a vec3 array in the shader from a number array.
  16835. * @param name Define the name of the uniform as defined in the shader
  16836. * @param value Define the value to give to the uniform
  16837. * @return the material itself allowing "fluent" like uniform updates
  16838. */
  16839. setArray3(name: string, value: number[]): ShaderMaterial;
  16840. private _checkCache;
  16841. /**
  16842. * Specifies that the submesh is ready to be used
  16843. * @param mesh defines the mesh to check
  16844. * @param subMesh defines which submesh to check
  16845. * @param useInstances specifies that instances should be used
  16846. * @returns a boolean indicating that the submesh is ready or not
  16847. */
  16848. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16849. /**
  16850. * Checks if the material is ready to render the requested mesh
  16851. * @param mesh Define the mesh to render
  16852. * @param useInstances Define whether or not the material is used with instances
  16853. * @returns true if ready, otherwise false
  16854. */
  16855. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16856. /**
  16857. * Binds the world matrix to the material
  16858. * @param world defines the world transformation matrix
  16859. */
  16860. bindOnlyWorldMatrix(world: Matrix): void;
  16861. /**
  16862. * Binds the material to the mesh
  16863. * @param world defines the world transformation matrix
  16864. * @param mesh defines the mesh to bind the material to
  16865. */
  16866. bind(world: Matrix, mesh?: Mesh): void;
  16867. /**
  16868. * Gets the active textures from the material
  16869. * @returns an array of textures
  16870. */
  16871. getActiveTextures(): BaseTexture[];
  16872. /**
  16873. * Specifies if the material uses a texture
  16874. * @param texture defines the texture to check against the material
  16875. * @returns a boolean specifying if the material uses the texture
  16876. */
  16877. hasTexture(texture: BaseTexture): boolean;
  16878. /**
  16879. * Makes a duplicate of the material, and gives it a new name
  16880. * @param name defines the new name for the duplicated material
  16881. * @returns the cloned material
  16882. */
  16883. clone(name: string): ShaderMaterial;
  16884. /**
  16885. * Disposes the material
  16886. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16887. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16888. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16889. */
  16890. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16891. /**
  16892. * Serializes this material in a JSON representation
  16893. * @returns the serialized material object
  16894. */
  16895. serialize(): any;
  16896. /**
  16897. * Creates a shader material from parsed shader material data
  16898. * @param source defines the JSON represnetation of the material
  16899. * @param scene defines the hosting scene
  16900. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16901. * @returns a new material
  16902. */
  16903. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16904. }
  16905. }
  16906. declare module BABYLON {
  16907. /** @hidden */
  16908. export var colorPixelShader: {
  16909. name: string;
  16910. shader: string;
  16911. };
  16912. }
  16913. declare module BABYLON {
  16914. /** @hidden */
  16915. export var colorVertexShader: {
  16916. name: string;
  16917. shader: string;
  16918. };
  16919. }
  16920. declare module BABYLON {
  16921. /**
  16922. * Line mesh
  16923. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16924. */
  16925. export class LinesMesh extends Mesh {
  16926. /**
  16927. * If vertex color should be applied to the mesh
  16928. */
  16929. useVertexColor?: boolean | undefined;
  16930. /**
  16931. * If vertex alpha should be applied to the mesh
  16932. */
  16933. useVertexAlpha?: boolean | undefined;
  16934. /**
  16935. * Color of the line (Default: White)
  16936. */
  16937. color: Color3;
  16938. /**
  16939. * Alpha of the line (Default: 1)
  16940. */
  16941. alpha: number;
  16942. /**
  16943. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16944. * This margin is expressed in world space coordinates, so its value may vary.
  16945. * Default value is 0.1
  16946. */
  16947. intersectionThreshold: number;
  16948. private _colorShader;
  16949. /**
  16950. * Creates a new LinesMesh
  16951. * @param name defines the name
  16952. * @param scene defines the hosting scene
  16953. * @param parent defines the parent mesh if any
  16954. * @param source defines the optional source LinesMesh used to clone data from
  16955. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16956. * When false, achieved by calling a clone(), also passing False.
  16957. * This will make creation of children, recursive.
  16958. * @param useVertexColor defines if this LinesMesh supports vertex color
  16959. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16960. */
  16961. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16962. /**
  16963. * If vertex color should be applied to the mesh
  16964. */
  16965. useVertexColor?: boolean | undefined,
  16966. /**
  16967. * If vertex alpha should be applied to the mesh
  16968. */
  16969. useVertexAlpha?: boolean | undefined);
  16970. private _addClipPlaneDefine;
  16971. private _removeClipPlaneDefine;
  16972. isReady(): boolean;
  16973. /**
  16974. * Returns the string "LineMesh"
  16975. */
  16976. getClassName(): string;
  16977. /**
  16978. * @hidden
  16979. */
  16980. /**
  16981. * @hidden
  16982. */
  16983. material: Material;
  16984. /**
  16985. * @hidden
  16986. */
  16987. readonly checkCollisions: boolean;
  16988. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16989. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16990. /**
  16991. * Disposes of the line mesh
  16992. * @param doNotRecurse If children should be disposed
  16993. */
  16994. dispose(doNotRecurse?: boolean): void;
  16995. /**
  16996. * Returns a new LineMesh object cloned from the current one.
  16997. */
  16998. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16999. /**
  17000. * Creates a new InstancedLinesMesh object from the mesh model.
  17001. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17002. * @param name defines the name of the new instance
  17003. * @returns a new InstancedLinesMesh
  17004. */
  17005. createInstance(name: string): InstancedLinesMesh;
  17006. }
  17007. /**
  17008. * Creates an instance based on a source LinesMesh
  17009. */
  17010. export class InstancedLinesMesh extends InstancedMesh {
  17011. /**
  17012. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17013. * This margin is expressed in world space coordinates, so its value may vary.
  17014. * Initilized with the intersectionThreshold value of the source LinesMesh
  17015. */
  17016. intersectionThreshold: number;
  17017. constructor(name: string, source: LinesMesh);
  17018. /**
  17019. * Returns the string "InstancedLinesMesh".
  17020. */
  17021. getClassName(): string;
  17022. }
  17023. }
  17024. declare module BABYLON {
  17025. /** @hidden */
  17026. export var linePixelShader: {
  17027. name: string;
  17028. shader: string;
  17029. };
  17030. }
  17031. declare module BABYLON {
  17032. /** @hidden */
  17033. export var lineVertexShader: {
  17034. name: string;
  17035. shader: string;
  17036. };
  17037. }
  17038. declare module BABYLON {
  17039. interface AbstractMesh {
  17040. /**
  17041. * Disables the mesh edge rendering mode
  17042. * @returns the currentAbstractMesh
  17043. */
  17044. disableEdgesRendering(): AbstractMesh;
  17045. /**
  17046. * Enables the edge rendering mode on the mesh.
  17047. * This mode makes the mesh edges visible
  17048. * @param epsilon defines the maximal distance between two angles to detect a face
  17049. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17050. * @returns the currentAbstractMesh
  17051. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17052. */
  17053. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17054. /**
  17055. * Gets the edgesRenderer associated with the mesh
  17056. */
  17057. edgesRenderer: Nullable<EdgesRenderer>;
  17058. }
  17059. interface LinesMesh {
  17060. /**
  17061. * Enables the edge rendering mode on the mesh.
  17062. * This mode makes the mesh edges visible
  17063. * @param epsilon defines the maximal distance between two angles to detect a face
  17064. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17065. * @returns the currentAbstractMesh
  17066. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17067. */
  17068. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17069. }
  17070. interface InstancedLinesMesh {
  17071. /**
  17072. * Enables the edge rendering mode on the mesh.
  17073. * This mode makes the mesh edges visible
  17074. * @param epsilon defines the maximal distance between two angles to detect a face
  17075. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17076. * @returns the current InstancedLinesMesh
  17077. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17078. */
  17079. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17080. }
  17081. /**
  17082. * Defines the minimum contract an Edges renderer should follow.
  17083. */
  17084. export interface IEdgesRenderer extends IDisposable {
  17085. /**
  17086. * Gets or sets a boolean indicating if the edgesRenderer is active
  17087. */
  17088. isEnabled: boolean;
  17089. /**
  17090. * Renders the edges of the attached mesh,
  17091. */
  17092. render(): void;
  17093. /**
  17094. * Checks wether or not the edges renderer is ready to render.
  17095. * @return true if ready, otherwise false.
  17096. */
  17097. isReady(): boolean;
  17098. }
  17099. /**
  17100. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17101. */
  17102. export class EdgesRenderer implements IEdgesRenderer {
  17103. /**
  17104. * Define the size of the edges with an orthographic camera
  17105. */
  17106. edgesWidthScalerForOrthographic: number;
  17107. /**
  17108. * Define the size of the edges with a perspective camera
  17109. */
  17110. edgesWidthScalerForPerspective: number;
  17111. protected _source: AbstractMesh;
  17112. protected _linesPositions: number[];
  17113. protected _linesNormals: number[];
  17114. protected _linesIndices: number[];
  17115. protected _epsilon: number;
  17116. protected _indicesCount: number;
  17117. protected _lineShader: ShaderMaterial;
  17118. protected _ib: DataBuffer;
  17119. protected _buffers: {
  17120. [key: string]: Nullable<VertexBuffer>;
  17121. };
  17122. protected _checkVerticesInsteadOfIndices: boolean;
  17123. private _meshRebuildObserver;
  17124. private _meshDisposeObserver;
  17125. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17126. isEnabled: boolean;
  17127. /**
  17128. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17129. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17130. * @param source Mesh used to create edges
  17131. * @param epsilon sum of angles in adjacency to check for edge
  17132. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17133. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17134. */
  17135. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17136. protected _prepareRessources(): void;
  17137. /** @hidden */ rebuild(): void;
  17138. /**
  17139. * Releases the required resources for the edges renderer
  17140. */
  17141. dispose(): void;
  17142. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17143. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17144. /**
  17145. * Checks if the pair of p0 and p1 is en edge
  17146. * @param faceIndex
  17147. * @param edge
  17148. * @param faceNormals
  17149. * @param p0
  17150. * @param p1
  17151. * @private
  17152. */
  17153. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17154. /**
  17155. * push line into the position, normal and index buffer
  17156. * @protected
  17157. */
  17158. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17159. /**
  17160. * Generates lines edges from adjacencjes
  17161. * @private
  17162. */ generateEdgesLines(): void;
  17163. /**
  17164. * Checks wether or not the edges renderer is ready to render.
  17165. * @return true if ready, otherwise false.
  17166. */
  17167. isReady(): boolean;
  17168. /**
  17169. * Renders the edges of the attached mesh,
  17170. */
  17171. render(): void;
  17172. }
  17173. /**
  17174. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17175. */
  17176. export class LineEdgesRenderer extends EdgesRenderer {
  17177. /**
  17178. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17179. * @param source LineMesh used to generate edges
  17180. * @param epsilon not important (specified angle for edge detection)
  17181. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17182. */
  17183. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17184. /**
  17185. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17186. */ generateEdgesLines(): void;
  17187. }
  17188. }
  17189. declare module BABYLON {
  17190. /**
  17191. * This represents the object necessary to create a rendering group.
  17192. * This is exclusively used and created by the rendering manager.
  17193. * To modify the behavior, you use the available helpers in your scene or meshes.
  17194. * @hidden
  17195. */
  17196. export class RenderingGroup {
  17197. index: number;
  17198. private _scene;
  17199. private _opaqueSubMeshes;
  17200. private _transparentSubMeshes;
  17201. private _alphaTestSubMeshes;
  17202. private _depthOnlySubMeshes;
  17203. private _particleSystems;
  17204. private _spriteManagers;
  17205. private _opaqueSortCompareFn;
  17206. private _alphaTestSortCompareFn;
  17207. private _transparentSortCompareFn;
  17208. private _renderOpaque;
  17209. private _renderAlphaTest;
  17210. private _renderTransparent;
  17211. /** @hidden */ edgesRenderers: SmartArray<IEdgesRenderer>;
  17212. onBeforeTransparentRendering: () => void;
  17213. /**
  17214. * Set the opaque sort comparison function.
  17215. * If null the sub meshes will be render in the order they were created
  17216. */
  17217. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17218. /**
  17219. * Set the alpha test sort comparison function.
  17220. * If null the sub meshes will be render in the order they were created
  17221. */
  17222. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17223. /**
  17224. * Set the transparent sort comparison function.
  17225. * If null the sub meshes will be render in the order they were created
  17226. */
  17227. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17228. /**
  17229. * Creates a new rendering group.
  17230. * @param index The rendering group index
  17231. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17232. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17233. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17234. */
  17235. 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>);
  17236. /**
  17237. * Render all the sub meshes contained in the group.
  17238. * @param customRenderFunction Used to override the default render behaviour of the group.
  17239. * @returns true if rendered some submeshes.
  17240. */
  17241. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17242. /**
  17243. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17244. * @param subMeshes The submeshes to render
  17245. */
  17246. private renderOpaqueSorted;
  17247. /**
  17248. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17249. * @param subMeshes The submeshes to render
  17250. */
  17251. private renderAlphaTestSorted;
  17252. /**
  17253. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17254. * @param subMeshes The submeshes to render
  17255. */
  17256. private renderTransparentSorted;
  17257. /**
  17258. * Renders the submeshes in a specified order.
  17259. * @param subMeshes The submeshes to sort before render
  17260. * @param sortCompareFn The comparison function use to sort
  17261. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17262. * @param transparent Specifies to activate blending if true
  17263. */
  17264. private static renderSorted;
  17265. /**
  17266. * Renders the submeshes in the order they were dispatched (no sort applied).
  17267. * @param subMeshes The submeshes to render
  17268. */
  17269. private static renderUnsorted;
  17270. /**
  17271. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17272. * are rendered back to front if in the same alpha index.
  17273. *
  17274. * @param a The first submesh
  17275. * @param b The second submesh
  17276. * @returns The result of the comparison
  17277. */
  17278. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17279. /**
  17280. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17281. * are rendered back to front.
  17282. *
  17283. * @param a The first submesh
  17284. * @param b The second submesh
  17285. * @returns The result of the comparison
  17286. */
  17287. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17288. /**
  17289. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17290. * are rendered front to back (prevent overdraw).
  17291. *
  17292. * @param a The first submesh
  17293. * @param b The second submesh
  17294. * @returns The result of the comparison
  17295. */
  17296. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17297. /**
  17298. * Resets the different lists of submeshes to prepare a new frame.
  17299. */
  17300. prepare(): void;
  17301. dispose(): void;
  17302. /**
  17303. * Inserts the submesh in its correct queue depending on its material.
  17304. * @param subMesh The submesh to dispatch
  17305. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17306. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17307. */
  17308. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17309. dispatchSprites(spriteManager: ISpriteManager): void;
  17310. dispatchParticles(particleSystem: IParticleSystem): void;
  17311. private _renderParticles;
  17312. private _renderSprites;
  17313. }
  17314. }
  17315. declare module BABYLON {
  17316. /**
  17317. * Interface describing the different options available in the rendering manager
  17318. * regarding Auto Clear between groups.
  17319. */
  17320. export interface IRenderingManagerAutoClearSetup {
  17321. /**
  17322. * Defines whether or not autoclear is enable.
  17323. */
  17324. autoClear: boolean;
  17325. /**
  17326. * Defines whether or not to autoclear the depth buffer.
  17327. */
  17328. depth: boolean;
  17329. /**
  17330. * Defines whether or not to autoclear the stencil buffer.
  17331. */
  17332. stencil: boolean;
  17333. }
  17334. /**
  17335. * This class is used by the onRenderingGroupObservable
  17336. */
  17337. export class RenderingGroupInfo {
  17338. /**
  17339. * The Scene that being rendered
  17340. */
  17341. scene: Scene;
  17342. /**
  17343. * The camera currently used for the rendering pass
  17344. */
  17345. camera: Nullable<Camera>;
  17346. /**
  17347. * The ID of the renderingGroup being processed
  17348. */
  17349. renderingGroupId: number;
  17350. }
  17351. /**
  17352. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17353. * It is enable to manage the different groups as well as the different necessary sort functions.
  17354. * This should not be used directly aside of the few static configurations
  17355. */
  17356. export class RenderingManager {
  17357. /**
  17358. * The max id used for rendering groups (not included)
  17359. */
  17360. static MAX_RENDERINGGROUPS: number;
  17361. /**
  17362. * The min id used for rendering groups (included)
  17363. */
  17364. static MIN_RENDERINGGROUPS: number;
  17365. /**
  17366. * Used to globally prevent autoclearing scenes.
  17367. */
  17368. static AUTOCLEAR: boolean;
  17369. /**
  17370. * @hidden
  17371. */ useSceneAutoClearSetup: boolean;
  17372. private _scene;
  17373. private _renderingGroups;
  17374. private _depthStencilBufferAlreadyCleaned;
  17375. private _autoClearDepthStencil;
  17376. private _customOpaqueSortCompareFn;
  17377. private _customAlphaTestSortCompareFn;
  17378. private _customTransparentSortCompareFn;
  17379. private _renderingGroupInfo;
  17380. /**
  17381. * Instantiates a new rendering group for a particular scene
  17382. * @param scene Defines the scene the groups belongs to
  17383. */
  17384. constructor(scene: Scene);
  17385. private _clearDepthStencilBuffer;
  17386. /**
  17387. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17388. * @hidden
  17389. */
  17390. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17391. /**
  17392. * Resets the different information of the group to prepare a new frame
  17393. * @hidden
  17394. */
  17395. reset(): void;
  17396. /**
  17397. * Dispose and release the group and its associated resources.
  17398. * @hidden
  17399. */
  17400. dispose(): void;
  17401. /**
  17402. * Clear the info related to rendering groups preventing retention points during dispose.
  17403. */
  17404. freeRenderingGroups(): void;
  17405. private _prepareRenderingGroup;
  17406. /**
  17407. * Add a sprite manager to the rendering manager in order to render it this frame.
  17408. * @param spriteManager Define the sprite manager to render
  17409. */
  17410. dispatchSprites(spriteManager: ISpriteManager): void;
  17411. /**
  17412. * Add a particle system to the rendering manager in order to render it this frame.
  17413. * @param particleSystem Define the particle system to render
  17414. */
  17415. dispatchParticles(particleSystem: IParticleSystem): void;
  17416. /**
  17417. * Add a submesh to the manager in order to render it this frame
  17418. * @param subMesh The submesh to dispatch
  17419. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17420. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17421. */
  17422. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17423. /**
  17424. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17425. * This allowed control for front to back rendering or reversly depending of the special needs.
  17426. *
  17427. * @param renderingGroupId The rendering group id corresponding to its index
  17428. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17429. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17430. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17431. */
  17432. 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;
  17433. /**
  17434. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17435. *
  17436. * @param renderingGroupId The rendering group id corresponding to its index
  17437. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17438. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17439. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17440. */
  17441. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17442. /**
  17443. * Gets the current auto clear configuration for one rendering group of the rendering
  17444. * manager.
  17445. * @param index the rendering group index to get the information for
  17446. * @returns The auto clear setup for the requested rendering group
  17447. */
  17448. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17449. }
  17450. }
  17451. declare module BABYLON {
  17452. /**
  17453. * This Helps creating a texture that will be created from a camera in your scene.
  17454. * It is basically a dynamic texture that could be used to create special effects for instance.
  17455. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17456. */
  17457. export class RenderTargetTexture extends Texture {
  17458. isCube: boolean;
  17459. /**
  17460. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17461. */
  17462. static readonly REFRESHRATE_RENDER_ONCE: number;
  17463. /**
  17464. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17465. */
  17466. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17467. /**
  17468. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17469. * the central point of your effect and can save a lot of performances.
  17470. */
  17471. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17472. /**
  17473. * Use this predicate to dynamically define the list of mesh you want to render.
  17474. * If set, the renderList property will be overwritten.
  17475. */
  17476. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17477. private _renderList;
  17478. /**
  17479. * Use this list to define the list of mesh you want to render.
  17480. */
  17481. renderList: Nullable<Array<AbstractMesh>>;
  17482. private _hookArray;
  17483. /**
  17484. * Define if particles should be rendered in your texture.
  17485. */
  17486. renderParticles: boolean;
  17487. /**
  17488. * Define if sprites should be rendered in your texture.
  17489. */
  17490. renderSprites: boolean;
  17491. /**
  17492. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17493. */
  17494. coordinatesMode: number;
  17495. /**
  17496. * Define the camera used to render the texture.
  17497. */
  17498. activeCamera: Nullable<Camera>;
  17499. /**
  17500. * Override the render function of the texture with your own one.
  17501. */
  17502. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17503. /**
  17504. * Define if camera post processes should be use while rendering the texture.
  17505. */
  17506. useCameraPostProcesses: boolean;
  17507. /**
  17508. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17509. */
  17510. ignoreCameraViewport: boolean;
  17511. private _postProcessManager;
  17512. private _postProcesses;
  17513. private _resizeObserver;
  17514. /**
  17515. * An event triggered when the texture is unbind.
  17516. */
  17517. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17518. /**
  17519. * An event triggered when the texture is unbind.
  17520. */
  17521. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17522. private _onAfterUnbindObserver;
  17523. /**
  17524. * Set a after unbind callback in the texture.
  17525. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17526. */
  17527. onAfterUnbind: () => void;
  17528. /**
  17529. * An event triggered before rendering the texture
  17530. */
  17531. onBeforeRenderObservable: Observable<number>;
  17532. private _onBeforeRenderObserver;
  17533. /**
  17534. * Set a before render callback in the texture.
  17535. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17536. */
  17537. onBeforeRender: (faceIndex: number) => void;
  17538. /**
  17539. * An event triggered after rendering the texture
  17540. */
  17541. onAfterRenderObservable: Observable<number>;
  17542. private _onAfterRenderObserver;
  17543. /**
  17544. * Set a after render callback in the texture.
  17545. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17546. */
  17547. onAfterRender: (faceIndex: number) => void;
  17548. /**
  17549. * An event triggered after the texture clear
  17550. */
  17551. onClearObservable: Observable<Engine>;
  17552. private _onClearObserver;
  17553. /**
  17554. * Set a clear callback in the texture.
  17555. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17556. */
  17557. onClear: (Engine: Engine) => void;
  17558. /**
  17559. * Define the clear color of the Render Target if it should be different from the scene.
  17560. */
  17561. clearColor: Color4;
  17562. protected _size: number | {
  17563. width: number;
  17564. height: number;
  17565. };
  17566. protected _initialSizeParameter: number | {
  17567. width: number;
  17568. height: number;
  17569. } | {
  17570. ratio: number;
  17571. };
  17572. protected _sizeRatio: Nullable<number>;
  17573. /** @hidden */ generateMipMaps: boolean;
  17574. protected _renderingManager: RenderingManager;
  17575. /** @hidden */ waitingRenderList: string[];
  17576. protected _doNotChangeAspectRatio: boolean;
  17577. protected _currentRefreshId: number;
  17578. protected _refreshRate: number;
  17579. protected _textureMatrix: Matrix;
  17580. protected _samples: number;
  17581. protected _renderTargetOptions: RenderTargetCreationOptions;
  17582. /**
  17583. * Gets render target creation options that were used.
  17584. */
  17585. readonly renderTargetOptions: RenderTargetCreationOptions;
  17586. protected _engine: Engine;
  17587. protected _onRatioRescale(): void;
  17588. /**
  17589. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17590. * It must define where the camera used to render the texture is set
  17591. */
  17592. boundingBoxPosition: Vector3;
  17593. private _boundingBoxSize;
  17594. /**
  17595. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17596. * When defined, the cubemap will switch to local mode
  17597. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17598. * @example https://www.babylonjs-playground.com/#RNASML
  17599. */
  17600. boundingBoxSize: Vector3;
  17601. /**
  17602. * In case the RTT has been created with a depth texture, get the associated
  17603. * depth texture.
  17604. * Otherwise, return null.
  17605. */
  17606. depthStencilTexture: Nullable<InternalTexture>;
  17607. /**
  17608. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17609. * or used a shadow, depth texture...
  17610. * @param name The friendly name of the texture
  17611. * @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)
  17612. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17613. * @param generateMipMaps True if mip maps need to be generated after render.
  17614. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17615. * @param type The type of the buffer in the RTT (int, half float, float...)
  17616. * @param isCube True if a cube texture needs to be created
  17617. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17618. * @param generateDepthBuffer True to generate a depth buffer
  17619. * @param generateStencilBuffer True to generate a stencil buffer
  17620. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17621. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17622. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17623. */
  17624. constructor(name: string, size: number | {
  17625. width: number;
  17626. height: number;
  17627. } | {
  17628. ratio: number;
  17629. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17630. /**
  17631. * Creates a depth stencil texture.
  17632. * This is only available in WebGL 2 or with the depth texture extension available.
  17633. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17634. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17635. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17636. */
  17637. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17638. private _processSizeParameter;
  17639. /**
  17640. * Define the number of samples to use in case of MSAA.
  17641. * It defaults to one meaning no MSAA has been enabled.
  17642. */
  17643. samples: number;
  17644. /**
  17645. * Resets the refresh counter of the texture and start bak from scratch.
  17646. * Could be useful to regenerate the texture if it is setup to render only once.
  17647. */
  17648. resetRefreshCounter(): void;
  17649. /**
  17650. * Define the refresh rate of the texture or the rendering frequency.
  17651. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17652. */
  17653. refreshRate: number;
  17654. /**
  17655. * Adds a post process to the render target rendering passes.
  17656. * @param postProcess define the post process to add
  17657. */
  17658. addPostProcess(postProcess: PostProcess): void;
  17659. /**
  17660. * Clear all the post processes attached to the render target
  17661. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17662. */
  17663. clearPostProcesses(dispose?: boolean): void;
  17664. /**
  17665. * Remove one of the post process from the list of attached post processes to the texture
  17666. * @param postProcess define the post process to remove from the list
  17667. */
  17668. removePostProcess(postProcess: PostProcess): void;
  17669. /** @hidden */ shouldRender(): boolean;
  17670. /**
  17671. * Gets the actual render size of the texture.
  17672. * @returns the width of the render size
  17673. */
  17674. getRenderSize(): number;
  17675. /**
  17676. * Gets the actual render width of the texture.
  17677. * @returns the width of the render size
  17678. */
  17679. getRenderWidth(): number;
  17680. /**
  17681. * Gets the actual render height of the texture.
  17682. * @returns the height of the render size
  17683. */
  17684. getRenderHeight(): number;
  17685. /**
  17686. * Get if the texture can be rescaled or not.
  17687. */
  17688. readonly canRescale: boolean;
  17689. /**
  17690. * Resize the texture using a ratio.
  17691. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17692. */
  17693. scale(ratio: number): void;
  17694. /**
  17695. * Get the texture reflection matrix used to rotate/transform the reflection.
  17696. * @returns the reflection matrix
  17697. */
  17698. getReflectionTextureMatrix(): Matrix;
  17699. /**
  17700. * Resize the texture to a new desired size.
  17701. * Be carrefull as it will recreate all the data in the new texture.
  17702. * @param size Define the new size. It can be:
  17703. * - a number for squared texture,
  17704. * - an object containing { width: number, height: number }
  17705. * - or an object containing a ratio { ratio: number }
  17706. */
  17707. resize(size: number | {
  17708. width: number;
  17709. height: number;
  17710. } | {
  17711. ratio: number;
  17712. }): void;
  17713. /**
  17714. * Renders all the objects from the render list into the texture.
  17715. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17716. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17717. */
  17718. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17719. private _bestReflectionRenderTargetDimension;
  17720. /**
  17721. * @hidden
  17722. * @param faceIndex face index to bind to if this is a cubetexture
  17723. */ bindFrameBuffer(faceIndex?: number): void;
  17724. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17725. private renderToTarget;
  17726. /**
  17727. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17728. * This allowed control for front to back rendering or reversly depending of the special needs.
  17729. *
  17730. * @param renderingGroupId The rendering group id corresponding to its index
  17731. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17732. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17733. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17734. */
  17735. 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;
  17736. /**
  17737. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17738. *
  17739. * @param renderingGroupId The rendering group id corresponding to its index
  17740. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17741. */
  17742. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17743. /**
  17744. * Clones the texture.
  17745. * @returns the cloned texture
  17746. */
  17747. clone(): RenderTargetTexture;
  17748. /**
  17749. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17750. * @returns The JSON representation of the texture
  17751. */
  17752. serialize(): any;
  17753. /**
  17754. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17755. */
  17756. disposeFramebufferObjects(): void;
  17757. /**
  17758. * Dispose the texture and release its associated resources.
  17759. */
  17760. dispose(): void;
  17761. /** @hidden */ rebuild(): void;
  17762. /**
  17763. * Clear the info related to rendering groups preventing retention point in material dispose.
  17764. */
  17765. freeRenderingGroups(): void;
  17766. /**
  17767. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17768. * @returns the view count
  17769. */
  17770. getViewCount(): number;
  17771. }
  17772. }
  17773. declare module BABYLON {
  17774. /**
  17775. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17776. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17777. * You can then easily use it as a reflectionTexture on a flat surface.
  17778. * In case the surface is not a plane, please consider relying on reflection probes.
  17779. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17780. */
  17781. export class MirrorTexture extends RenderTargetTexture {
  17782. private scene;
  17783. /**
  17784. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17785. * 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.
  17786. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17787. */
  17788. mirrorPlane: Plane;
  17789. /**
  17790. * Define the blur ratio used to blur the reflection if needed.
  17791. */
  17792. blurRatio: number;
  17793. /**
  17794. * Define the adaptive blur kernel used to blur the reflection if needed.
  17795. * This will autocompute the closest best match for the `blurKernel`
  17796. */
  17797. adaptiveBlurKernel: number;
  17798. /**
  17799. * Define the blur kernel used to blur the reflection if needed.
  17800. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17801. */
  17802. blurKernel: number;
  17803. /**
  17804. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17805. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17806. */
  17807. blurKernelX: number;
  17808. /**
  17809. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17810. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17811. */
  17812. blurKernelY: number;
  17813. private _autoComputeBlurKernel;
  17814. protected _onRatioRescale(): void;
  17815. private _updateGammaSpace;
  17816. private _imageProcessingConfigChangeObserver;
  17817. private _transformMatrix;
  17818. private _mirrorMatrix;
  17819. private _savedViewMatrix;
  17820. private _blurX;
  17821. private _blurY;
  17822. private _adaptiveBlurKernel;
  17823. private _blurKernelX;
  17824. private _blurKernelY;
  17825. private _blurRatio;
  17826. /**
  17827. * Instantiates a Mirror Texture.
  17828. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17829. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17830. * You can then easily use it as a reflectionTexture on a flat surface.
  17831. * In case the surface is not a plane, please consider relying on reflection probes.
  17832. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17833. * @param name
  17834. * @param size
  17835. * @param scene
  17836. * @param generateMipMaps
  17837. * @param type
  17838. * @param samplingMode
  17839. * @param generateDepthBuffer
  17840. */
  17841. constructor(name: string, size: number | {
  17842. width: number;
  17843. height: number;
  17844. } | {
  17845. ratio: number;
  17846. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17847. private _preparePostProcesses;
  17848. /**
  17849. * Clone the mirror texture.
  17850. * @returns the cloned texture
  17851. */
  17852. clone(): MirrorTexture;
  17853. /**
  17854. * Serialize the texture to a JSON representation you could use in Parse later on
  17855. * @returns the serialized JSON representation
  17856. */
  17857. serialize(): any;
  17858. /**
  17859. * Dispose the texture and release its associated resources.
  17860. */
  17861. dispose(): void;
  17862. }
  17863. }
  17864. declare module BABYLON {
  17865. /**
  17866. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17867. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17868. */
  17869. export class Texture extends BaseTexture {
  17870. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17871. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17872. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17873. /** nearest is mag = nearest and min = nearest and mip = linear */
  17874. static readonly NEAREST_SAMPLINGMODE: number;
  17875. /** nearest is mag = nearest and min = nearest and mip = linear */
  17876. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17877. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17878. static readonly BILINEAR_SAMPLINGMODE: number;
  17879. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17880. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17881. /** Trilinear is mag = linear and min = linear and mip = linear */
  17882. static readonly TRILINEAR_SAMPLINGMODE: number;
  17883. /** Trilinear is mag = linear and min = linear and mip = linear */
  17884. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17885. /** mag = nearest and min = nearest and mip = nearest */
  17886. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17887. /** mag = nearest and min = linear and mip = nearest */
  17888. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17889. /** mag = nearest and min = linear and mip = linear */
  17890. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17891. /** mag = nearest and min = linear and mip = none */
  17892. static readonly NEAREST_LINEAR: number;
  17893. /** mag = nearest and min = nearest and mip = none */
  17894. static readonly NEAREST_NEAREST: number;
  17895. /** mag = linear and min = nearest and mip = nearest */
  17896. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17897. /** mag = linear and min = nearest and mip = linear */
  17898. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17899. /** mag = linear and min = linear and mip = none */
  17900. static readonly LINEAR_LINEAR: number;
  17901. /** mag = linear and min = nearest and mip = none */
  17902. static readonly LINEAR_NEAREST: number;
  17903. /** Explicit coordinates mode */
  17904. static readonly EXPLICIT_MODE: number;
  17905. /** Spherical coordinates mode */
  17906. static readonly SPHERICAL_MODE: number;
  17907. /** Planar coordinates mode */
  17908. static readonly PLANAR_MODE: number;
  17909. /** Cubic coordinates mode */
  17910. static readonly CUBIC_MODE: number;
  17911. /** Projection coordinates mode */
  17912. static readonly PROJECTION_MODE: number;
  17913. /** Inverse Cubic coordinates mode */
  17914. static readonly SKYBOX_MODE: number;
  17915. /** Inverse Cubic coordinates mode */
  17916. static readonly INVCUBIC_MODE: number;
  17917. /** Equirectangular coordinates mode */
  17918. static readonly EQUIRECTANGULAR_MODE: number;
  17919. /** Equirectangular Fixed coordinates mode */
  17920. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17921. /** Equirectangular Fixed Mirrored coordinates mode */
  17922. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17923. /** Texture is not repeating outside of 0..1 UVs */
  17924. static readonly CLAMP_ADDRESSMODE: number;
  17925. /** Texture is repeating outside of 0..1 UVs */
  17926. static readonly WRAP_ADDRESSMODE: number;
  17927. /** Texture is repeating and mirrored */
  17928. static readonly MIRROR_ADDRESSMODE: number;
  17929. /**
  17930. * 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
  17931. */
  17932. static UseSerializedUrlIfAny: boolean;
  17933. /**
  17934. * Define the url of the texture.
  17935. */
  17936. url: Nullable<string>;
  17937. /**
  17938. * Define an offset on the texture to offset the u coordinates of the UVs
  17939. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17940. */
  17941. uOffset: number;
  17942. /**
  17943. * Define an offset on the texture to offset the v coordinates of the UVs
  17944. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17945. */
  17946. vOffset: number;
  17947. /**
  17948. * Define an offset on the texture to scale the u coordinates of the UVs
  17949. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17950. */
  17951. uScale: number;
  17952. /**
  17953. * Define an offset on the texture to scale the v coordinates of the UVs
  17954. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17955. */
  17956. vScale: number;
  17957. /**
  17958. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17959. * @see http://doc.babylonjs.com/how_to/more_materials
  17960. */
  17961. uAng: number;
  17962. /**
  17963. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17964. * @see http://doc.babylonjs.com/how_to/more_materials
  17965. */
  17966. vAng: number;
  17967. /**
  17968. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17969. * @see http://doc.babylonjs.com/how_to/more_materials
  17970. */
  17971. wAng: number;
  17972. /**
  17973. * Defines the center of rotation (U)
  17974. */
  17975. uRotationCenter: number;
  17976. /**
  17977. * Defines the center of rotation (V)
  17978. */
  17979. vRotationCenter: number;
  17980. /**
  17981. * Defines the center of rotation (W)
  17982. */
  17983. wRotationCenter: number;
  17984. /**
  17985. * Are mip maps generated for this texture or not.
  17986. */
  17987. readonly noMipmap: boolean;
  17988. /**
  17989. * List of inspectable custom properties (used by the Inspector)
  17990. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17991. */
  17992. inspectableCustomProperties: Nullable<IInspectable[]>;
  17993. private _noMipmap;
  17994. /** @hidden */ invertY: boolean;
  17995. private _rowGenerationMatrix;
  17996. private _cachedTextureMatrix;
  17997. private _projectionModeMatrix;
  17998. private _t0;
  17999. private _t1;
  18000. private _t2;
  18001. private _cachedUOffset;
  18002. private _cachedVOffset;
  18003. private _cachedUScale;
  18004. private _cachedVScale;
  18005. private _cachedUAng;
  18006. private _cachedVAng;
  18007. private _cachedWAng;
  18008. private _cachedProjectionMatrixId;
  18009. private _cachedCoordinatesMode;
  18010. /** @hidden */
  18011. protected _initialSamplingMode: number;
  18012. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18013. private _deleteBuffer;
  18014. protected _format: Nullable<number>;
  18015. private _delayedOnLoad;
  18016. private _delayedOnError;
  18017. /**
  18018. * Observable triggered once the texture has been loaded.
  18019. */
  18020. onLoadObservable: Observable<Texture>;
  18021. protected _isBlocking: boolean;
  18022. /**
  18023. * Is the texture preventing material to render while loading.
  18024. * If false, a default texture will be used instead of the loading one during the preparation step.
  18025. */
  18026. isBlocking: boolean;
  18027. /**
  18028. * Get the current sampling mode associated with the texture.
  18029. */
  18030. readonly samplingMode: number;
  18031. /**
  18032. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18033. */
  18034. readonly invertY: boolean;
  18035. /**
  18036. * Instantiates a new texture.
  18037. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18038. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18039. * @param url define the url of the picture to load as a texture
  18040. * @param scene define the scene the texture will belong to
  18041. * @param noMipmap define if the texture will require mip maps or not
  18042. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18043. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18044. * @param onLoad define a callback triggered when the texture has been loaded
  18045. * @param onError define a callback triggered when an error occurred during the loading session
  18046. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18047. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18048. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18049. */
  18050. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18051. /**
  18052. * Update the url (and optional buffer) of this texture if url was null during construction.
  18053. * @param url the url of the texture
  18054. * @param buffer the buffer of the texture (defaults to null)
  18055. * @param onLoad callback called when the texture is loaded (defaults to null)
  18056. */
  18057. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18058. /**
  18059. * Finish the loading sequence of a texture flagged as delayed load.
  18060. * @hidden
  18061. */
  18062. delayLoad(): void;
  18063. private _prepareRowForTextureGeneration;
  18064. /**
  18065. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18066. * @returns the transform matrix of the texture.
  18067. */
  18068. getTextureMatrix(): Matrix;
  18069. /**
  18070. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18071. * @returns The reflection texture transform
  18072. */
  18073. getReflectionTextureMatrix(): Matrix;
  18074. /**
  18075. * Clones the texture.
  18076. * @returns the cloned texture
  18077. */
  18078. clone(): Texture;
  18079. /**
  18080. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18081. * @returns The JSON representation of the texture
  18082. */
  18083. serialize(): any;
  18084. /**
  18085. * Get the current class name of the texture useful for serialization or dynamic coding.
  18086. * @returns "Texture"
  18087. */
  18088. getClassName(): string;
  18089. /**
  18090. * Dispose the texture and release its associated resources.
  18091. */
  18092. dispose(): void;
  18093. /**
  18094. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18095. * @param parsedTexture Define the JSON representation of the texture
  18096. * @param scene Define the scene the parsed texture should be instantiated in
  18097. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18098. * @returns The parsed texture if successful
  18099. */
  18100. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18101. /**
  18102. * Creates a texture from its base 64 representation.
  18103. * @param data Define the base64 payload without the data: prefix
  18104. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18105. * @param scene Define the scene the texture should belong to
  18106. * @param noMipmap Forces the texture to not create mip map information if true
  18107. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18108. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18109. * @param onLoad define a callback triggered when the texture has been loaded
  18110. * @param onError define a callback triggered when an error occurred during the loading session
  18111. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18112. * @returns the created texture
  18113. */
  18114. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18115. /**
  18116. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18117. * @param data Define the base64 payload without the data: prefix
  18118. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18119. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18120. * @param scene Define the scene the texture should belong to
  18121. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18122. * @param noMipmap Forces the texture to not create mip map information if true
  18123. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18124. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18125. * @param onLoad define a callback triggered when the texture has been loaded
  18126. * @param onError define a callback triggered when an error occurred during the loading session
  18127. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18128. * @returns the created texture
  18129. */
  18130. 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;
  18131. }
  18132. }
  18133. declare module BABYLON {
  18134. interface Engine {
  18135. /**
  18136. * Creates a raw texture
  18137. * @param data defines the data to store in the texture
  18138. * @param width defines the width of the texture
  18139. * @param height defines the height of the texture
  18140. * @param format defines the format of the data
  18141. * @param generateMipMaps defines if the engine should generate the mip levels
  18142. * @param invertY defines if data must be stored with Y axis inverted
  18143. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18144. * @param compression defines the compression used (null by default)
  18145. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18146. * @returns the raw texture inside an InternalTexture
  18147. */
  18148. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18149. /**
  18150. * Update a raw texture
  18151. * @param texture defines the texture to update
  18152. * @param data defines the data to store in the texture
  18153. * @param format defines the format of the data
  18154. * @param invertY defines if data must be stored with Y axis inverted
  18155. */
  18156. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18157. /**
  18158. * Update a raw texture
  18159. * @param texture defines the texture to update
  18160. * @param data defines the data to store in the texture
  18161. * @param format defines the format of the data
  18162. * @param invertY defines if data must be stored with Y axis inverted
  18163. * @param compression defines the compression used (null by default)
  18164. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18165. */
  18166. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18167. /**
  18168. * Creates a new raw cube texture
  18169. * @param data defines the array of data to use to create each face
  18170. * @param size defines the size of the textures
  18171. * @param format defines the format of the data
  18172. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18173. * @param generateMipMaps defines if the engine should generate the mip levels
  18174. * @param invertY defines if data must be stored with Y axis inverted
  18175. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18176. * @param compression defines the compression used (null by default)
  18177. * @returns the cube texture as an InternalTexture
  18178. */
  18179. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18180. /**
  18181. * Update a raw cube texture
  18182. * @param texture defines the texture to udpdate
  18183. * @param data defines the data to store
  18184. * @param format defines the data format
  18185. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18186. * @param invertY defines if data must be stored with Y axis inverted
  18187. */
  18188. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18189. /**
  18190. * Update a raw cube texture
  18191. * @param texture defines the texture to udpdate
  18192. * @param data defines the data to store
  18193. * @param format defines the data format
  18194. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18195. * @param invertY defines if data must be stored with Y axis inverted
  18196. * @param compression defines the compression used (null by default)
  18197. */
  18198. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18199. /**
  18200. * Update a raw cube texture
  18201. * @param texture defines the texture to udpdate
  18202. * @param data defines the data to store
  18203. * @param format defines the data format
  18204. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18205. * @param invertY defines if data must be stored with Y axis inverted
  18206. * @param compression defines the compression used (null by default)
  18207. * @param level defines which level of the texture to update
  18208. */
  18209. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18210. /**
  18211. * Creates a new raw cube texture from a specified url
  18212. * @param url defines the url where the data is located
  18213. * @param scene defines the current scene
  18214. * @param size defines the size of the textures
  18215. * @param format defines the format of the data
  18216. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18217. * @param noMipmap defines if the engine should avoid generating the mip levels
  18218. * @param callback defines a callback used to extract texture data from loaded data
  18219. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18220. * @param onLoad defines a callback called when texture is loaded
  18221. * @param onError defines a callback called if there is an error
  18222. * @returns the cube texture as an InternalTexture
  18223. */
  18224. 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;
  18225. /**
  18226. * Creates a new raw cube texture from a specified url
  18227. * @param url defines the url where the data is located
  18228. * @param scene defines the current scene
  18229. * @param size defines the size of the textures
  18230. * @param format defines the format of the data
  18231. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18232. * @param noMipmap defines if the engine should avoid generating the mip levels
  18233. * @param callback defines a callback used to extract texture data from loaded data
  18234. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18235. * @param onLoad defines a callback called when texture is loaded
  18236. * @param onError defines a callback called if there is an error
  18237. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18238. * @param invertY defines if data must be stored with Y axis inverted
  18239. * @returns the cube texture as an InternalTexture
  18240. */
  18241. 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;
  18242. /**
  18243. * Creates a new raw 3D texture
  18244. * @param data defines the data used to create the texture
  18245. * @param width defines the width of the texture
  18246. * @param height defines the height of the texture
  18247. * @param depth defines the depth of the texture
  18248. * @param format defines the format of the texture
  18249. * @param generateMipMaps defines if the engine must generate mip levels
  18250. * @param invertY defines if data must be stored with Y axis inverted
  18251. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18252. * @param compression defines the compressed used (can be null)
  18253. * @param textureType defines the compressed used (can be null)
  18254. * @returns a new raw 3D texture (stored in an InternalTexture)
  18255. */
  18256. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18257. /**
  18258. * Update a raw 3D texture
  18259. * @param texture defines the texture to update
  18260. * @param data defines the data to store
  18261. * @param format defines the data format
  18262. * @param invertY defines if data must be stored with Y axis inverted
  18263. */
  18264. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18265. /**
  18266. * Update a raw 3D texture
  18267. * @param texture defines the texture to update
  18268. * @param data defines the data to store
  18269. * @param format defines the data format
  18270. * @param invertY defines if data must be stored with Y axis inverted
  18271. * @param compression defines the used compression (can be null)
  18272. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18273. */
  18274. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18275. }
  18276. }
  18277. declare module BABYLON {
  18278. /**
  18279. * Raw texture can help creating a texture directly from an array of data.
  18280. * This can be super useful if you either get the data from an uncompressed source or
  18281. * if you wish to create your texture pixel by pixel.
  18282. */
  18283. export class RawTexture extends Texture {
  18284. /**
  18285. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18286. */
  18287. format: number;
  18288. private _engine;
  18289. /**
  18290. * Instantiates a new RawTexture.
  18291. * Raw texture can help creating a texture directly from an array of data.
  18292. * This can be super useful if you either get the data from an uncompressed source or
  18293. * if you wish to create your texture pixel by pixel.
  18294. * @param data define the array of data to use to create the texture
  18295. * @param width define the width of the texture
  18296. * @param height define the height of the texture
  18297. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18298. * @param scene define the scene the texture belongs to
  18299. * @param generateMipMaps define whether mip maps should be generated or not
  18300. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18301. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18302. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18303. */
  18304. constructor(data: ArrayBufferView, width: number, height: number,
  18305. /**
  18306. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18307. */
  18308. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18309. /**
  18310. * Updates the texture underlying data.
  18311. * @param data Define the new data of the texture
  18312. */
  18313. update(data: ArrayBufferView): void;
  18314. /**
  18315. * Creates a luminance texture from some data.
  18316. * @param data Define the texture data
  18317. * @param width Define the width of the texture
  18318. * @param height Define the height of the texture
  18319. * @param scene Define the scene the texture belongs to
  18320. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18321. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18322. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18323. * @returns the luminance texture
  18324. */
  18325. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18326. /**
  18327. * Creates a luminance alpha texture from some data.
  18328. * @param data Define the texture data
  18329. * @param width Define the width of the texture
  18330. * @param height Define the height of the texture
  18331. * @param scene Define the scene the texture belongs to
  18332. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18333. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18334. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18335. * @returns the luminance alpha texture
  18336. */
  18337. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18338. /**
  18339. * Creates an alpha texture from some data.
  18340. * @param data Define the texture data
  18341. * @param width Define the width of the texture
  18342. * @param height Define the height of the texture
  18343. * @param scene Define the scene the texture belongs to
  18344. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18345. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18346. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18347. * @returns the alpha texture
  18348. */
  18349. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18350. /**
  18351. * Creates a RGB texture from some data.
  18352. * @param data Define the texture data
  18353. * @param width Define the width of the texture
  18354. * @param height Define the height of the texture
  18355. * @param scene Define the scene the texture belongs to
  18356. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18357. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18358. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18359. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18360. * @returns the RGB alpha texture
  18361. */
  18362. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18363. /**
  18364. * Creates a RGBA texture from some data.
  18365. * @param data Define the texture data
  18366. * @param width Define the width of the texture
  18367. * @param height Define the height of the texture
  18368. * @param scene Define the scene the texture belongs to
  18369. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18370. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18371. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18372. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18373. * @returns the RGBA texture
  18374. */
  18375. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18376. /**
  18377. * Creates a R texture from some data.
  18378. * @param data Define the texture data
  18379. * @param width Define the width of the texture
  18380. * @param height Define the height of the texture
  18381. * @param scene Define the scene the texture belongs to
  18382. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18383. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18384. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18385. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18386. * @returns the R texture
  18387. */
  18388. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18389. }
  18390. }
  18391. declare module BABYLON {
  18392. /**
  18393. * Defines a runtime animation
  18394. */
  18395. export class RuntimeAnimation {
  18396. private _events;
  18397. /**
  18398. * The current frame of the runtime animation
  18399. */
  18400. private _currentFrame;
  18401. /**
  18402. * The animation used by the runtime animation
  18403. */
  18404. private _animation;
  18405. /**
  18406. * The target of the runtime animation
  18407. */
  18408. private _target;
  18409. /**
  18410. * The initiating animatable
  18411. */
  18412. private _host;
  18413. /**
  18414. * The original value of the runtime animation
  18415. */
  18416. private _originalValue;
  18417. /**
  18418. * The original blend value of the runtime animation
  18419. */
  18420. private _originalBlendValue;
  18421. /**
  18422. * The offsets cache of the runtime animation
  18423. */
  18424. private _offsetsCache;
  18425. /**
  18426. * The high limits cache of the runtime animation
  18427. */
  18428. private _highLimitsCache;
  18429. /**
  18430. * Specifies if the runtime animation has been stopped
  18431. */
  18432. private _stopped;
  18433. /**
  18434. * The blending factor of the runtime animation
  18435. */
  18436. private _blendingFactor;
  18437. /**
  18438. * The BabylonJS scene
  18439. */
  18440. private _scene;
  18441. /**
  18442. * The current value of the runtime animation
  18443. */
  18444. private _currentValue;
  18445. /** @hidden */ animationState: _IAnimationState;
  18446. /**
  18447. * The active target of the runtime animation
  18448. */
  18449. private _activeTargets;
  18450. private _currentActiveTarget;
  18451. private _directTarget;
  18452. /**
  18453. * The target path of the runtime animation
  18454. */
  18455. private _targetPath;
  18456. /**
  18457. * The weight of the runtime animation
  18458. */
  18459. private _weight;
  18460. /**
  18461. * The ratio offset of the runtime animation
  18462. */
  18463. private _ratioOffset;
  18464. /**
  18465. * The previous delay of the runtime animation
  18466. */
  18467. private _previousDelay;
  18468. /**
  18469. * The previous ratio of the runtime animation
  18470. */
  18471. private _previousRatio;
  18472. private _enableBlending;
  18473. private _keys;
  18474. private _minFrame;
  18475. private _maxFrame;
  18476. private _minValue;
  18477. private _maxValue;
  18478. private _targetIsArray;
  18479. /**
  18480. * Gets the current frame of the runtime animation
  18481. */
  18482. readonly currentFrame: number;
  18483. /**
  18484. * Gets the weight of the runtime animation
  18485. */
  18486. readonly weight: number;
  18487. /**
  18488. * Gets the current value of the runtime animation
  18489. */
  18490. readonly currentValue: any;
  18491. /**
  18492. * Gets the target path of the runtime animation
  18493. */
  18494. readonly targetPath: string;
  18495. /**
  18496. * Gets the actual target of the runtime animation
  18497. */
  18498. readonly target: any;
  18499. /** @hidden */ onLoop: () => void;
  18500. /**
  18501. * Create a new RuntimeAnimation object
  18502. * @param target defines the target of the animation
  18503. * @param animation defines the source animation object
  18504. * @param scene defines the hosting scene
  18505. * @param host defines the initiating Animatable
  18506. */
  18507. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18508. private _preparePath;
  18509. /**
  18510. * Gets the animation from the runtime animation
  18511. */
  18512. readonly animation: Animation;
  18513. /**
  18514. * Resets the runtime animation to the beginning
  18515. * @param restoreOriginal defines whether to restore the target property to the original value
  18516. */
  18517. reset(restoreOriginal?: boolean): void;
  18518. /**
  18519. * Specifies if the runtime animation is stopped
  18520. * @returns Boolean specifying if the runtime animation is stopped
  18521. */
  18522. isStopped(): boolean;
  18523. /**
  18524. * Disposes of the runtime animation
  18525. */
  18526. dispose(): void;
  18527. /**
  18528. * Apply the interpolated value to the target
  18529. * @param currentValue defines the value computed by the animation
  18530. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18531. */
  18532. setValue(currentValue: any, weight: number): void;
  18533. private _getOriginalValues;
  18534. private _setValue;
  18535. /**
  18536. * Gets the loop pmode of the runtime animation
  18537. * @returns Loop Mode
  18538. */
  18539. private _getCorrectLoopMode;
  18540. /**
  18541. * Move the current animation to a given frame
  18542. * @param frame defines the frame to move to
  18543. */
  18544. goToFrame(frame: number): void;
  18545. /**
  18546. * @hidden Internal use only
  18547. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18548. /**
  18549. * Execute the current animation
  18550. * @param delay defines the delay to add to the current frame
  18551. * @param from defines the lower bound of the animation range
  18552. * @param to defines the upper bound of the animation range
  18553. * @param loop defines if the current animation must loop
  18554. * @param speedRatio defines the current speed ratio
  18555. * @param weight defines the weight of the animation (default is -1 so no weight)
  18556. * @param onLoop optional callback called when animation loops
  18557. * @returns a boolean indicating if the animation is running
  18558. */
  18559. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18560. }
  18561. }
  18562. declare module BABYLON {
  18563. /**
  18564. * Class used to store an actual running animation
  18565. */
  18566. export class Animatable {
  18567. /** defines the target object */
  18568. target: any;
  18569. /** defines the starting frame number (default is 0) */
  18570. fromFrame: number;
  18571. /** defines the ending frame number (default is 100) */
  18572. toFrame: number;
  18573. /** defines if the animation must loop (default is false) */
  18574. loopAnimation: boolean;
  18575. /** defines a callback to call when animation ends if it is not looping */
  18576. onAnimationEnd?: (() => void) | null | undefined;
  18577. /** defines a callback to call when animation loops */
  18578. onAnimationLoop?: (() => void) | null | undefined;
  18579. private _localDelayOffset;
  18580. private _pausedDelay;
  18581. private _runtimeAnimations;
  18582. private _paused;
  18583. private _scene;
  18584. private _speedRatio;
  18585. private _weight;
  18586. private _syncRoot;
  18587. /**
  18588. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18589. * This will only apply for non looping animation (default is true)
  18590. */
  18591. disposeOnEnd: boolean;
  18592. /**
  18593. * Gets a boolean indicating if the animation has started
  18594. */
  18595. animationStarted: boolean;
  18596. /**
  18597. * Observer raised when the animation ends
  18598. */
  18599. onAnimationEndObservable: Observable<Animatable>;
  18600. /**
  18601. * Observer raised when the animation loops
  18602. */
  18603. onAnimationLoopObservable: Observable<Animatable>;
  18604. /**
  18605. * Gets the root Animatable used to synchronize and normalize animations
  18606. */
  18607. readonly syncRoot: Nullable<Animatable>;
  18608. /**
  18609. * Gets the current frame of the first RuntimeAnimation
  18610. * Used to synchronize Animatables
  18611. */
  18612. readonly masterFrame: number;
  18613. /**
  18614. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18615. */
  18616. weight: number;
  18617. /**
  18618. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18619. */
  18620. speedRatio: number;
  18621. /**
  18622. * Creates a new Animatable
  18623. * @param scene defines the hosting scene
  18624. * @param target defines the target object
  18625. * @param fromFrame defines the starting frame number (default is 0)
  18626. * @param toFrame defines the ending frame number (default is 100)
  18627. * @param loopAnimation defines if the animation must loop (default is false)
  18628. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18629. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18630. * @param animations defines a group of animation to add to the new Animatable
  18631. * @param onAnimationLoop defines a callback to call when animation loops
  18632. */
  18633. constructor(scene: Scene,
  18634. /** defines the target object */
  18635. target: any,
  18636. /** defines the starting frame number (default is 0) */
  18637. fromFrame?: number,
  18638. /** defines the ending frame number (default is 100) */
  18639. toFrame?: number,
  18640. /** defines if the animation must loop (default is false) */
  18641. loopAnimation?: boolean, speedRatio?: number,
  18642. /** defines a callback to call when animation ends if it is not looping */
  18643. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18644. /** defines a callback to call when animation loops */
  18645. onAnimationLoop?: (() => void) | null | undefined);
  18646. /**
  18647. * Synchronize and normalize current Animatable with a source Animatable
  18648. * This is useful when using animation weights and when animations are not of the same length
  18649. * @param root defines the root Animatable to synchronize with
  18650. * @returns the current Animatable
  18651. */
  18652. syncWith(root: Animatable): Animatable;
  18653. /**
  18654. * Gets the list of runtime animations
  18655. * @returns an array of RuntimeAnimation
  18656. */
  18657. getAnimations(): RuntimeAnimation[];
  18658. /**
  18659. * Adds more animations to the current animatable
  18660. * @param target defines the target of the animations
  18661. * @param animations defines the new animations to add
  18662. */
  18663. appendAnimations(target: any, animations: Animation[]): void;
  18664. /**
  18665. * Gets the source animation for a specific property
  18666. * @param property defines the propertyu to look for
  18667. * @returns null or the source animation for the given property
  18668. */
  18669. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18670. /**
  18671. * Gets the runtime animation for a specific property
  18672. * @param property defines the propertyu to look for
  18673. * @returns null or the runtime animation for the given property
  18674. */
  18675. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18676. /**
  18677. * Resets the animatable to its original state
  18678. */
  18679. reset(): void;
  18680. /**
  18681. * Allows the animatable to blend with current running animations
  18682. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18683. * @param blendingSpeed defines the blending speed to use
  18684. */
  18685. enableBlending(blendingSpeed: number): void;
  18686. /**
  18687. * Disable animation blending
  18688. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18689. */
  18690. disableBlending(): void;
  18691. /**
  18692. * Jump directly to a given frame
  18693. * @param frame defines the frame to jump to
  18694. */
  18695. goToFrame(frame: number): void;
  18696. /**
  18697. * Pause the animation
  18698. */
  18699. pause(): void;
  18700. /**
  18701. * Restart the animation
  18702. */
  18703. restart(): void;
  18704. private _raiseOnAnimationEnd;
  18705. /**
  18706. * Stop and delete the current animation
  18707. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18708. * @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)
  18709. */
  18710. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18711. /**
  18712. * Wait asynchronously for the animation to end
  18713. * @returns a promise which will be fullfilled when the animation ends
  18714. */
  18715. waitAsync(): Promise<Animatable>;
  18716. /** @hidden */ animate(delay: number): boolean;
  18717. }
  18718. interface Scene {
  18719. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18720. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18721. totalWeight: number;
  18722. animations: RuntimeAnimation[];
  18723. originalValue: Matrix;
  18724. }): any;
  18725. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18726. totalWeight: number;
  18727. animations: RuntimeAnimation[];
  18728. originalValue: Quaternion;
  18729. }, refQuaternion: Quaternion): Quaternion;
  18730. /** @hidden */ processLateAnimationBindings(): void;
  18731. /**
  18732. * Will start the animation sequence of a given target
  18733. * @param target defines the target
  18734. * @param from defines from which frame should animation start
  18735. * @param to defines until which frame should animation run.
  18736. * @param weight defines the weight to apply to the animation (1.0 by default)
  18737. * @param loop defines if the animation loops
  18738. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18739. * @param onAnimationEnd defines the function to be executed when the animation ends
  18740. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18741. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18742. * @param onAnimationLoop defines the callback to call when an animation loops
  18743. * @returns the animatable object created for this animation
  18744. */
  18745. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18746. /**
  18747. * Will start the animation sequence of a given target
  18748. * @param target defines the target
  18749. * @param from defines from which frame should animation start
  18750. * @param to defines until which frame should animation run.
  18751. * @param loop defines if the animation loops
  18752. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18753. * @param onAnimationEnd defines the function to be executed when the animation ends
  18754. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18755. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18756. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18757. * @param onAnimationLoop defines the callback to call when an animation loops
  18758. * @returns the animatable object created for this animation
  18759. */
  18760. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18761. /**
  18762. * Will start the animation sequence of a given target and its hierarchy
  18763. * @param target defines the target
  18764. * @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.
  18765. * @param from defines from which frame should animation start
  18766. * @param to defines until which frame should animation run.
  18767. * @param loop defines if the animation loops
  18768. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18769. * @param onAnimationEnd defines the function to be executed when the animation ends
  18770. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18771. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18772. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18773. * @param onAnimationLoop defines the callback to call when an animation loops
  18774. * @returns the list of created animatables
  18775. */
  18776. 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[];
  18777. /**
  18778. * Begin a new animation on a given node
  18779. * @param target defines the target where the animation will take place
  18780. * @param animations defines the list of animations to start
  18781. * @param from defines the initial value
  18782. * @param to defines the final value
  18783. * @param loop defines if you want animation to loop (off by default)
  18784. * @param speedRatio defines the speed ratio to apply to all animations
  18785. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18786. * @param onAnimationLoop defines the callback to call when an animation loops
  18787. * @returns the list of created animatables
  18788. */
  18789. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18790. /**
  18791. * Begin a new animation on a given node and its hierarchy
  18792. * @param target defines the root node where the animation will take place
  18793. * @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.
  18794. * @param animations defines the list of animations to start
  18795. * @param from defines the initial value
  18796. * @param to defines the final value
  18797. * @param loop defines if you want animation to loop (off by default)
  18798. * @param speedRatio defines the speed ratio to apply to all animations
  18799. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18800. * @param onAnimationLoop defines the callback to call when an animation loops
  18801. * @returns the list of animatables created for all nodes
  18802. */
  18803. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18804. /**
  18805. * Gets the animatable associated with a specific target
  18806. * @param target defines the target of the animatable
  18807. * @returns the required animatable if found
  18808. */
  18809. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18810. /**
  18811. * Gets all animatables associated with a given target
  18812. * @param target defines the target to look animatables for
  18813. * @returns an array of Animatables
  18814. */
  18815. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18816. /**
  18817. * Stops and removes all animations that have been applied to the scene
  18818. */
  18819. stopAllAnimations(): void;
  18820. }
  18821. interface Bone {
  18822. /**
  18823. * Copy an animation range from another bone
  18824. * @param source defines the source bone
  18825. * @param rangeName defines the range name to copy
  18826. * @param frameOffset defines the frame offset
  18827. * @param rescaleAsRequired defines if rescaling must be applied if required
  18828. * @param skelDimensionsRatio defines the scaling ratio
  18829. * @returns true if operation was successful
  18830. */
  18831. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18832. }
  18833. }
  18834. declare module BABYLON {
  18835. /**
  18836. * Class used to handle skinning animations
  18837. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18838. */
  18839. export class Skeleton implements IAnimatable {
  18840. /** defines the skeleton name */
  18841. name: string;
  18842. /** defines the skeleton Id */
  18843. id: string;
  18844. /**
  18845. * Defines the list of child bones
  18846. */
  18847. bones: Bone[];
  18848. /**
  18849. * Defines an estimate of the dimension of the skeleton at rest
  18850. */
  18851. dimensionsAtRest: Vector3;
  18852. /**
  18853. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18854. */
  18855. needInitialSkinMatrix: boolean;
  18856. /**
  18857. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18858. */
  18859. overrideMesh: Nullable<AbstractMesh>;
  18860. /**
  18861. * Gets the list of animations attached to this skeleton
  18862. */
  18863. animations: Array<Animation>;
  18864. private _scene;
  18865. private _isDirty;
  18866. private _transformMatrices;
  18867. private _transformMatrixTexture;
  18868. private _meshesWithPoseMatrix;
  18869. private _animatables;
  18870. private _identity;
  18871. private _synchronizedWithMesh;
  18872. private _ranges;
  18873. private _lastAbsoluteTransformsUpdateId;
  18874. private _canUseTextureForBones;
  18875. private _uniqueId;
  18876. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18877. /** @hidden */ hasWaitingData: Nullable<boolean>;
  18878. /**
  18879. * Specifies if the skeleton should be serialized
  18880. */
  18881. doNotSerialize: boolean;
  18882. private _useTextureToStoreBoneMatrices;
  18883. /**
  18884. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18885. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18886. */
  18887. useTextureToStoreBoneMatrices: boolean;
  18888. private _animationPropertiesOverride;
  18889. /**
  18890. * Gets or sets the animation properties override
  18891. */
  18892. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18893. /**
  18894. * List of inspectable custom properties (used by the Inspector)
  18895. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18896. */
  18897. inspectableCustomProperties: IInspectable[];
  18898. /**
  18899. * An observable triggered before computing the skeleton's matrices
  18900. */
  18901. onBeforeComputeObservable: Observable<Skeleton>;
  18902. /**
  18903. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18904. */
  18905. readonly isUsingTextureForMatrices: boolean;
  18906. /**
  18907. * Gets the unique ID of this skeleton
  18908. */
  18909. readonly uniqueId: number;
  18910. /**
  18911. * Creates a new skeleton
  18912. * @param name defines the skeleton name
  18913. * @param id defines the skeleton Id
  18914. * @param scene defines the hosting scene
  18915. */
  18916. constructor(
  18917. /** defines the skeleton name */
  18918. name: string,
  18919. /** defines the skeleton Id */
  18920. id: string, scene: Scene);
  18921. /**
  18922. * Gets the current object class name.
  18923. * @return the class name
  18924. */
  18925. getClassName(): string;
  18926. /**
  18927. * Returns an array containing the root bones
  18928. * @returns an array containing the root bones
  18929. */
  18930. getChildren(): Array<Bone>;
  18931. /**
  18932. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18933. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18934. * @returns a Float32Array containing matrices data
  18935. */
  18936. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18937. /**
  18938. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18939. * @returns a raw texture containing the data
  18940. */
  18941. getTransformMatrixTexture(): Nullable<RawTexture>;
  18942. /**
  18943. * Gets the current hosting scene
  18944. * @returns a scene object
  18945. */
  18946. getScene(): Scene;
  18947. /**
  18948. * Gets a string representing the current skeleton data
  18949. * @param fullDetails defines a boolean indicating if we want a verbose version
  18950. * @returns a string representing the current skeleton data
  18951. */
  18952. toString(fullDetails?: boolean): string;
  18953. /**
  18954. * Get bone's index searching by name
  18955. * @param name defines bone's name to search for
  18956. * @return the indice of the bone. Returns -1 if not found
  18957. */
  18958. getBoneIndexByName(name: string): number;
  18959. /**
  18960. * Creater a new animation range
  18961. * @param name defines the name of the range
  18962. * @param from defines the start key
  18963. * @param to defines the end key
  18964. */
  18965. createAnimationRange(name: string, from: number, to: number): void;
  18966. /**
  18967. * Delete a specific animation range
  18968. * @param name defines the name of the range
  18969. * @param deleteFrames defines if frames must be removed as well
  18970. */
  18971. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18972. /**
  18973. * Gets a specific animation range
  18974. * @param name defines the name of the range to look for
  18975. * @returns the requested animation range or null if not found
  18976. */
  18977. getAnimationRange(name: string): Nullable<AnimationRange>;
  18978. /**
  18979. * Gets the list of all animation ranges defined on this skeleton
  18980. * @returns an array
  18981. */
  18982. getAnimationRanges(): Nullable<AnimationRange>[];
  18983. /**
  18984. * Copy animation range from a source skeleton.
  18985. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18986. * @param source defines the source skeleton
  18987. * @param name defines the name of the range to copy
  18988. * @param rescaleAsRequired defines if rescaling must be applied if required
  18989. * @returns true if operation was successful
  18990. */
  18991. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18992. /**
  18993. * Forces the skeleton to go to rest pose
  18994. */
  18995. returnToRest(): void;
  18996. private _getHighestAnimationFrame;
  18997. /**
  18998. * Begin a specific animation range
  18999. * @param name defines the name of the range to start
  19000. * @param loop defines if looping must be turned on (false by default)
  19001. * @param speedRatio defines the speed ratio to apply (1 by default)
  19002. * @param onAnimationEnd defines a callback which will be called when animation will end
  19003. * @returns a new animatable
  19004. */
  19005. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19006. /** @hidden */ markAsDirty(): void;
  19007. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19008. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19009. private _computeTransformMatrices;
  19010. /**
  19011. * Build all resources required to render a skeleton
  19012. */
  19013. prepare(): void;
  19014. /**
  19015. * Gets the list of animatables currently running for this skeleton
  19016. * @returns an array of animatables
  19017. */
  19018. getAnimatables(): IAnimatable[];
  19019. /**
  19020. * Clone the current skeleton
  19021. * @param name defines the name of the new skeleton
  19022. * @param id defines the id of the new skeleton
  19023. * @returns the new skeleton
  19024. */
  19025. clone(name: string, id: string): Skeleton;
  19026. /**
  19027. * Enable animation blending for this skeleton
  19028. * @param blendingSpeed defines the blending speed to apply
  19029. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19030. */
  19031. enableBlending(blendingSpeed?: number): void;
  19032. /**
  19033. * Releases all resources associated with the current skeleton
  19034. */
  19035. dispose(): void;
  19036. /**
  19037. * Serialize the skeleton in a JSON object
  19038. * @returns a JSON object
  19039. */
  19040. serialize(): any;
  19041. /**
  19042. * Creates a new skeleton from serialized data
  19043. * @param parsedSkeleton defines the serialized data
  19044. * @param scene defines the hosting scene
  19045. * @returns a new skeleton
  19046. */
  19047. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19048. /**
  19049. * Compute all node absolute transforms
  19050. * @param forceUpdate defines if computation must be done even if cache is up to date
  19051. */
  19052. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19053. /**
  19054. * Gets the root pose matrix
  19055. * @returns a matrix
  19056. */
  19057. getPoseMatrix(): Nullable<Matrix>;
  19058. /**
  19059. * Sorts bones per internal index
  19060. */
  19061. sortBones(): void;
  19062. private _sortBones;
  19063. }
  19064. }
  19065. declare module BABYLON {
  19066. /**
  19067. * Defines a target to use with MorphTargetManager
  19068. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19069. */
  19070. export class MorphTarget implements IAnimatable {
  19071. /** defines the name of the target */
  19072. name: string;
  19073. /**
  19074. * Gets or sets the list of animations
  19075. */
  19076. animations: Animation[];
  19077. private _scene;
  19078. private _positions;
  19079. private _normals;
  19080. private _tangents;
  19081. private _influence;
  19082. /**
  19083. * Observable raised when the influence changes
  19084. */
  19085. onInfluenceChanged: Observable<boolean>;
  19086. /** @hidden */ onDataLayoutChanged: Observable<void>;
  19087. /**
  19088. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19089. */
  19090. influence: number;
  19091. /**
  19092. * Gets or sets the id of the morph Target
  19093. */
  19094. id: string;
  19095. private _animationPropertiesOverride;
  19096. /**
  19097. * Gets or sets the animation properties override
  19098. */
  19099. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19100. /**
  19101. * Creates a new MorphTarget
  19102. * @param name defines the name of the target
  19103. * @param influence defines the influence to use
  19104. * @param scene defines the scene the morphtarget belongs to
  19105. */
  19106. constructor(
  19107. /** defines the name of the target */
  19108. name: string, influence?: number, scene?: Nullable<Scene>);
  19109. /**
  19110. * Gets a boolean defining if the target contains position data
  19111. */
  19112. readonly hasPositions: boolean;
  19113. /**
  19114. * Gets a boolean defining if the target contains normal data
  19115. */
  19116. readonly hasNormals: boolean;
  19117. /**
  19118. * Gets a boolean defining if the target contains tangent data
  19119. */
  19120. readonly hasTangents: boolean;
  19121. /**
  19122. * Affects position data to this target
  19123. * @param data defines the position data to use
  19124. */
  19125. setPositions(data: Nullable<FloatArray>): void;
  19126. /**
  19127. * Gets the position data stored in this target
  19128. * @returns a FloatArray containing the position data (or null if not present)
  19129. */
  19130. getPositions(): Nullable<FloatArray>;
  19131. /**
  19132. * Affects normal data to this target
  19133. * @param data defines the normal data to use
  19134. */
  19135. setNormals(data: Nullable<FloatArray>): void;
  19136. /**
  19137. * Gets the normal data stored in this target
  19138. * @returns a FloatArray containing the normal data (or null if not present)
  19139. */
  19140. getNormals(): Nullable<FloatArray>;
  19141. /**
  19142. * Affects tangent data to this target
  19143. * @param data defines the tangent data to use
  19144. */
  19145. setTangents(data: Nullable<FloatArray>): void;
  19146. /**
  19147. * Gets the tangent data stored in this target
  19148. * @returns a FloatArray containing the tangent data (or null if not present)
  19149. */
  19150. getTangents(): Nullable<FloatArray>;
  19151. /**
  19152. * Serializes the current target into a Serialization object
  19153. * @returns the serialized object
  19154. */
  19155. serialize(): any;
  19156. /**
  19157. * Returns the string "MorphTarget"
  19158. * @returns "MorphTarget"
  19159. */
  19160. getClassName(): string;
  19161. /**
  19162. * Creates a new target from serialized data
  19163. * @param serializationObject defines the serialized data to use
  19164. * @returns a new MorphTarget
  19165. */
  19166. static Parse(serializationObject: any): MorphTarget;
  19167. /**
  19168. * Creates a MorphTarget from mesh data
  19169. * @param mesh defines the source mesh
  19170. * @param name defines the name to use for the new target
  19171. * @param influence defines the influence to attach to the target
  19172. * @returns a new MorphTarget
  19173. */
  19174. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19175. }
  19176. }
  19177. declare module BABYLON {
  19178. /**
  19179. * This class is used to deform meshes using morphing between different targets
  19180. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19181. */
  19182. export class MorphTargetManager {
  19183. private _targets;
  19184. private _targetInfluenceChangedObservers;
  19185. private _targetDataLayoutChangedObservers;
  19186. private _activeTargets;
  19187. private _scene;
  19188. private _influences;
  19189. private _supportsNormals;
  19190. private _supportsTangents;
  19191. private _vertexCount;
  19192. private _uniqueId;
  19193. private _tempInfluences;
  19194. /**
  19195. * Creates a new MorphTargetManager
  19196. * @param scene defines the current scene
  19197. */
  19198. constructor(scene?: Nullable<Scene>);
  19199. /**
  19200. * Gets the unique ID of this manager
  19201. */
  19202. readonly uniqueId: number;
  19203. /**
  19204. * Gets the number of vertices handled by this manager
  19205. */
  19206. readonly vertexCount: number;
  19207. /**
  19208. * Gets a boolean indicating if this manager supports morphing of normals
  19209. */
  19210. readonly supportsNormals: boolean;
  19211. /**
  19212. * Gets a boolean indicating if this manager supports morphing of tangents
  19213. */
  19214. readonly supportsTangents: boolean;
  19215. /**
  19216. * Gets the number of targets stored in this manager
  19217. */
  19218. readonly numTargets: number;
  19219. /**
  19220. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19221. */
  19222. readonly numInfluencers: number;
  19223. /**
  19224. * Gets the list of influences (one per target)
  19225. */
  19226. readonly influences: Float32Array;
  19227. /**
  19228. * Gets the active target at specified index. An active target is a target with an influence > 0
  19229. * @param index defines the index to check
  19230. * @returns the requested target
  19231. */
  19232. getActiveTarget(index: number): MorphTarget;
  19233. /**
  19234. * Gets the target at specified index
  19235. * @param index defines the index to check
  19236. * @returns the requested target
  19237. */
  19238. getTarget(index: number): MorphTarget;
  19239. /**
  19240. * Add a new target to this manager
  19241. * @param target defines the target to add
  19242. */
  19243. addTarget(target: MorphTarget): void;
  19244. /**
  19245. * Removes a target from the manager
  19246. * @param target defines the target to remove
  19247. */
  19248. removeTarget(target: MorphTarget): void;
  19249. /**
  19250. * Serializes the current manager into a Serialization object
  19251. * @returns the serialized object
  19252. */
  19253. serialize(): any;
  19254. private _syncActiveTargets;
  19255. /**
  19256. * Syncrhonize the targets with all the meshes using this morph target manager
  19257. */
  19258. synchronize(): void;
  19259. /**
  19260. * Creates a new MorphTargetManager from serialized data
  19261. * @param serializationObject defines the serialized data
  19262. * @param scene defines the hosting scene
  19263. * @returns the new MorphTargetManager
  19264. */
  19265. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19266. }
  19267. }
  19268. declare module BABYLON {
  19269. /**
  19270. * Class used to represent a specific level of detail of a mesh
  19271. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19272. */
  19273. export class MeshLODLevel {
  19274. /** Defines the distance where this level should star being displayed */
  19275. distance: number;
  19276. /** Defines the mesh to use to render this level */
  19277. mesh: Nullable<Mesh>;
  19278. /**
  19279. * Creates a new LOD level
  19280. * @param distance defines the distance where this level should star being displayed
  19281. * @param mesh defines the mesh to use to render this level
  19282. */
  19283. constructor(
  19284. /** Defines the distance where this level should star being displayed */
  19285. distance: number,
  19286. /** Defines the mesh to use to render this level */
  19287. mesh: Nullable<Mesh>);
  19288. }
  19289. }
  19290. declare module BABYLON {
  19291. /**
  19292. * Mesh representing the gorund
  19293. */
  19294. export class GroundMesh extends Mesh {
  19295. /** If octree should be generated */
  19296. generateOctree: boolean;
  19297. private _heightQuads;
  19298. /** @hidden */ subdivisionsX: number;
  19299. /** @hidden */ subdivisionsY: number;
  19300. /** @hidden */ width: number;
  19301. /** @hidden */ height: number;
  19302. /** @hidden */ minX: number;
  19303. /** @hidden */ maxX: number;
  19304. /** @hidden */ minZ: number;
  19305. /** @hidden */ maxZ: number;
  19306. constructor(name: string, scene: Scene);
  19307. /**
  19308. * "GroundMesh"
  19309. * @returns "GroundMesh"
  19310. */
  19311. getClassName(): string;
  19312. /**
  19313. * The minimum of x and y subdivisions
  19314. */
  19315. readonly subdivisions: number;
  19316. /**
  19317. * X subdivisions
  19318. */
  19319. readonly subdivisionsX: number;
  19320. /**
  19321. * Y subdivisions
  19322. */
  19323. readonly subdivisionsY: number;
  19324. /**
  19325. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19326. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19327. * @param chunksCount the number of subdivisions for x and y
  19328. * @param octreeBlocksSize (Default: 32)
  19329. */
  19330. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19331. /**
  19332. * Returns a height (y) value in the Worl system :
  19333. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19334. * @param x x coordinate
  19335. * @param z z coordinate
  19336. * @returns the ground y position if (x, z) are outside the ground surface.
  19337. */
  19338. getHeightAtCoordinates(x: number, z: number): number;
  19339. /**
  19340. * Returns a normalized vector (Vector3) orthogonal to the ground
  19341. * at the ground coordinates (x, z) expressed in the World system.
  19342. * @param x x coordinate
  19343. * @param z z coordinate
  19344. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19345. */
  19346. getNormalAtCoordinates(x: number, z: number): Vector3;
  19347. /**
  19348. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19349. * at the ground coordinates (x, z) expressed in the World system.
  19350. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19351. * @param x x coordinate
  19352. * @param z z coordinate
  19353. * @param ref vector to store the result
  19354. * @returns the GroundMesh.
  19355. */
  19356. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19357. /**
  19358. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19359. * if the ground has been updated.
  19360. * This can be used in the render loop.
  19361. * @returns the GroundMesh.
  19362. */
  19363. updateCoordinateHeights(): GroundMesh;
  19364. private _getFacetAt;
  19365. private _initHeightQuads;
  19366. private _computeHeightQuads;
  19367. /**
  19368. * Serializes this ground mesh
  19369. * @param serializationObject object to write serialization to
  19370. */
  19371. serialize(serializationObject: any): void;
  19372. /**
  19373. * Parses a serialized ground mesh
  19374. * @param parsedMesh the serialized mesh
  19375. * @param scene the scene to create the ground mesh in
  19376. * @returns the created ground mesh
  19377. */
  19378. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19379. }
  19380. }
  19381. declare module BABYLON {
  19382. /**
  19383. * Interface for Physics-Joint data
  19384. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19385. */
  19386. export interface PhysicsJointData {
  19387. /**
  19388. * The main pivot of the joint
  19389. */
  19390. mainPivot?: Vector3;
  19391. /**
  19392. * The connected pivot of the joint
  19393. */
  19394. connectedPivot?: Vector3;
  19395. /**
  19396. * The main axis of the joint
  19397. */
  19398. mainAxis?: Vector3;
  19399. /**
  19400. * The connected axis of the joint
  19401. */
  19402. connectedAxis?: Vector3;
  19403. /**
  19404. * The collision of the joint
  19405. */
  19406. collision?: boolean;
  19407. /**
  19408. * Native Oimo/Cannon/Energy data
  19409. */
  19410. nativeParams?: any;
  19411. }
  19412. /**
  19413. * This is a holder class for the physics joint created by the physics plugin
  19414. * It holds a set of functions to control the underlying joint
  19415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19416. */
  19417. export class PhysicsJoint {
  19418. /**
  19419. * The type of the physics joint
  19420. */
  19421. type: number;
  19422. /**
  19423. * The data for the physics joint
  19424. */
  19425. jointData: PhysicsJointData;
  19426. private _physicsJoint;
  19427. protected _physicsPlugin: IPhysicsEnginePlugin;
  19428. /**
  19429. * Initializes the physics joint
  19430. * @param type The type of the physics joint
  19431. * @param jointData The data for the physics joint
  19432. */
  19433. constructor(
  19434. /**
  19435. * The type of the physics joint
  19436. */
  19437. type: number,
  19438. /**
  19439. * The data for the physics joint
  19440. */
  19441. jointData: PhysicsJointData);
  19442. /**
  19443. * Gets the physics joint
  19444. */
  19445. /**
  19446. * Sets the physics joint
  19447. */
  19448. physicsJoint: any;
  19449. /**
  19450. * Sets the physics plugin
  19451. */
  19452. physicsPlugin: IPhysicsEnginePlugin;
  19453. /**
  19454. * Execute a function that is physics-plugin specific.
  19455. * @param {Function} func the function that will be executed.
  19456. * It accepts two parameters: the physics world and the physics joint
  19457. */
  19458. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19459. /**
  19460. * Distance-Joint type
  19461. */
  19462. static DistanceJoint: number;
  19463. /**
  19464. * Hinge-Joint type
  19465. */
  19466. static HingeJoint: number;
  19467. /**
  19468. * Ball-and-Socket joint type
  19469. */
  19470. static BallAndSocketJoint: number;
  19471. /**
  19472. * Wheel-Joint type
  19473. */
  19474. static WheelJoint: number;
  19475. /**
  19476. * Slider-Joint type
  19477. */
  19478. static SliderJoint: number;
  19479. /**
  19480. * Prismatic-Joint type
  19481. */
  19482. static PrismaticJoint: number;
  19483. /**
  19484. * Universal-Joint type
  19485. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19486. */
  19487. static UniversalJoint: number;
  19488. /**
  19489. * Hinge-Joint 2 type
  19490. */
  19491. static Hinge2Joint: number;
  19492. /**
  19493. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19494. */
  19495. static PointToPointJoint: number;
  19496. /**
  19497. * Spring-Joint type
  19498. */
  19499. static SpringJoint: number;
  19500. /**
  19501. * Lock-Joint type
  19502. */
  19503. static LockJoint: number;
  19504. }
  19505. /**
  19506. * A class representing a physics distance joint
  19507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19508. */
  19509. export class DistanceJoint extends PhysicsJoint {
  19510. /**
  19511. *
  19512. * @param jointData The data for the Distance-Joint
  19513. */
  19514. constructor(jointData: DistanceJointData);
  19515. /**
  19516. * Update the predefined distance.
  19517. * @param maxDistance The maximum preferred distance
  19518. * @param minDistance The minimum preferred distance
  19519. */
  19520. updateDistance(maxDistance: number, minDistance?: number): void;
  19521. }
  19522. /**
  19523. * Represents a Motor-Enabled Joint
  19524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19525. */
  19526. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19527. /**
  19528. * Initializes the Motor-Enabled Joint
  19529. * @param type The type of the joint
  19530. * @param jointData The physica joint data for the joint
  19531. */
  19532. constructor(type: number, jointData: PhysicsJointData);
  19533. /**
  19534. * Set the motor values.
  19535. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19536. * @param force the force to apply
  19537. * @param maxForce max force for this motor.
  19538. */
  19539. setMotor(force?: number, maxForce?: number): void;
  19540. /**
  19541. * Set the motor's limits.
  19542. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19543. * @param upperLimit The upper limit of the motor
  19544. * @param lowerLimit The lower limit of the motor
  19545. */
  19546. setLimit(upperLimit: number, lowerLimit?: number): void;
  19547. }
  19548. /**
  19549. * This class represents a single physics Hinge-Joint
  19550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19551. */
  19552. export class HingeJoint extends MotorEnabledJoint {
  19553. /**
  19554. * Initializes the Hinge-Joint
  19555. * @param jointData The joint data for the Hinge-Joint
  19556. */
  19557. constructor(jointData: PhysicsJointData);
  19558. /**
  19559. * Set the motor values.
  19560. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19561. * @param {number} force the force to apply
  19562. * @param {number} maxForce max force for this motor.
  19563. */
  19564. setMotor(force?: number, maxForce?: number): void;
  19565. /**
  19566. * Set the motor's limits.
  19567. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19568. * @param upperLimit The upper limit of the motor
  19569. * @param lowerLimit The lower limit of the motor
  19570. */
  19571. setLimit(upperLimit: number, lowerLimit?: number): void;
  19572. }
  19573. /**
  19574. * This class represents a dual hinge physics joint (same as wheel joint)
  19575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19576. */
  19577. export class Hinge2Joint extends MotorEnabledJoint {
  19578. /**
  19579. * Initializes the Hinge2-Joint
  19580. * @param jointData The joint data for the Hinge2-Joint
  19581. */
  19582. constructor(jointData: PhysicsJointData);
  19583. /**
  19584. * Set the motor values.
  19585. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19586. * @param {number} targetSpeed the speed the motor is to reach
  19587. * @param {number} maxForce max force for this motor.
  19588. * @param {motorIndex} the motor's index, 0 or 1.
  19589. */
  19590. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19591. /**
  19592. * Set the motor limits.
  19593. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19594. * @param {number} upperLimit the upper limit
  19595. * @param {number} lowerLimit lower limit
  19596. * @param {motorIndex} the motor's index, 0 or 1.
  19597. */
  19598. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19599. }
  19600. /**
  19601. * Interface for a motor enabled joint
  19602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19603. */
  19604. export interface IMotorEnabledJoint {
  19605. /**
  19606. * Physics joint
  19607. */
  19608. physicsJoint: any;
  19609. /**
  19610. * Sets the motor of the motor-enabled joint
  19611. * @param force The force of the motor
  19612. * @param maxForce The maximum force of the motor
  19613. * @param motorIndex The index of the motor
  19614. */
  19615. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19616. /**
  19617. * Sets the limit of the motor
  19618. * @param upperLimit The upper limit of the motor
  19619. * @param lowerLimit The lower limit of the motor
  19620. * @param motorIndex The index of the motor
  19621. */
  19622. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19623. }
  19624. /**
  19625. * Joint data for a Distance-Joint
  19626. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19627. */
  19628. export interface DistanceJointData extends PhysicsJointData {
  19629. /**
  19630. * Max distance the 2 joint objects can be apart
  19631. */
  19632. maxDistance: number;
  19633. }
  19634. /**
  19635. * Joint data from a spring joint
  19636. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19637. */
  19638. export interface SpringJointData extends PhysicsJointData {
  19639. /**
  19640. * Length of the spring
  19641. */
  19642. length: number;
  19643. /**
  19644. * Stiffness of the spring
  19645. */
  19646. stiffness: number;
  19647. /**
  19648. * Damping of the spring
  19649. */
  19650. damping: number;
  19651. /** this callback will be called when applying the force to the impostors. */
  19652. forceApplicationCallback: () => void;
  19653. }
  19654. }
  19655. declare module BABYLON {
  19656. /**
  19657. * Holds the data for the raycast result
  19658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19659. */
  19660. export class PhysicsRaycastResult {
  19661. private _hasHit;
  19662. private _hitDistance;
  19663. private _hitNormalWorld;
  19664. private _hitPointWorld;
  19665. private _rayFromWorld;
  19666. private _rayToWorld;
  19667. /**
  19668. * Gets if there was a hit
  19669. */
  19670. readonly hasHit: boolean;
  19671. /**
  19672. * Gets the distance from the hit
  19673. */
  19674. readonly hitDistance: number;
  19675. /**
  19676. * Gets the hit normal/direction in the world
  19677. */
  19678. readonly hitNormalWorld: Vector3;
  19679. /**
  19680. * Gets the hit point in the world
  19681. */
  19682. readonly hitPointWorld: Vector3;
  19683. /**
  19684. * Gets the ray "start point" of the ray in the world
  19685. */
  19686. readonly rayFromWorld: Vector3;
  19687. /**
  19688. * Gets the ray "end point" of the ray in the world
  19689. */
  19690. readonly rayToWorld: Vector3;
  19691. /**
  19692. * Sets the hit data (normal & point in world space)
  19693. * @param hitNormalWorld defines the normal in world space
  19694. * @param hitPointWorld defines the point in world space
  19695. */
  19696. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19697. /**
  19698. * Sets the distance from the start point to the hit point
  19699. * @param distance
  19700. */
  19701. setHitDistance(distance: number): void;
  19702. /**
  19703. * Calculates the distance manually
  19704. */
  19705. calculateHitDistance(): void;
  19706. /**
  19707. * Resets all the values to default
  19708. * @param from The from point on world space
  19709. * @param to The to point on world space
  19710. */
  19711. reset(from?: Vector3, to?: Vector3): void;
  19712. }
  19713. /**
  19714. * Interface for the size containing width and height
  19715. */
  19716. interface IXYZ {
  19717. /**
  19718. * X
  19719. */
  19720. x: number;
  19721. /**
  19722. * Y
  19723. */
  19724. y: number;
  19725. /**
  19726. * Z
  19727. */
  19728. z: number;
  19729. }
  19730. }
  19731. declare module BABYLON {
  19732. /**
  19733. * Interface used to describe a physics joint
  19734. */
  19735. export interface PhysicsImpostorJoint {
  19736. /** Defines the main impostor to which the joint is linked */
  19737. mainImpostor: PhysicsImpostor;
  19738. /** Defines the impostor that is connected to the main impostor using this joint */
  19739. connectedImpostor: PhysicsImpostor;
  19740. /** Defines the joint itself */
  19741. joint: PhysicsJoint;
  19742. }
  19743. /** @hidden */
  19744. export interface IPhysicsEnginePlugin {
  19745. world: any;
  19746. name: string;
  19747. setGravity(gravity: Vector3): void;
  19748. setTimeStep(timeStep: number): void;
  19749. getTimeStep(): number;
  19750. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19751. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19752. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19753. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19754. removePhysicsBody(impostor: PhysicsImpostor): void;
  19755. generateJoint(joint: PhysicsImpostorJoint): void;
  19756. removeJoint(joint: PhysicsImpostorJoint): void;
  19757. isSupported(): boolean;
  19758. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19759. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19760. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19761. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19762. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19763. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19764. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19765. getBodyMass(impostor: PhysicsImpostor): number;
  19766. getBodyFriction(impostor: PhysicsImpostor): number;
  19767. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19768. getBodyRestitution(impostor: PhysicsImpostor): number;
  19769. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19770. getBodyPressure?(impostor: PhysicsImpostor): number;
  19771. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19772. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19773. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19774. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19775. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19776. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19777. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19778. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19779. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19780. sleepBody(impostor: PhysicsImpostor): void;
  19781. wakeUpBody(impostor: PhysicsImpostor): void;
  19782. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19783. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19784. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19785. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19786. getRadius(impostor: PhysicsImpostor): number;
  19787. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19788. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19789. dispose(): void;
  19790. }
  19791. /**
  19792. * Interface used to define a physics engine
  19793. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19794. */
  19795. export interface IPhysicsEngine {
  19796. /**
  19797. * Gets the gravity vector used by the simulation
  19798. */
  19799. gravity: Vector3;
  19800. /**
  19801. * Sets the gravity vector used by the simulation
  19802. * @param gravity defines the gravity vector to use
  19803. */
  19804. setGravity(gravity: Vector3): void;
  19805. /**
  19806. * Set the time step of the physics engine.
  19807. * Default is 1/60.
  19808. * To slow it down, enter 1/600 for example.
  19809. * To speed it up, 1/30
  19810. * @param newTimeStep the new timestep to apply to this world.
  19811. */
  19812. setTimeStep(newTimeStep: number): void;
  19813. /**
  19814. * Get the time step of the physics engine.
  19815. * @returns the current time step
  19816. */
  19817. getTimeStep(): number;
  19818. /**
  19819. * Release all resources
  19820. */
  19821. dispose(): void;
  19822. /**
  19823. * Gets the name of the current physics plugin
  19824. * @returns the name of the plugin
  19825. */
  19826. getPhysicsPluginName(): string;
  19827. /**
  19828. * Adding a new impostor for the impostor tracking.
  19829. * This will be done by the impostor itself.
  19830. * @param impostor the impostor to add
  19831. */
  19832. addImpostor(impostor: PhysicsImpostor): void;
  19833. /**
  19834. * Remove an impostor from the engine.
  19835. * This impostor and its mesh will not longer be updated by the physics engine.
  19836. * @param impostor the impostor to remove
  19837. */
  19838. removeImpostor(impostor: PhysicsImpostor): void;
  19839. /**
  19840. * Add a joint to the physics engine
  19841. * @param mainImpostor defines the main impostor to which the joint is added.
  19842. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19843. * @param joint defines the joint that will connect both impostors.
  19844. */
  19845. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19846. /**
  19847. * Removes a joint from the simulation
  19848. * @param mainImpostor defines the impostor used with the joint
  19849. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19850. * @param joint defines the joint to remove
  19851. */
  19852. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19853. /**
  19854. * Gets the current plugin used to run the simulation
  19855. * @returns current plugin
  19856. */
  19857. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19858. /**
  19859. * Gets the list of physic impostors
  19860. * @returns an array of PhysicsImpostor
  19861. */
  19862. getImpostors(): Array<PhysicsImpostor>;
  19863. /**
  19864. * Gets the impostor for a physics enabled object
  19865. * @param object defines the object impersonated by the impostor
  19866. * @returns the PhysicsImpostor or null if not found
  19867. */
  19868. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19869. /**
  19870. * Gets the impostor for a physics body object
  19871. * @param body defines physics body used by the impostor
  19872. * @returns the PhysicsImpostor or null if not found
  19873. */
  19874. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19875. /**
  19876. * Does a raycast in the physics world
  19877. * @param from when should the ray start?
  19878. * @param to when should the ray end?
  19879. * @returns PhysicsRaycastResult
  19880. */
  19881. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19882. /**
  19883. * Called by the scene. No need to call it.
  19884. * @param delta defines the timespam between frames
  19885. */ step(delta: number): void;
  19886. }
  19887. }
  19888. declare module BABYLON {
  19889. /**
  19890. * The interface for the physics imposter parameters
  19891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19892. */
  19893. export interface PhysicsImpostorParameters {
  19894. /**
  19895. * The mass of the physics imposter
  19896. */
  19897. mass: number;
  19898. /**
  19899. * The friction of the physics imposter
  19900. */
  19901. friction?: number;
  19902. /**
  19903. * The coefficient of restitution of the physics imposter
  19904. */
  19905. restitution?: number;
  19906. /**
  19907. * The native options of the physics imposter
  19908. */
  19909. nativeOptions?: any;
  19910. /**
  19911. * Specifies if the parent should be ignored
  19912. */
  19913. ignoreParent?: boolean;
  19914. /**
  19915. * Specifies if bi-directional transformations should be disabled
  19916. */
  19917. disableBidirectionalTransformation?: boolean;
  19918. /**
  19919. * The pressure inside the physics imposter, soft object only
  19920. */
  19921. pressure?: number;
  19922. /**
  19923. * The stiffness the physics imposter, soft object only
  19924. */
  19925. stiffness?: number;
  19926. /**
  19927. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19928. */
  19929. velocityIterations?: number;
  19930. /**
  19931. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19932. */
  19933. positionIterations?: number;
  19934. /**
  19935. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19936. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19937. * Add to fix multiple points
  19938. */
  19939. fixedPoints?: number;
  19940. /**
  19941. * The collision margin around a soft object
  19942. */
  19943. margin?: number;
  19944. /**
  19945. * The collision margin around a soft object
  19946. */
  19947. damping?: number;
  19948. /**
  19949. * The path for a rope based on an extrusion
  19950. */
  19951. path?: any;
  19952. /**
  19953. * The shape of an extrusion used for a rope based on an extrusion
  19954. */
  19955. shape?: any;
  19956. }
  19957. /**
  19958. * Interface for a physics-enabled object
  19959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19960. */
  19961. export interface IPhysicsEnabledObject {
  19962. /**
  19963. * The position of the physics-enabled object
  19964. */
  19965. position: Vector3;
  19966. /**
  19967. * The rotation of the physics-enabled object
  19968. */
  19969. rotationQuaternion: Nullable<Quaternion>;
  19970. /**
  19971. * The scale of the physics-enabled object
  19972. */
  19973. scaling: Vector3;
  19974. /**
  19975. * The rotation of the physics-enabled object
  19976. */
  19977. rotation?: Vector3;
  19978. /**
  19979. * The parent of the physics-enabled object
  19980. */
  19981. parent?: any;
  19982. /**
  19983. * The bounding info of the physics-enabled object
  19984. * @returns The bounding info of the physics-enabled object
  19985. */
  19986. getBoundingInfo(): BoundingInfo;
  19987. /**
  19988. * Computes the world matrix
  19989. * @param force Specifies if the world matrix should be computed by force
  19990. * @returns A world matrix
  19991. */
  19992. computeWorldMatrix(force: boolean): Matrix;
  19993. /**
  19994. * Gets the world matrix
  19995. * @returns A world matrix
  19996. */
  19997. getWorldMatrix?(): Matrix;
  19998. /**
  19999. * Gets the child meshes
  20000. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20001. * @returns An array of abstract meshes
  20002. */
  20003. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20004. /**
  20005. * Gets the vertex data
  20006. * @param kind The type of vertex data
  20007. * @returns A nullable array of numbers, or a float32 array
  20008. */
  20009. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20010. /**
  20011. * Gets the indices from the mesh
  20012. * @returns A nullable array of index arrays
  20013. */
  20014. getIndices?(): Nullable<IndicesArray>;
  20015. /**
  20016. * Gets the scene from the mesh
  20017. * @returns the indices array or null
  20018. */
  20019. getScene?(): Scene;
  20020. /**
  20021. * Gets the absolute position from the mesh
  20022. * @returns the absolute position
  20023. */
  20024. getAbsolutePosition(): Vector3;
  20025. /**
  20026. * Gets the absolute pivot point from the mesh
  20027. * @returns the absolute pivot point
  20028. */
  20029. getAbsolutePivotPoint(): Vector3;
  20030. /**
  20031. * Rotates the mesh
  20032. * @param axis The axis of rotation
  20033. * @param amount The amount of rotation
  20034. * @param space The space of the rotation
  20035. * @returns The rotation transform node
  20036. */
  20037. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20038. /**
  20039. * Translates the mesh
  20040. * @param axis The axis of translation
  20041. * @param distance The distance of translation
  20042. * @param space The space of the translation
  20043. * @returns The transform node
  20044. */
  20045. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20046. /**
  20047. * Sets the absolute position of the mesh
  20048. * @param absolutePosition The absolute position of the mesh
  20049. * @returns The transform node
  20050. */
  20051. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20052. /**
  20053. * Gets the class name of the mesh
  20054. * @returns The class name
  20055. */
  20056. getClassName(): string;
  20057. }
  20058. /**
  20059. * Represents a physics imposter
  20060. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20061. */
  20062. export class PhysicsImpostor {
  20063. /**
  20064. * The physics-enabled object used as the physics imposter
  20065. */
  20066. object: IPhysicsEnabledObject;
  20067. /**
  20068. * The type of the physics imposter
  20069. */
  20070. type: number;
  20071. private _options;
  20072. private _scene?;
  20073. /**
  20074. * The default object size of the imposter
  20075. */
  20076. static DEFAULT_OBJECT_SIZE: Vector3;
  20077. /**
  20078. * The identity quaternion of the imposter
  20079. */
  20080. static IDENTITY_QUATERNION: Quaternion;
  20081. /** @hidden */ pluginData: any;
  20082. private _physicsEngine;
  20083. private _physicsBody;
  20084. private _bodyUpdateRequired;
  20085. private _onBeforePhysicsStepCallbacks;
  20086. private _onAfterPhysicsStepCallbacks;
  20087. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  20088. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20089. otherImpostors: Array<PhysicsImpostor>;
  20090. }>;
  20091. private _deltaPosition;
  20092. private _deltaRotation;
  20093. private _deltaRotationConjugated;
  20094. /** hidden */ isFromLine: boolean;
  20095. private _parent;
  20096. private _isDisposed;
  20097. private static _tmpVecs;
  20098. private static _tmpQuat;
  20099. /**
  20100. * Specifies if the physics imposter is disposed
  20101. */
  20102. readonly isDisposed: boolean;
  20103. /**
  20104. * Gets the mass of the physics imposter
  20105. */
  20106. mass: number;
  20107. /**
  20108. * Gets the coefficient of friction
  20109. */
  20110. /**
  20111. * Sets the coefficient of friction
  20112. */
  20113. friction: number;
  20114. /**
  20115. * Gets the coefficient of restitution
  20116. */
  20117. /**
  20118. * Sets the coefficient of restitution
  20119. */
  20120. restitution: number;
  20121. /**
  20122. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20123. */
  20124. /**
  20125. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20126. */
  20127. pressure: number;
  20128. /**
  20129. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20130. */
  20131. /**
  20132. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20133. */
  20134. stiffness: number;
  20135. /**
  20136. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20137. */
  20138. /**
  20139. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20140. */
  20141. velocityIterations: number;
  20142. /**
  20143. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20144. */
  20145. /**
  20146. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20147. */
  20148. positionIterations: number;
  20149. /**
  20150. * The unique id of the physics imposter
  20151. * set by the physics engine when adding this impostor to the array
  20152. */
  20153. uniqueId: number;
  20154. /**
  20155. * @hidden
  20156. */
  20157. soft: boolean;
  20158. /**
  20159. * @hidden
  20160. */
  20161. segments: number;
  20162. private _joints;
  20163. /**
  20164. * Initializes the physics imposter
  20165. * @param object The physics-enabled object used as the physics imposter
  20166. * @param type The type of the physics imposter
  20167. * @param _options The options for the physics imposter
  20168. * @param _scene The Babylon scene
  20169. */
  20170. constructor(
  20171. /**
  20172. * The physics-enabled object used as the physics imposter
  20173. */
  20174. object: IPhysicsEnabledObject,
  20175. /**
  20176. * The type of the physics imposter
  20177. */
  20178. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20179. /**
  20180. * This function will completly initialize this impostor.
  20181. * It will create a new body - but only if this mesh has no parent.
  20182. * If it has, this impostor will not be used other than to define the impostor
  20183. * of the child mesh.
  20184. * @hidden
  20185. */ init(): void;
  20186. private _getPhysicsParent;
  20187. /**
  20188. * Should a new body be generated.
  20189. * @returns boolean specifying if body initialization is required
  20190. */
  20191. isBodyInitRequired(): boolean;
  20192. /**
  20193. * Sets the updated scaling
  20194. * @param updated Specifies if the scaling is updated
  20195. */
  20196. setScalingUpdated(): void;
  20197. /**
  20198. * Force a regeneration of this or the parent's impostor's body.
  20199. * Use under cautious - This will remove all joints already implemented.
  20200. */
  20201. forceUpdate(): void;
  20202. /**
  20203. * Gets the body that holds this impostor. Either its own, or its parent.
  20204. */
  20205. /**
  20206. * Set the physics body. Used mainly by the physics engine/plugin
  20207. */
  20208. physicsBody: any;
  20209. /**
  20210. * Get the parent of the physics imposter
  20211. * @returns Physics imposter or null
  20212. */
  20213. /**
  20214. * Sets the parent of the physics imposter
  20215. */
  20216. parent: Nullable<PhysicsImpostor>;
  20217. /**
  20218. * Resets the update flags
  20219. */
  20220. resetUpdateFlags(): void;
  20221. /**
  20222. * Gets the object extend size
  20223. * @returns the object extend size
  20224. */
  20225. getObjectExtendSize(): Vector3;
  20226. /**
  20227. * Gets the object center
  20228. * @returns The object center
  20229. */
  20230. getObjectCenter(): Vector3;
  20231. /**
  20232. * Get a specific parametes from the options parameter
  20233. * @param paramName The object parameter name
  20234. * @returns The object parameter
  20235. */
  20236. getParam(paramName: string): any;
  20237. /**
  20238. * Sets a specific parameter in the options given to the physics plugin
  20239. * @param paramName The parameter name
  20240. * @param value The value of the parameter
  20241. */
  20242. setParam(paramName: string, value: number): void;
  20243. /**
  20244. * Specifically change the body's mass option. Won't recreate the physics body object
  20245. * @param mass The mass of the physics imposter
  20246. */
  20247. setMass(mass: number): void;
  20248. /**
  20249. * Gets the linear velocity
  20250. * @returns linear velocity or null
  20251. */
  20252. getLinearVelocity(): Nullable<Vector3>;
  20253. /**
  20254. * Sets the linear velocity
  20255. * @param velocity linear velocity or null
  20256. */
  20257. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20258. /**
  20259. * Gets the angular velocity
  20260. * @returns angular velocity or null
  20261. */
  20262. getAngularVelocity(): Nullable<Vector3>;
  20263. /**
  20264. * Sets the angular velocity
  20265. * @param velocity The velocity or null
  20266. */
  20267. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20268. /**
  20269. * Execute a function with the physics plugin native code
  20270. * Provide a function the will have two variables - the world object and the physics body object
  20271. * @param func The function to execute with the physics plugin native code
  20272. */
  20273. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20274. /**
  20275. * Register a function that will be executed before the physics world is stepping forward
  20276. * @param func The function to execute before the physics world is stepped forward
  20277. */
  20278. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20279. /**
  20280. * Unregister a function that will be executed before the physics world is stepping forward
  20281. * @param func The function to execute before the physics world is stepped forward
  20282. */
  20283. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20284. /**
  20285. * Register a function that will be executed after the physics step
  20286. * @param func The function to execute after physics step
  20287. */
  20288. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20289. /**
  20290. * Unregisters a function that will be executed after the physics step
  20291. * @param func The function to execute after physics step
  20292. */
  20293. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20294. /**
  20295. * register a function that will be executed when this impostor collides against a different body
  20296. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20297. * @param func Callback that is executed on collision
  20298. */
  20299. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20300. /**
  20301. * Unregisters the physics imposter on contact
  20302. * @param collideAgainst The physics object to collide against
  20303. * @param func Callback to execute on collision
  20304. */
  20305. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20306. private _tmpQuat;
  20307. private _tmpQuat2;
  20308. /**
  20309. * Get the parent rotation
  20310. * @returns The parent rotation
  20311. */
  20312. getParentsRotation(): Quaternion;
  20313. /**
  20314. * this function is executed by the physics engine.
  20315. */
  20316. beforeStep: () => void;
  20317. /**
  20318. * this function is executed by the physics engine
  20319. */
  20320. afterStep: () => void;
  20321. /**
  20322. * Legacy collision detection event support
  20323. */
  20324. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20325. /**
  20326. * event and body object due to cannon's event-based architecture.
  20327. */
  20328. onCollide: (e: {
  20329. body: any;
  20330. }) => void;
  20331. /**
  20332. * Apply a force
  20333. * @param force The force to apply
  20334. * @param contactPoint The contact point for the force
  20335. * @returns The physics imposter
  20336. */
  20337. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20338. /**
  20339. * Apply an impulse
  20340. * @param force The impulse force
  20341. * @param contactPoint The contact point for the impulse force
  20342. * @returns The physics imposter
  20343. */
  20344. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20345. /**
  20346. * A help function to create a joint
  20347. * @param otherImpostor A physics imposter used to create a joint
  20348. * @param jointType The type of joint
  20349. * @param jointData The data for the joint
  20350. * @returns The physics imposter
  20351. */
  20352. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20353. /**
  20354. * Add a joint to this impostor with a different impostor
  20355. * @param otherImpostor A physics imposter used to add a joint
  20356. * @param joint The joint to add
  20357. * @returns The physics imposter
  20358. */
  20359. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20360. /**
  20361. * Add an anchor to a cloth impostor
  20362. * @param otherImpostor rigid impostor to anchor to
  20363. * @param width ratio across width from 0 to 1
  20364. * @param height ratio up height from 0 to 1
  20365. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20366. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20367. * @returns impostor the soft imposter
  20368. */
  20369. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20370. /**
  20371. * Add a hook to a rope impostor
  20372. * @param otherImpostor rigid impostor to anchor to
  20373. * @param length ratio across rope from 0 to 1
  20374. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20375. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20376. * @returns impostor the rope imposter
  20377. */
  20378. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20379. /**
  20380. * Will keep this body still, in a sleep mode.
  20381. * @returns the physics imposter
  20382. */
  20383. sleep(): PhysicsImpostor;
  20384. /**
  20385. * Wake the body up.
  20386. * @returns The physics imposter
  20387. */
  20388. wakeUp(): PhysicsImpostor;
  20389. /**
  20390. * Clones the physics imposter
  20391. * @param newObject The physics imposter clones to this physics-enabled object
  20392. * @returns A nullable physics imposter
  20393. */
  20394. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20395. /**
  20396. * Disposes the physics imposter
  20397. */
  20398. dispose(): void;
  20399. /**
  20400. * Sets the delta position
  20401. * @param position The delta position amount
  20402. */
  20403. setDeltaPosition(position: Vector3): void;
  20404. /**
  20405. * Sets the delta rotation
  20406. * @param rotation The delta rotation amount
  20407. */
  20408. setDeltaRotation(rotation: Quaternion): void;
  20409. /**
  20410. * Gets the box size of the physics imposter and stores the result in the input parameter
  20411. * @param result Stores the box size
  20412. * @returns The physics imposter
  20413. */
  20414. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20415. /**
  20416. * Gets the radius of the physics imposter
  20417. * @returns Radius of the physics imposter
  20418. */
  20419. getRadius(): number;
  20420. /**
  20421. * Sync a bone with this impostor
  20422. * @param bone The bone to sync to the impostor.
  20423. * @param boneMesh The mesh that the bone is influencing.
  20424. * @param jointPivot The pivot of the joint / bone in local space.
  20425. * @param distToJoint Optional distance from the impostor to the joint.
  20426. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20427. */
  20428. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20429. /**
  20430. * Sync impostor to a bone
  20431. * @param bone The bone that the impostor will be synced to.
  20432. * @param boneMesh The mesh that the bone is influencing.
  20433. * @param jointPivot The pivot of the joint / bone in local space.
  20434. * @param distToJoint Optional distance from the impostor to the joint.
  20435. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20436. * @param boneAxis Optional vector3 axis the bone is aligned with
  20437. */
  20438. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20439. /**
  20440. * No-Imposter type
  20441. */
  20442. static NoImpostor: number;
  20443. /**
  20444. * Sphere-Imposter type
  20445. */
  20446. static SphereImpostor: number;
  20447. /**
  20448. * Box-Imposter type
  20449. */
  20450. static BoxImpostor: number;
  20451. /**
  20452. * Plane-Imposter type
  20453. */
  20454. static PlaneImpostor: number;
  20455. /**
  20456. * Mesh-imposter type
  20457. */
  20458. static MeshImpostor: number;
  20459. /**
  20460. * Cylinder-Imposter type
  20461. */
  20462. static CylinderImpostor: number;
  20463. /**
  20464. * Particle-Imposter type
  20465. */
  20466. static ParticleImpostor: number;
  20467. /**
  20468. * Heightmap-Imposter type
  20469. */
  20470. static HeightmapImpostor: number;
  20471. /**
  20472. * ConvexHull-Impostor type (Ammo.js plugin only)
  20473. */
  20474. static ConvexHullImpostor: number;
  20475. /**
  20476. * Rope-Imposter type
  20477. */
  20478. static RopeImpostor: number;
  20479. /**
  20480. * Cloth-Imposter type
  20481. */
  20482. static ClothImpostor: number;
  20483. /**
  20484. * Softbody-Imposter type
  20485. */
  20486. static SoftbodyImpostor: number;
  20487. }
  20488. }
  20489. declare module BABYLON {
  20490. /**
  20491. * @hidden
  20492. **/
  20493. export class _CreationDataStorage {
  20494. closePath?: boolean;
  20495. closeArray?: boolean;
  20496. idx: number[];
  20497. dashSize: number;
  20498. gapSize: number;
  20499. path3D: Path3D;
  20500. pathArray: Vector3[][];
  20501. arc: number;
  20502. radius: number;
  20503. cap: number;
  20504. tessellation: number;
  20505. }
  20506. /**
  20507. * @hidden
  20508. **/ private class _InstanceDataStorage {
  20509. visibleInstances: any;
  20510. batchCache: _InstancesBatch;
  20511. instancesBufferSize: number;
  20512. instancesBuffer: Nullable<Buffer>;
  20513. instancesData: Float32Array;
  20514. overridenInstanceCount: number;
  20515. isFrozen: boolean;
  20516. previousBatch: _InstancesBatch;
  20517. hardwareInstancedRendering: boolean;
  20518. sideOrientation: number;
  20519. }
  20520. /**
  20521. * @hidden
  20522. **/
  20523. export class _InstancesBatch {
  20524. mustReturn: boolean;
  20525. visibleInstances: Nullable<InstancedMesh[]>[];
  20526. renderSelf: boolean[];
  20527. hardwareInstancedRendering: boolean[];
  20528. }
  20529. /**
  20530. * Class used to represent renderable models
  20531. */
  20532. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20533. /**
  20534. * Mesh side orientation : usually the external or front surface
  20535. */
  20536. static readonly FRONTSIDE: number;
  20537. /**
  20538. * Mesh side orientation : usually the internal or back surface
  20539. */
  20540. static readonly BACKSIDE: number;
  20541. /**
  20542. * Mesh side orientation : both internal and external or front and back surfaces
  20543. */
  20544. static readonly DOUBLESIDE: number;
  20545. /**
  20546. * Mesh side orientation : by default, `FRONTSIDE`
  20547. */
  20548. static readonly DEFAULTSIDE: number;
  20549. /**
  20550. * Mesh cap setting : no cap
  20551. */
  20552. static readonly NO_CAP: number;
  20553. /**
  20554. * Mesh cap setting : one cap at the beginning of the mesh
  20555. */
  20556. static readonly CAP_START: number;
  20557. /**
  20558. * Mesh cap setting : one cap at the end of the mesh
  20559. */
  20560. static readonly CAP_END: number;
  20561. /**
  20562. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20563. */
  20564. static readonly CAP_ALL: number;
  20565. /**
  20566. * Gets the default side orientation.
  20567. * @param orientation the orientation to value to attempt to get
  20568. * @returns the default orientation
  20569. * @hidden
  20570. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20571. private _onBeforeRenderObservable;
  20572. private _onBeforeBindObservable;
  20573. private _onAfterRenderObservable;
  20574. private _onBeforeDrawObservable;
  20575. /**
  20576. * An event triggered before rendering the mesh
  20577. */
  20578. readonly onBeforeRenderObservable: Observable<Mesh>;
  20579. /**
  20580. * An event triggered before binding the mesh
  20581. */
  20582. readonly onBeforeBindObservable: Observable<Mesh>;
  20583. /**
  20584. * An event triggered after rendering the mesh
  20585. */
  20586. readonly onAfterRenderObservable: Observable<Mesh>;
  20587. /**
  20588. * An event triggered before drawing the mesh
  20589. */
  20590. readonly onBeforeDrawObservable: Observable<Mesh>;
  20591. private _onBeforeDrawObserver;
  20592. /**
  20593. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20594. */
  20595. onBeforeDraw: () => void;
  20596. /**
  20597. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20598. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20599. */
  20600. delayLoadState: number;
  20601. /**
  20602. * Gets the list of instances created from this mesh
  20603. * it is not supposed to be modified manually.
  20604. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20605. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20606. */
  20607. instances: InstancedMesh[];
  20608. /**
  20609. * Gets the file containing delay loading data for this mesh
  20610. */
  20611. delayLoadingFile: string;
  20612. /** @hidden */ binaryInfo: any;
  20613. private _LODLevels;
  20614. /**
  20615. * User defined function used to change how LOD level selection is done
  20616. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20617. */
  20618. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20619. private _morphTargetManager;
  20620. /**
  20621. * Gets or sets the morph target manager
  20622. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20623. */
  20624. morphTargetManager: Nullable<MorphTargetManager>;
  20625. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20626. /** @hidden */ geometry: Nullable<Geometry>;
  20627. /** @hidden */ delayInfo: Array<string>;
  20628. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20629. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20630. private _effectiveMaterial;
  20631. /** @hidden */ shouldGenerateFlatShading: boolean;
  20632. private _preActivateId;
  20633. /** @hidden */ originalBuilderSideOrientation: number;
  20634. /**
  20635. * Use this property to change the original side orientation defined at construction time
  20636. */
  20637. overrideMaterialSideOrientation: Nullable<number>;
  20638. private _areNormalsFrozen;
  20639. private _sourcePositions;
  20640. private _sourceNormals;
  20641. private _source;
  20642. private meshMap;
  20643. /**
  20644. * Gets the source mesh (the one used to clone this one from)
  20645. */
  20646. readonly source: Nullable<Mesh>;
  20647. /**
  20648. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20649. */
  20650. isUnIndexed: boolean;
  20651. /**
  20652. * @constructor
  20653. * @param name The value used by scene.getMeshByName() to do a lookup.
  20654. * @param scene The scene to add this mesh to.
  20655. * @param parent The parent of this mesh, if it has one
  20656. * @param source An optional Mesh from which geometry is shared, cloned.
  20657. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20658. * When false, achieved by calling a clone(), also passing False.
  20659. * This will make creation of children, recursive.
  20660. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20661. */
  20662. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20663. /**
  20664. * Gets the class name
  20665. * @returns the string "Mesh".
  20666. */
  20667. getClassName(): string;
  20668. /** @hidden */ protected readonly _isMesh: boolean;
  20669. /**
  20670. * Returns a description of this mesh
  20671. * @param fullDetails define if full details about this mesh must be used
  20672. * @returns a descriptive string representing this mesh
  20673. */
  20674. toString(fullDetails?: boolean): string;
  20675. /** @hidden */ unBindEffect(): void;
  20676. /**
  20677. * Gets a boolean indicating if this mesh has LOD
  20678. */
  20679. readonly hasLODLevels: boolean;
  20680. /**
  20681. * Gets the list of MeshLODLevel associated with the current mesh
  20682. * @returns an array of MeshLODLevel
  20683. */
  20684. getLODLevels(): MeshLODLevel[];
  20685. private _sortLODLevels;
  20686. /**
  20687. * Add a mesh as LOD level triggered at the given distance.
  20688. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20689. * @param distance The distance from the center of the object to show this level
  20690. * @param mesh The mesh to be added as LOD level (can be null)
  20691. * @return This mesh (for chaining)
  20692. */
  20693. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20694. /**
  20695. * Returns the LOD level mesh at the passed distance or null if not found.
  20696. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20697. * @param distance The distance from the center of the object to show this level
  20698. * @returns a Mesh or `null`
  20699. */
  20700. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20701. /**
  20702. * Remove a mesh from the LOD array
  20703. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20704. * @param mesh defines the mesh to be removed
  20705. * @return This mesh (for chaining)
  20706. */
  20707. removeLODLevel(mesh: Mesh): Mesh;
  20708. /**
  20709. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20710. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20711. * @param camera defines the camera to use to compute distance
  20712. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20713. * @return This mesh (for chaining)
  20714. */
  20715. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20716. /**
  20717. * Gets the mesh internal Geometry object
  20718. */
  20719. readonly geometry: Nullable<Geometry>;
  20720. /**
  20721. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20722. * @returns the total number of vertices
  20723. */
  20724. getTotalVertices(): number;
  20725. /**
  20726. * Returns the content of an associated vertex buffer
  20727. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20728. * - VertexBuffer.PositionKind
  20729. * - VertexBuffer.UVKind
  20730. * - VertexBuffer.UV2Kind
  20731. * - VertexBuffer.UV3Kind
  20732. * - VertexBuffer.UV4Kind
  20733. * - VertexBuffer.UV5Kind
  20734. * - VertexBuffer.UV6Kind
  20735. * - VertexBuffer.ColorKind
  20736. * - VertexBuffer.MatricesIndicesKind
  20737. * - VertexBuffer.MatricesIndicesExtraKind
  20738. * - VertexBuffer.MatricesWeightsKind
  20739. * - VertexBuffer.MatricesWeightsExtraKind
  20740. * @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
  20741. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20742. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20743. */
  20744. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20745. /**
  20746. * Returns the mesh VertexBuffer object from the requested `kind`
  20747. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20748. * - VertexBuffer.PositionKind
  20749. * - VertexBuffer.UVKind
  20750. * - VertexBuffer.UV2Kind
  20751. * - VertexBuffer.UV3Kind
  20752. * - VertexBuffer.UV4Kind
  20753. * - VertexBuffer.UV5Kind
  20754. * - VertexBuffer.UV6Kind
  20755. * - VertexBuffer.ColorKind
  20756. * - VertexBuffer.MatricesIndicesKind
  20757. * - VertexBuffer.MatricesIndicesExtraKind
  20758. * - VertexBuffer.MatricesWeightsKind
  20759. * - VertexBuffer.MatricesWeightsExtraKind
  20760. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20761. */
  20762. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20763. /**
  20764. * Tests if a specific vertex buffer is associated with this mesh
  20765. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20766. * - VertexBuffer.PositionKind
  20767. * - VertexBuffer.UVKind
  20768. * - VertexBuffer.UV2Kind
  20769. * - VertexBuffer.UV3Kind
  20770. * - VertexBuffer.UV4Kind
  20771. * - VertexBuffer.UV5Kind
  20772. * - VertexBuffer.UV6Kind
  20773. * - VertexBuffer.ColorKind
  20774. * - VertexBuffer.MatricesIndicesKind
  20775. * - VertexBuffer.MatricesIndicesExtraKind
  20776. * - VertexBuffer.MatricesWeightsKind
  20777. * - VertexBuffer.MatricesWeightsExtraKind
  20778. * @returns a boolean
  20779. */
  20780. isVerticesDataPresent(kind: string): boolean;
  20781. /**
  20782. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20783. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20784. * - VertexBuffer.PositionKind
  20785. * - VertexBuffer.UVKind
  20786. * - VertexBuffer.UV2Kind
  20787. * - VertexBuffer.UV3Kind
  20788. * - VertexBuffer.UV4Kind
  20789. * - VertexBuffer.UV5Kind
  20790. * - VertexBuffer.UV6Kind
  20791. * - VertexBuffer.ColorKind
  20792. * - VertexBuffer.MatricesIndicesKind
  20793. * - VertexBuffer.MatricesIndicesExtraKind
  20794. * - VertexBuffer.MatricesWeightsKind
  20795. * - VertexBuffer.MatricesWeightsExtraKind
  20796. * @returns a boolean
  20797. */
  20798. isVertexBufferUpdatable(kind: string): boolean;
  20799. /**
  20800. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20801. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20802. * - VertexBuffer.PositionKind
  20803. * - VertexBuffer.UVKind
  20804. * - VertexBuffer.UV2Kind
  20805. * - VertexBuffer.UV3Kind
  20806. * - VertexBuffer.UV4Kind
  20807. * - VertexBuffer.UV5Kind
  20808. * - VertexBuffer.UV6Kind
  20809. * - VertexBuffer.ColorKind
  20810. * - VertexBuffer.MatricesIndicesKind
  20811. * - VertexBuffer.MatricesIndicesExtraKind
  20812. * - VertexBuffer.MatricesWeightsKind
  20813. * - VertexBuffer.MatricesWeightsExtraKind
  20814. * @returns an array of strings
  20815. */
  20816. getVerticesDataKinds(): string[];
  20817. /**
  20818. * Returns a positive integer : the total number of indices in this mesh geometry.
  20819. * @returns the numner of indices or zero if the mesh has no geometry.
  20820. */
  20821. getTotalIndices(): number;
  20822. /**
  20823. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20824. * @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.
  20825. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20826. * @returns the indices array or an empty array if the mesh has no geometry
  20827. */
  20828. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20829. readonly isBlocked: boolean;
  20830. /**
  20831. * Determine if the current mesh is ready to be rendered
  20832. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20833. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20834. * @returns true if all associated assets are ready (material, textures, shaders)
  20835. */
  20836. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20837. /**
  20838. * 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.
  20839. */
  20840. readonly areNormalsFrozen: boolean;
  20841. /**
  20842. * 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.
  20843. * @returns the current mesh
  20844. */
  20845. freezeNormals(): Mesh;
  20846. /**
  20847. * 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
  20848. * @returns the current mesh
  20849. */
  20850. unfreezeNormals(): Mesh;
  20851. /**
  20852. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20853. */
  20854. overridenInstanceCount: number;
  20855. /** @hidden */ preActivate(): Mesh;
  20856. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20857. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20858. /**
  20859. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20860. * This means the mesh underlying bounding box and sphere are recomputed.
  20861. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20862. * @returns the current mesh
  20863. */
  20864. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20865. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20866. /**
  20867. * This function will subdivide the mesh into multiple submeshes
  20868. * @param count defines the expected number of submeshes
  20869. */
  20870. subdivide(count: number): void;
  20871. /**
  20872. * Copy a FloatArray into a specific associated vertex buffer
  20873. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20874. * - VertexBuffer.PositionKind
  20875. * - VertexBuffer.UVKind
  20876. * - VertexBuffer.UV2Kind
  20877. * - VertexBuffer.UV3Kind
  20878. * - VertexBuffer.UV4Kind
  20879. * - VertexBuffer.UV5Kind
  20880. * - VertexBuffer.UV6Kind
  20881. * - VertexBuffer.ColorKind
  20882. * - VertexBuffer.MatricesIndicesKind
  20883. * - VertexBuffer.MatricesIndicesExtraKind
  20884. * - VertexBuffer.MatricesWeightsKind
  20885. * - VertexBuffer.MatricesWeightsExtraKind
  20886. * @param data defines the data source
  20887. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20888. * @param stride defines the data stride size (can be null)
  20889. * @returns the current mesh
  20890. */
  20891. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20892. /**
  20893. * Flags an associated vertex buffer as updatable
  20894. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20895. * - VertexBuffer.PositionKind
  20896. * - VertexBuffer.UVKind
  20897. * - VertexBuffer.UV2Kind
  20898. * - VertexBuffer.UV3Kind
  20899. * - VertexBuffer.UV4Kind
  20900. * - VertexBuffer.UV5Kind
  20901. * - VertexBuffer.UV6Kind
  20902. * - VertexBuffer.ColorKind
  20903. * - VertexBuffer.MatricesIndicesKind
  20904. * - VertexBuffer.MatricesIndicesExtraKind
  20905. * - VertexBuffer.MatricesWeightsKind
  20906. * - VertexBuffer.MatricesWeightsExtraKind
  20907. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20908. */
  20909. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20910. /**
  20911. * Sets the mesh global Vertex Buffer
  20912. * @param buffer defines the buffer to use
  20913. * @returns the current mesh
  20914. */
  20915. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20916. /**
  20917. * Update a specific associated vertex buffer
  20918. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20919. * - VertexBuffer.PositionKind
  20920. * - VertexBuffer.UVKind
  20921. * - VertexBuffer.UV2Kind
  20922. * - VertexBuffer.UV3Kind
  20923. * - VertexBuffer.UV4Kind
  20924. * - VertexBuffer.UV5Kind
  20925. * - VertexBuffer.UV6Kind
  20926. * - VertexBuffer.ColorKind
  20927. * - VertexBuffer.MatricesIndicesKind
  20928. * - VertexBuffer.MatricesIndicesExtraKind
  20929. * - VertexBuffer.MatricesWeightsKind
  20930. * - VertexBuffer.MatricesWeightsExtraKind
  20931. * @param data defines the data source
  20932. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20933. * @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)
  20934. * @returns the current mesh
  20935. */
  20936. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20937. /**
  20938. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20939. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20940. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20941. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20942. * @returns the current mesh
  20943. */
  20944. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20945. /**
  20946. * Creates a un-shared specific occurence of the geometry for the mesh.
  20947. * @returns the current mesh
  20948. */
  20949. makeGeometryUnique(): Mesh;
  20950. /**
  20951. * Set the index buffer of this mesh
  20952. * @param indices defines the source data
  20953. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20954. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20955. * @returns the current mesh
  20956. */
  20957. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20958. /**
  20959. * Update the current index buffer
  20960. * @param indices defines the source data
  20961. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20962. * @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)
  20963. * @returns the current mesh
  20964. */
  20965. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20966. /**
  20967. * Invert the geometry to move from a right handed system to a left handed one.
  20968. * @returns the current mesh
  20969. */
  20970. toLeftHanded(): Mesh;
  20971. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20972. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20973. /**
  20974. * Registers for this mesh a javascript function called just before the rendering process
  20975. * @param func defines the function to call before rendering this mesh
  20976. * @returns the current mesh
  20977. */
  20978. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20979. /**
  20980. * Disposes a previously registered javascript function called before the rendering
  20981. * @param func defines the function to remove
  20982. * @returns the current mesh
  20983. */
  20984. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20985. /**
  20986. * Registers for this mesh a javascript function called just after the rendering is complete
  20987. * @param func defines the function to call after rendering this mesh
  20988. * @returns the current mesh
  20989. */
  20990. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20991. /**
  20992. * Disposes a previously registered javascript function called after the rendering.
  20993. * @param func defines the function to remove
  20994. * @returns the current mesh
  20995. */
  20996. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20997. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20998. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20999. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21000. /** @hidden */ freeze(): void;
  21001. /** @hidden */ unFreeze(): void;
  21002. /**
  21003. * 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
  21004. * @param subMesh defines the subMesh to render
  21005. * @param enableAlphaMode defines if alpha mode can be changed
  21006. * @returns the current mesh
  21007. */
  21008. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21009. private _onBeforeDraw;
  21010. /**
  21011. * Renormalize the mesh and patch it up if there are no weights
  21012. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21013. * However in the case of zero weights then we set just a single influence to 1.
  21014. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21015. */
  21016. cleanMatrixWeights(): void;
  21017. private normalizeSkinFourWeights;
  21018. private normalizeSkinWeightsAndExtra;
  21019. /**
  21020. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21021. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21022. * the user know there was an issue with importing the mesh
  21023. * @returns a validation object with skinned, valid and report string
  21024. */
  21025. validateSkinning(): {
  21026. skinned: boolean;
  21027. valid: boolean;
  21028. report: string;
  21029. };
  21030. /** @hidden */ checkDelayState(): Mesh;
  21031. private _queueLoad;
  21032. /**
  21033. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21034. * A mesh is in the frustum if its bounding box intersects the frustum
  21035. * @param frustumPlanes defines the frustum to test
  21036. * @returns true if the mesh is in the frustum planes
  21037. */
  21038. isInFrustum(frustumPlanes: Plane[]): boolean;
  21039. /**
  21040. * Sets the mesh material by the material or multiMaterial `id` property
  21041. * @param id is a string identifying the material or the multiMaterial
  21042. * @returns the current mesh
  21043. */
  21044. setMaterialByID(id: string): Mesh;
  21045. /**
  21046. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21047. * @returns an array of IAnimatable
  21048. */
  21049. getAnimatables(): IAnimatable[];
  21050. /**
  21051. * Modifies the mesh geometry according to the passed transformation matrix.
  21052. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21053. * The mesh normals are modified using the same transformation.
  21054. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21055. * @param transform defines the transform matrix to use
  21056. * @see http://doc.babylonjs.com/resources/baking_transformations
  21057. * @returns the current mesh
  21058. */
  21059. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21060. /**
  21061. * Modifies the mesh geometry according to its own current World Matrix.
  21062. * The mesh World Matrix is then reset.
  21063. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21064. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21065. * @see http://doc.babylonjs.com/resources/baking_transformations
  21066. * @returns the current mesh
  21067. */
  21068. bakeCurrentTransformIntoVertices(): Mesh;
  21069. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  21070. /** @hidden */ resetPointsArrayCache(): Mesh;
  21071. /** @hidden */ generatePointsArray(): boolean;
  21072. /**
  21073. * Returns a new Mesh object generated from the current mesh properties.
  21074. * This method must not get confused with createInstance()
  21075. * @param name is a string, the name given to the new mesh
  21076. * @param newParent can be any Node object (default `null`)
  21077. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21078. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21079. * @returns a new mesh
  21080. */
  21081. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21082. /**
  21083. * Releases resources associated with this mesh.
  21084. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21085. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21086. */
  21087. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21088. /**
  21089. * Modifies the mesh geometry according to a displacement map.
  21090. * 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.
  21091. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21092. * @param url is a string, the URL from the image file is to be downloaded.
  21093. * @param minHeight is the lower limit of the displacement.
  21094. * @param maxHeight is the upper limit of the displacement.
  21095. * @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.
  21096. * @param uvOffset is an optional vector2 used to offset UV.
  21097. * @param uvScale is an optional vector2 used to scale UV.
  21098. * @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.
  21099. * @returns the Mesh.
  21100. */
  21101. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21102. /**
  21103. * Modifies the mesh geometry according to a displacementMap buffer.
  21104. * 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.
  21105. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21106. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21107. * @param heightMapWidth is the width of the buffer image.
  21108. * @param heightMapHeight is the height of the buffer image.
  21109. * @param minHeight is the lower limit of the displacement.
  21110. * @param maxHeight is the upper limit of the displacement.
  21111. * @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.
  21112. * @param uvOffset is an optional vector2 used to offset UV.
  21113. * @param uvScale is an optional vector2 used to scale UV.
  21114. * @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.
  21115. * @returns the Mesh.
  21116. */
  21117. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21118. /**
  21119. * Modify the mesh to get a flat shading rendering.
  21120. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21121. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21122. * @returns current mesh
  21123. */
  21124. convertToFlatShadedMesh(): Mesh;
  21125. /**
  21126. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21127. * In other words, more vertices, no more indices and a single bigger VBO.
  21128. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21129. * @returns current mesh
  21130. */
  21131. convertToUnIndexedMesh(): Mesh;
  21132. /**
  21133. * Inverses facet orientations.
  21134. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21135. * @param flipNormals will also inverts the normals
  21136. * @returns current mesh
  21137. */
  21138. flipFaces(flipNormals?: boolean): Mesh;
  21139. /**
  21140. * Increase the number of facets and hence vertices in a mesh
  21141. * Vertex normals are interpolated from existing vertex normals
  21142. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21143. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21144. */
  21145. increaseVertices(numberPerEdge: number): void;
  21146. /**
  21147. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21148. * This will undo any application of covertToFlatShadedMesh
  21149. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21150. */
  21151. forceSharedVertices(): void;
  21152. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21153. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21154. /**
  21155. * Creates a new InstancedMesh object from the mesh model.
  21156. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21157. * @param name defines the name of the new instance
  21158. * @returns a new InstancedMesh
  21159. */
  21160. createInstance(name: string): InstancedMesh;
  21161. /**
  21162. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21163. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21164. * @returns the current mesh
  21165. */
  21166. synchronizeInstances(): Mesh;
  21167. /**
  21168. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21169. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21170. * This should be used together with the simplification to avoid disappearing triangles.
  21171. * @param successCallback an optional success callback to be called after the optimization finished.
  21172. * @returns the current mesh
  21173. */
  21174. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21175. /**
  21176. * Serialize current mesh
  21177. * @param serializationObject defines the object which will receive the serialization data
  21178. */
  21179. serialize(serializationObject: any): void;
  21180. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  21181. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21182. /**
  21183. * Returns a new Mesh object parsed from the source provided.
  21184. * @param parsedMesh is the source
  21185. * @param scene defines the hosting scene
  21186. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21187. * @returns a new Mesh
  21188. */
  21189. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21190. /**
  21191. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21192. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21193. * @param name defines the name of the mesh to create
  21194. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21195. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21196. * @param closePath creates a seam between the first and the last points of each path of the path array
  21197. * @param offset is taken in account only if the `pathArray` is containing a single path
  21198. * @param scene defines the hosting scene
  21199. * @param updatable defines if the mesh must be flagged as updatable
  21200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21201. * @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)
  21202. * @returns a new Mesh
  21203. */
  21204. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21205. /**
  21206. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21207. * @param name defines the name of the mesh to create
  21208. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21209. * @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
  21210. * @param scene defines the hosting scene
  21211. * @param updatable defines if the mesh must be flagged as updatable
  21212. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21213. * @returns a new Mesh
  21214. */
  21215. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21216. /**
  21217. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21218. * @param name defines the name of the mesh to create
  21219. * @param size sets the size (float) of each box side (default 1)
  21220. * @param scene defines the hosting scene
  21221. * @param updatable defines if the mesh must be flagged as updatable
  21222. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21223. * @returns a new Mesh
  21224. */
  21225. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21226. /**
  21227. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21228. * @param name defines the name of the mesh to create
  21229. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21230. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21231. * @param scene defines the hosting scene
  21232. * @param updatable defines if the mesh must be flagged as updatable
  21233. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21234. * @returns a new Mesh
  21235. */
  21236. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21237. /**
  21238. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21239. * @param name defines the name of the mesh to create
  21240. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21241. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21242. * @param scene defines the hosting scene
  21243. * @returns a new Mesh
  21244. */
  21245. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21246. /**
  21247. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21248. * @param name defines the name of the mesh to create
  21249. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21250. * @param diameterTop set the top cap diameter (floats, default 1)
  21251. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21252. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21253. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21254. * @param scene defines the hosting scene
  21255. * @param updatable defines if the mesh must be flagged as updatable
  21256. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21257. * @returns a new Mesh
  21258. */
  21259. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21260. /**
  21261. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21262. * @param name defines the name of the mesh to create
  21263. * @param diameter sets the diameter size (float) of the torus (default 1)
  21264. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21265. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21266. * @param scene defines the hosting scene
  21267. * @param updatable defines if the mesh must be flagged as updatable
  21268. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21269. * @returns a new Mesh
  21270. */
  21271. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21272. /**
  21273. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21274. * @param name defines the name of the mesh to create
  21275. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21276. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21277. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21278. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21279. * @param p the number of windings on X axis (positive integers, default 2)
  21280. * @param q the number of windings on Y axis (positive integers, default 3)
  21281. * @param scene defines the hosting scene
  21282. * @param updatable defines if the mesh must be flagged as updatable
  21283. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21284. * @returns a new Mesh
  21285. */
  21286. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21287. /**
  21288. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21289. * @param name defines the name of the mesh to create
  21290. * @param points is an array successive Vector3
  21291. * @param scene defines the hosting scene
  21292. * @param updatable defines if the mesh must be flagged as updatable
  21293. * @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).
  21294. * @returns a new Mesh
  21295. */
  21296. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21297. /**
  21298. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21299. * @param name defines the name of the mesh to create
  21300. * @param points is an array successive Vector3
  21301. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21302. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21303. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21304. * @param scene defines the hosting scene
  21305. * @param updatable defines if the mesh must be flagged as updatable
  21306. * @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)
  21307. * @returns a new Mesh
  21308. */
  21309. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21310. /**
  21311. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21312. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21313. * 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.
  21314. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21315. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21316. * Remember you can only change the shape positions, not their number when updating a polygon.
  21317. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21318. * @param name defines the name of the mesh to create
  21319. * @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
  21320. * @param scene defines the hosting scene
  21321. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21322. * @param updatable defines if the mesh must be flagged as updatable
  21323. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21324. * @param earcutInjection can be used to inject your own earcut reference
  21325. * @returns a new Mesh
  21326. */
  21327. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21328. /**
  21329. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21330. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21331. * @param name defines the name of the mesh to create
  21332. * @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
  21333. * @param depth defines the height of extrusion
  21334. * @param scene defines the hosting scene
  21335. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21336. * @param updatable defines if the mesh must be flagged as updatable
  21337. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21338. * @param earcutInjection can be used to inject your own earcut reference
  21339. * @returns a new Mesh
  21340. */
  21341. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21342. /**
  21343. * Creates an extruded shape mesh.
  21344. * 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
  21345. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21346. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21347. * @param name defines the name of the mesh to create
  21348. * @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
  21349. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21350. * @param scale is the value to scale the shape
  21351. * @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
  21352. * @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
  21353. * @param scene defines the hosting scene
  21354. * @param updatable defines if the mesh must be flagged as updatable
  21355. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21356. * @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)
  21357. * @returns a new Mesh
  21358. */
  21359. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21360. /**
  21361. * Creates an custom extruded shape mesh.
  21362. * The custom extrusion is a parametric shape.
  21363. * It has no predefined shape. Its final shape will depend on the input parameters.
  21364. * Please consider using the same method from the MeshBuilder class instead
  21365. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21366. * @param name defines the name of the mesh to create
  21367. * @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
  21368. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21369. * @param scaleFunction is a custom Javascript function called on each path point
  21370. * @param rotationFunction is a custom Javascript function called on each path point
  21371. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21372. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21373. * @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
  21374. * @param scene defines the hosting scene
  21375. * @param updatable defines if the mesh must be flagged as updatable
  21376. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21377. * @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)
  21378. * @returns a new Mesh
  21379. */
  21380. 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;
  21381. /**
  21382. * Creates lathe mesh.
  21383. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21384. * Please consider using the same method from the MeshBuilder class instead
  21385. * @param name defines the name of the mesh to create
  21386. * @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
  21387. * @param radius is the radius value of the lathe
  21388. * @param tessellation is the side number of the lathe.
  21389. * @param scene defines the hosting scene
  21390. * @param updatable defines if the mesh must be flagged as updatable
  21391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21392. * @returns a new Mesh
  21393. */
  21394. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21395. /**
  21396. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21397. * @param name defines the name of the mesh to create
  21398. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21399. * @param scene defines the hosting scene
  21400. * @param updatable defines if the mesh must be flagged as updatable
  21401. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21402. * @returns a new Mesh
  21403. */
  21404. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21405. /**
  21406. * Creates a ground mesh.
  21407. * Please consider using the same method from the MeshBuilder class instead
  21408. * @param name defines the name of the mesh to create
  21409. * @param width set the width of the ground
  21410. * @param height set the height of the ground
  21411. * @param subdivisions sets the number of subdivisions per side
  21412. * @param scene defines the hosting scene
  21413. * @param updatable defines if the mesh must be flagged as updatable
  21414. * @returns a new Mesh
  21415. */
  21416. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21417. /**
  21418. * Creates a tiled ground mesh.
  21419. * Please consider using the same method from the MeshBuilder class instead
  21420. * @param name defines the name of the mesh to create
  21421. * @param xmin set the ground minimum X coordinate
  21422. * @param zmin set the ground minimum Y coordinate
  21423. * @param xmax set the ground maximum X coordinate
  21424. * @param zmax set the ground maximum Z coordinate
  21425. * @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
  21426. * @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
  21427. * @param scene defines the hosting scene
  21428. * @param updatable defines if the mesh must be flagged as updatable
  21429. * @returns a new Mesh
  21430. */
  21431. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21432. w: number;
  21433. h: number;
  21434. }, precision: {
  21435. w: number;
  21436. h: number;
  21437. }, scene: Scene, updatable?: boolean): Mesh;
  21438. /**
  21439. * Creates a ground mesh from a height map.
  21440. * Please consider using the same method from the MeshBuilder class instead
  21441. * @see http://doc.babylonjs.com/babylon101/height_map
  21442. * @param name defines the name of the mesh to create
  21443. * @param url sets the URL of the height map image resource
  21444. * @param width set the ground width size
  21445. * @param height set the ground height size
  21446. * @param subdivisions sets the number of subdivision per side
  21447. * @param minHeight is the minimum altitude on the ground
  21448. * @param maxHeight is the maximum altitude on the ground
  21449. * @param scene defines the hosting scene
  21450. * @param updatable defines if the mesh must be flagged as updatable
  21451. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21452. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21453. * @returns a new Mesh
  21454. */
  21455. 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;
  21456. /**
  21457. * Creates a tube mesh.
  21458. * The tube is a parametric shape.
  21459. * It has no predefined shape. Its final shape will depend on the input parameters.
  21460. * Please consider using the same method from the MeshBuilder class instead
  21461. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21462. * @param name defines the name of the mesh to create
  21463. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21464. * @param radius sets the tube radius size
  21465. * @param tessellation is the number of sides on the tubular surface
  21466. * @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
  21467. * @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
  21468. * @param scene defines the hosting scene
  21469. * @param updatable defines if the mesh must be flagged as updatable
  21470. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21471. * @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)
  21472. * @returns a new Mesh
  21473. */
  21474. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21475. (i: number, distance: number): number;
  21476. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21477. /**
  21478. * Creates a polyhedron mesh.
  21479. * Please consider using the same method from the MeshBuilder class instead.
  21480. * * 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
  21481. * * The parameter `size` (positive float, default 1) sets the polygon size
  21482. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21483. * * 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`
  21484. * * 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
  21485. * * 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)`)
  21486. * * 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
  21487. * * 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
  21488. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21489. * * 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
  21490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21491. * @param name defines the name of the mesh to create
  21492. * @param options defines the options used to create the mesh
  21493. * @param scene defines the hosting scene
  21494. * @returns a new Mesh
  21495. */
  21496. static CreatePolyhedron(name: string, options: {
  21497. type?: number;
  21498. size?: number;
  21499. sizeX?: number;
  21500. sizeY?: number;
  21501. sizeZ?: number;
  21502. custom?: any;
  21503. faceUV?: Vector4[];
  21504. faceColors?: Color4[];
  21505. updatable?: boolean;
  21506. sideOrientation?: number;
  21507. }, scene: Scene): Mesh;
  21508. /**
  21509. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21510. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21511. * * 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`)
  21512. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21513. * * 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
  21514. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21515. * * 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
  21516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21517. * @param name defines the name of the mesh
  21518. * @param options defines the options used to create the mesh
  21519. * @param scene defines the hosting scene
  21520. * @returns a new Mesh
  21521. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21522. */
  21523. static CreateIcoSphere(name: string, options: {
  21524. radius?: number;
  21525. flat?: boolean;
  21526. subdivisions?: number;
  21527. sideOrientation?: number;
  21528. updatable?: boolean;
  21529. }, scene: Scene): Mesh;
  21530. /**
  21531. * Creates a decal mesh.
  21532. * Please consider using the same method from the MeshBuilder class instead.
  21533. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21534. * @param name defines the name of the mesh
  21535. * @param sourceMesh defines the mesh receiving the decal
  21536. * @param position sets the position of the decal in world coordinates
  21537. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21538. * @param size sets the decal scaling
  21539. * @param angle sets the angle to rotate the decal
  21540. * @returns a new Mesh
  21541. */
  21542. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21543. /**
  21544. * Prepare internal position array for software CPU skinning
  21545. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21546. */
  21547. setPositionsForCPUSkinning(): Float32Array;
  21548. /**
  21549. * Prepare internal normal array for software CPU skinning
  21550. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21551. */
  21552. setNormalsForCPUSkinning(): Float32Array;
  21553. /**
  21554. * Updates the vertex buffer by applying transformation from the bones
  21555. * @param skeleton defines the skeleton to apply to current mesh
  21556. * @returns the current mesh
  21557. */
  21558. applySkeleton(skeleton: Skeleton): Mesh;
  21559. /**
  21560. * 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
  21561. * @param meshes defines the list of meshes to scan
  21562. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21563. */
  21564. static MinMax(meshes: AbstractMesh[]): {
  21565. min: Vector3;
  21566. max: Vector3;
  21567. };
  21568. /**
  21569. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21570. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21571. * @returns a vector3
  21572. */
  21573. static Center(meshesOrMinMaxVector: {
  21574. min: Vector3;
  21575. max: Vector3;
  21576. } | AbstractMesh[]): Vector3;
  21577. /**
  21578. * Merge the array of meshes into a single mesh for performance reasons.
  21579. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21580. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21581. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21582. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21583. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21584. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21585. * @returns a new mesh
  21586. */
  21587. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21588. /** @hidden */
  21589. addInstance(instance: InstancedMesh): void;
  21590. /** @hidden */
  21591. removeInstance(instance: InstancedMesh): void;
  21592. }
  21593. }
  21594. declare module BABYLON {
  21595. /**
  21596. * Base class for the main features of a material in Babylon.js
  21597. */
  21598. export class Material implements IAnimatable {
  21599. /**
  21600. * Returns the triangle fill mode
  21601. */
  21602. static readonly TriangleFillMode: number;
  21603. /**
  21604. * Returns the wireframe mode
  21605. */
  21606. static readonly WireFrameFillMode: number;
  21607. /**
  21608. * Returns the point fill mode
  21609. */
  21610. static readonly PointFillMode: number;
  21611. /**
  21612. * Returns the point list draw mode
  21613. */
  21614. static readonly PointListDrawMode: number;
  21615. /**
  21616. * Returns the line list draw mode
  21617. */
  21618. static readonly LineListDrawMode: number;
  21619. /**
  21620. * Returns the line loop draw mode
  21621. */
  21622. static readonly LineLoopDrawMode: number;
  21623. /**
  21624. * Returns the line strip draw mode
  21625. */
  21626. static readonly LineStripDrawMode: number;
  21627. /**
  21628. * Returns the triangle strip draw mode
  21629. */
  21630. static readonly TriangleStripDrawMode: number;
  21631. /**
  21632. * Returns the triangle fan draw mode
  21633. */
  21634. static readonly TriangleFanDrawMode: number;
  21635. /**
  21636. * Stores the clock-wise side orientation
  21637. */
  21638. static readonly ClockWiseSideOrientation: number;
  21639. /**
  21640. * Stores the counter clock-wise side orientation
  21641. */
  21642. static readonly CounterClockWiseSideOrientation: number;
  21643. /**
  21644. * The dirty texture flag value
  21645. */
  21646. static readonly TextureDirtyFlag: number;
  21647. /**
  21648. * The dirty light flag value
  21649. */
  21650. static readonly LightDirtyFlag: number;
  21651. /**
  21652. * The dirty fresnel flag value
  21653. */
  21654. static readonly FresnelDirtyFlag: number;
  21655. /**
  21656. * The dirty attribute flag value
  21657. */
  21658. static readonly AttributesDirtyFlag: number;
  21659. /**
  21660. * The dirty misc flag value
  21661. */
  21662. static readonly MiscDirtyFlag: number;
  21663. /**
  21664. * The all dirty flag value
  21665. */
  21666. static readonly AllDirtyFlag: number;
  21667. /**
  21668. * The ID of the material
  21669. */
  21670. id: string;
  21671. /**
  21672. * Gets or sets the unique id of the material
  21673. */
  21674. uniqueId: number;
  21675. /**
  21676. * The name of the material
  21677. */
  21678. name: string;
  21679. /**
  21680. * Gets or sets user defined metadata
  21681. */
  21682. metadata: any;
  21683. /**
  21684. * For internal use only. Please do not use.
  21685. */
  21686. reservedDataStore: any;
  21687. /**
  21688. * Specifies if the ready state should be checked on each call
  21689. */
  21690. checkReadyOnEveryCall: boolean;
  21691. /**
  21692. * Specifies if the ready state should be checked once
  21693. */
  21694. checkReadyOnlyOnce: boolean;
  21695. /**
  21696. * The state of the material
  21697. */
  21698. state: string;
  21699. /**
  21700. * The alpha value of the material
  21701. */
  21702. protected _alpha: number;
  21703. /**
  21704. * List of inspectable custom properties (used by the Inspector)
  21705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21706. */
  21707. inspectableCustomProperties: IInspectable[];
  21708. /**
  21709. * Sets the alpha value of the material
  21710. */
  21711. /**
  21712. * Gets the alpha value of the material
  21713. */
  21714. alpha: number;
  21715. /**
  21716. * Specifies if back face culling is enabled
  21717. */
  21718. protected _backFaceCulling: boolean;
  21719. /**
  21720. * Sets the back-face culling state
  21721. */
  21722. /**
  21723. * Gets the back-face culling state
  21724. */
  21725. backFaceCulling: boolean;
  21726. /**
  21727. * Stores the value for side orientation
  21728. */
  21729. sideOrientation: number;
  21730. /**
  21731. * Callback triggered when the material is compiled
  21732. */
  21733. onCompiled: Nullable<(effect: Effect) => void>;
  21734. /**
  21735. * Callback triggered when an error occurs
  21736. */
  21737. onError: Nullable<(effect: Effect, errors: string) => void>;
  21738. /**
  21739. * Callback triggered to get the render target textures
  21740. */
  21741. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21742. /**
  21743. * Gets a boolean indicating that current material needs to register RTT
  21744. */
  21745. readonly hasRenderTargetTextures: boolean;
  21746. /**
  21747. * Specifies if the material should be serialized
  21748. */
  21749. doNotSerialize: boolean;
  21750. /**
  21751. * @hidden
  21752. */ storeEffectOnSubMeshes: boolean;
  21753. /**
  21754. * Stores the animations for the material
  21755. */
  21756. animations: Nullable<Array<Animation>>;
  21757. /**
  21758. * An event triggered when the material is disposed
  21759. */
  21760. onDisposeObservable: Observable<Material>;
  21761. /**
  21762. * An observer which watches for dispose events
  21763. */
  21764. private _onDisposeObserver;
  21765. private _onUnBindObservable;
  21766. /**
  21767. * Called during a dispose event
  21768. */
  21769. onDispose: () => void;
  21770. private _onBindObservable;
  21771. /**
  21772. * An event triggered when the material is bound
  21773. */
  21774. readonly onBindObservable: Observable<AbstractMesh>;
  21775. /**
  21776. * An observer which watches for bind events
  21777. */
  21778. private _onBindObserver;
  21779. /**
  21780. * Called during a bind event
  21781. */
  21782. onBind: (Mesh: AbstractMesh) => void;
  21783. /**
  21784. * An event triggered when the material is unbound
  21785. */
  21786. readonly onUnBindObservable: Observable<Material>;
  21787. /**
  21788. * Stores the value of the alpha mode
  21789. */
  21790. private _alphaMode;
  21791. /**
  21792. * Sets the value of the alpha mode.
  21793. *
  21794. * | Value | Type | Description |
  21795. * | --- | --- | --- |
  21796. * | 0 | ALPHA_DISABLE | |
  21797. * | 1 | ALPHA_ADD | |
  21798. * | 2 | ALPHA_COMBINE | |
  21799. * | 3 | ALPHA_SUBTRACT | |
  21800. * | 4 | ALPHA_MULTIPLY | |
  21801. * | 5 | ALPHA_MAXIMIZED | |
  21802. * | 6 | ALPHA_ONEONE | |
  21803. * | 7 | ALPHA_PREMULTIPLIED | |
  21804. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21805. * | 9 | ALPHA_INTERPOLATE | |
  21806. * | 10 | ALPHA_SCREENMODE | |
  21807. *
  21808. */
  21809. /**
  21810. * Gets the value of the alpha mode
  21811. */
  21812. alphaMode: number;
  21813. /**
  21814. * Stores the state of the need depth pre-pass value
  21815. */
  21816. private _needDepthPrePass;
  21817. /**
  21818. * Sets the need depth pre-pass value
  21819. */
  21820. /**
  21821. * Gets the depth pre-pass value
  21822. */
  21823. needDepthPrePass: boolean;
  21824. /**
  21825. * Specifies if depth writing should be disabled
  21826. */
  21827. disableDepthWrite: boolean;
  21828. /**
  21829. * Specifies if depth writing should be forced
  21830. */
  21831. forceDepthWrite: boolean;
  21832. /**
  21833. * Specifies if there should be a separate pass for culling
  21834. */
  21835. separateCullingPass: boolean;
  21836. /**
  21837. * Stores the state specifing if fog should be enabled
  21838. */
  21839. private _fogEnabled;
  21840. /**
  21841. * Sets the state for enabling fog
  21842. */
  21843. /**
  21844. * Gets the value of the fog enabled state
  21845. */
  21846. fogEnabled: boolean;
  21847. /**
  21848. * Stores the size of points
  21849. */
  21850. pointSize: number;
  21851. /**
  21852. * Stores the z offset value
  21853. */
  21854. zOffset: number;
  21855. /**
  21856. * Gets a value specifying if wireframe mode is enabled
  21857. */
  21858. /**
  21859. * Sets the state of wireframe mode
  21860. */
  21861. wireframe: boolean;
  21862. /**
  21863. * Gets the value specifying if point clouds are enabled
  21864. */
  21865. /**
  21866. * Sets the state of point cloud mode
  21867. */
  21868. pointsCloud: boolean;
  21869. /**
  21870. * Gets the material fill mode
  21871. */
  21872. /**
  21873. * Sets the material fill mode
  21874. */
  21875. fillMode: number;
  21876. /**
  21877. * @hidden
  21878. * Stores the effects for the material
  21879. */ effect: Nullable<Effect>;
  21880. /**
  21881. * @hidden
  21882. * Specifies if the material was previously ready
  21883. */ wasPreviouslyReady: boolean;
  21884. /**
  21885. * Specifies if uniform buffers should be used
  21886. */
  21887. private _useUBO;
  21888. /**
  21889. * Stores a reference to the scene
  21890. */
  21891. private _scene;
  21892. /**
  21893. * Stores the fill mode state
  21894. */
  21895. private _fillMode;
  21896. /**
  21897. * Specifies if the depth write state should be cached
  21898. */
  21899. private _cachedDepthWriteState;
  21900. /**
  21901. * Stores the uniform buffer
  21902. */
  21903. protected _uniformBuffer: UniformBuffer;
  21904. /** @hidden */ indexInSceneMaterialArray: number;
  21905. /** @hidden */
  21906. meshMap: Nullable<{
  21907. [id: string]: AbstractMesh | undefined;
  21908. }>;
  21909. /**
  21910. * Creates a material instance
  21911. * @param name defines the name of the material
  21912. * @param scene defines the scene to reference
  21913. * @param doNotAdd specifies if the material should be added to the scene
  21914. */
  21915. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21916. /**
  21917. * Returns a string representation of the current material
  21918. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21919. * @returns a string with material information
  21920. */
  21921. toString(fullDetails?: boolean): string;
  21922. /**
  21923. * Gets the class name of the material
  21924. * @returns a string with the class name of the material
  21925. */
  21926. getClassName(): string;
  21927. /**
  21928. * Specifies if updates for the material been locked
  21929. */
  21930. readonly isFrozen: boolean;
  21931. /**
  21932. * Locks updates for the material
  21933. */
  21934. freeze(): void;
  21935. /**
  21936. * Unlocks updates for the material
  21937. */
  21938. unfreeze(): void;
  21939. /**
  21940. * Specifies if the material is ready to be used
  21941. * @param mesh defines the mesh to check
  21942. * @param useInstances specifies if instances should be used
  21943. * @returns a boolean indicating if the material is ready to be used
  21944. */
  21945. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21946. /**
  21947. * Specifies that the submesh is ready to be used
  21948. * @param mesh defines the mesh to check
  21949. * @param subMesh defines which submesh to check
  21950. * @param useInstances specifies that instances should be used
  21951. * @returns a boolean indicating that the submesh is ready or not
  21952. */
  21953. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21954. /**
  21955. * Returns the material effect
  21956. * @returns the effect associated with the material
  21957. */
  21958. getEffect(): Nullable<Effect>;
  21959. /**
  21960. * Returns the current scene
  21961. * @returns a Scene
  21962. */
  21963. getScene(): Scene;
  21964. /**
  21965. * Specifies if the material will require alpha blending
  21966. * @returns a boolean specifying if alpha blending is needed
  21967. */
  21968. needAlphaBlending(): boolean;
  21969. /**
  21970. * Specifies if the mesh will require alpha blending
  21971. * @param mesh defines the mesh to check
  21972. * @returns a boolean specifying if alpha blending is needed for the mesh
  21973. */
  21974. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21975. /**
  21976. * Specifies if this material should be rendered in alpha test mode
  21977. * @returns a boolean specifying if an alpha test is needed.
  21978. */
  21979. needAlphaTesting(): boolean;
  21980. /**
  21981. * Gets the texture used for the alpha test
  21982. * @returns the texture to use for alpha testing
  21983. */
  21984. getAlphaTestTexture(): Nullable<BaseTexture>;
  21985. /**
  21986. * Marks the material to indicate that it needs to be re-calculated
  21987. */
  21988. markDirty(): void;
  21989. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21990. /**
  21991. * Binds the material to the mesh
  21992. * @param world defines the world transformation matrix
  21993. * @param mesh defines the mesh to bind the material to
  21994. */
  21995. bind(world: Matrix, mesh?: Mesh): void;
  21996. /**
  21997. * Binds the submesh to the material
  21998. * @param world defines the world transformation matrix
  21999. * @param mesh defines the mesh containing the submesh
  22000. * @param subMesh defines the submesh to bind the material to
  22001. */
  22002. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22003. /**
  22004. * Binds the world matrix to the material
  22005. * @param world defines the world transformation matrix
  22006. */
  22007. bindOnlyWorldMatrix(world: Matrix): void;
  22008. /**
  22009. * Binds the scene's uniform buffer to the effect.
  22010. * @param effect defines the effect to bind to the scene uniform buffer
  22011. * @param sceneUbo defines the uniform buffer storing scene data
  22012. */
  22013. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22014. /**
  22015. * Binds the view matrix to the effect
  22016. * @param effect defines the effect to bind the view matrix to
  22017. */
  22018. bindView(effect: Effect): void;
  22019. /**
  22020. * Binds the view projection matrix to the effect
  22021. * @param effect defines the effect to bind the view projection matrix to
  22022. */
  22023. bindViewProjection(effect: Effect): void;
  22024. /**
  22025. * Specifies if material alpha testing should be turned on for the mesh
  22026. * @param mesh defines the mesh to check
  22027. */
  22028. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22029. /**
  22030. * Processes to execute after binding the material to a mesh
  22031. * @param mesh defines the rendered mesh
  22032. */
  22033. protected _afterBind(mesh?: Mesh): void;
  22034. /**
  22035. * Unbinds the material from the mesh
  22036. */
  22037. unbind(): void;
  22038. /**
  22039. * Gets the active textures from the material
  22040. * @returns an array of textures
  22041. */
  22042. getActiveTextures(): BaseTexture[];
  22043. /**
  22044. * Specifies if the material uses a texture
  22045. * @param texture defines the texture to check against the material
  22046. * @returns a boolean specifying if the material uses the texture
  22047. */
  22048. hasTexture(texture: BaseTexture): boolean;
  22049. /**
  22050. * Makes a duplicate of the material, and gives it a new name
  22051. * @param name defines the new name for the duplicated material
  22052. * @returns the cloned material
  22053. */
  22054. clone(name: string): Nullable<Material>;
  22055. /**
  22056. * Gets the meshes bound to the material
  22057. * @returns an array of meshes bound to the material
  22058. */
  22059. getBindedMeshes(): AbstractMesh[];
  22060. /**
  22061. * Force shader compilation
  22062. * @param mesh defines the mesh associated with this material
  22063. * @param onCompiled defines a function to execute once the material is compiled
  22064. * @param options defines the options to configure the compilation
  22065. */
  22066. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22067. clipPlane: boolean;
  22068. }>): void;
  22069. /**
  22070. * Force shader compilation
  22071. * @param mesh defines the mesh that will use this material
  22072. * @param options defines additional options for compiling the shaders
  22073. * @returns a promise that resolves when the compilation completes
  22074. */
  22075. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22076. clipPlane: boolean;
  22077. }>): Promise<void>;
  22078. private static readonly _ImageProcessingDirtyCallBack;
  22079. private static readonly _TextureDirtyCallBack;
  22080. private static readonly _FresnelDirtyCallBack;
  22081. private static readonly _MiscDirtyCallBack;
  22082. private static readonly _LightsDirtyCallBack;
  22083. private static readonly _AttributeDirtyCallBack;
  22084. private static _FresnelAndMiscDirtyCallBack;
  22085. private static _TextureAndMiscDirtyCallBack;
  22086. private static readonly _DirtyCallbackArray;
  22087. private static readonly _RunDirtyCallBacks;
  22088. /**
  22089. * Marks a define in the material to indicate that it needs to be re-computed
  22090. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22091. */
  22092. markAsDirty(flag: number): void;
  22093. /**
  22094. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22095. * @param func defines a function which checks material defines against the submeshes
  22096. */
  22097. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22098. /**
  22099. * Indicates that image processing needs to be re-calculated for all submeshes
  22100. */
  22101. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22102. /**
  22103. * Indicates that textures need to be re-calculated for all submeshes
  22104. */
  22105. protected _markAllSubMeshesAsTexturesDirty(): void;
  22106. /**
  22107. * Indicates that fresnel needs to be re-calculated for all submeshes
  22108. */
  22109. protected _markAllSubMeshesAsFresnelDirty(): void;
  22110. /**
  22111. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22112. */
  22113. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22114. /**
  22115. * Indicates that lights need to be re-calculated for all submeshes
  22116. */
  22117. protected _markAllSubMeshesAsLightsDirty(): void;
  22118. /**
  22119. * Indicates that attributes need to be re-calculated for all submeshes
  22120. */
  22121. protected _markAllSubMeshesAsAttributesDirty(): void;
  22122. /**
  22123. * Indicates that misc needs to be re-calculated for all submeshes
  22124. */
  22125. protected _markAllSubMeshesAsMiscDirty(): void;
  22126. /**
  22127. * Indicates that textures and misc need to be re-calculated for all submeshes
  22128. */
  22129. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22130. /**
  22131. * Disposes the material
  22132. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22133. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22134. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22135. */
  22136. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22137. /** @hidden */
  22138. private releaseVertexArrayObject;
  22139. /**
  22140. * Serializes this material
  22141. * @returns the serialized material object
  22142. */
  22143. serialize(): any;
  22144. /**
  22145. * Creates a material from parsed material data
  22146. * @param parsedMaterial defines parsed material data
  22147. * @param scene defines the hosting scene
  22148. * @param rootUrl defines the root URL to use to load textures
  22149. * @returns a new material
  22150. */
  22151. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22152. }
  22153. }
  22154. declare module BABYLON {
  22155. /**
  22156. * Base class for submeshes
  22157. */
  22158. export class BaseSubMesh {
  22159. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  22160. /** @hidden */ materialEffect: Nullable<Effect>;
  22161. /**
  22162. * Gets associated effect
  22163. */
  22164. readonly effect: Nullable<Effect>;
  22165. /**
  22166. * Sets associated effect (effect used to render this submesh)
  22167. * @param effect defines the effect to associate with
  22168. * @param defines defines the set of defines used to compile this effect
  22169. */
  22170. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22171. }
  22172. /**
  22173. * Defines a subdivision inside a mesh
  22174. */
  22175. export class SubMesh extends BaseSubMesh implements ICullable {
  22176. /** the material index to use */
  22177. materialIndex: number;
  22178. /** vertex index start */
  22179. verticesStart: number;
  22180. /** vertices count */
  22181. verticesCount: number;
  22182. /** index start */
  22183. indexStart: number;
  22184. /** indices count */
  22185. indexCount: number;
  22186. /** @hidden */ linesIndexCount: number;
  22187. private _mesh;
  22188. private _renderingMesh;
  22189. private _boundingInfo;
  22190. private _linesIndexBuffer;
  22191. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  22192. /** @hidden */ trianglePlanes: Plane[];
  22193. /** @hidden */ lastColliderTransformMatrix: Nullable<Matrix>;
  22194. /** @hidden */ renderId: number;
  22195. /** @hidden */ alphaIndex: number;
  22196. /** @hidden */ distanceToCamera: number;
  22197. /** @hidden */ id: number;
  22198. private _currentMaterial;
  22199. /**
  22200. * Add a new submesh to a mesh
  22201. * @param materialIndex defines the material index to use
  22202. * @param verticesStart defines vertex index start
  22203. * @param verticesCount defines vertices count
  22204. * @param indexStart defines index start
  22205. * @param indexCount defines indices count
  22206. * @param mesh defines the parent mesh
  22207. * @param renderingMesh defines an optional rendering mesh
  22208. * @param createBoundingBox defines if bounding box should be created for this submesh
  22209. * @returns the new submesh
  22210. */
  22211. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22212. /**
  22213. * Creates a new submesh
  22214. * @param materialIndex defines the material index to use
  22215. * @param verticesStart defines vertex index start
  22216. * @param verticesCount defines vertices count
  22217. * @param indexStart defines index start
  22218. * @param indexCount defines indices count
  22219. * @param mesh defines the parent mesh
  22220. * @param renderingMesh defines an optional rendering mesh
  22221. * @param createBoundingBox defines if bounding box should be created for this submesh
  22222. */
  22223. constructor(
  22224. /** the material index to use */
  22225. materialIndex: number,
  22226. /** vertex index start */
  22227. verticesStart: number,
  22228. /** vertices count */
  22229. verticesCount: number,
  22230. /** index start */
  22231. indexStart: number,
  22232. /** indices count */
  22233. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22234. /**
  22235. * Returns true if this submesh covers the entire parent mesh
  22236. * @ignorenaming
  22237. */
  22238. readonly IsGlobal: boolean;
  22239. /**
  22240. * Returns the submesh BoudingInfo object
  22241. * @returns current bounding info (or mesh's one if the submesh is global)
  22242. */
  22243. getBoundingInfo(): BoundingInfo;
  22244. /**
  22245. * Sets the submesh BoundingInfo
  22246. * @param boundingInfo defines the new bounding info to use
  22247. * @returns the SubMesh
  22248. */
  22249. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22250. /**
  22251. * Returns the mesh of the current submesh
  22252. * @return the parent mesh
  22253. */
  22254. getMesh(): AbstractMesh;
  22255. /**
  22256. * Returns the rendering mesh of the submesh
  22257. * @returns the rendering mesh (could be different from parent mesh)
  22258. */
  22259. getRenderingMesh(): Mesh;
  22260. /**
  22261. * Returns the submesh material
  22262. * @returns null or the current material
  22263. */
  22264. getMaterial(): Nullable<Material>;
  22265. /**
  22266. * Sets a new updated BoundingInfo object to the submesh
  22267. * @param data defines an optional position array to use to determine the bounding info
  22268. * @returns the SubMesh
  22269. */
  22270. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22271. /** @hidden */ checkCollision(collider: Collider): boolean;
  22272. /**
  22273. * Updates the submesh BoundingInfo
  22274. * @param world defines the world matrix to use to update the bounding info
  22275. * @returns the submesh
  22276. */
  22277. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22278. /**
  22279. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22280. * @param frustumPlanes defines the frustum planes
  22281. * @returns true if the submesh is intersecting with the frustum
  22282. */
  22283. isInFrustum(frustumPlanes: Plane[]): boolean;
  22284. /**
  22285. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22286. * @param frustumPlanes defines the frustum planes
  22287. * @returns true if the submesh is inside the frustum
  22288. */
  22289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22290. /**
  22291. * Renders the submesh
  22292. * @param enableAlphaMode defines if alpha needs to be used
  22293. * @returns the submesh
  22294. */
  22295. render(enableAlphaMode: boolean): SubMesh;
  22296. /**
  22297. * @hidden
  22298. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22299. /**
  22300. * Checks if the submesh intersects with a ray
  22301. * @param ray defines the ray to test
  22302. * @returns true is the passed ray intersects the submesh bounding box
  22303. */
  22304. canIntersects(ray: Ray): boolean;
  22305. /**
  22306. * Intersects current submesh with a ray
  22307. * @param ray defines the ray to test
  22308. * @param positions defines mesh's positions array
  22309. * @param indices defines mesh's indices array
  22310. * @param fastCheck defines if only bounding info should be used
  22311. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22312. * @returns intersection info or null if no intersection
  22313. */
  22314. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22315. /** @hidden */
  22316. private _intersectLines;
  22317. /** @hidden */
  22318. private _intersectTriangles;
  22319. /** @hidden */
  22320. private _intersectUnIndexedTriangles;
  22321. /** @hidden */ rebuild(): void;
  22322. /**
  22323. * Creates a new submesh from the passed mesh
  22324. * @param newMesh defines the new hosting mesh
  22325. * @param newRenderingMesh defines an optional rendering mesh
  22326. * @returns the new submesh
  22327. */
  22328. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22329. /**
  22330. * Release associated resources
  22331. */
  22332. dispose(): void;
  22333. /**
  22334. * Gets the class name
  22335. * @returns the string "SubMesh".
  22336. */
  22337. getClassName(): string;
  22338. /**
  22339. * Creates a new submesh from indices data
  22340. * @param materialIndex the index of the main mesh material
  22341. * @param startIndex the index where to start the copy in the mesh indices array
  22342. * @param indexCount the number of indices to copy then from the startIndex
  22343. * @param mesh the main mesh to create the submesh from
  22344. * @param renderingMesh the optional rendering mesh
  22345. * @returns a new submesh
  22346. */
  22347. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22348. }
  22349. }
  22350. declare module BABYLON {
  22351. /**
  22352. * Class used to store geometry data (vertex buffers + index buffer)
  22353. */
  22354. export class Geometry implements IGetSetVerticesData {
  22355. /**
  22356. * Gets or sets the ID of the geometry
  22357. */
  22358. id: string;
  22359. /**
  22360. * Gets or sets the unique ID of the geometry
  22361. */
  22362. uniqueId: number;
  22363. /**
  22364. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22365. */
  22366. delayLoadState: number;
  22367. /**
  22368. * Gets the file containing the data to load when running in delay load state
  22369. */
  22370. delayLoadingFile: Nullable<string>;
  22371. /**
  22372. * Callback called when the geometry is updated
  22373. */
  22374. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22375. private _scene;
  22376. private _engine;
  22377. private _meshes;
  22378. private _totalVertices;
  22379. /** @hidden */ indices: IndicesArray;
  22380. /** @hidden */ vertexBuffers: {
  22381. [key: string]: VertexBuffer;
  22382. };
  22383. private _isDisposed;
  22384. private _extend;
  22385. private _boundingBias;
  22386. /** @hidden */ delayInfo: Array<string>;
  22387. private _indexBuffer;
  22388. private _indexBufferIsUpdatable;
  22389. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  22390. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22391. /** @hidden */ softwareSkinningFrameId: number;
  22392. private _vertexArrayObjects;
  22393. private _updatable;
  22394. /** @hidden */ positions: Nullable<Vector3[]>;
  22395. /**
  22396. * 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
  22397. */
  22398. /**
  22399. * 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
  22400. */
  22401. boundingBias: Vector2;
  22402. /**
  22403. * Static function used to attach a new empty geometry to a mesh
  22404. * @param mesh defines the mesh to attach the geometry to
  22405. * @returns the new Geometry
  22406. */
  22407. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22408. /**
  22409. * Creates a new geometry
  22410. * @param id defines the unique ID
  22411. * @param scene defines the hosting scene
  22412. * @param vertexData defines the VertexData used to get geometry data
  22413. * @param updatable defines if geometry must be updatable (false by default)
  22414. * @param mesh defines the mesh that will be associated with the geometry
  22415. */
  22416. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22417. /**
  22418. * Gets the current extend of the geometry
  22419. */
  22420. readonly extend: {
  22421. minimum: Vector3;
  22422. maximum: Vector3;
  22423. };
  22424. /**
  22425. * Gets the hosting scene
  22426. * @returns the hosting Scene
  22427. */
  22428. getScene(): Scene;
  22429. /**
  22430. * Gets the hosting engine
  22431. * @returns the hosting Engine
  22432. */
  22433. getEngine(): Engine;
  22434. /**
  22435. * Defines if the geometry is ready to use
  22436. * @returns true if the geometry is ready to be used
  22437. */
  22438. isReady(): boolean;
  22439. /**
  22440. * Gets a value indicating that the geometry should not be serialized
  22441. */
  22442. readonly doNotSerialize: boolean;
  22443. /** @hidden */ rebuild(): void;
  22444. /**
  22445. * Affects all geometry data in one call
  22446. * @param vertexData defines the geometry data
  22447. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22448. */
  22449. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22450. /**
  22451. * Set specific vertex data
  22452. * @param kind defines the data kind (Position, normal, etc...)
  22453. * @param data defines the vertex data to use
  22454. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22455. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22456. */
  22457. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22458. /**
  22459. * Removes a specific vertex data
  22460. * @param kind defines the data kind (Position, normal, etc...)
  22461. */
  22462. removeVerticesData(kind: string): void;
  22463. /**
  22464. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22465. * @param buffer defines the vertex buffer to use
  22466. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22467. */
  22468. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22469. /**
  22470. * Update a specific vertex buffer
  22471. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22472. * It will do nothing if the buffer is not updatable
  22473. * @param kind defines the data kind (Position, normal, etc...)
  22474. * @param data defines the data to use
  22475. * @param offset defines the offset in the target buffer where to store the data
  22476. * @param useBytes set to true if the offset is in bytes
  22477. */
  22478. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22479. /**
  22480. * Update a specific vertex buffer
  22481. * This function will create a new buffer if the current one is not updatable
  22482. * @param kind defines the data kind (Position, normal, etc...)
  22483. * @param data defines the data to use
  22484. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22485. */
  22486. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22487. private _updateBoundingInfo;
  22488. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22489. /**
  22490. * Gets total number of vertices
  22491. * @returns the total number of vertices
  22492. */
  22493. getTotalVertices(): number;
  22494. /**
  22495. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22496. * @param kind defines the data kind (Position, normal, etc...)
  22497. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22498. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22499. * @returns a float array containing vertex data
  22500. */
  22501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22502. /**
  22503. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22504. * @param kind defines the data kind (Position, normal, etc...)
  22505. * @returns true if the vertex buffer with the specified kind is updatable
  22506. */
  22507. isVertexBufferUpdatable(kind: string): boolean;
  22508. /**
  22509. * Gets a specific vertex buffer
  22510. * @param kind defines the data kind (Position, normal, etc...)
  22511. * @returns a VertexBuffer
  22512. */
  22513. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22514. /**
  22515. * Returns all vertex buffers
  22516. * @return an object holding all vertex buffers indexed by kind
  22517. */
  22518. getVertexBuffers(): Nullable<{
  22519. [key: string]: VertexBuffer;
  22520. }>;
  22521. /**
  22522. * Gets a boolean indicating if specific vertex buffer is present
  22523. * @param kind defines the data kind (Position, normal, etc...)
  22524. * @returns true if data is present
  22525. */
  22526. isVerticesDataPresent(kind: string): boolean;
  22527. /**
  22528. * Gets a list of all attached data kinds (Position, normal, etc...)
  22529. * @returns a list of string containing all kinds
  22530. */
  22531. getVerticesDataKinds(): string[];
  22532. /**
  22533. * Update index buffer
  22534. * @param indices defines the indices to store in the index buffer
  22535. * @param offset defines the offset in the target buffer where to store the data
  22536. * @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)
  22537. */
  22538. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22539. /**
  22540. * Creates a new index buffer
  22541. * @param indices defines the indices to store in the index buffer
  22542. * @param totalVertices defines the total number of vertices (could be null)
  22543. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22544. */
  22545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22546. /**
  22547. * Return the total number of indices
  22548. * @returns the total number of indices
  22549. */
  22550. getTotalIndices(): number;
  22551. /**
  22552. * Gets the index buffer array
  22553. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22555. * @returns the index buffer array
  22556. */
  22557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22558. /**
  22559. * Gets the index buffer
  22560. * @return the index buffer
  22561. */
  22562. getIndexBuffer(): Nullable<DataBuffer>;
  22563. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22564. /**
  22565. * Release the associated resources for a specific mesh
  22566. * @param mesh defines the source mesh
  22567. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22568. */
  22569. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22570. /**
  22571. * Apply current geometry to a given mesh
  22572. * @param mesh defines the mesh to apply geometry to
  22573. */
  22574. applyToMesh(mesh: Mesh): void;
  22575. private _updateExtend;
  22576. private _applyToMesh;
  22577. private notifyUpdate;
  22578. /**
  22579. * Load the geometry if it was flagged as delay loaded
  22580. * @param scene defines the hosting scene
  22581. * @param onLoaded defines a callback called when the geometry is loaded
  22582. */
  22583. load(scene: Scene, onLoaded?: () => void): void;
  22584. private _queueLoad;
  22585. /**
  22586. * Invert the geometry to move from a right handed system to a left handed one.
  22587. */
  22588. toLeftHanded(): void;
  22589. /** @hidden */ resetPointsArrayCache(): void;
  22590. /** @hidden */ generatePointsArray(): boolean;
  22591. /**
  22592. * Gets a value indicating if the geometry is disposed
  22593. * @returns true if the geometry was disposed
  22594. */
  22595. isDisposed(): boolean;
  22596. private _disposeVertexArrayObjects;
  22597. /**
  22598. * Free all associated resources
  22599. */
  22600. dispose(): void;
  22601. /**
  22602. * Clone the current geometry into a new geometry
  22603. * @param id defines the unique ID of the new geometry
  22604. * @returns a new geometry object
  22605. */
  22606. copy(id: string): Geometry;
  22607. /**
  22608. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22609. * @return a JSON representation of the current geometry data (without the vertices data)
  22610. */
  22611. serialize(): any;
  22612. private toNumberArray;
  22613. /**
  22614. * Serialize all vertices data into a JSON oject
  22615. * @returns a JSON representation of the current geometry data
  22616. */
  22617. serializeVerticeData(): any;
  22618. /**
  22619. * Extracts a clone of a mesh geometry
  22620. * @param mesh defines the source mesh
  22621. * @param id defines the unique ID of the new geometry object
  22622. * @returns the new geometry object
  22623. */
  22624. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22625. /**
  22626. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22627. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22628. * Be aware Math.random() could cause collisions, but:
  22629. * "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"
  22630. * @returns a string containing a new GUID
  22631. */
  22632. static RandomId(): string;
  22633. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22634. private static _CleanMatricesWeights;
  22635. /**
  22636. * Create a new geometry from persisted data (Using .babylon file format)
  22637. * @param parsedVertexData defines the persisted data
  22638. * @param scene defines the hosting scene
  22639. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22640. * @returns the new geometry object
  22641. */
  22642. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22643. }
  22644. }
  22645. declare module BABYLON {
  22646. /**
  22647. * Define an interface for all classes that will get and set the data on vertices
  22648. */
  22649. export interface IGetSetVerticesData {
  22650. /**
  22651. * Gets a boolean indicating if specific vertex data is present
  22652. * @param kind defines the vertex data kind to use
  22653. * @returns true is data kind is present
  22654. */
  22655. isVerticesDataPresent(kind: string): boolean;
  22656. /**
  22657. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22658. * @param kind defines the data kind (Position, normal, etc...)
  22659. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22660. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22661. * @returns a float array containing vertex data
  22662. */
  22663. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22664. /**
  22665. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22666. * @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.
  22667. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22668. * @returns the indices array or an empty array if the mesh has no geometry
  22669. */
  22670. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22671. /**
  22672. * Set specific vertex data
  22673. * @param kind defines the data kind (Position, normal, etc...)
  22674. * @param data defines the vertex data to use
  22675. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22676. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22677. */
  22678. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22679. /**
  22680. * Update a specific associated vertex buffer
  22681. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22682. * - VertexBuffer.PositionKind
  22683. * - VertexBuffer.UVKind
  22684. * - VertexBuffer.UV2Kind
  22685. * - VertexBuffer.UV3Kind
  22686. * - VertexBuffer.UV4Kind
  22687. * - VertexBuffer.UV5Kind
  22688. * - VertexBuffer.UV6Kind
  22689. * - VertexBuffer.ColorKind
  22690. * - VertexBuffer.MatricesIndicesKind
  22691. * - VertexBuffer.MatricesIndicesExtraKind
  22692. * - VertexBuffer.MatricesWeightsKind
  22693. * - VertexBuffer.MatricesWeightsExtraKind
  22694. * @param data defines the data source
  22695. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22696. * @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)
  22697. */
  22698. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22699. /**
  22700. * Creates a new index buffer
  22701. * @param indices defines the indices to store in the index buffer
  22702. * @param totalVertices defines the total number of vertices (could be null)
  22703. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22704. */
  22705. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22706. }
  22707. /**
  22708. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22709. */
  22710. export class VertexData {
  22711. /**
  22712. * Mesh side orientation : usually the external or front surface
  22713. */
  22714. static readonly FRONTSIDE: number;
  22715. /**
  22716. * Mesh side orientation : usually the internal or back surface
  22717. */
  22718. static readonly BACKSIDE: number;
  22719. /**
  22720. * Mesh side orientation : both internal and external or front and back surfaces
  22721. */
  22722. static readonly DOUBLESIDE: number;
  22723. /**
  22724. * Mesh side orientation : by default, `FRONTSIDE`
  22725. */
  22726. static readonly DEFAULTSIDE: number;
  22727. /**
  22728. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22729. */
  22730. positions: Nullable<FloatArray>;
  22731. /**
  22732. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22733. */
  22734. normals: Nullable<FloatArray>;
  22735. /**
  22736. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22737. */
  22738. tangents: Nullable<FloatArray>;
  22739. /**
  22740. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22741. */
  22742. uvs: Nullable<FloatArray>;
  22743. /**
  22744. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22745. */
  22746. uvs2: Nullable<FloatArray>;
  22747. /**
  22748. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22749. */
  22750. uvs3: Nullable<FloatArray>;
  22751. /**
  22752. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22753. */
  22754. uvs4: Nullable<FloatArray>;
  22755. /**
  22756. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22757. */
  22758. uvs5: Nullable<FloatArray>;
  22759. /**
  22760. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22761. */
  22762. uvs6: Nullable<FloatArray>;
  22763. /**
  22764. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22765. */
  22766. colors: Nullable<FloatArray>;
  22767. /**
  22768. * 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).
  22769. */
  22770. matricesIndices: Nullable<FloatArray>;
  22771. /**
  22772. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22773. */
  22774. matricesWeights: Nullable<FloatArray>;
  22775. /**
  22776. * An array extending the number of possible indices
  22777. */
  22778. matricesIndicesExtra: Nullable<FloatArray>;
  22779. /**
  22780. * An array extending the number of possible weights when the number of indices is extended
  22781. */
  22782. matricesWeightsExtra: Nullable<FloatArray>;
  22783. /**
  22784. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22785. */
  22786. indices: Nullable<IndicesArray>;
  22787. /**
  22788. * Uses the passed data array to set the set the values for the specified kind of data
  22789. * @param data a linear array of floating numbers
  22790. * @param kind the type of data that is being set, eg positions, colors etc
  22791. */
  22792. set(data: FloatArray, kind: string): void;
  22793. /**
  22794. * Associates the vertexData to the passed Mesh.
  22795. * Sets it as updatable or not (default `false`)
  22796. * @param mesh the mesh the vertexData is applied to
  22797. * @param updatable when used and having the value true allows new data to update the vertexData
  22798. * @returns the VertexData
  22799. */
  22800. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22801. /**
  22802. * Associates the vertexData to the passed Geometry.
  22803. * Sets it as updatable or not (default `false`)
  22804. * @param geometry the geometry the vertexData is applied to
  22805. * @param updatable when used and having the value true allows new data to update the vertexData
  22806. * @returns VertexData
  22807. */
  22808. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22809. /**
  22810. * Updates the associated mesh
  22811. * @param mesh the mesh to be updated
  22812. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22813. * @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
  22814. * @returns VertexData
  22815. */
  22816. updateMesh(mesh: Mesh): VertexData;
  22817. /**
  22818. * Updates the associated geometry
  22819. * @param geometry the geometry to be updated
  22820. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22821. * @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
  22822. * @returns VertexData.
  22823. */
  22824. updateGeometry(geometry: Geometry): VertexData;
  22825. private _applyTo;
  22826. private _update;
  22827. /**
  22828. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22829. * @param matrix the transforming matrix
  22830. * @returns the VertexData
  22831. */
  22832. transform(matrix: Matrix): VertexData;
  22833. /**
  22834. * Merges the passed VertexData into the current one
  22835. * @param other the VertexData to be merged into the current one
  22836. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22837. * @returns the modified VertexData
  22838. */
  22839. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22840. private _mergeElement;
  22841. private _validate;
  22842. /**
  22843. * Serializes the VertexData
  22844. * @returns a serialized object
  22845. */
  22846. serialize(): any;
  22847. /**
  22848. * Extracts the vertexData from a mesh
  22849. * @param mesh the mesh from which to extract the VertexData
  22850. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22851. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22852. * @returns the object VertexData associated to the passed mesh
  22853. */
  22854. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22855. /**
  22856. * Extracts the vertexData from the geometry
  22857. * @param geometry the geometry from which to extract the VertexData
  22858. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22859. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22860. * @returns the object VertexData associated to the passed mesh
  22861. */
  22862. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22863. private static _ExtractFrom;
  22864. /**
  22865. * Creates the VertexData for a Ribbon
  22866. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22867. * * pathArray array of paths, each of which an array of successive Vector3
  22868. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22869. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22870. * * 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
  22871. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22872. * * 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)
  22873. * * 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)
  22874. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22875. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22876. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22877. * @returns the VertexData of the ribbon
  22878. */
  22879. static CreateRibbon(options: {
  22880. pathArray: Vector3[][];
  22881. closeArray?: boolean;
  22882. closePath?: boolean;
  22883. offset?: number;
  22884. sideOrientation?: number;
  22885. frontUVs?: Vector4;
  22886. backUVs?: Vector4;
  22887. invertUV?: boolean;
  22888. uvs?: Vector2[];
  22889. colors?: Color4[];
  22890. }): VertexData;
  22891. /**
  22892. * Creates the VertexData for a box
  22893. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22894. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22895. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22896. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22897. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22898. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22899. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22900. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22901. * * 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)
  22902. * * 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)
  22903. * @returns the VertexData of the box
  22904. */
  22905. static CreateBox(options: {
  22906. size?: number;
  22907. width?: number;
  22908. height?: number;
  22909. depth?: number;
  22910. faceUV?: Vector4[];
  22911. faceColors?: Color4[];
  22912. sideOrientation?: number;
  22913. frontUVs?: Vector4;
  22914. backUVs?: Vector4;
  22915. }): VertexData;
  22916. /**
  22917. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22918. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22919. * * segments sets the number of horizontal strips optional, default 32
  22920. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22921. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22922. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22923. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22924. * * 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
  22925. * * 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
  22926. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22927. * * 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)
  22928. * * 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)
  22929. * @returns the VertexData of the ellipsoid
  22930. */
  22931. static CreateSphere(options: {
  22932. segments?: number;
  22933. diameter?: number;
  22934. diameterX?: number;
  22935. diameterY?: number;
  22936. diameterZ?: number;
  22937. arc?: number;
  22938. slice?: number;
  22939. sideOrientation?: number;
  22940. frontUVs?: Vector4;
  22941. backUVs?: Vector4;
  22942. }): VertexData;
  22943. /**
  22944. * Creates the VertexData for a cylinder, cone or prism
  22945. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22946. * * height sets the height (y direction) of the cylinder, optional, default 2
  22947. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22948. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22949. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22950. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22951. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22952. * * 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
  22953. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22954. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22955. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22956. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22957. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22958. * * 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)
  22959. * * 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)
  22960. * @returns the VertexData of the cylinder, cone or prism
  22961. */
  22962. static CreateCylinder(options: {
  22963. height?: number;
  22964. diameterTop?: number;
  22965. diameterBottom?: number;
  22966. diameter?: number;
  22967. tessellation?: number;
  22968. subdivisions?: number;
  22969. arc?: number;
  22970. faceColors?: Color4[];
  22971. faceUV?: Vector4[];
  22972. hasRings?: boolean;
  22973. enclose?: boolean;
  22974. sideOrientation?: number;
  22975. frontUVs?: Vector4;
  22976. backUVs?: Vector4;
  22977. }): VertexData;
  22978. /**
  22979. * Creates the VertexData for a torus
  22980. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22981. * * diameter the diameter of the torus, optional default 1
  22982. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22983. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22985. * * 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)
  22986. * * 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)
  22987. * @returns the VertexData of the torus
  22988. */
  22989. static CreateTorus(options: {
  22990. diameter?: number;
  22991. thickness?: number;
  22992. tessellation?: number;
  22993. sideOrientation?: number;
  22994. frontUVs?: Vector4;
  22995. backUVs?: Vector4;
  22996. }): VertexData;
  22997. /**
  22998. * Creates the VertexData of the LineSystem
  22999. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23000. * - lines an array of lines, each line being an array of successive Vector3
  23001. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23002. * @returns the VertexData of the LineSystem
  23003. */
  23004. static CreateLineSystem(options: {
  23005. lines: Vector3[][];
  23006. colors?: Nullable<Color4[][]>;
  23007. }): VertexData;
  23008. /**
  23009. * Create the VertexData for a DashedLines
  23010. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23011. * - points an array successive Vector3
  23012. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23013. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23014. * - dashNb the intended total number of dashes, optional, default 200
  23015. * @returns the VertexData for the DashedLines
  23016. */
  23017. static CreateDashedLines(options: {
  23018. points: Vector3[];
  23019. dashSize?: number;
  23020. gapSize?: number;
  23021. dashNb?: number;
  23022. }): VertexData;
  23023. /**
  23024. * Creates the VertexData for a Ground
  23025. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23026. * - width the width (x direction) of the ground, optional, default 1
  23027. * - height the height (z direction) of the ground, optional, default 1
  23028. * - subdivisions the number of subdivisions per side, optional, default 1
  23029. * @returns the VertexData of the Ground
  23030. */
  23031. static CreateGround(options: {
  23032. width?: number;
  23033. height?: number;
  23034. subdivisions?: number;
  23035. subdivisionsX?: number;
  23036. subdivisionsY?: number;
  23037. }): VertexData;
  23038. /**
  23039. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23040. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23041. * * xmin the ground minimum X coordinate, optional, default -1
  23042. * * zmin the ground minimum Z coordinate, optional, default -1
  23043. * * xmax the ground maximum X coordinate, optional, default 1
  23044. * * zmax the ground maximum Z coordinate, optional, default 1
  23045. * * 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}
  23046. * * 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}
  23047. * @returns the VertexData of the TiledGround
  23048. */
  23049. static CreateTiledGround(options: {
  23050. xmin: number;
  23051. zmin: number;
  23052. xmax: number;
  23053. zmax: number;
  23054. subdivisions?: {
  23055. w: number;
  23056. h: number;
  23057. };
  23058. precision?: {
  23059. w: number;
  23060. h: number;
  23061. };
  23062. }): VertexData;
  23063. /**
  23064. * Creates the VertexData of the Ground designed from a heightmap
  23065. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23066. * * width the width (x direction) of the ground
  23067. * * height the height (z direction) of the ground
  23068. * * subdivisions the number of subdivisions per side
  23069. * * minHeight the minimum altitude on the ground, optional, default 0
  23070. * * maxHeight the maximum altitude on the ground, optional default 1
  23071. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23072. * * buffer the array holding the image color data
  23073. * * bufferWidth the width of image
  23074. * * bufferHeight the height of image
  23075. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23076. * @returns the VertexData of the Ground designed from a heightmap
  23077. */
  23078. static CreateGroundFromHeightMap(options: {
  23079. width: number;
  23080. height: number;
  23081. subdivisions: number;
  23082. minHeight: number;
  23083. maxHeight: number;
  23084. colorFilter: Color3;
  23085. buffer: Uint8Array;
  23086. bufferWidth: number;
  23087. bufferHeight: number;
  23088. alphaFilter: number;
  23089. }): VertexData;
  23090. /**
  23091. * Creates the VertexData for a Plane
  23092. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23093. * * size sets the width and height of the plane to the value of size, optional default 1
  23094. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23095. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23097. * * 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)
  23098. * * 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)
  23099. * @returns the VertexData of the box
  23100. */
  23101. static CreatePlane(options: {
  23102. size?: number;
  23103. width?: number;
  23104. height?: number;
  23105. sideOrientation?: number;
  23106. frontUVs?: Vector4;
  23107. backUVs?: Vector4;
  23108. }): VertexData;
  23109. /**
  23110. * Creates the VertexData of the Disc or regular Polygon
  23111. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23112. * * radius the radius of the disc, optional default 0.5
  23113. * * tessellation the number of polygon sides, optional, default 64
  23114. * * 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
  23115. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23116. * * 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)
  23117. * * 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)
  23118. * @returns the VertexData of the box
  23119. */
  23120. static CreateDisc(options: {
  23121. radius?: number;
  23122. tessellation?: number;
  23123. arc?: number;
  23124. sideOrientation?: number;
  23125. frontUVs?: Vector4;
  23126. backUVs?: Vector4;
  23127. }): VertexData;
  23128. /**
  23129. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23130. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23131. * @param polygon a mesh built from polygonTriangulation.build()
  23132. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23133. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23134. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23135. * @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)
  23136. * @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)
  23137. * @returns the VertexData of the Polygon
  23138. */
  23139. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23140. /**
  23141. * Creates the VertexData of the IcoSphere
  23142. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23143. * * radius the radius of the IcoSphere, optional default 1
  23144. * * radiusX allows stretching in the x direction, optional, default radius
  23145. * * radiusY allows stretching in the y direction, optional, default radius
  23146. * * radiusZ allows stretching in the z direction, optional, default radius
  23147. * * flat when true creates a flat shaded mesh, optional, default true
  23148. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23150. * * 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)
  23151. * * 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)
  23152. * @returns the VertexData of the IcoSphere
  23153. */
  23154. static CreateIcoSphere(options: {
  23155. radius?: number;
  23156. radiusX?: number;
  23157. radiusY?: number;
  23158. radiusZ?: number;
  23159. flat?: boolean;
  23160. subdivisions?: number;
  23161. sideOrientation?: number;
  23162. frontUVs?: Vector4;
  23163. backUVs?: Vector4;
  23164. }): VertexData;
  23165. /**
  23166. * Creates the VertexData for a Polyhedron
  23167. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23168. * * type provided types are:
  23169. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23170. * * 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)
  23171. * * size the size of the IcoSphere, optional default 1
  23172. * * sizeX allows stretching in the x direction, optional, default size
  23173. * * sizeY allows stretching in the y direction, optional, default size
  23174. * * sizeZ allows stretching in the z direction, optional, default size
  23175. * * 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
  23176. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23177. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23178. * * flat when true creates a flat shaded mesh, optional, default true
  23179. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23181. * * 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)
  23182. * * 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)
  23183. * @returns the VertexData of the Polyhedron
  23184. */
  23185. static CreatePolyhedron(options: {
  23186. type?: number;
  23187. size?: number;
  23188. sizeX?: number;
  23189. sizeY?: number;
  23190. sizeZ?: number;
  23191. custom?: any;
  23192. faceUV?: Vector4[];
  23193. faceColors?: Color4[];
  23194. flat?: boolean;
  23195. sideOrientation?: number;
  23196. frontUVs?: Vector4;
  23197. backUVs?: Vector4;
  23198. }): VertexData;
  23199. /**
  23200. * Creates the VertexData for a TorusKnot
  23201. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23202. * * radius the radius of the torus knot, optional, default 2
  23203. * * tube the thickness of the tube, optional, default 0.5
  23204. * * radialSegments the number of sides on each tube segments, optional, default 32
  23205. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23206. * * p the number of windings around the z axis, optional, default 2
  23207. * * q the number of windings around the x axis, optional, default 3
  23208. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23209. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23210. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23211. * @returns the VertexData of the Torus Knot
  23212. */
  23213. static CreateTorusKnot(options: {
  23214. radius?: number;
  23215. tube?: number;
  23216. radialSegments?: number;
  23217. tubularSegments?: number;
  23218. p?: number;
  23219. q?: number;
  23220. sideOrientation?: number;
  23221. frontUVs?: Vector4;
  23222. backUVs?: Vector4;
  23223. }): VertexData;
  23224. /**
  23225. * Compute normals for given positions and indices
  23226. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23227. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23228. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23229. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23230. * * facetNormals : optional array of facet normals (vector3)
  23231. * * facetPositions : optional array of facet positions (vector3)
  23232. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23233. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23234. * * bInfo : optional bounding info, required for facetPartitioning computation
  23235. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23236. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23237. * * useRightHandedSystem: optional boolean to for right handed system computation
  23238. * * depthSort : optional boolean to enable the facet depth sort computation
  23239. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23240. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23241. */
  23242. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23243. facetNormals?: any;
  23244. facetPositions?: any;
  23245. facetPartitioning?: any;
  23246. ratio?: number;
  23247. bInfo?: any;
  23248. bbSize?: Vector3;
  23249. subDiv?: any;
  23250. useRightHandedSystem?: boolean;
  23251. depthSort?: boolean;
  23252. distanceTo?: Vector3;
  23253. depthSortedFacets?: any;
  23254. }): void;
  23255. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23256. /**
  23257. * Applies VertexData created from the imported parameters to the geometry
  23258. * @param parsedVertexData the parsed data from an imported file
  23259. * @param geometry the geometry to apply the VertexData to
  23260. */
  23261. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23262. }
  23263. }
  23264. declare module BABYLON {
  23265. /**
  23266. * Class containing static functions to help procedurally build meshes
  23267. */
  23268. export class DiscBuilder {
  23269. /**
  23270. * Creates a plane polygonal mesh. By default, this is a disc
  23271. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23272. * * 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
  23273. * * 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
  23274. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23275. * * 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
  23276. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23277. * @param name defines the name of the mesh
  23278. * @param options defines the options used to create the mesh
  23279. * @param scene defines the hosting scene
  23280. * @returns the plane polygonal mesh
  23281. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23282. */
  23283. static CreateDisc(name: string, options: {
  23284. radius?: number;
  23285. tessellation?: number;
  23286. arc?: number;
  23287. updatable?: boolean;
  23288. sideOrientation?: number;
  23289. frontUVs?: Vector4;
  23290. backUVs?: Vector4;
  23291. }, scene?: Nullable<Scene>): Mesh;
  23292. }
  23293. }
  23294. declare module BABYLON {
  23295. /**
  23296. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23297. *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.
  23298. * The SPS is also a particle system. It provides some methods to manage the particles.
  23299. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23300. *
  23301. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23302. */
  23303. export class SolidParticleSystem implements IDisposable {
  23304. /**
  23305. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23306. * Example : var p = SPS.particles[i];
  23307. */
  23308. particles: SolidParticle[];
  23309. /**
  23310. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23311. */
  23312. nbParticles: number;
  23313. /**
  23314. * If the particles must ever face the camera (default false). Useful for planar particles.
  23315. */
  23316. billboard: boolean;
  23317. /**
  23318. * Recompute normals when adding a shape
  23319. */
  23320. recomputeNormals: boolean;
  23321. /**
  23322. * This a counter ofr your own usage. It's not set by any SPS functions.
  23323. */
  23324. counter: number;
  23325. /**
  23326. * The SPS name. This name is also given to the underlying mesh.
  23327. */
  23328. name: string;
  23329. /**
  23330. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23331. */
  23332. mesh: Mesh;
  23333. /**
  23334. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23335. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23336. */
  23337. vars: any;
  23338. /**
  23339. * This array is populated when the SPS is set as 'pickable'.
  23340. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23341. * Each element of this array is an object `{idx: int, faceId: int}`.
  23342. * `idx` is the picked particle index in the `SPS.particles` array
  23343. * `faceId` is the picked face index counted within this particle.
  23344. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23345. */
  23346. pickedParticles: {
  23347. idx: number;
  23348. faceId: number;
  23349. }[];
  23350. /**
  23351. * This array is populated when `enableDepthSort` is set to true.
  23352. * Each element of this array is an instance of the class DepthSortedParticle.
  23353. */
  23354. depthSortedParticles: DepthSortedParticle[];
  23355. /**
  23356. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23357. * @hidden
  23358. */ bSphereOnly: boolean;
  23359. /**
  23360. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23361. * @hidden
  23362. */ bSphereRadiusFactor: number;
  23363. private _scene;
  23364. private _positions;
  23365. private _indices;
  23366. private _normals;
  23367. private _colors;
  23368. private _uvs;
  23369. private _indices32;
  23370. private _positions32;
  23371. private _normals32;
  23372. private _fixedNormal32;
  23373. private _colors32;
  23374. private _uvs32;
  23375. private _index;
  23376. private _updatable;
  23377. private _pickable;
  23378. private _isVisibilityBoxLocked;
  23379. private _alwaysVisible;
  23380. private _depthSort;
  23381. private _shapeCounter;
  23382. private _copy;
  23383. private _color;
  23384. private _computeParticleColor;
  23385. private _computeParticleTexture;
  23386. private _computeParticleRotation;
  23387. private _computeParticleVertex;
  23388. private _computeBoundingBox;
  23389. private _depthSortParticles;
  23390. private _camera;
  23391. private _mustUnrotateFixedNormals;
  23392. private _particlesIntersect;
  23393. private _needs32Bits;
  23394. /**
  23395. * Creates a SPS (Solid Particle System) object.
  23396. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23397. * @param scene (Scene) is the scene in which the SPS is added.
  23398. * @param options defines the options of the sps e.g.
  23399. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23400. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23401. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23402. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23403. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23404. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23405. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23406. */
  23407. constructor(name: string, scene: Scene, options?: {
  23408. updatable?: boolean;
  23409. isPickable?: boolean;
  23410. enableDepthSort?: boolean;
  23411. particleIntersection?: boolean;
  23412. boundingSphereOnly?: boolean;
  23413. bSphereRadiusFactor?: number;
  23414. });
  23415. /**
  23416. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23417. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23418. * @returns the created mesh
  23419. */
  23420. buildMesh(): Mesh;
  23421. /**
  23422. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23423. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23424. * Thus the particles generated from `digest()` have their property `position` set yet.
  23425. * @param mesh ( Mesh ) is the mesh to be digested
  23426. * @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
  23427. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23428. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23429. * @returns the current SPS
  23430. */
  23431. digest(mesh: Mesh, options?: {
  23432. facetNb?: number;
  23433. number?: number;
  23434. delta?: number;
  23435. }): SolidParticleSystem;
  23436. private _unrotateFixedNormals;
  23437. private _resetCopy;
  23438. private _meshBuilder;
  23439. private _posToShape;
  23440. private _uvsToShapeUV;
  23441. private _addParticle;
  23442. /**
  23443. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23444. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23445. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23446. * @param nb (positive integer) the number of particles to be created from this model
  23447. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23448. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23449. * @returns the number of shapes in the system
  23450. */
  23451. addShape(mesh: Mesh, nb: number, options?: {
  23452. positionFunction?: any;
  23453. vertexFunction?: any;
  23454. }): number;
  23455. private _rebuildParticle;
  23456. /**
  23457. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23458. * @returns the SPS.
  23459. */
  23460. rebuildMesh(): SolidParticleSystem;
  23461. /**
  23462. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23463. * This method calls `updateParticle()` for each particle of the SPS.
  23464. * For an animated SPS, it is usually called within the render loop.
  23465. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23466. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23467. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23468. * @returns the SPS.
  23469. */
  23470. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23471. /**
  23472. * Disposes the SPS.
  23473. */
  23474. dispose(): void;
  23475. /**
  23476. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23477. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23478. * @returns the SPS.
  23479. */
  23480. refreshVisibleSize(): SolidParticleSystem;
  23481. /**
  23482. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23483. * @param size the size (float) of the visibility box
  23484. * note : this doesn't lock the SPS mesh bounding box.
  23485. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23486. */
  23487. setVisibilityBox(size: number): void;
  23488. /**
  23489. * Gets whether the SPS as always visible or not
  23490. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23491. */
  23492. /**
  23493. * Sets the SPS as always visible or not
  23494. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23495. */
  23496. isAlwaysVisible: boolean;
  23497. /**
  23498. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23499. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23500. */
  23501. /**
  23502. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23503. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23504. */
  23505. isVisibilityBoxLocked: boolean;
  23506. /**
  23507. * Tells to `setParticles()` to compute the particle rotations or not.
  23508. * Default value : true. The SPS is faster when it's set to false.
  23509. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23510. */
  23511. /**
  23512. * Gets if `setParticles()` computes the particle rotations or not.
  23513. * Default value : true. The SPS is faster when it's set to false.
  23514. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23515. */
  23516. computeParticleRotation: boolean;
  23517. /**
  23518. * Tells to `setParticles()` to compute the particle colors or not.
  23519. * Default value : true. The SPS is faster when it's set to false.
  23520. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23521. */
  23522. /**
  23523. * Gets if `setParticles()` computes the particle colors or not.
  23524. * Default value : true. The SPS is faster when it's set to false.
  23525. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23526. */
  23527. computeParticleColor: boolean;
  23528. /**
  23529. * Gets if `setParticles()` computes the particle textures or not.
  23530. * Default value : true. The SPS is faster when it's set to false.
  23531. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23532. */
  23533. computeParticleTexture: boolean;
  23534. /**
  23535. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23536. * Default value : false. The SPS is faster when it's set to false.
  23537. * Note : the particle custom vertex positions aren't stored values.
  23538. */
  23539. /**
  23540. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23541. * Default value : false. The SPS is faster when it's set to false.
  23542. * Note : the particle custom vertex positions aren't stored values.
  23543. */
  23544. computeParticleVertex: boolean;
  23545. /**
  23546. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23547. */
  23548. /**
  23549. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23550. */
  23551. computeBoundingBox: boolean;
  23552. /**
  23553. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23554. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23555. * Default : `true`
  23556. */
  23557. /**
  23558. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23559. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23560. * Default : `true`
  23561. */
  23562. depthSortParticles: boolean;
  23563. /**
  23564. * This function does nothing. It may be overwritten to set all the particle first values.
  23565. * The SPS doesn't call this function, you may have to call it by your own.
  23566. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23567. */
  23568. initParticles(): void;
  23569. /**
  23570. * This function does nothing. It may be overwritten to recycle a particle.
  23571. * The SPS doesn't call this function, you may have to call it by your own.
  23572. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23573. * @param particle The particle to recycle
  23574. * @returns the recycled particle
  23575. */
  23576. recycleParticle(particle: SolidParticle): SolidParticle;
  23577. /**
  23578. * Updates a particle : this function should be overwritten by the user.
  23579. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23580. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23581. * @example : just set a particle position or velocity and recycle conditions
  23582. * @param particle The particle to update
  23583. * @returns the updated particle
  23584. */
  23585. updateParticle(particle: SolidParticle): SolidParticle;
  23586. /**
  23587. * Updates a vertex of a particle : it can be overwritten by the user.
  23588. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23589. * @param particle the current particle
  23590. * @param vertex the current index of the current particle
  23591. * @param pt the index of the current vertex in the particle shape
  23592. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23593. * @example : just set a vertex particle position
  23594. * @returns the updated vertex
  23595. */
  23596. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23597. /**
  23598. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23599. * This does nothing and may be overwritten by the user.
  23600. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23601. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23602. * @param update the boolean update value actually passed to setParticles()
  23603. */
  23604. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23605. /**
  23606. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23607. * This will be passed three parameters.
  23608. * This does nothing and may be overwritten by the user.
  23609. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23610. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23611. * @param update the boolean update value actually passed to setParticles()
  23612. */
  23613. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23614. }
  23615. }
  23616. declare module BABYLON {
  23617. /**
  23618. * Represents one particle of a solid particle system.
  23619. */
  23620. export class SolidParticle {
  23621. /**
  23622. * particle global index
  23623. */
  23624. idx: number;
  23625. /**
  23626. * The color of the particle
  23627. */
  23628. color: Nullable<Color4>;
  23629. /**
  23630. * The world space position of the particle.
  23631. */
  23632. position: Vector3;
  23633. /**
  23634. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23635. */
  23636. rotation: Vector3;
  23637. /**
  23638. * The world space rotation quaternion of the particle.
  23639. */
  23640. rotationQuaternion: Nullable<Quaternion>;
  23641. /**
  23642. * The scaling of the particle.
  23643. */
  23644. scaling: Vector3;
  23645. /**
  23646. * The uvs of the particle.
  23647. */
  23648. uvs: Vector4;
  23649. /**
  23650. * The current speed of the particle.
  23651. */
  23652. velocity: Vector3;
  23653. /**
  23654. * The pivot point in the particle local space.
  23655. */
  23656. pivot: Vector3;
  23657. /**
  23658. * Must the particle be translated from its pivot point in its local space ?
  23659. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23660. * Default : false
  23661. */
  23662. translateFromPivot: boolean;
  23663. /**
  23664. * Is the particle active or not ?
  23665. */
  23666. alive: boolean;
  23667. /**
  23668. * Is the particle visible or not ?
  23669. */
  23670. isVisible: boolean;
  23671. /**
  23672. * Index of this particle in the global "positions" array (Internal use)
  23673. * @hidden
  23674. */ pos: number;
  23675. /**
  23676. * @hidden Index of this particle in the global "indices" array (Internal use)
  23677. */ ind: number;
  23678. /**
  23679. * @hidden ModelShape of this particle (Internal use)
  23680. */ model: ModelShape;
  23681. /**
  23682. * ModelShape id of this particle
  23683. */
  23684. shapeId: number;
  23685. /**
  23686. * Index of the particle in its shape id (Internal use)
  23687. */
  23688. idxInShape: number;
  23689. /**
  23690. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23691. */ modelBoundingInfo: BoundingInfo;
  23692. /**
  23693. * @hidden Particle BoundingInfo object (Internal use)
  23694. */ boundingInfo: BoundingInfo;
  23695. /**
  23696. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23697. */ sps: SolidParticleSystem;
  23698. /**
  23699. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23700. */ stillInvisible: boolean;
  23701. /**
  23702. * @hidden Last computed particle rotation matrix
  23703. */ rotationMatrix: number[];
  23704. /**
  23705. * Parent particle Id, if any.
  23706. * Default null.
  23707. */
  23708. parentId: Nullable<number>;
  23709. /**
  23710. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23711. * The possible values are :
  23712. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23713. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23714. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23715. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23716. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23717. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23718. * */
  23719. cullingStrategy: number;
  23720. /**
  23721. * @hidden Internal global position in the SPS.
  23722. */ globalPosition: Vector3;
  23723. /**
  23724. * Creates a Solid Particle object.
  23725. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23726. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23727. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23728. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23729. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23730. * @param shapeId (integer) is the model shape identifier in the SPS.
  23731. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23732. * @param sps defines the sps it is associated to
  23733. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23734. */
  23735. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23736. /**
  23737. * Legacy support, changed scale to scaling
  23738. */
  23739. /**
  23740. * Legacy support, changed scale to scaling
  23741. */
  23742. scale: Vector3;
  23743. /**
  23744. * Legacy support, changed quaternion to rotationQuaternion
  23745. */
  23746. /**
  23747. * Legacy support, changed quaternion to rotationQuaternion
  23748. */
  23749. quaternion: Nullable<Quaternion>;
  23750. /**
  23751. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23752. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23753. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23754. * @returns true if it intersects
  23755. */
  23756. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23757. /**
  23758. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23759. * A particle is in the frustum if its bounding box intersects the frustum
  23760. * @param frustumPlanes defines the frustum to test
  23761. * @returns true if the particle is in the frustum planes
  23762. */
  23763. isInFrustum(frustumPlanes: Plane[]): boolean;
  23764. /**
  23765. * get the rotation matrix of the particle
  23766. * @hidden
  23767. */
  23768. getRotationMatrix(m: Matrix): void;
  23769. }
  23770. /**
  23771. * Represents the shape of the model used by one particle of a solid particle system.
  23772. * SPS internal tool, don't use it manually.
  23773. */
  23774. export class ModelShape {
  23775. /**
  23776. * The shape id
  23777. * @hidden
  23778. */
  23779. shapeID: number;
  23780. /**
  23781. * flat array of model positions (internal use)
  23782. * @hidden
  23783. */ shape: Vector3[];
  23784. /**
  23785. * flat array of model UVs (internal use)
  23786. * @hidden
  23787. */ shapeUV: number[];
  23788. /**
  23789. * length of the shape in the model indices array (internal use)
  23790. * @hidden
  23791. */ indicesLength: number;
  23792. /**
  23793. * Custom position function (internal use)
  23794. * @hidden
  23795. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23796. /**
  23797. * Custom vertex function (internal use)
  23798. * @hidden
  23799. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23800. /**
  23801. * 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.
  23802. * SPS internal tool, don't use it manually.
  23803. * @hidden
  23804. */
  23805. 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>);
  23806. }
  23807. /**
  23808. * Represents a Depth Sorted Particle in the solid particle system.
  23809. */
  23810. export class DepthSortedParticle {
  23811. /**
  23812. * Index of the particle in the "indices" array
  23813. */
  23814. ind: number;
  23815. /**
  23816. * Length of the particle shape in the "indices" array
  23817. */
  23818. indicesLength: number;
  23819. /**
  23820. * Squared distance from the particle to the camera
  23821. */
  23822. sqDistance: number;
  23823. }
  23824. }
  23825. declare module BABYLON {
  23826. /**
  23827. * Class used to store all common mesh properties
  23828. */
  23829. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23830. /** No occlusion */
  23831. static OCCLUSION_TYPE_NONE: number;
  23832. /** Occlusion set to optimisitic */
  23833. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23834. /** Occlusion set to strict */
  23835. static OCCLUSION_TYPE_STRICT: number;
  23836. /** Use an accurante occlusion algorithm */
  23837. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23838. /** Use a conservative occlusion algorithm */
  23839. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23840. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23841. * Test order :
  23842. * Is the bounding sphere outside the frustum ?
  23843. * If not, are the bounding box vertices outside the frustum ?
  23844. * It not, then the cullable object is in the frustum.
  23845. */
  23846. static readonly CULLINGSTRATEGY_STANDARD: number;
  23847. /** Culling strategy : Bounding Sphere Only.
  23848. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23849. * It's also less accurate than the standard because some not visible objects can still be selected.
  23850. * Test : is the bounding sphere outside the frustum ?
  23851. * If not, then the cullable object is in the frustum.
  23852. */
  23853. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23854. /** Culling strategy : Optimistic Inclusion.
  23855. * This in an inclusion test first, then the standard exclusion test.
  23856. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23857. * 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.
  23858. * Anyway, it's as accurate as the standard strategy.
  23859. * Test :
  23860. * Is the cullable object bounding sphere center in the frustum ?
  23861. * If not, apply the default culling strategy.
  23862. */
  23863. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23864. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23865. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23866. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23867. * 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.
  23868. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23869. * Test :
  23870. * Is the cullable object bounding sphere center in the frustum ?
  23871. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23872. */
  23873. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23874. /**
  23875. * No billboard
  23876. */
  23877. static readonly BILLBOARDMODE_NONE: number;
  23878. /** Billboard on X axis */
  23879. static readonly BILLBOARDMODE_X: number;
  23880. /** Billboard on Y axis */
  23881. static readonly BILLBOARDMODE_Y: number;
  23882. /** Billboard on Z axis */
  23883. static readonly BILLBOARDMODE_Z: number;
  23884. /** Billboard on all axes */
  23885. static readonly BILLBOARDMODE_ALL: number;
  23886. private _facetData;
  23887. /**
  23888. * The culling strategy to use to check whether the mesh must be rendered or not.
  23889. * This value can be changed at any time and will be used on the next render mesh selection.
  23890. * The possible values are :
  23891. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23892. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23893. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23894. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23895. * Please read each static variable documentation to get details about the culling process.
  23896. * */
  23897. cullingStrategy: number;
  23898. /**
  23899. * Gets the number of facets in the mesh
  23900. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23901. */
  23902. readonly facetNb: number;
  23903. /**
  23904. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23905. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23906. */
  23907. partitioningSubdivisions: number;
  23908. /**
  23909. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23910. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23911. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23912. */
  23913. partitioningBBoxRatio: number;
  23914. /**
  23915. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23916. * Works only for updatable meshes.
  23917. * Doesn't work with multi-materials
  23918. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23919. */
  23920. mustDepthSortFacets: boolean;
  23921. /**
  23922. * The location (Vector3) where the facet depth sort must be computed from.
  23923. * By default, the active camera position.
  23924. * Used only when facet depth sort is enabled
  23925. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23926. */
  23927. facetDepthSortFrom: Vector3;
  23928. /**
  23929. * gets a boolean indicating if facetData is enabled
  23930. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23931. */
  23932. readonly isFacetDataEnabled: boolean;
  23933. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23934. /**
  23935. * An event triggered when this mesh collides with another one
  23936. */
  23937. onCollideObservable: Observable<AbstractMesh>;
  23938. private _onCollideObserver;
  23939. /** Set a function to call when this mesh collides with another one */
  23940. onCollide: () => void;
  23941. /**
  23942. * An event triggered when the collision's position changes
  23943. */
  23944. onCollisionPositionChangeObservable: Observable<Vector3>;
  23945. private _onCollisionPositionChangeObserver;
  23946. /** Set a function to call when the collision's position changes */
  23947. onCollisionPositionChange: () => void;
  23948. /**
  23949. * An event triggered when material is changed
  23950. */
  23951. onMaterialChangedObservable: Observable<AbstractMesh>;
  23952. /**
  23953. * Gets or sets the orientation for POV movement & rotation
  23954. */
  23955. definedFacingForward: boolean;
  23956. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23957. private _visibility;
  23958. /** @hidden */ isActive: boolean;
  23959. /** @hidden */ onlyForInstances: boolean;
  23960. /** @hidden */ renderingGroup: Nullable<RenderingGroup>;
  23961. /**
  23962. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23963. */
  23964. /**
  23965. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23966. */
  23967. visibility: number;
  23968. /** Gets or sets the alpha index used to sort transparent meshes
  23969. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23970. */
  23971. alphaIndex: number;
  23972. /**
  23973. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23974. */
  23975. isVisible: boolean;
  23976. /**
  23977. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23978. */
  23979. isPickable: boolean;
  23980. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23981. showSubMeshesBoundingBox: boolean;
  23982. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23983. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23984. */
  23985. isBlocker: boolean;
  23986. /**
  23987. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23988. */
  23989. enablePointerMoveEvents: boolean;
  23990. /**
  23991. * Specifies the rendering group id for this mesh (0 by default)
  23992. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23993. */
  23994. renderingGroupId: number;
  23995. private _material;
  23996. /** Gets or sets current material */
  23997. material: Nullable<Material>;
  23998. private _receiveShadows;
  23999. /**
  24000. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24001. * @see http://doc.babylonjs.com/babylon101/shadows
  24002. */
  24003. receiveShadows: boolean;
  24004. /** Defines color to use when rendering outline */
  24005. outlineColor: Color3;
  24006. /** Define width to use when rendering outline */
  24007. outlineWidth: number;
  24008. /** Defines color to use when rendering overlay */
  24009. overlayColor: Color3;
  24010. /** Defines alpha to use when rendering overlay */
  24011. overlayAlpha: number;
  24012. private _hasVertexAlpha;
  24013. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24014. hasVertexAlpha: boolean;
  24015. private _useVertexColors;
  24016. /** 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) */
  24017. useVertexColors: boolean;
  24018. private _computeBonesUsingShaders;
  24019. /**
  24020. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24021. */
  24022. computeBonesUsingShaders: boolean;
  24023. private _numBoneInfluencers;
  24024. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24025. numBoneInfluencers: number;
  24026. private _applyFog;
  24027. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24028. applyFog: boolean;
  24029. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24030. useOctreeForRenderingSelection: boolean;
  24031. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24032. useOctreeForPicking: boolean;
  24033. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24034. useOctreeForCollisions: boolean;
  24035. private _layerMask;
  24036. /**
  24037. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24038. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24039. */
  24040. layerMask: number;
  24041. /**
  24042. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24043. */
  24044. alwaysSelectAsActiveMesh: boolean;
  24045. /**
  24046. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24047. */
  24048. doNotSyncBoundingInfo: boolean;
  24049. /**
  24050. * Gets or sets the current action manager
  24051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24052. */
  24053. actionManager: Nullable<AbstractActionManager>;
  24054. private _checkCollisions;
  24055. private _collisionMask;
  24056. private _collisionGroup;
  24057. /**
  24058. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24059. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24060. */
  24061. ellipsoid: Vector3;
  24062. /**
  24063. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24064. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24065. */
  24066. ellipsoidOffset: Vector3;
  24067. private _collider;
  24068. private _oldPositionForCollisions;
  24069. private _diffPositionForCollisions;
  24070. /**
  24071. * Gets or sets a collision mask used to mask collisions (default is -1).
  24072. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24073. */
  24074. collisionMask: number;
  24075. /**
  24076. * Gets or sets the current collision group mask (-1 by default).
  24077. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24078. */
  24079. collisionGroup: number;
  24080. /**
  24081. * Defines edge width used when edgesRenderer is enabled
  24082. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24083. */
  24084. edgesWidth: number;
  24085. /**
  24086. * Defines edge color used when edgesRenderer is enabled
  24087. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24088. */
  24089. edgesColor: Color4;
  24090. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  24091. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  24092. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  24093. /** @hidden */ renderId: number;
  24094. /**
  24095. * Gets or sets the list of subMeshes
  24096. * @see http://doc.babylonjs.com/how_to/multi_materials
  24097. */
  24098. subMeshes: SubMesh[];
  24099. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  24100. /** @hidden */ unIndexed: boolean;
  24101. /** @hidden */ lightSources: Light[];
  24102. /** Gets the list of lights affecting that mesh */
  24103. readonly lightSources: Light[];
  24104. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24105. /** @hidden */ waitingData: {
  24106. lods: Nullable<any>;
  24107. actions: Nullable<any>;
  24108. freezeWorldMatrix: Nullable<boolean>;
  24109. };
  24110. private _skeleton;
  24111. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  24112. /**
  24113. * Gets or sets a skeleton to apply skining transformations
  24114. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24115. */
  24116. skeleton: Nullable<Skeleton>;
  24117. /**
  24118. * An event triggered when the mesh is rebuilt.
  24119. */
  24120. onRebuildObservable: Observable<AbstractMesh>;
  24121. /**
  24122. * Creates a new AbstractMesh
  24123. * @param name defines the name of the mesh
  24124. * @param scene defines the hosting scene
  24125. */
  24126. constructor(name: string, scene?: Nullable<Scene>);
  24127. /**
  24128. * Returns the string "AbstractMesh"
  24129. * @returns "AbstractMesh"
  24130. */
  24131. getClassName(): string;
  24132. /**
  24133. * Gets a string representation of the current mesh
  24134. * @param fullDetails defines a boolean indicating if full details must be included
  24135. * @returns a string representation of the current mesh
  24136. */
  24137. toString(fullDetails?: boolean): string;
  24138. /**
  24139. * @hidden
  24140. */
  24141. protected _getEffectiveParent(): Nullable<Node>;
  24142. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24143. /** @hidden */ rebuild(): void;
  24144. /** @hidden */ resyncLightSources(): void;
  24145. /** @hidden */ resyncLighSource(light: Light): void;
  24146. /** @hidden */ unBindEffect(): void;
  24147. /** @hidden */ removeLightSource(light: Light): void;
  24148. private _markSubMeshesAsDirty;
  24149. /** @hidden */ markSubMeshesAsLightDirty(): void;
  24150. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  24151. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  24152. /**
  24153. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24154. */
  24155. scaling: Vector3;
  24156. /**
  24157. * Returns true if the mesh is blocked. Implemented by child classes
  24158. */
  24159. readonly isBlocked: boolean;
  24160. /**
  24161. * Returns the mesh itself by default. Implemented by child classes
  24162. * @param camera defines the camera to use to pick the right LOD level
  24163. * @returns the currentAbstractMesh
  24164. */
  24165. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24166. /**
  24167. * Returns 0 by default. Implemented by child classes
  24168. * @returns an integer
  24169. */
  24170. getTotalVertices(): number;
  24171. /**
  24172. * Returns a positive integer : the total number of indices in this mesh geometry.
  24173. * @returns the numner of indices or zero if the mesh has no geometry.
  24174. */
  24175. getTotalIndices(): number;
  24176. /**
  24177. * Returns null by default. Implemented by child classes
  24178. * @returns null
  24179. */
  24180. getIndices(): Nullable<IndicesArray>;
  24181. /**
  24182. * Returns the array of the requested vertex data kind. Implemented by child classes
  24183. * @param kind defines the vertex data kind to use
  24184. * @returns null
  24185. */
  24186. getVerticesData(kind: string): Nullable<FloatArray>;
  24187. /**
  24188. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24189. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24190. * Note that a new underlying VertexBuffer object is created each call.
  24191. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24192. * @param kind defines vertex data kind:
  24193. * * VertexBuffer.PositionKind
  24194. * * VertexBuffer.UVKind
  24195. * * VertexBuffer.UV2Kind
  24196. * * VertexBuffer.UV3Kind
  24197. * * VertexBuffer.UV4Kind
  24198. * * VertexBuffer.UV5Kind
  24199. * * VertexBuffer.UV6Kind
  24200. * * VertexBuffer.ColorKind
  24201. * * VertexBuffer.MatricesIndicesKind
  24202. * * VertexBuffer.MatricesIndicesExtraKind
  24203. * * VertexBuffer.MatricesWeightsKind
  24204. * * VertexBuffer.MatricesWeightsExtraKind
  24205. * @param data defines the data source
  24206. * @param updatable defines if the data must be flagged as updatable (or static)
  24207. * @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
  24208. * @returns the current mesh
  24209. */
  24210. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24211. /**
  24212. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24213. * If the mesh has no geometry, it is simply returned as it is.
  24214. * @param kind defines vertex data kind:
  24215. * * VertexBuffer.PositionKind
  24216. * * VertexBuffer.UVKind
  24217. * * VertexBuffer.UV2Kind
  24218. * * VertexBuffer.UV3Kind
  24219. * * VertexBuffer.UV4Kind
  24220. * * VertexBuffer.UV5Kind
  24221. * * VertexBuffer.UV6Kind
  24222. * * VertexBuffer.ColorKind
  24223. * * VertexBuffer.MatricesIndicesKind
  24224. * * VertexBuffer.MatricesIndicesExtraKind
  24225. * * VertexBuffer.MatricesWeightsKind
  24226. * * VertexBuffer.MatricesWeightsExtraKind
  24227. * @param data defines the data source
  24228. * @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
  24229. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24230. * @returns the current mesh
  24231. */
  24232. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24233. /**
  24234. * Sets the mesh indices,
  24235. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24236. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24237. * @param totalVertices Defines the total number of vertices
  24238. * @returns the current mesh
  24239. */
  24240. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24241. /**
  24242. * Gets a boolean indicating if specific vertex data is present
  24243. * @param kind defines the vertex data kind to use
  24244. * @returns true is data kind is present
  24245. */
  24246. isVerticesDataPresent(kind: string): boolean;
  24247. /**
  24248. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24249. * @returns a BoundingInfo
  24250. */
  24251. getBoundingInfo(): BoundingInfo;
  24252. /**
  24253. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24254. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24255. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24256. * @returns the current mesh
  24257. */
  24258. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24259. /**
  24260. * Overwrite the current bounding info
  24261. * @param boundingInfo defines the new bounding info
  24262. * @returns the current mesh
  24263. */
  24264. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24265. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24266. readonly useBones: boolean;
  24267. /** @hidden */ preActivate(): void;
  24268. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  24269. /** @hidden */ activate(renderId: number): boolean;
  24270. /** @hidden */ postActivate(): void;
  24271. /** @hidden */ freeze(): void;
  24272. /** @hidden */ unFreeze(): void;
  24273. /**
  24274. * Gets the current world matrix
  24275. * @returns a Matrix
  24276. */
  24277. getWorldMatrix(): Matrix;
  24278. /** @hidden */ getWorldMatrixDeterminant(): number;
  24279. /**
  24280. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24281. */
  24282. readonly isAnInstance: boolean;
  24283. /**
  24284. * Perform relative position change from the point of view of behind the front of the mesh.
  24285. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24286. * Supports definition of mesh facing forward or backward
  24287. * @param amountRight defines the distance on the right axis
  24288. * @param amountUp defines the distance on the up axis
  24289. * @param amountForward defines the distance on the forward axis
  24290. * @returns the current mesh
  24291. */
  24292. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24293. /**
  24294. * Calculate relative position change from the point of view of behind the front of the mesh.
  24295. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24296. * Supports definition of mesh facing forward or backward
  24297. * @param amountRight defines the distance on the right axis
  24298. * @param amountUp defines the distance on the up axis
  24299. * @param amountForward defines the distance on the forward axis
  24300. * @returns the new displacement vector
  24301. */
  24302. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24303. /**
  24304. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24305. * Supports definition of mesh facing forward or backward
  24306. * @param flipBack defines the flip
  24307. * @param twirlClockwise defines the twirl
  24308. * @param tiltRight defines the tilt
  24309. * @returns the current mesh
  24310. */
  24311. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24312. /**
  24313. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24314. * Supports definition of mesh facing forward or backward.
  24315. * @param flipBack defines the flip
  24316. * @param twirlClockwise defines the twirl
  24317. * @param tiltRight defines the tilt
  24318. * @returns the new rotation vector
  24319. */
  24320. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24321. /**
  24322. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24323. * This means the mesh underlying bounding box and sphere are recomputed.
  24324. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24325. * @returns the current mesh
  24326. */
  24327. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24328. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24329. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24330. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  24331. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24332. /** @hidden */
  24333. protected _afterComputeWorldMatrix(): void;
  24334. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24335. /**
  24336. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24337. * A mesh is in the frustum if its bounding box intersects the frustum
  24338. * @param frustumPlanes defines the frustum to test
  24339. * @returns true if the mesh is in the frustum planes
  24340. */
  24341. isInFrustum(frustumPlanes: Plane[]): boolean;
  24342. /**
  24343. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24344. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24345. * @param frustumPlanes defines the frustum to test
  24346. * @returns true if the mesh is completely in the frustum planes
  24347. */
  24348. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24349. /**
  24350. * True if the mesh intersects another mesh or a SolidParticle object
  24351. * @param mesh defines a target mesh or SolidParticle to test
  24352. * @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)
  24353. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24354. * @returns true if there is an intersection
  24355. */
  24356. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24357. /**
  24358. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24359. * @param point defines the point to test
  24360. * @returns true if there is an intersection
  24361. */
  24362. intersectsPoint(point: Vector3): boolean;
  24363. /**
  24364. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24365. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24366. */
  24367. checkCollisions: boolean;
  24368. /**
  24369. * Gets Collider object used to compute collisions (not physics)
  24370. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24371. */
  24372. readonly collider: Nullable<Collider>;
  24373. /**
  24374. * Move the mesh using collision engine
  24375. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24376. * @param displacement defines the requested displacement vector
  24377. * @returns the current mesh
  24378. */
  24379. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24380. private _onCollisionPositionChange;
  24381. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24382. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24383. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  24384. /** @hidden */ generatePointsArray(): boolean;
  24385. /**
  24386. * Checks if the passed Ray intersects with the mesh
  24387. * @param ray defines the ray to use
  24388. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24389. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24390. * @returns the picking info
  24391. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24392. */
  24393. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24394. /**
  24395. * Clones the current mesh
  24396. * @param name defines the mesh name
  24397. * @param newParent defines the new mesh parent
  24398. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24399. * @returns the new mesh
  24400. */
  24401. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24402. /**
  24403. * Disposes all the submeshes of the current meshnp
  24404. * @returns the current mesh
  24405. */
  24406. releaseSubMeshes(): AbstractMesh;
  24407. /**
  24408. * Releases resources associated with this abstract mesh.
  24409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24411. */
  24412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24413. /**
  24414. * Adds the passed mesh as a child to the current mesh
  24415. * @param mesh defines the child mesh
  24416. * @returns the current mesh
  24417. */
  24418. addChild(mesh: AbstractMesh): AbstractMesh;
  24419. /**
  24420. * Removes the passed mesh from the current mesh children list
  24421. * @param mesh defines the child mesh
  24422. * @returns the current mesh
  24423. */
  24424. removeChild(mesh: AbstractMesh): AbstractMesh;
  24425. /** @hidden */
  24426. private _initFacetData;
  24427. /**
  24428. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24429. * This method can be called within the render loop.
  24430. * 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
  24431. * @returns the current mesh
  24432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24433. */
  24434. updateFacetData(): AbstractMesh;
  24435. /**
  24436. * Returns the facetLocalNormals array.
  24437. * The normals are expressed in the mesh local spac
  24438. * @returns an array of Vector3
  24439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24440. */
  24441. getFacetLocalNormals(): Vector3[];
  24442. /**
  24443. * Returns the facetLocalPositions array.
  24444. * The facet positions are expressed in the mesh local space
  24445. * @returns an array of Vector3
  24446. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24447. */
  24448. getFacetLocalPositions(): Vector3[];
  24449. /**
  24450. * Returns the facetLocalPartioning array
  24451. * @returns an array of array of numbers
  24452. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24453. */
  24454. getFacetLocalPartitioning(): number[][];
  24455. /**
  24456. * Returns the i-th facet position in the world system.
  24457. * This method allocates a new Vector3 per call
  24458. * @param i defines the facet index
  24459. * @returns a new Vector3
  24460. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24461. */
  24462. getFacetPosition(i: number): Vector3;
  24463. /**
  24464. * Sets the reference Vector3 with the i-th facet position in the world system
  24465. * @param i defines the facet index
  24466. * @param ref defines the target vector
  24467. * @returns the current mesh
  24468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24469. */
  24470. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24471. /**
  24472. * Returns the i-th facet normal in the world system.
  24473. * This method allocates a new Vector3 per call
  24474. * @param i defines the facet index
  24475. * @returns a new Vector3
  24476. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24477. */
  24478. getFacetNormal(i: number): Vector3;
  24479. /**
  24480. * Sets the reference Vector3 with the i-th facet normal in the world system
  24481. * @param i defines the facet index
  24482. * @param ref defines the target vector
  24483. * @returns the current mesh
  24484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24485. */
  24486. getFacetNormalToRef(i: number, ref: Vector3): this;
  24487. /**
  24488. * 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)
  24489. * @param x defines x coordinate
  24490. * @param y defines y coordinate
  24491. * @param z defines z coordinate
  24492. * @returns the array of facet indexes
  24493. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24494. */
  24495. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24496. /**
  24497. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24498. * @param projected sets as the (x,y,z) world projection on the facet
  24499. * @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
  24500. * @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
  24501. * @param x defines x coordinate
  24502. * @param y defines y coordinate
  24503. * @param z defines z coordinate
  24504. * @returns the face index if found (or null instead)
  24505. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24506. */
  24507. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24508. /**
  24509. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24510. * @param projected sets as the (x,y,z) local projection on the facet
  24511. * @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
  24512. * @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
  24513. * @param x defines x coordinate
  24514. * @param y defines y coordinate
  24515. * @param z defines z coordinate
  24516. * @returns the face index if found (or null instead)
  24517. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24518. */
  24519. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24520. /**
  24521. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24522. * @returns the parameters
  24523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24524. */
  24525. getFacetDataParameters(): any;
  24526. /**
  24527. * Disables the feature FacetData and frees the related memory
  24528. * @returns the current mesh
  24529. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24530. */
  24531. disableFacetData(): AbstractMesh;
  24532. /**
  24533. * Updates the AbstractMesh indices array
  24534. * @param indices defines the data source
  24535. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24536. * @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)
  24537. * @returns the current mesh
  24538. */
  24539. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24540. /**
  24541. * Creates new normals data for the mesh
  24542. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24543. * @returns the current mesh
  24544. */
  24545. createNormals(updatable: boolean): AbstractMesh;
  24546. /**
  24547. * Align the mesh with a normal
  24548. * @param normal defines the normal to use
  24549. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24550. * @returns the current mesh
  24551. */
  24552. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24553. /** @hidden */ checkOcclusionQuery(): boolean;
  24554. }
  24555. }
  24556. declare module BABYLON {
  24557. /**
  24558. * Interface used to define ActionEvent
  24559. */
  24560. export interface IActionEvent {
  24561. /** The mesh or sprite that triggered the action */
  24562. source: any;
  24563. /** The X mouse cursor position at the time of the event */
  24564. pointerX: number;
  24565. /** The Y mouse cursor position at the time of the event */
  24566. pointerY: number;
  24567. /** The mesh that is currently pointed at (can be null) */
  24568. meshUnderPointer: Nullable<AbstractMesh>;
  24569. /** the original (browser) event that triggered the ActionEvent */
  24570. sourceEvent?: any;
  24571. /** additional data for the event */
  24572. additionalData?: any;
  24573. }
  24574. /**
  24575. * ActionEvent is the event being sent when an action is triggered.
  24576. */
  24577. export class ActionEvent implements IActionEvent {
  24578. /** The mesh or sprite that triggered the action */
  24579. source: any;
  24580. /** The X mouse cursor position at the time of the event */
  24581. pointerX: number;
  24582. /** The Y mouse cursor position at the time of the event */
  24583. pointerY: number;
  24584. /** The mesh that is currently pointed at (can be null) */
  24585. meshUnderPointer: Nullable<AbstractMesh>;
  24586. /** the original (browser) event that triggered the ActionEvent */
  24587. sourceEvent?: any;
  24588. /** additional data for the event */
  24589. additionalData?: any;
  24590. /**
  24591. * Creates a new ActionEvent
  24592. * @param source The mesh or sprite that triggered the action
  24593. * @param pointerX The X mouse cursor position at the time of the event
  24594. * @param pointerY The Y mouse cursor position at the time of the event
  24595. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24596. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24597. * @param additionalData additional data for the event
  24598. */
  24599. constructor(
  24600. /** The mesh or sprite that triggered the action */
  24601. source: any,
  24602. /** The X mouse cursor position at the time of the event */
  24603. pointerX: number,
  24604. /** The Y mouse cursor position at the time of the event */
  24605. pointerY: number,
  24606. /** The mesh that is currently pointed at (can be null) */
  24607. meshUnderPointer: Nullable<AbstractMesh>,
  24608. /** the original (browser) event that triggered the ActionEvent */
  24609. sourceEvent?: any,
  24610. /** additional data for the event */
  24611. additionalData?: any);
  24612. /**
  24613. * Helper function to auto-create an ActionEvent from a source mesh.
  24614. * @param source The source mesh that triggered the event
  24615. * @param evt The original (browser) event
  24616. * @param additionalData additional data for the event
  24617. * @returns the new ActionEvent
  24618. */
  24619. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24620. /**
  24621. * Helper function to auto-create an ActionEvent from a source sprite
  24622. * @param source The source sprite that triggered the event
  24623. * @param scene Scene associated with the sprite
  24624. * @param evt The original (browser) event
  24625. * @param additionalData additional data for the event
  24626. * @returns the new ActionEvent
  24627. */
  24628. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24629. /**
  24630. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24631. * @param scene the scene where the event occurred
  24632. * @param evt The original (browser) event
  24633. * @returns the new ActionEvent
  24634. */
  24635. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24636. /**
  24637. * Helper function to auto-create an ActionEvent from a primitive
  24638. * @param prim defines the target primitive
  24639. * @param pointerPos defines the pointer position
  24640. * @param evt The original (browser) event
  24641. * @param additionalData additional data for the event
  24642. * @returns the new ActionEvent
  24643. */
  24644. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24645. }
  24646. }
  24647. declare module BABYLON {
  24648. /**
  24649. * Abstract class used to decouple action Manager from scene and meshes.
  24650. * Do not instantiate.
  24651. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24652. */
  24653. export abstract class AbstractActionManager implements IDisposable {
  24654. /** Gets the list of active triggers */
  24655. static Triggers: {
  24656. [key: string]: number;
  24657. };
  24658. /** Gets the cursor to use when hovering items */
  24659. hoverCursor: string;
  24660. /** Gets the list of actions */
  24661. actions: IAction[];
  24662. /**
  24663. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24664. */
  24665. isRecursive: boolean;
  24666. /**
  24667. * Releases all associated resources
  24668. */
  24669. abstract dispose(): void;
  24670. /**
  24671. * Does this action manager has pointer triggers
  24672. */
  24673. abstract readonly hasPointerTriggers: boolean;
  24674. /**
  24675. * Does this action manager has pick triggers
  24676. */
  24677. abstract readonly hasPickTriggers: boolean;
  24678. /**
  24679. * Process a specific trigger
  24680. * @param trigger defines the trigger to process
  24681. * @param evt defines the event details to be processed
  24682. */
  24683. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24684. /**
  24685. * Does this action manager handles actions of any of the given triggers
  24686. * @param triggers defines the triggers to be tested
  24687. * @return a boolean indicating whether one (or more) of the triggers is handled
  24688. */
  24689. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24690. /**
  24691. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24692. * speed.
  24693. * @param triggerA defines the trigger to be tested
  24694. * @param triggerB defines the trigger to be tested
  24695. * @return a boolean indicating whether one (or more) of the triggers is handled
  24696. */
  24697. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24698. /**
  24699. * Does this action manager handles actions of a given trigger
  24700. * @param trigger defines the trigger to be tested
  24701. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24702. * @return whether the trigger is handled
  24703. */
  24704. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24705. /**
  24706. * Serialize this manager to a JSON object
  24707. * @param name defines the property name to store this manager
  24708. * @returns a JSON representation of this manager
  24709. */
  24710. abstract serialize(name: string): any;
  24711. /**
  24712. * Registers an action to this action manager
  24713. * @param action defines the action to be registered
  24714. * @return the action amended (prepared) after registration
  24715. */
  24716. abstract registerAction(action: IAction): Nullable<IAction>;
  24717. /**
  24718. * Unregisters an action to this action manager
  24719. * @param action defines the action to be unregistered
  24720. * @return a boolean indicating whether the action has been unregistered
  24721. */
  24722. abstract unregisterAction(action: IAction): Boolean;
  24723. /**
  24724. * Does exist one action manager with at least one trigger
  24725. **/
  24726. static readonly HasTriggers: boolean;
  24727. /**
  24728. * Does exist one action manager with at least one pick trigger
  24729. **/
  24730. static readonly HasPickTriggers: boolean;
  24731. /**
  24732. * Does exist one action manager that handles actions of a given trigger
  24733. * @param trigger defines the trigger to be tested
  24734. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24735. **/
  24736. static HasSpecificTrigger(trigger: number): boolean;
  24737. }
  24738. }
  24739. declare module BABYLON {
  24740. /**
  24741. * Defines how a node can be built from a string name.
  24742. */
  24743. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24744. /**
  24745. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24746. */
  24747. export class Node implements IBehaviorAware<Node> {
  24748. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24749. private static _NodeConstructors;
  24750. /**
  24751. * Add a new node constructor
  24752. * @param type defines the type name of the node to construct
  24753. * @param constructorFunc defines the constructor function
  24754. */
  24755. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24756. /**
  24757. * Returns a node constructor based on type name
  24758. * @param type defines the type name
  24759. * @param name defines the new node name
  24760. * @param scene defines the hosting scene
  24761. * @param options defines optional options to transmit to constructors
  24762. * @returns the new constructor or null
  24763. */
  24764. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24765. /**
  24766. * Gets or sets the name of the node
  24767. */
  24768. name: string;
  24769. /**
  24770. * Gets or sets the id of the node
  24771. */
  24772. id: string;
  24773. /**
  24774. * Gets or sets the unique id of the node
  24775. */
  24776. uniqueId: number;
  24777. /**
  24778. * Gets or sets a string used to store user defined state for the node
  24779. */
  24780. state: string;
  24781. /**
  24782. * Gets or sets an object used to store user defined information for the node
  24783. */
  24784. metadata: any;
  24785. /**
  24786. * For internal use only. Please do not use.
  24787. */
  24788. reservedDataStore: any;
  24789. /**
  24790. * List of inspectable custom properties (used by the Inspector)
  24791. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24792. */
  24793. inspectableCustomProperties: IInspectable[];
  24794. /**
  24795. * Gets or sets a boolean used to define if the node must be serialized
  24796. */
  24797. doNotSerialize: boolean;
  24798. /** @hidden */ isDisposed: boolean;
  24799. /**
  24800. * Gets a list of Animations associated with the node
  24801. */
  24802. animations: Animation[];
  24803. protected _ranges: {
  24804. [name: string]: Nullable<AnimationRange>;
  24805. };
  24806. /**
  24807. * Callback raised when the node is ready to be used
  24808. */
  24809. onReady: Nullable<(node: Node) => void>;
  24810. private _isEnabled;
  24811. private _isParentEnabled;
  24812. private _isReady;
  24813. /** @hidden */ currentRenderId: number;
  24814. private _parentUpdateId;
  24815. /** @hidden */ childUpdateId: number;
  24816. /** @hidden */ waitingParentId: Nullable<string>;
  24817. /** @hidden */ scene: Scene;
  24818. /** @hidden */ cache: any;
  24819. private _parentNode;
  24820. private _children;
  24821. /** @hidden */ worldMatrix: Matrix;
  24822. /** @hidden */ worldMatrixDeterminant: number;
  24823. /** @hidden */ worldMatrixDeterminantIsDirty: boolean;
  24824. /** @hidden */
  24825. private _sceneRootNodesIndex;
  24826. /**
  24827. * Gets a boolean indicating if the node has been disposed
  24828. * @returns true if the node was disposed
  24829. */
  24830. isDisposed(): boolean;
  24831. /**
  24832. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24833. * @see https://doc.babylonjs.com/how_to/parenting
  24834. */
  24835. parent: Nullable<Node>;
  24836. private addToSceneRootNodes;
  24837. private removeFromSceneRootNodes;
  24838. private _animationPropertiesOverride;
  24839. /**
  24840. * Gets or sets the animation properties override
  24841. */
  24842. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24843. /**
  24844. * Gets a string idenfifying the name of the class
  24845. * @returns "Node" string
  24846. */
  24847. getClassName(): string;
  24848. /** @hidden */ protected readonly _isNode: boolean;
  24849. /**
  24850. * An event triggered when the mesh is disposed
  24851. */
  24852. onDisposeObservable: Observable<Node>;
  24853. private _onDisposeObserver;
  24854. /**
  24855. * Sets a callback that will be raised when the node will be disposed
  24856. */
  24857. onDispose: () => void;
  24858. /**
  24859. * Creates a new Node
  24860. * @param name the name and id to be given to this node
  24861. * @param scene the scene this node will be added to
  24862. * @param addToRootNodes the node will be added to scene.rootNodes
  24863. */
  24864. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24865. /**
  24866. * Gets the scene of the node
  24867. * @returns a scene
  24868. */
  24869. getScene(): Scene;
  24870. /**
  24871. * Gets the engine of the node
  24872. * @returns a Engine
  24873. */
  24874. getEngine(): Engine;
  24875. private _behaviors;
  24876. /**
  24877. * Attach a behavior to the node
  24878. * @see http://doc.babylonjs.com/features/behaviour
  24879. * @param behavior defines the behavior to attach
  24880. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24881. * @returns the current Node
  24882. */
  24883. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24884. /**
  24885. * Remove an attached behavior
  24886. * @see http://doc.babylonjs.com/features/behaviour
  24887. * @param behavior defines the behavior to attach
  24888. * @returns the current Node
  24889. */
  24890. removeBehavior(behavior: Behavior<Node>): Node;
  24891. /**
  24892. * Gets the list of attached behaviors
  24893. * @see http://doc.babylonjs.com/features/behaviour
  24894. */
  24895. readonly behaviors: Behavior<Node>[];
  24896. /**
  24897. * Gets an attached behavior by name
  24898. * @param name defines the name of the behavior to look for
  24899. * @see http://doc.babylonjs.com/features/behaviour
  24900. * @returns null if behavior was not found else the requested behavior
  24901. */
  24902. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24903. /**
  24904. * Returns the latest update of the World matrix
  24905. * @returns a Matrix
  24906. */
  24907. getWorldMatrix(): Matrix;
  24908. /** @hidden */ getWorldMatrixDeterminant(): number;
  24909. /**
  24910. * Returns directly the latest state of the mesh World matrix.
  24911. * A Matrix is returned.
  24912. */
  24913. readonly worldMatrixFromCache: Matrix;
  24914. /** @hidden */ initCache(): void;
  24915. /** @hidden */
  24916. updateCache(force?: boolean): void;
  24917. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24918. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24919. /** @hidden */ isSynchronized(): boolean;
  24920. /** @hidden */ markSyncedWithParent(): void;
  24921. /** @hidden */
  24922. isSynchronizedWithParent(): boolean;
  24923. /** @hidden */
  24924. isSynchronized(): boolean;
  24925. /**
  24926. * Is this node ready to be used/rendered
  24927. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24928. * @return true if the node is ready
  24929. */
  24930. isReady(completeCheck?: boolean): boolean;
  24931. /**
  24932. * Is this node enabled?
  24933. * 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
  24934. * @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
  24935. * @return whether this node (and its parent) is enabled
  24936. */
  24937. isEnabled(checkAncestors?: boolean): boolean;
  24938. /** @hidden */
  24939. protected _syncParentEnabledState(): void;
  24940. /**
  24941. * Set the enabled state of this node
  24942. * @param value defines the new enabled state
  24943. */
  24944. setEnabled(value: boolean): void;
  24945. /**
  24946. * Is this node a descendant of the given node?
  24947. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24948. * @param ancestor defines the parent node to inspect
  24949. * @returns a boolean indicating if this node is a descendant of the given node
  24950. */
  24951. isDescendantOf(ancestor: Node): boolean;
  24952. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24953. /**
  24954. * Will return all nodes that have this node as ascendant
  24955. * @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
  24956. * @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
  24957. * @return all children nodes of all types
  24958. */
  24959. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24960. /**
  24961. * Get all child-meshes of this node
  24962. * @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)
  24963. * @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
  24964. * @returns an array of AbstractMesh
  24965. */
  24966. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24967. /**
  24968. * Get all direct children of this node
  24969. * @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
  24970. * @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)
  24971. * @returns an array of Node
  24972. */
  24973. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24974. /** @hidden */ setReady(state: boolean): void;
  24975. /**
  24976. * Get an animation by name
  24977. * @param name defines the name of the animation to look for
  24978. * @returns null if not found else the requested animation
  24979. */
  24980. getAnimationByName(name: string): Nullable<Animation>;
  24981. /**
  24982. * Creates an animation range for this node
  24983. * @param name defines the name of the range
  24984. * @param from defines the starting key
  24985. * @param to defines the end key
  24986. */
  24987. createAnimationRange(name: string, from: number, to: number): void;
  24988. /**
  24989. * Delete a specific animation range
  24990. * @param name defines the name of the range to delete
  24991. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24992. */
  24993. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24994. /**
  24995. * Get an animation range by name
  24996. * @param name defines the name of the animation range to look for
  24997. * @returns null if not found else the requested animation range
  24998. */
  24999. getAnimationRange(name: string): Nullable<AnimationRange>;
  25000. /**
  25001. * Gets the list of all animation ranges defined on this node
  25002. * @returns an array
  25003. */
  25004. getAnimationRanges(): Nullable<AnimationRange>[];
  25005. /**
  25006. * Will start the animation sequence
  25007. * @param name defines the range frames for animation sequence
  25008. * @param loop defines if the animation should loop (false by default)
  25009. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25010. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25011. * @returns the object created for this animation. If range does not exist, it will return null
  25012. */
  25013. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25014. /**
  25015. * Serialize animation ranges into a JSON compatible object
  25016. * @returns serialization object
  25017. */
  25018. serializeAnimationRanges(): any;
  25019. /**
  25020. * Computes the world matrix of the node
  25021. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25022. * @returns the world matrix
  25023. */
  25024. computeWorldMatrix(force?: boolean): Matrix;
  25025. /**
  25026. * Releases resources associated with this node.
  25027. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25028. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25029. */
  25030. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25031. /**
  25032. * Parse animation range data from a serialization object and store them into a given node
  25033. * @param node defines where to store the animation ranges
  25034. * @param parsedNode defines the serialization object to read data from
  25035. * @param scene defines the hosting scene
  25036. */
  25037. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25038. /**
  25039. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25040. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25041. * @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
  25042. * @returns the new bounding vectors
  25043. */
  25044. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25045. min: Vector3;
  25046. max: Vector3;
  25047. };
  25048. }
  25049. }
  25050. declare module BABYLON {
  25051. /**
  25052. * @hidden
  25053. */
  25054. export class _IAnimationState {
  25055. key: number;
  25056. repeatCount: number;
  25057. workValue?: any;
  25058. loopMode?: number;
  25059. offsetValue?: any;
  25060. highLimitValue?: any;
  25061. }
  25062. /**
  25063. * Class used to store any kind of animation
  25064. */
  25065. export class Animation {
  25066. /**Name of the animation */
  25067. name: string;
  25068. /**Property to animate */
  25069. targetProperty: string;
  25070. /**The frames per second of the animation */
  25071. framePerSecond: number;
  25072. /**The data type of the animation */
  25073. dataType: number;
  25074. /**The loop mode of the animation */
  25075. loopMode?: number | undefined;
  25076. /**Specifies if blending should be enabled */
  25077. enableBlending?: boolean | undefined;
  25078. /**
  25079. * Use matrix interpolation instead of using direct key value when animating matrices
  25080. */
  25081. static AllowMatricesInterpolation: boolean;
  25082. /**
  25083. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25084. */
  25085. static AllowMatrixDecomposeForInterpolation: boolean;
  25086. /**
  25087. * Stores the key frames of the animation
  25088. */
  25089. private _keys;
  25090. /**
  25091. * Stores the easing function of the animation
  25092. */
  25093. private _easingFunction;
  25094. /**
  25095. * @hidden Internal use only
  25096. */ runtimeAnimations: RuntimeAnimation[];
  25097. /**
  25098. * The set of event that will be linked to this animation
  25099. */
  25100. private _events;
  25101. /**
  25102. * Stores an array of target property paths
  25103. */
  25104. targetPropertyPath: string[];
  25105. /**
  25106. * Stores the blending speed of the animation
  25107. */
  25108. blendingSpeed: number;
  25109. /**
  25110. * Stores the animation ranges for the animation
  25111. */
  25112. private _ranges;
  25113. /**
  25114. * @hidden Internal use
  25115. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25116. /**
  25117. * Sets up an animation
  25118. * @param property The property to animate
  25119. * @param animationType The animation type to apply
  25120. * @param framePerSecond The frames per second of the animation
  25121. * @param easingFunction The easing function used in the animation
  25122. * @returns The created animation
  25123. */
  25124. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25125. /**
  25126. * Create and start an animation on a node
  25127. * @param name defines the name of the global animation that will be run on all nodes
  25128. * @param node defines the root node where the animation will take place
  25129. * @param targetProperty defines property to animate
  25130. * @param framePerSecond defines the number of frame per second yo use
  25131. * @param totalFrame defines the number of frames in total
  25132. * @param from defines the initial value
  25133. * @param to defines the final value
  25134. * @param loopMode defines which loop mode you want to use (off by default)
  25135. * @param easingFunction defines the easing function to use (linear by default)
  25136. * @param onAnimationEnd defines the callback to call when animation end
  25137. * @returns the animatable created for this animation
  25138. */
  25139. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25140. /**
  25141. * Create and start an animation on a node and its descendants
  25142. * @param name defines the name of the global animation that will be run on all nodes
  25143. * @param node defines the root node where the animation will take place
  25144. * @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
  25145. * @param targetProperty defines property to animate
  25146. * @param framePerSecond defines the number of frame per second to use
  25147. * @param totalFrame defines the number of frames in total
  25148. * @param from defines the initial value
  25149. * @param to defines the final value
  25150. * @param loopMode defines which loop mode you want to use (off by default)
  25151. * @param easingFunction defines the easing function to use (linear by default)
  25152. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25153. * @returns the list of animatables created for all nodes
  25154. * @example https://www.babylonjs-playground.com/#MH0VLI
  25155. */
  25156. 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[]>;
  25157. /**
  25158. * Creates a new animation, merges it with the existing animations and starts it
  25159. * @param name Name of the animation
  25160. * @param node Node which contains the scene that begins the animations
  25161. * @param targetProperty Specifies which property to animate
  25162. * @param framePerSecond The frames per second of the animation
  25163. * @param totalFrame The total number of frames
  25164. * @param from The frame at the beginning of the animation
  25165. * @param to The frame at the end of the animation
  25166. * @param loopMode Specifies the loop mode of the animation
  25167. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25168. * @param onAnimationEnd Callback to run once the animation is complete
  25169. * @returns Nullable animation
  25170. */
  25171. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25172. /**
  25173. * Transition property of an host to the target Value
  25174. * @param property The property to transition
  25175. * @param targetValue The target Value of the property
  25176. * @param host The object where the property to animate belongs
  25177. * @param scene Scene used to run the animation
  25178. * @param frameRate Framerate (in frame/s) to use
  25179. * @param transition The transition type we want to use
  25180. * @param duration The duration of the animation, in milliseconds
  25181. * @param onAnimationEnd Callback trigger at the end of the animation
  25182. * @returns Nullable animation
  25183. */
  25184. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25185. /**
  25186. * Return the array of runtime animations currently using this animation
  25187. */
  25188. readonly runtimeAnimations: RuntimeAnimation[];
  25189. /**
  25190. * Specifies if any of the runtime animations are currently running
  25191. */
  25192. readonly hasRunningRuntimeAnimations: boolean;
  25193. /**
  25194. * Initializes the animation
  25195. * @param name Name of the animation
  25196. * @param targetProperty Property to animate
  25197. * @param framePerSecond The frames per second of the animation
  25198. * @param dataType The data type of the animation
  25199. * @param loopMode The loop mode of the animation
  25200. * @param enableBlending Specifies if blending should be enabled
  25201. */
  25202. constructor(
  25203. /**Name of the animation */
  25204. name: string,
  25205. /**Property to animate */
  25206. targetProperty: string,
  25207. /**The frames per second of the animation */
  25208. framePerSecond: number,
  25209. /**The data type of the animation */
  25210. dataType: number,
  25211. /**The loop mode of the animation */
  25212. loopMode?: number | undefined,
  25213. /**Specifies if blending should be enabled */
  25214. enableBlending?: boolean | undefined);
  25215. /**
  25216. * Converts the animation to a string
  25217. * @param fullDetails support for multiple levels of logging within scene loading
  25218. * @returns String form of the animation
  25219. */
  25220. toString(fullDetails?: boolean): string;
  25221. /**
  25222. * Add an event to this animation
  25223. * @param event Event to add
  25224. */
  25225. addEvent(event: AnimationEvent): void;
  25226. /**
  25227. * Remove all events found at the given frame
  25228. * @param frame The frame to remove events from
  25229. */
  25230. removeEvents(frame: number): void;
  25231. /**
  25232. * Retrieves all the events from the animation
  25233. * @returns Events from the animation
  25234. */
  25235. getEvents(): AnimationEvent[];
  25236. /**
  25237. * Creates an animation range
  25238. * @param name Name of the animation range
  25239. * @param from Starting frame of the animation range
  25240. * @param to Ending frame of the animation
  25241. */
  25242. createRange(name: string, from: number, to: number): void;
  25243. /**
  25244. * Deletes an animation range by name
  25245. * @param name Name of the animation range to delete
  25246. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25247. */
  25248. deleteRange(name: string, deleteFrames?: boolean): void;
  25249. /**
  25250. * Gets the animation range by name, or null if not defined
  25251. * @param name Name of the animation range
  25252. * @returns Nullable animation range
  25253. */
  25254. getRange(name: string): Nullable<AnimationRange>;
  25255. /**
  25256. * Gets the key frames from the animation
  25257. * @returns The key frames of the animation
  25258. */
  25259. getKeys(): Array<IAnimationKey>;
  25260. /**
  25261. * Gets the highest frame rate of the animation
  25262. * @returns Highest frame rate of the animation
  25263. */
  25264. getHighestFrame(): number;
  25265. /**
  25266. * Gets the easing function of the animation
  25267. * @returns Easing function of the animation
  25268. */
  25269. getEasingFunction(): IEasingFunction;
  25270. /**
  25271. * Sets the easing function of the animation
  25272. * @param easingFunction A custom mathematical formula for animation
  25273. */
  25274. setEasingFunction(easingFunction: EasingFunction): void;
  25275. /**
  25276. * Interpolates a scalar linearly
  25277. * @param startValue Start value of the animation curve
  25278. * @param endValue End value of the animation curve
  25279. * @param gradient Scalar amount to interpolate
  25280. * @returns Interpolated scalar value
  25281. */
  25282. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25283. /**
  25284. * Interpolates a scalar cubically
  25285. * @param startValue Start value of the animation curve
  25286. * @param outTangent End tangent of the animation
  25287. * @param endValue End value of the animation curve
  25288. * @param inTangent Start tangent of the animation curve
  25289. * @param gradient Scalar amount to interpolate
  25290. * @returns Interpolated scalar value
  25291. */
  25292. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25293. /**
  25294. * Interpolates a quaternion using a spherical linear interpolation
  25295. * @param startValue Start value of the animation curve
  25296. * @param endValue End value of the animation curve
  25297. * @param gradient Scalar amount to interpolate
  25298. * @returns Interpolated quaternion value
  25299. */
  25300. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25301. /**
  25302. * Interpolates a quaternion cubically
  25303. * @param startValue Start value of the animation curve
  25304. * @param outTangent End tangent of the animation curve
  25305. * @param endValue End value of the animation curve
  25306. * @param inTangent Start tangent of the animation curve
  25307. * @param gradient Scalar amount to interpolate
  25308. * @returns Interpolated quaternion value
  25309. */
  25310. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25311. /**
  25312. * Interpolates a Vector3 linearl
  25313. * @param startValue Start value of the animation curve
  25314. * @param endValue End value of the animation curve
  25315. * @param gradient Scalar amount to interpolate
  25316. * @returns Interpolated scalar value
  25317. */
  25318. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25319. /**
  25320. * Interpolates a Vector3 cubically
  25321. * @param startValue Start value of the animation curve
  25322. * @param outTangent End tangent of the animation
  25323. * @param endValue End value of the animation curve
  25324. * @param inTangent Start tangent of the animation curve
  25325. * @param gradient Scalar amount to interpolate
  25326. * @returns InterpolatedVector3 value
  25327. */
  25328. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25329. /**
  25330. * Interpolates a Vector2 linearly
  25331. * @param startValue Start value of the animation curve
  25332. * @param endValue End value of the animation curve
  25333. * @param gradient Scalar amount to interpolate
  25334. * @returns Interpolated Vector2 value
  25335. */
  25336. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25337. /**
  25338. * Interpolates a Vector2 cubically
  25339. * @param startValue Start value of the animation curve
  25340. * @param outTangent End tangent of the animation
  25341. * @param endValue End value of the animation curve
  25342. * @param inTangent Start tangent of the animation curve
  25343. * @param gradient Scalar amount to interpolate
  25344. * @returns Interpolated Vector2 value
  25345. */
  25346. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25347. /**
  25348. * Interpolates a size linearly
  25349. * @param startValue Start value of the animation curve
  25350. * @param endValue End value of the animation curve
  25351. * @param gradient Scalar amount to interpolate
  25352. * @returns Interpolated Size value
  25353. */
  25354. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25355. /**
  25356. * Interpolates a Color3 linearly
  25357. * @param startValue Start value of the animation curve
  25358. * @param endValue End value of the animation curve
  25359. * @param gradient Scalar amount to interpolate
  25360. * @returns Interpolated Color3 value
  25361. */
  25362. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25363. /**
  25364. * @hidden Internal use only
  25365. */ getKeyValue(value: any): any;
  25366. /**
  25367. * @hidden Internal use only
  25368. */ interpolate(currentFrame: number, state: _IAnimationState): any;
  25369. /**
  25370. * Defines the function to use to interpolate matrices
  25371. * @param startValue defines the start matrix
  25372. * @param endValue defines the end matrix
  25373. * @param gradient defines the gradient between both matrices
  25374. * @param result defines an optional target matrix where to store the interpolation
  25375. * @returns the interpolated matrix
  25376. */
  25377. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25378. /**
  25379. * Makes a copy of the animation
  25380. * @returns Cloned animation
  25381. */
  25382. clone(): Animation;
  25383. /**
  25384. * Sets the key frames of the animation
  25385. * @param values The animation key frames to set
  25386. */
  25387. setKeys(values: Array<IAnimationKey>): void;
  25388. /**
  25389. * Serializes the animation to an object
  25390. * @returns Serialized object
  25391. */
  25392. serialize(): any;
  25393. /**
  25394. * Float animation type
  25395. */
  25396. private static _ANIMATIONTYPE_FLOAT;
  25397. /**
  25398. * Vector3 animation type
  25399. */
  25400. private static _ANIMATIONTYPE_VECTOR3;
  25401. /**
  25402. * Quaternion animation type
  25403. */
  25404. private static _ANIMATIONTYPE_QUATERNION;
  25405. /**
  25406. * Matrix animation type
  25407. */
  25408. private static _ANIMATIONTYPE_MATRIX;
  25409. /**
  25410. * Color3 animation type
  25411. */
  25412. private static _ANIMATIONTYPE_COLOR3;
  25413. /**
  25414. * Vector2 animation type
  25415. */
  25416. private static _ANIMATIONTYPE_VECTOR2;
  25417. /**
  25418. * Size animation type
  25419. */
  25420. private static _ANIMATIONTYPE_SIZE;
  25421. /**
  25422. * Relative Loop Mode
  25423. */
  25424. private static _ANIMATIONLOOPMODE_RELATIVE;
  25425. /**
  25426. * Cycle Loop Mode
  25427. */
  25428. private static _ANIMATIONLOOPMODE_CYCLE;
  25429. /**
  25430. * Constant Loop Mode
  25431. */
  25432. private static _ANIMATIONLOOPMODE_CONSTANT;
  25433. /**
  25434. * Get the float animation type
  25435. */
  25436. static readonly ANIMATIONTYPE_FLOAT: number;
  25437. /**
  25438. * Get the Vector3 animation type
  25439. */
  25440. static readonly ANIMATIONTYPE_VECTOR3: number;
  25441. /**
  25442. * Get the Vector2 animation type
  25443. */
  25444. static readonly ANIMATIONTYPE_VECTOR2: number;
  25445. /**
  25446. * Get the Size animation type
  25447. */
  25448. static readonly ANIMATIONTYPE_SIZE: number;
  25449. /**
  25450. * Get the Quaternion animation type
  25451. */
  25452. static readonly ANIMATIONTYPE_QUATERNION: number;
  25453. /**
  25454. * Get the Matrix animation type
  25455. */
  25456. static readonly ANIMATIONTYPE_MATRIX: number;
  25457. /**
  25458. * Get the Color3 animation type
  25459. */
  25460. static readonly ANIMATIONTYPE_COLOR3: number;
  25461. /**
  25462. * Get the Relative Loop Mode
  25463. */
  25464. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25465. /**
  25466. * Get the Cycle Loop Mode
  25467. */
  25468. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25469. /**
  25470. * Get the Constant Loop Mode
  25471. */
  25472. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25473. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25474. /**
  25475. * Parses an animation object and creates an animation
  25476. * @param parsedAnimation Parsed animation object
  25477. * @returns Animation object
  25478. */
  25479. static Parse(parsedAnimation: any): Animation;
  25480. /**
  25481. * Appends the serialized animations from the source animations
  25482. * @param source Source containing the animations
  25483. * @param destination Target to store the animations
  25484. */
  25485. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25486. }
  25487. }
  25488. declare module BABYLON {
  25489. /**
  25490. * Base class of all the textures in babylon.
  25491. * It groups all the common properties the materials, post process, lights... might need
  25492. * in order to make a correct use of the texture.
  25493. */
  25494. export class BaseTexture implements IAnimatable {
  25495. /**
  25496. * Default anisotropic filtering level for the application.
  25497. * It is set to 4 as a good tradeoff between perf and quality.
  25498. */
  25499. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25500. /**
  25501. * Gets or sets the unique id of the texture
  25502. */
  25503. uniqueId: number;
  25504. /**
  25505. * Define the name of the texture.
  25506. */
  25507. name: string;
  25508. /**
  25509. * Gets or sets an object used to store user defined information.
  25510. */
  25511. metadata: any;
  25512. /**
  25513. * For internal use only. Please do not use.
  25514. */
  25515. reservedDataStore: any;
  25516. private _hasAlpha;
  25517. /**
  25518. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25519. */
  25520. hasAlpha: boolean;
  25521. /**
  25522. * Defines if the alpha value should be determined via the rgb values.
  25523. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25524. */
  25525. getAlphaFromRGB: boolean;
  25526. /**
  25527. * Intensity or strength of the texture.
  25528. * It is commonly used by materials to fine tune the intensity of the texture
  25529. */
  25530. level: number;
  25531. /**
  25532. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25533. * This is part of the texture as textures usually maps to one uv set.
  25534. */
  25535. coordinatesIndex: number;
  25536. private _coordinatesMode;
  25537. /**
  25538. * How a texture is mapped.
  25539. *
  25540. * | Value | Type | Description |
  25541. * | ----- | ----------------------------------- | ----------- |
  25542. * | 0 | EXPLICIT_MODE | |
  25543. * | 1 | SPHERICAL_MODE | |
  25544. * | 2 | PLANAR_MODE | |
  25545. * | 3 | CUBIC_MODE | |
  25546. * | 4 | PROJECTION_MODE | |
  25547. * | 5 | SKYBOX_MODE | |
  25548. * | 6 | INVCUBIC_MODE | |
  25549. * | 7 | EQUIRECTANGULAR_MODE | |
  25550. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25551. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25552. */
  25553. coordinatesMode: number;
  25554. /**
  25555. * | Value | Type | Description |
  25556. * | ----- | ------------------ | ----------- |
  25557. * | 0 | CLAMP_ADDRESSMODE | |
  25558. * | 1 | WRAP_ADDRESSMODE | |
  25559. * | 2 | MIRROR_ADDRESSMODE | |
  25560. */
  25561. wrapU: number;
  25562. /**
  25563. * | Value | Type | Description |
  25564. * | ----- | ------------------ | ----------- |
  25565. * | 0 | CLAMP_ADDRESSMODE | |
  25566. * | 1 | WRAP_ADDRESSMODE | |
  25567. * | 2 | MIRROR_ADDRESSMODE | |
  25568. */
  25569. wrapV: number;
  25570. /**
  25571. * | Value | Type | Description |
  25572. * | ----- | ------------------ | ----------- |
  25573. * | 0 | CLAMP_ADDRESSMODE | |
  25574. * | 1 | WRAP_ADDRESSMODE | |
  25575. * | 2 | MIRROR_ADDRESSMODE | |
  25576. */
  25577. wrapR: number;
  25578. /**
  25579. * With compliant hardware and browser (supporting anisotropic filtering)
  25580. * this defines the level of anisotropic filtering in the texture.
  25581. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25582. */
  25583. anisotropicFilteringLevel: number;
  25584. /**
  25585. * Define if the texture is a cube texture or if false a 2d texture.
  25586. */
  25587. isCube: boolean;
  25588. /**
  25589. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25590. */
  25591. is3D: boolean;
  25592. /**
  25593. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25594. * HDR texture are usually stored in linear space.
  25595. * This only impacts the PBR and Background materials
  25596. */
  25597. gammaSpace: boolean;
  25598. /**
  25599. * Gets whether or not the texture contains RGBD data.
  25600. */
  25601. readonly isRGBD: boolean;
  25602. /**
  25603. * Is Z inverted in the texture (useful in a cube texture).
  25604. */
  25605. invertZ: boolean;
  25606. /**
  25607. * Are mip maps generated for this texture or not.
  25608. */
  25609. readonly noMipmap: boolean;
  25610. /**
  25611. * @hidden
  25612. */
  25613. lodLevelInAlpha: boolean;
  25614. /**
  25615. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25616. */
  25617. lodGenerationOffset: number;
  25618. /**
  25619. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25620. */
  25621. lodGenerationScale: number;
  25622. /**
  25623. * Define if the texture is a render target.
  25624. */
  25625. isRenderTarget: boolean;
  25626. /**
  25627. * Define the unique id of the texture in the scene.
  25628. */
  25629. readonly uid: string;
  25630. /**
  25631. * Return a string representation of the texture.
  25632. * @returns the texture as a string
  25633. */
  25634. toString(): string;
  25635. /**
  25636. * Get the class name of the texture.
  25637. * @returns "BaseTexture"
  25638. */
  25639. getClassName(): string;
  25640. /**
  25641. * Define the list of animation attached to the texture.
  25642. */
  25643. animations: Animation[];
  25644. /**
  25645. * An event triggered when the texture is disposed.
  25646. */
  25647. onDisposeObservable: Observable<BaseTexture>;
  25648. private _onDisposeObserver;
  25649. /**
  25650. * Callback triggered when the texture has been disposed.
  25651. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25652. */
  25653. onDispose: () => void;
  25654. /**
  25655. * Define the current state of the loading sequence when in delayed load mode.
  25656. */
  25657. delayLoadState: number;
  25658. private _scene;
  25659. /** @hidden */ texture: Nullable<InternalTexture>;
  25660. private _uid;
  25661. /**
  25662. * Define if the texture is preventinga material to render or not.
  25663. * If not and the texture is not ready, the engine will use a default black texture instead.
  25664. */
  25665. readonly isBlocking: boolean;
  25666. /**
  25667. * Instantiates a new BaseTexture.
  25668. * Base class of all the textures in babylon.
  25669. * It groups all the common properties the materials, post process, lights... might need
  25670. * in order to make a correct use of the texture.
  25671. * @param scene Define the scene the texture blongs to
  25672. */
  25673. constructor(scene: Nullable<Scene>);
  25674. /**
  25675. * Get the scene the texture belongs to.
  25676. * @returns the scene or null if undefined
  25677. */
  25678. getScene(): Nullable<Scene>;
  25679. /**
  25680. * Get the texture transform matrix used to offset tile the texture for istance.
  25681. * @returns the transformation matrix
  25682. */
  25683. getTextureMatrix(): Matrix;
  25684. /**
  25685. * Get the texture reflection matrix used to rotate/transform the reflection.
  25686. * @returns the reflection matrix
  25687. */
  25688. getReflectionTextureMatrix(): Matrix;
  25689. /**
  25690. * Get the underlying lower level texture from Babylon.
  25691. * @returns the insternal texture
  25692. */
  25693. getInternalTexture(): Nullable<InternalTexture>;
  25694. /**
  25695. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25696. * @returns true if ready or not blocking
  25697. */
  25698. isReadyOrNotBlocking(): boolean;
  25699. /**
  25700. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25701. * @returns true if fully ready
  25702. */
  25703. isReady(): boolean;
  25704. private _cachedSize;
  25705. /**
  25706. * Get the size of the texture.
  25707. * @returns the texture size.
  25708. */
  25709. getSize(): ISize;
  25710. /**
  25711. * Get the base size of the texture.
  25712. * It can be different from the size if the texture has been resized for POT for instance
  25713. * @returns the base size
  25714. */
  25715. getBaseSize(): ISize;
  25716. /**
  25717. * Update the sampling mode of the texture.
  25718. * Default is Trilinear mode.
  25719. *
  25720. * | Value | Type | Description |
  25721. * | ----- | ------------------ | ----------- |
  25722. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25723. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25724. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25725. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25726. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25727. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25728. * | 7 | NEAREST_LINEAR | |
  25729. * | 8 | NEAREST_NEAREST | |
  25730. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25731. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25732. * | 11 | LINEAR_LINEAR | |
  25733. * | 12 | LINEAR_NEAREST | |
  25734. *
  25735. * > _mag_: magnification filter (close to the viewer)
  25736. * > _min_: minification filter (far from the viewer)
  25737. * > _mip_: filter used between mip map levels
  25738. *@param samplingMode Define the new sampling mode of the texture
  25739. */
  25740. updateSamplingMode(samplingMode: number): void;
  25741. /**
  25742. * Scales the texture if is `canRescale()`
  25743. * @param ratio the resize factor we want to use to rescale
  25744. */
  25745. scale(ratio: number): void;
  25746. /**
  25747. * Get if the texture can rescale.
  25748. */
  25749. readonly canRescale: boolean;
  25750. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25751. /** @hidden */ rebuild(): void;
  25752. /**
  25753. * Triggers the load sequence in delayed load mode.
  25754. */
  25755. delayLoad(): void;
  25756. /**
  25757. * Clones the texture.
  25758. * @returns the cloned texture
  25759. */
  25760. clone(): Nullable<BaseTexture>;
  25761. /**
  25762. * Get the texture underlying type (INT, FLOAT...)
  25763. */
  25764. readonly textureType: number;
  25765. /**
  25766. * Get the texture underlying format (RGB, RGBA...)
  25767. */
  25768. readonly textureFormat: number;
  25769. /**
  25770. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25771. * This will returns an RGBA array buffer containing either in values (0-255) or
  25772. * float values (0-1) depending of the underlying buffer type.
  25773. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25774. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25775. * @param buffer defines a user defined buffer to fill with data (can be null)
  25776. * @returns The Array buffer containing the pixels data.
  25777. */
  25778. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25779. /**
  25780. * Release and destroy the underlying lower level texture aka internalTexture.
  25781. */
  25782. releaseInternalTexture(): void;
  25783. /**
  25784. * Get the polynomial representation of the texture data.
  25785. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25786. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25787. */
  25788. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25789. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25790. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25791. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25792. /**
  25793. * Dispose the texture and release its associated resources.
  25794. */
  25795. dispose(): void;
  25796. /**
  25797. * Serialize the texture into a JSON representation that can be parsed later on.
  25798. * @returns the JSON representation of the texture
  25799. */
  25800. serialize(): any;
  25801. /**
  25802. * Helper function to be called back once a list of texture contains only ready textures.
  25803. * @param textures Define the list of textures to wait for
  25804. * @param callback Define the callback triggered once the entire list will be ready
  25805. */
  25806. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25807. }
  25808. }
  25809. declare module BABYLON {
  25810. /**
  25811. * Uniform buffer objects.
  25812. *
  25813. * Handles blocks of uniform on the GPU.
  25814. *
  25815. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25816. *
  25817. * For more information, please refer to :
  25818. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25819. */
  25820. export class UniformBuffer {
  25821. private _engine;
  25822. private _buffer;
  25823. private _data;
  25824. private _bufferData;
  25825. private _dynamic?;
  25826. private _uniformLocations;
  25827. private _uniformSizes;
  25828. private _uniformLocationPointer;
  25829. private _needSync;
  25830. private _noUBO;
  25831. private _currentEffect;
  25832. private static _MAX_UNIFORM_SIZE;
  25833. private static _tempBuffer;
  25834. /**
  25835. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25836. * This is dynamic to allow compat with webgl 1 and 2.
  25837. * You will need to pass the name of the uniform as well as the value.
  25838. */
  25839. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25840. /**
  25841. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25842. * This is dynamic to allow compat with webgl 1 and 2.
  25843. * You will need to pass the name of the uniform as well as the value.
  25844. */
  25845. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25846. /**
  25847. * Lambda to Update a single float in a uniform buffer.
  25848. * This is dynamic to allow compat with webgl 1 and 2.
  25849. * You will need to pass the name of the uniform as well as the value.
  25850. */
  25851. updateFloat: (name: string, x: number) => void;
  25852. /**
  25853. * Lambda to Update a vec2 of float in a uniform buffer.
  25854. * This is dynamic to allow compat with webgl 1 and 2.
  25855. * You will need to pass the name of the uniform as well as the value.
  25856. */
  25857. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25858. /**
  25859. * Lambda to Update a vec3 of float in a uniform buffer.
  25860. * This is dynamic to allow compat with webgl 1 and 2.
  25861. * You will need to pass the name of the uniform as well as the value.
  25862. */
  25863. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25864. /**
  25865. * Lambda to Update a vec4 of float in a uniform buffer.
  25866. * This is dynamic to allow compat with webgl 1 and 2.
  25867. * You will need to pass the name of the uniform as well as the value.
  25868. */
  25869. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25870. /**
  25871. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25872. * This is dynamic to allow compat with webgl 1 and 2.
  25873. * You will need to pass the name of the uniform as well as the value.
  25874. */
  25875. updateMatrix: (name: string, mat: Matrix) => void;
  25876. /**
  25877. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25878. * This is dynamic to allow compat with webgl 1 and 2.
  25879. * You will need to pass the name of the uniform as well as the value.
  25880. */
  25881. updateVector3: (name: string, vector: Vector3) => void;
  25882. /**
  25883. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25884. * This is dynamic to allow compat with webgl 1 and 2.
  25885. * You will need to pass the name of the uniform as well as the value.
  25886. */
  25887. updateVector4: (name: string, vector: Vector4) => void;
  25888. /**
  25889. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25890. * This is dynamic to allow compat with webgl 1 and 2.
  25891. * You will need to pass the name of the uniform as well as the value.
  25892. */
  25893. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25894. /**
  25895. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25896. * This is dynamic to allow compat with webgl 1 and 2.
  25897. * You will need to pass the name of the uniform as well as the value.
  25898. */
  25899. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25900. /**
  25901. * Instantiates a new Uniform buffer objects.
  25902. *
  25903. * Handles blocks of uniform on the GPU.
  25904. *
  25905. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25906. *
  25907. * For more information, please refer to :
  25908. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25909. * @param engine Define the engine the buffer is associated with
  25910. * @param data Define the data contained in the buffer
  25911. * @param dynamic Define if the buffer is updatable
  25912. */
  25913. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25914. /**
  25915. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25916. * or just falling back on setUniformXXX calls.
  25917. */
  25918. readonly useUbo: boolean;
  25919. /**
  25920. * Indicates if the WebGL underlying uniform buffer is in sync
  25921. * with the javascript cache data.
  25922. */
  25923. readonly isSync: boolean;
  25924. /**
  25925. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25926. * Also, a dynamic UniformBuffer will disable cache verification and always
  25927. * update the underlying WebGL uniform buffer to the GPU.
  25928. * @returns if Dynamic, otherwise false
  25929. */
  25930. isDynamic(): boolean;
  25931. /**
  25932. * The data cache on JS side.
  25933. * @returns the underlying data as a float array
  25934. */
  25935. getData(): Float32Array;
  25936. /**
  25937. * The underlying WebGL Uniform buffer.
  25938. * @returns the webgl buffer
  25939. */
  25940. getBuffer(): Nullable<DataBuffer>;
  25941. /**
  25942. * std140 layout specifies how to align data within an UBO structure.
  25943. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25944. * for specs.
  25945. */
  25946. private _fillAlignment;
  25947. /**
  25948. * Adds an uniform in the buffer.
  25949. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25950. * for the layout to be correct !
  25951. * @param name Name of the uniform, as used in the uniform block in the shader.
  25952. * @param size Data size, or data directly.
  25953. */
  25954. addUniform(name: string, size: number | number[]): void;
  25955. /**
  25956. * Adds a Matrix 4x4 to the uniform buffer.
  25957. * @param name Name of the uniform, as used in the uniform block in the shader.
  25958. * @param mat A 4x4 matrix.
  25959. */
  25960. addMatrix(name: string, mat: Matrix): void;
  25961. /**
  25962. * Adds a vec2 to the uniform buffer.
  25963. * @param name Name of the uniform, as used in the uniform block in the shader.
  25964. * @param x Define the x component value of the vec2
  25965. * @param y Define the y component value of the vec2
  25966. */
  25967. addFloat2(name: string, x: number, y: number): void;
  25968. /**
  25969. * Adds a vec3 to the uniform buffer.
  25970. * @param name Name of the uniform, as used in the uniform block in the shader.
  25971. * @param x Define the x component value of the vec3
  25972. * @param y Define the y component value of the vec3
  25973. * @param z Define the z component value of the vec3
  25974. */
  25975. addFloat3(name: string, x: number, y: number, z: number): void;
  25976. /**
  25977. * Adds a vec3 to the uniform buffer.
  25978. * @param name Name of the uniform, as used in the uniform block in the shader.
  25979. * @param color Define the vec3 from a Color
  25980. */
  25981. addColor3(name: string, color: Color3): void;
  25982. /**
  25983. * Adds a vec4 to the uniform buffer.
  25984. * @param name Name of the uniform, as used in the uniform block in the shader.
  25985. * @param color Define the rgb components from a Color
  25986. * @param alpha Define the a component of the vec4
  25987. */
  25988. addColor4(name: string, color: Color3, alpha: number): void;
  25989. /**
  25990. * Adds a vec3 to the uniform buffer.
  25991. * @param name Name of the uniform, as used in the uniform block in the shader.
  25992. * @param vector Define the vec3 components from a Vector
  25993. */
  25994. addVector3(name: string, vector: Vector3): void;
  25995. /**
  25996. * Adds a Matrix 3x3 to the uniform buffer.
  25997. * @param name Name of the uniform, as used in the uniform block in the shader.
  25998. */
  25999. addMatrix3x3(name: string): void;
  26000. /**
  26001. * Adds a Matrix 2x2 to the uniform buffer.
  26002. * @param name Name of the uniform, as used in the uniform block in the shader.
  26003. */
  26004. addMatrix2x2(name: string): void;
  26005. /**
  26006. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26007. */
  26008. create(): void;
  26009. /** @hidden */ rebuild(): void;
  26010. /**
  26011. * Updates the WebGL Uniform Buffer on the GPU.
  26012. * If the `dynamic` flag is set to true, no cache comparison is done.
  26013. * Otherwise, the buffer will be updated only if the cache differs.
  26014. */
  26015. update(): void;
  26016. /**
  26017. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26018. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26019. * @param data Define the flattened data
  26020. * @param size Define the size of the data.
  26021. */
  26022. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26023. private _updateMatrix3x3ForUniform;
  26024. private _updateMatrix3x3ForEffect;
  26025. private _updateMatrix2x2ForEffect;
  26026. private _updateMatrix2x2ForUniform;
  26027. private _updateFloatForEffect;
  26028. private _updateFloatForUniform;
  26029. private _updateFloat2ForEffect;
  26030. private _updateFloat2ForUniform;
  26031. private _updateFloat3ForEffect;
  26032. private _updateFloat3ForUniform;
  26033. private _updateFloat4ForEffect;
  26034. private _updateFloat4ForUniform;
  26035. private _updateMatrixForEffect;
  26036. private _updateMatrixForUniform;
  26037. private _updateVector3ForEffect;
  26038. private _updateVector3ForUniform;
  26039. private _updateVector4ForEffect;
  26040. private _updateVector4ForUniform;
  26041. private _updateColor3ForEffect;
  26042. private _updateColor3ForUniform;
  26043. private _updateColor4ForEffect;
  26044. private _updateColor4ForUniform;
  26045. /**
  26046. * Sets a sampler uniform on the effect.
  26047. * @param name Define the name of the sampler.
  26048. * @param texture Define the texture to set in the sampler
  26049. */
  26050. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26051. /**
  26052. * Directly updates the value of the uniform in the cache AND on the GPU.
  26053. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26054. * @param data Define the flattened data
  26055. */
  26056. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26057. /**
  26058. * Binds this uniform buffer to an effect.
  26059. * @param effect Define the effect to bind the buffer to
  26060. * @param name Name of the uniform block in the shader.
  26061. */
  26062. bindToEffect(effect: Effect, name: string): void;
  26063. /**
  26064. * Disposes the uniform buffer.
  26065. */
  26066. dispose(): void;
  26067. }
  26068. }
  26069. declare module BABYLON {
  26070. /**
  26071. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26073. */
  26074. export class Analyser {
  26075. /**
  26076. * Gets or sets the smoothing
  26077. * @ignorenaming
  26078. */
  26079. SMOOTHING: number;
  26080. /**
  26081. * Gets or sets the FFT table size
  26082. * @ignorenaming
  26083. */
  26084. FFT_SIZE: number;
  26085. /**
  26086. * Gets or sets the bar graph amplitude
  26087. * @ignorenaming
  26088. */
  26089. BARGRAPHAMPLITUDE: number;
  26090. /**
  26091. * Gets or sets the position of the debug canvas
  26092. * @ignorenaming
  26093. */
  26094. DEBUGCANVASPOS: {
  26095. x: number;
  26096. y: number;
  26097. };
  26098. /**
  26099. * Gets or sets the debug canvas size
  26100. * @ignorenaming
  26101. */
  26102. DEBUGCANVASSIZE: {
  26103. width: number;
  26104. height: number;
  26105. };
  26106. private _byteFreqs;
  26107. private _byteTime;
  26108. private _floatFreqs;
  26109. private _webAudioAnalyser;
  26110. private _debugCanvas;
  26111. private _debugCanvasContext;
  26112. private _scene;
  26113. private _registerFunc;
  26114. private _audioEngine;
  26115. /**
  26116. * Creates a new analyser
  26117. * @param scene defines hosting scene
  26118. */
  26119. constructor(scene: Scene);
  26120. /**
  26121. * Get the number of data values you will have to play with for the visualization
  26122. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26123. * @returns a number
  26124. */
  26125. getFrequencyBinCount(): number;
  26126. /**
  26127. * Gets the current frequency data as a byte array
  26128. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26129. * @returns a Uint8Array
  26130. */
  26131. getByteFrequencyData(): Uint8Array;
  26132. /**
  26133. * Gets the current waveform as a byte array
  26134. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26135. * @returns a Uint8Array
  26136. */
  26137. getByteTimeDomainData(): Uint8Array;
  26138. /**
  26139. * Gets the current frequency data as a float array
  26140. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26141. * @returns a Float32Array
  26142. */
  26143. getFloatFrequencyData(): Float32Array;
  26144. /**
  26145. * Renders the debug canvas
  26146. */
  26147. drawDebugCanvas(): void;
  26148. /**
  26149. * Stops rendering the debug canvas and removes it
  26150. */
  26151. stopDebugCanvas(): void;
  26152. /**
  26153. * Connects two audio nodes
  26154. * @param inputAudioNode defines first node to connect
  26155. * @param outputAudioNode defines second node to connect
  26156. */
  26157. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26158. /**
  26159. * Releases all associated resources
  26160. */
  26161. dispose(): void;
  26162. }
  26163. }
  26164. declare module BABYLON {
  26165. /**
  26166. * This represents an audio engine and it is responsible
  26167. * to play, synchronize and analyse sounds throughout the application.
  26168. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26169. */
  26170. export interface IAudioEngine extends IDisposable {
  26171. /**
  26172. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26173. */
  26174. readonly canUseWebAudio: boolean;
  26175. /**
  26176. * Gets the current AudioContext if available.
  26177. */
  26178. readonly audioContext: Nullable<AudioContext>;
  26179. /**
  26180. * The master gain node defines the global audio volume of your audio engine.
  26181. */
  26182. readonly masterGain: GainNode;
  26183. /**
  26184. * Gets whether or not mp3 are supported by your browser.
  26185. */
  26186. readonly isMP3supported: boolean;
  26187. /**
  26188. * Gets whether or not ogg are supported by your browser.
  26189. */
  26190. readonly isOGGsupported: boolean;
  26191. /**
  26192. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26193. * @ignoreNaming
  26194. */
  26195. WarnedWebAudioUnsupported: boolean;
  26196. /**
  26197. * Defines if the audio engine relies on a custom unlocked button.
  26198. * In this case, the embedded button will not be displayed.
  26199. */
  26200. useCustomUnlockedButton: boolean;
  26201. /**
  26202. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26203. */
  26204. readonly unlocked: boolean;
  26205. /**
  26206. * Event raised when audio has been unlocked on the browser.
  26207. */
  26208. onAudioUnlockedObservable: Observable<AudioEngine>;
  26209. /**
  26210. * Event raised when audio has been locked on the browser.
  26211. */
  26212. onAudioLockedObservable: Observable<AudioEngine>;
  26213. /**
  26214. * Flags the audio engine in Locked state.
  26215. * This happens due to new browser policies preventing audio to autoplay.
  26216. */
  26217. lock(): void;
  26218. /**
  26219. * Unlocks the audio engine once a user action has been done on the dom.
  26220. * This is helpful to resume play once browser policies have been satisfied.
  26221. */
  26222. unlock(): void;
  26223. }
  26224. /**
  26225. * This represents the default audio engine used in babylon.
  26226. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26227. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26228. */
  26229. export class AudioEngine implements IAudioEngine {
  26230. private _audioContext;
  26231. private _audioContextInitialized;
  26232. private _muteButton;
  26233. private _hostElement;
  26234. /**
  26235. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26236. */
  26237. canUseWebAudio: boolean;
  26238. /**
  26239. * The master gain node defines the global audio volume of your audio engine.
  26240. */
  26241. masterGain: GainNode;
  26242. /**
  26243. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26244. * @ignoreNaming
  26245. */
  26246. WarnedWebAudioUnsupported: boolean;
  26247. /**
  26248. * Gets whether or not mp3 are supported by your browser.
  26249. */
  26250. isMP3supported: boolean;
  26251. /**
  26252. * Gets whether or not ogg are supported by your browser.
  26253. */
  26254. isOGGsupported: boolean;
  26255. /**
  26256. * Gets whether audio has been unlocked on the device.
  26257. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26258. * a user interaction has happened.
  26259. */
  26260. unlocked: boolean;
  26261. /**
  26262. * Defines if the audio engine relies on a custom unlocked button.
  26263. * In this case, the embedded button will not be displayed.
  26264. */
  26265. useCustomUnlockedButton: boolean;
  26266. /**
  26267. * Event raised when audio has been unlocked on the browser.
  26268. */
  26269. onAudioUnlockedObservable: Observable<AudioEngine>;
  26270. /**
  26271. * Event raised when audio has been locked on the browser.
  26272. */
  26273. onAudioLockedObservable: Observable<AudioEngine>;
  26274. /**
  26275. * Gets the current AudioContext if available.
  26276. */
  26277. readonly audioContext: Nullable<AudioContext>;
  26278. private _connectedAnalyser;
  26279. /**
  26280. * Instantiates a new audio engine.
  26281. *
  26282. * There should be only one per page as some browsers restrict the number
  26283. * of audio contexts you can create.
  26284. * @param hostElement defines the host element where to display the mute icon if necessary
  26285. */
  26286. constructor(hostElement?: Nullable<HTMLElement>);
  26287. /**
  26288. * Flags the audio engine in Locked state.
  26289. * This happens due to new browser policies preventing audio to autoplay.
  26290. */
  26291. lock(): void;
  26292. /**
  26293. * Unlocks the audio engine once a user action has been done on the dom.
  26294. * This is helpful to resume play once browser policies have been satisfied.
  26295. */
  26296. unlock(): void;
  26297. private _resumeAudioContext;
  26298. private _initializeAudioContext;
  26299. private _tryToRun;
  26300. private _triggerRunningState;
  26301. private _triggerSuspendedState;
  26302. private _displayMuteButton;
  26303. private _moveButtonToTopLeft;
  26304. private _onResize;
  26305. private _hideMuteButton;
  26306. /**
  26307. * Destroy and release the resources associated with the audio ccontext.
  26308. */
  26309. dispose(): void;
  26310. /**
  26311. * Gets the global volume sets on the master gain.
  26312. * @returns the global volume if set or -1 otherwise
  26313. */
  26314. getGlobalVolume(): number;
  26315. /**
  26316. * Sets the global volume of your experience (sets on the master gain).
  26317. * @param newVolume Defines the new global volume of the application
  26318. */
  26319. setGlobalVolume(newVolume: number): void;
  26320. /**
  26321. * Connect the audio engine to an audio analyser allowing some amazing
  26322. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26324. * @param analyser The analyser to connect to the engine
  26325. */
  26326. connectToAnalyser(analyser: Analyser): void;
  26327. }
  26328. }
  26329. declare module BABYLON {
  26330. /**
  26331. * Interface used to present a loading screen while loading a scene
  26332. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26333. */
  26334. export interface ILoadingScreen {
  26335. /**
  26336. * Function called to display the loading screen
  26337. */
  26338. displayLoadingUI: () => void;
  26339. /**
  26340. * Function called to hide the loading screen
  26341. */
  26342. hideLoadingUI: () => void;
  26343. /**
  26344. * Gets or sets the color to use for the background
  26345. */
  26346. loadingUIBackgroundColor: string;
  26347. /**
  26348. * Gets or sets the text to display while loading
  26349. */
  26350. loadingUIText: string;
  26351. }
  26352. /**
  26353. * Class used for the default loading screen
  26354. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26355. */
  26356. export class DefaultLoadingScreen implements ILoadingScreen {
  26357. private _renderingCanvas;
  26358. private _loadingText;
  26359. private _loadingDivBackgroundColor;
  26360. private _loadingDiv;
  26361. private _loadingTextDiv;
  26362. /**
  26363. * Creates a new default loading screen
  26364. * @param _renderingCanvas defines the canvas used to render the scene
  26365. * @param _loadingText defines the default text to display
  26366. * @param _loadingDivBackgroundColor defines the default background color
  26367. */
  26368. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26369. /**
  26370. * Function called to display the loading screen
  26371. */
  26372. displayLoadingUI(): void;
  26373. /**
  26374. * Function called to hide the loading screen
  26375. */
  26376. hideLoadingUI(): void;
  26377. /**
  26378. * Gets or sets the text to display while loading
  26379. */
  26380. loadingUIText: string;
  26381. /**
  26382. * Gets or sets the color to use for the background
  26383. */
  26384. loadingUIBackgroundColor: string;
  26385. private _resizeLoadingUI;
  26386. }
  26387. }
  26388. declare module BABYLON {
  26389. /** @hidden */
  26390. export class WebGLPipelineContext implements IPipelineContext {
  26391. engine: Engine;
  26392. program: Nullable<WebGLProgram>;
  26393. context?: WebGLRenderingContext;
  26394. vertexShader?: WebGLShader;
  26395. fragmentShader?: WebGLShader;
  26396. isParallelCompiled: boolean;
  26397. onCompiled?: () => void;
  26398. transformFeedback?: WebGLTransformFeedback | null;
  26399. readonly isAsync: boolean;
  26400. readonly isReady: boolean; handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26401. }
  26402. }
  26403. declare module BABYLON {
  26404. /** @hidden */
  26405. export class WebGLDataBuffer extends DataBuffer {
  26406. private _buffer;
  26407. constructor(resource: WebGLBuffer);
  26408. readonly underlyingResource: any;
  26409. }
  26410. }
  26411. declare module BABYLON {
  26412. /**
  26413. * Settings for finer control over video usage
  26414. */
  26415. export interface VideoTextureSettings {
  26416. /**
  26417. * Applies `autoplay` to video, if specified
  26418. */
  26419. autoPlay?: boolean;
  26420. /**
  26421. * Applies `loop` to video, if specified
  26422. */
  26423. loop?: boolean;
  26424. /**
  26425. * Automatically updates internal texture from video at every frame in the render loop
  26426. */
  26427. autoUpdateTexture: boolean;
  26428. /**
  26429. * Image src displayed during the video loading or until the user interacts with the video.
  26430. */
  26431. poster?: string;
  26432. }
  26433. /**
  26434. * If you want to display a video in your scene, this is the special texture for that.
  26435. * This special texture works similar to other textures, with the exception of a few parameters.
  26436. * @see https://doc.babylonjs.com/how_to/video_texture
  26437. */
  26438. export class VideoTexture extends Texture {
  26439. /**
  26440. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26441. */
  26442. readonly autoUpdateTexture: boolean;
  26443. /**
  26444. * The video instance used by the texture internally
  26445. */
  26446. readonly video: HTMLVideoElement;
  26447. private _onUserActionRequestedObservable;
  26448. /**
  26449. * Event triggerd when a dom action is required by the user to play the video.
  26450. * This happens due to recent changes in browser policies preventing video to auto start.
  26451. */
  26452. readonly onUserActionRequestedObservable: Observable<Texture>;
  26453. private _generateMipMaps;
  26454. private _engine;
  26455. private _stillImageCaptured;
  26456. private _displayingPosterTexture;
  26457. private _settings;
  26458. private _createInternalTextureOnEvent;
  26459. /**
  26460. * Creates a video texture.
  26461. * If you want to display a video in your scene, this is the special texture for that.
  26462. * This special texture works similar to other textures, with the exception of a few parameters.
  26463. * @see https://doc.babylonjs.com/how_to/video_texture
  26464. * @param name optional name, will detect from video source, if not defined
  26465. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26466. * @param scene is obviously the current scene.
  26467. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26468. * @param invertY is false by default but can be used to invert video on Y axis
  26469. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26470. * @param settings allows finer control over video usage
  26471. */
  26472. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26473. private _getName;
  26474. private _getVideo;
  26475. private _createInternalTexture;
  26476. private reset;
  26477. /**
  26478. * @hidden Internal method to initiate `update`.
  26479. */ rebuild(): void;
  26480. /**
  26481. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26482. */
  26483. update(): void;
  26484. /**
  26485. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26486. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26487. */
  26488. updateTexture(isVisible: boolean): void;
  26489. protected _updateInternalTexture: () => void;
  26490. /**
  26491. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26492. * @param url New url.
  26493. */
  26494. updateURL(url: string): void;
  26495. /**
  26496. * Dispose the texture and release its associated resources.
  26497. */
  26498. dispose(): void;
  26499. /**
  26500. * Creates a video texture straight from a stream.
  26501. * @param scene Define the scene the texture should be created in
  26502. * @param stream Define the stream the texture should be created from
  26503. * @returns The created video texture as a promise
  26504. */
  26505. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26506. /**
  26507. * Creates a video texture straight from your WebCam video feed.
  26508. * @param scene Define the scene the texture should be created in
  26509. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26510. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26511. * @returns The created video texture as a promise
  26512. */
  26513. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26514. minWidth: number;
  26515. maxWidth: number;
  26516. minHeight: number;
  26517. maxHeight: number;
  26518. deviceId: string;
  26519. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26520. /**
  26521. * Creates a video texture straight from your WebCam video feed.
  26522. * @param scene Define the scene the texture should be created in
  26523. * @param onReady Define a callback to triggered once the texture will be ready
  26524. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26525. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26526. */
  26527. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26528. minWidth: number;
  26529. maxWidth: number;
  26530. minHeight: number;
  26531. maxHeight: number;
  26532. deviceId: string;
  26533. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26534. }
  26535. }
  26536. declare module BABYLON {
  26537. /**
  26538. * Interface for attribute information associated with buffer instanciation
  26539. */
  26540. export class InstancingAttributeInfo {
  26541. /**
  26542. * Index/offset of the attribute in the vertex shader
  26543. */
  26544. index: number;
  26545. /**
  26546. * size of the attribute, 1, 2, 3 or 4
  26547. */
  26548. attributeSize: number;
  26549. /**
  26550. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26551. * default is FLOAT
  26552. */
  26553. attribyteType: number;
  26554. /**
  26555. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26556. */
  26557. normalized: boolean;
  26558. /**
  26559. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26560. */
  26561. offset: number;
  26562. /**
  26563. * Name of the GLSL attribute, for debugging purpose only
  26564. */
  26565. attributeName: string;
  26566. }
  26567. /**
  26568. * Define options used to create a depth texture
  26569. */
  26570. export class DepthTextureCreationOptions {
  26571. /** Specifies whether or not a stencil should be allocated in the texture */
  26572. generateStencil?: boolean;
  26573. /** Specifies whether or not bilinear filtering is enable on the texture */
  26574. bilinearFiltering?: boolean;
  26575. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26576. comparisonFunction?: number;
  26577. /** Specifies if the created texture is a cube texture */
  26578. isCube?: boolean;
  26579. }
  26580. /**
  26581. * Class used to describe the capabilities of the engine relatively to the current browser
  26582. */
  26583. export class EngineCapabilities {
  26584. /** Maximum textures units per fragment shader */
  26585. maxTexturesImageUnits: number;
  26586. /** Maximum texture units per vertex shader */
  26587. maxVertexTextureImageUnits: number;
  26588. /** Maximum textures units in the entire pipeline */
  26589. maxCombinedTexturesImageUnits: number;
  26590. /** Maximum texture size */
  26591. maxTextureSize: number;
  26592. /** Maximum cube texture size */
  26593. maxCubemapTextureSize: number;
  26594. /** Maximum render texture size */
  26595. maxRenderTextureSize: number;
  26596. /** Maximum number of vertex attributes */
  26597. maxVertexAttribs: number;
  26598. /** Maximum number of varyings */
  26599. maxVaryingVectors: number;
  26600. /** Maximum number of uniforms per vertex shader */
  26601. maxVertexUniformVectors: number;
  26602. /** Maximum number of uniforms per fragment shader */
  26603. maxFragmentUniformVectors: number;
  26604. /** Defines if standard derivates (dx/dy) are supported */
  26605. standardDerivatives: boolean;
  26606. /** Defines if s3tc texture compression is supported */
  26607. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26608. /** Defines if pvrtc texture compression is supported */
  26609. pvrtc: any;
  26610. /** Defines if etc1 texture compression is supported */
  26611. etc1: any;
  26612. /** Defines if etc2 texture compression is supported */
  26613. etc2: any;
  26614. /** Defines if astc texture compression is supported */
  26615. astc: any;
  26616. /** Defines if float textures are supported */
  26617. textureFloat: boolean;
  26618. /** Defines if vertex array objects are supported */
  26619. vertexArrayObject: boolean;
  26620. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26621. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26622. /** Gets the maximum level of anisotropy supported */
  26623. maxAnisotropy: number;
  26624. /** Defines if instancing is supported */
  26625. instancedArrays: boolean;
  26626. /** Defines if 32 bits indices are supported */
  26627. uintIndices: boolean;
  26628. /** Defines if high precision shaders are supported */
  26629. highPrecisionShaderSupported: boolean;
  26630. /** Defines if depth reading in the fragment shader is supported */
  26631. fragmentDepthSupported: boolean;
  26632. /** Defines if float texture linear filtering is supported*/
  26633. textureFloatLinearFiltering: boolean;
  26634. /** Defines if rendering to float textures is supported */
  26635. textureFloatRender: boolean;
  26636. /** Defines if half float textures are supported*/
  26637. textureHalfFloat: boolean;
  26638. /** Defines if half float texture linear filtering is supported*/
  26639. textureHalfFloatLinearFiltering: boolean;
  26640. /** Defines if rendering to half float textures is supported */
  26641. textureHalfFloatRender: boolean;
  26642. /** Defines if textureLOD shader command is supported */
  26643. textureLOD: boolean;
  26644. /** Defines if draw buffers extension is supported */
  26645. drawBuffersExtension: boolean;
  26646. /** Defines if depth textures are supported */
  26647. depthTextureExtension: boolean;
  26648. /** Defines if float color buffer are supported */
  26649. colorBufferFloat: boolean;
  26650. /** Gets disjoint timer query extension (null if not supported) */
  26651. timerQuery: EXT_disjoint_timer_query;
  26652. /** Defines if timestamp can be used with timer query */
  26653. canUseTimestampForTimerQuery: boolean;
  26654. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26655. multiview: any;
  26656. /** Function used to let the system compiles shaders in background */
  26657. parallelShaderCompile: {
  26658. COMPLETION_STATUS_KHR: number;
  26659. };
  26660. }
  26661. /** Interface defining initialization parameters for Engine class */
  26662. export interface EngineOptions extends WebGLContextAttributes {
  26663. /**
  26664. * Defines if the engine should no exceed a specified device ratio
  26665. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26666. */
  26667. limitDeviceRatio?: number;
  26668. /**
  26669. * Defines if webvr should be enabled automatically
  26670. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26671. */
  26672. autoEnableWebVR?: boolean;
  26673. /**
  26674. * Defines if webgl2 should be turned off even if supported
  26675. * @see http://doc.babylonjs.com/features/webgl2
  26676. */
  26677. disableWebGL2Support?: boolean;
  26678. /**
  26679. * Defines if webaudio should be initialized as well
  26680. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26681. */
  26682. audioEngine?: boolean;
  26683. /**
  26684. * Defines if animations should run using a deterministic lock step
  26685. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26686. */
  26687. deterministicLockstep?: boolean;
  26688. /** Defines the maximum steps to use with deterministic lock step mode */
  26689. lockstepMaxSteps?: number;
  26690. /**
  26691. * Defines that engine should ignore context lost events
  26692. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26693. */
  26694. doNotHandleContextLost?: boolean;
  26695. /**
  26696. * Defines that engine should ignore modifying touch action attribute and style
  26697. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26698. */
  26699. doNotHandleTouchAction?: boolean;
  26700. /**
  26701. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26702. */
  26703. useHighPrecisionFloats?: boolean;
  26704. }
  26705. /**
  26706. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26707. */
  26708. export class Engine {
  26709. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26710. static ExceptionList: ({
  26711. key: string;
  26712. capture: string;
  26713. captureConstraint: number;
  26714. targets: string[];
  26715. } | {
  26716. key: string;
  26717. capture: null;
  26718. captureConstraint: null;
  26719. targets: string[];
  26720. })[];
  26721. /** Gets the list of created engines */
  26722. static readonly Instances: Engine[];
  26723. /**
  26724. * Gets the latest created engine
  26725. */
  26726. static readonly LastCreatedEngine: Nullable<Engine>;
  26727. /**
  26728. * Gets the latest created scene
  26729. */
  26730. static readonly LastCreatedScene: Nullable<Scene>;
  26731. /**
  26732. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26733. * @param flag defines which part of the materials must be marked as dirty
  26734. * @param predicate defines a predicate used to filter which materials should be affected
  26735. */
  26736. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26737. /**
  26738. * Hidden
  26739. */ private static _TextureLoaders: IInternalTextureLoader[];
  26740. /** Defines that alpha blending is disabled */
  26741. static readonly ALPHA_DISABLE: number;
  26742. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26743. static readonly ALPHA_ADD: number;
  26744. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26745. static readonly ALPHA_COMBINE: number;
  26746. /** Defines that alpha blending to DEST - SRC * DEST */
  26747. static readonly ALPHA_SUBTRACT: number;
  26748. /** Defines that alpha blending to SRC * DEST */
  26749. static readonly ALPHA_MULTIPLY: number;
  26750. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26751. static readonly ALPHA_MAXIMIZED: number;
  26752. /** Defines that alpha blending to SRC + DEST */
  26753. static readonly ALPHA_ONEONE: number;
  26754. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26755. static readonly ALPHA_PREMULTIPLIED: number;
  26756. /**
  26757. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26758. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26759. */
  26760. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26761. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26762. static readonly ALPHA_INTERPOLATE: number;
  26763. /**
  26764. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26765. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26766. */
  26767. static readonly ALPHA_SCREENMODE: number;
  26768. /** Defines that the ressource is not delayed*/
  26769. static readonly DELAYLOADSTATE_NONE: number;
  26770. /** Defines that the ressource was successfully delay loaded */
  26771. static readonly DELAYLOADSTATE_LOADED: number;
  26772. /** Defines that the ressource is currently delay loading */
  26773. static readonly DELAYLOADSTATE_LOADING: number;
  26774. /** Defines that the ressource is delayed and has not started loading */
  26775. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26776. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26777. static readonly NEVER: number;
  26778. /** 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 */
  26779. static readonly ALWAYS: number;
  26780. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26781. static readonly LESS: number;
  26782. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26783. static readonly EQUAL: number;
  26784. /** 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 */
  26785. static readonly LEQUAL: number;
  26786. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26787. static readonly GREATER: number;
  26788. /** 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 */
  26789. static readonly GEQUAL: number;
  26790. /** 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 */
  26791. static readonly NOTEQUAL: number;
  26792. /** Passed to stencilOperation to specify that stencil value must be kept */
  26793. static readonly KEEP: number;
  26794. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26795. static readonly REPLACE: number;
  26796. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26797. static readonly INCR: number;
  26798. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26799. static readonly DECR: number;
  26800. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26801. static readonly INVERT: number;
  26802. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26803. static readonly INCR_WRAP: number;
  26804. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26805. static readonly DECR_WRAP: number;
  26806. /** Texture is not repeating outside of 0..1 UVs */
  26807. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26808. /** Texture is repeating outside of 0..1 UVs */
  26809. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26810. /** Texture is repeating and mirrored */
  26811. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26812. /** ALPHA */
  26813. static readonly TEXTUREFORMAT_ALPHA: number;
  26814. /** LUMINANCE */
  26815. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26816. /** LUMINANCE_ALPHA */
  26817. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26818. /** RGB */
  26819. static readonly TEXTUREFORMAT_RGB: number;
  26820. /** RGBA */
  26821. static readonly TEXTUREFORMAT_RGBA: number;
  26822. /** RED */
  26823. static readonly TEXTUREFORMAT_RED: number;
  26824. /** RED (2nd reference) */
  26825. static readonly TEXTUREFORMAT_R: number;
  26826. /** RG */
  26827. static readonly TEXTUREFORMAT_RG: number;
  26828. /** RED_INTEGER */
  26829. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26830. /** RED_INTEGER (2nd reference) */
  26831. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26832. /** RG_INTEGER */
  26833. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26834. /** RGB_INTEGER */
  26835. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26836. /** RGBA_INTEGER */
  26837. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26838. /** UNSIGNED_BYTE */
  26839. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26840. /** UNSIGNED_BYTE (2nd reference) */
  26841. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26842. /** FLOAT */
  26843. static readonly TEXTURETYPE_FLOAT: number;
  26844. /** HALF_FLOAT */
  26845. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26846. /** BYTE */
  26847. static readonly TEXTURETYPE_BYTE: number;
  26848. /** SHORT */
  26849. static readonly TEXTURETYPE_SHORT: number;
  26850. /** UNSIGNED_SHORT */
  26851. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26852. /** INT */
  26853. static readonly TEXTURETYPE_INT: number;
  26854. /** UNSIGNED_INT */
  26855. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26856. /** UNSIGNED_SHORT_4_4_4_4 */
  26857. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26858. /** UNSIGNED_SHORT_5_5_5_1 */
  26859. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26860. /** UNSIGNED_SHORT_5_6_5 */
  26861. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26862. /** UNSIGNED_INT_2_10_10_10_REV */
  26863. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26864. /** UNSIGNED_INT_24_8 */
  26865. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26866. /** UNSIGNED_INT_10F_11F_11F_REV */
  26867. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26868. /** UNSIGNED_INT_5_9_9_9_REV */
  26869. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26870. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26871. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26872. /** nearest is mag = nearest and min = nearest and mip = linear */
  26873. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26874. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26875. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26876. /** Trilinear is mag = linear and min = linear and mip = linear */
  26877. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26878. /** nearest is mag = nearest and min = nearest and mip = linear */
  26879. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26880. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26881. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26882. /** Trilinear is mag = linear and min = linear and mip = linear */
  26883. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26884. /** mag = nearest and min = nearest and mip = nearest */
  26885. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26886. /** mag = nearest and min = linear and mip = nearest */
  26887. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26888. /** mag = nearest and min = linear and mip = linear */
  26889. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26890. /** mag = nearest and min = linear and mip = none */
  26891. static readonly TEXTURE_NEAREST_LINEAR: number;
  26892. /** mag = nearest and min = nearest and mip = none */
  26893. static readonly TEXTURE_NEAREST_NEAREST: number;
  26894. /** mag = linear and min = nearest and mip = nearest */
  26895. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26896. /** mag = linear and min = nearest and mip = linear */
  26897. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26898. /** mag = linear and min = linear and mip = none */
  26899. static readonly TEXTURE_LINEAR_LINEAR: number;
  26900. /** mag = linear and min = nearest and mip = none */
  26901. static readonly TEXTURE_LINEAR_NEAREST: number;
  26902. /** Explicit coordinates mode */
  26903. static readonly TEXTURE_EXPLICIT_MODE: number;
  26904. /** Spherical coordinates mode */
  26905. static readonly TEXTURE_SPHERICAL_MODE: number;
  26906. /** Planar coordinates mode */
  26907. static readonly TEXTURE_PLANAR_MODE: number;
  26908. /** Cubic coordinates mode */
  26909. static readonly TEXTURE_CUBIC_MODE: number;
  26910. /** Projection coordinates mode */
  26911. static readonly TEXTURE_PROJECTION_MODE: number;
  26912. /** Skybox coordinates mode */
  26913. static readonly TEXTURE_SKYBOX_MODE: number;
  26914. /** Inverse Cubic coordinates mode */
  26915. static readonly TEXTURE_INVCUBIC_MODE: number;
  26916. /** Equirectangular coordinates mode */
  26917. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26918. /** Equirectangular Fixed coordinates mode */
  26919. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26920. /** Equirectangular Fixed Mirrored coordinates mode */
  26921. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26922. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26923. static readonly SCALEMODE_FLOOR: number;
  26924. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26925. static readonly SCALEMODE_NEAREST: number;
  26926. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26927. static readonly SCALEMODE_CEILING: number;
  26928. /**
  26929. * Returns the current npm package of the sdk
  26930. */
  26931. static readonly NpmPackage: string;
  26932. /**
  26933. * Returns the current version of the framework
  26934. */
  26935. static readonly Version: string;
  26936. /**
  26937. * Returns a string describing the current engine
  26938. */
  26939. readonly description: string;
  26940. /**
  26941. * Gets or sets the epsilon value used by collision engine
  26942. */
  26943. static CollisionsEpsilon: number;
  26944. /**
  26945. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26946. */
  26947. static ShadersRepository: string;
  26948. /**
  26949. * Method called to create the default loading screen.
  26950. * This can be overriden in your own app.
  26951. * @param canvas The rendering canvas element
  26952. * @returns The loading screen
  26953. */
  26954. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26955. /**
  26956. * Method called to create the default rescale post process on each engine.
  26957. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26958. /**
  26959. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26960. */
  26961. forcePOTTextures: boolean;
  26962. /**
  26963. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26964. */
  26965. isFullscreen: boolean;
  26966. /**
  26967. * Gets a boolean indicating if the pointer is currently locked
  26968. */
  26969. isPointerLock: boolean;
  26970. /**
  26971. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26972. */
  26973. cullBackFaces: boolean;
  26974. /**
  26975. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26976. */
  26977. renderEvenInBackground: boolean;
  26978. /**
  26979. * Gets or sets a boolean indicating that cache can be kept between frames
  26980. */
  26981. preventCacheWipeBetweenFrames: boolean;
  26982. /**
  26983. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26984. **/
  26985. enableOfflineSupport: boolean;
  26986. /**
  26987. * 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)
  26988. **/
  26989. disableManifestCheck: boolean;
  26990. /**
  26991. * Gets the list of created scenes
  26992. */
  26993. scenes: Scene[];
  26994. /**
  26995. * Event raised when a new scene is created
  26996. */
  26997. onNewSceneAddedObservable: Observable<Scene>;
  26998. /**
  26999. * Gets the list of created postprocesses
  27000. */
  27001. postProcesses: PostProcess[];
  27002. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27003. validateShaderPrograms: boolean;
  27004. /**
  27005. * Observable event triggered each time the rendering canvas is resized
  27006. */
  27007. onResizeObservable: Observable<Engine>;
  27008. /**
  27009. * Observable event triggered each time the canvas loses focus
  27010. */
  27011. onCanvasBlurObservable: Observable<Engine>;
  27012. /**
  27013. * Observable event triggered each time the canvas gains focus
  27014. */
  27015. onCanvasFocusObservable: Observable<Engine>;
  27016. /**
  27017. * Observable event triggered each time the canvas receives pointerout event
  27018. */
  27019. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27020. /**
  27021. * Observable event triggered before each texture is initialized
  27022. */
  27023. onBeforeTextureInitObservable: Observable<Texture>;
  27024. /**
  27025. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27026. */
  27027. disableUniformBuffers: boolean;
  27028. /** @hidden */ uniformBuffers: UniformBuffer[];
  27029. /**
  27030. * Gets a boolean indicating that the engine supports uniform buffers
  27031. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27032. */
  27033. readonly supportsUniformBuffers: boolean;
  27034. /**
  27035. * Observable raised when the engine begins a new frame
  27036. */
  27037. onBeginFrameObservable: Observable<Engine>;
  27038. /**
  27039. * If set, will be used to request the next animation frame for the render loop
  27040. */
  27041. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27042. /**
  27043. * Observable raised when the engine ends the current frame
  27044. */
  27045. onEndFrameObservable: Observable<Engine>;
  27046. /**
  27047. * Observable raised when the engine is about to compile a shader
  27048. */
  27049. onBeforeShaderCompilationObservable: Observable<Engine>;
  27050. /**
  27051. * Observable raised when the engine has jsut compiled a shader
  27052. */
  27053. onAfterShaderCompilationObservable: Observable<Engine>;
  27054. /** @hidden */ gl: WebGLRenderingContext;
  27055. private _renderingCanvas;
  27056. private _windowIsBackground;
  27057. private _webGLVersion;
  27058. protected _highPrecisionShadersAllowed: boolean;
  27059. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27060. /**
  27061. * Gets a boolean indicating that only power of 2 textures are supported
  27062. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27063. */
  27064. readonly needPOTTextures: boolean;
  27065. /** @hidden */ badOS: boolean;
  27066. /** @hidden */ badDesktopOS: boolean;
  27067. /**
  27068. * Gets the audio engine
  27069. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27070. * @ignorenaming
  27071. */
  27072. static audioEngine: IAudioEngine;
  27073. /**
  27074. * Default AudioEngine factory responsible of creating the Audio Engine.
  27075. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27076. */
  27077. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27078. /**
  27079. * Default offline support factory responsible of creating a tool used to store data locally.
  27080. * By default, this will create a Database object if the workload has been embedded.
  27081. */
  27082. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27083. private _onFocus;
  27084. private _onBlur;
  27085. private _onCanvasPointerOut;
  27086. private _onCanvasBlur;
  27087. private _onCanvasFocus;
  27088. private _onFullscreenChange;
  27089. private _onPointerLockChange;
  27090. private _hardwareScalingLevel;
  27091. /** @hidden */ caps: EngineCapabilities;
  27092. private _pointerLockRequested;
  27093. private _isStencilEnable;
  27094. private _colorWrite;
  27095. private _loadingScreen;
  27096. /** @hidden */ drawCalls: PerfCounter;
  27097. private _glVersion;
  27098. private _glRenderer;
  27099. private _glVendor;
  27100. private _videoTextureSupported;
  27101. private _renderingQueueLaunched;
  27102. private _activeRenderLoops;
  27103. private _deterministicLockstep;
  27104. private _lockstepMaxSteps;
  27105. /**
  27106. * Observable signaled when a context lost event is raised
  27107. */
  27108. onContextLostObservable: Observable<Engine>;
  27109. /**
  27110. * Observable signaled when a context restored event is raised
  27111. */
  27112. onContextRestoredObservable: Observable<Engine>;
  27113. private _onContextLost;
  27114. private _onContextRestored;
  27115. private _contextWasLost;
  27116. /** @hidden */ doNotHandleContextLost: boolean;
  27117. /**
  27118. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27120. */
  27121. doNotHandleContextLost: boolean;
  27122. private _performanceMonitor;
  27123. private _fps;
  27124. private _deltaTime;
  27125. /**
  27126. * Turn this value on if you want to pause FPS computation when in background
  27127. */
  27128. disablePerformanceMonitorInBackground: boolean;
  27129. /**
  27130. * Gets the performance monitor attached to this engine
  27131. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27132. */
  27133. readonly performanceMonitor: PerformanceMonitor;
  27134. /**
  27135. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27136. */
  27137. disableVertexArrayObjects: boolean;
  27138. /** @hidden */
  27139. protected _depthCullingState: _DepthCullingState;
  27140. /** @hidden */
  27141. protected _stencilState: _StencilState;
  27142. /** @hidden */
  27143. protected _alphaState: _AlphaState;
  27144. /** @hidden */
  27145. protected _alphaMode: number;
  27146. /** @hidden */ internalTexturesCache: InternalTexture[];
  27147. /** @hidden */
  27148. protected _activeChannel: number;
  27149. private _currentTextureChannel;
  27150. /** @hidden */
  27151. protected _boundTexturesCache: {
  27152. [key: string]: Nullable<InternalTexture>;
  27153. };
  27154. /** @hidden */
  27155. protected _currentEffect: Nullable<Effect>;
  27156. /** @hidden */
  27157. protected _currentProgram: Nullable<WebGLProgram>;
  27158. private _compiledEffects;
  27159. private _vertexAttribArraysEnabled;
  27160. /** @hidden */
  27161. protected _cachedViewport: Nullable<Viewport>;
  27162. private _cachedVertexArrayObject;
  27163. /** @hidden */
  27164. protected _cachedVertexBuffers: any;
  27165. /** @hidden */
  27166. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27167. /** @hidden */
  27168. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27169. /** @hidden */ currentRenderTarget: Nullable<InternalTexture>;
  27170. private _uintIndicesCurrentlySet;
  27171. private _currentBoundBuffer;
  27172. /** @hidden */
  27173. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27174. private _currentBufferPointers;
  27175. private _currentInstanceLocations;
  27176. private _currentInstanceBuffers;
  27177. private _textureUnits;
  27178. /** @hidden */ workingCanvas: Nullable<HTMLCanvasElement>;
  27179. /** @hidden */ workingContext: Nullable<CanvasRenderingContext2D>;
  27180. private _rescalePostProcess;
  27181. private _dummyFramebuffer;
  27182. private _externalData;
  27183. /** @hidden */ bindedRenderFunction: any;
  27184. private _vaoRecordInProgress;
  27185. private _mustWipeVertexAttributes;
  27186. private _emptyTexture;
  27187. private _emptyCubeTexture;
  27188. private _emptyTexture3D;
  27189. /** @hidden */ frameHandler: number;
  27190. private _nextFreeTextureSlots;
  27191. private _maxSimultaneousTextures;
  27192. private _activeRequests;
  27193. private _texturesSupported;
  27194. /** @hidden */ textureFormatInUse: Nullable<string>;
  27195. /**
  27196. * Gets the list of texture formats supported
  27197. */
  27198. readonly texturesSupported: Array<string>;
  27199. /**
  27200. * Gets the list of texture formats in use
  27201. */
  27202. readonly textureFormatInUse: Nullable<string>;
  27203. /**
  27204. * Gets the current viewport
  27205. */
  27206. readonly currentViewport: Nullable<Viewport>;
  27207. /**
  27208. * Gets the default empty texture
  27209. */
  27210. readonly emptyTexture: InternalTexture;
  27211. /**
  27212. * Gets the default empty 3D texture
  27213. */
  27214. readonly emptyTexture3D: InternalTexture;
  27215. /**
  27216. * Gets the default empty cube texture
  27217. */
  27218. readonly emptyCubeTexture: InternalTexture;
  27219. /**
  27220. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27221. */
  27222. readonly premultipliedAlpha: boolean;
  27223. /**
  27224. * Creates a new engine
  27225. * @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
  27226. * @param antialias defines enable antialiasing (default: false)
  27227. * @param options defines further options to be sent to the getContext() function
  27228. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27229. */
  27230. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27231. /**
  27232. * Initializes a webVR display and starts listening to display change events
  27233. * The onVRDisplayChangedObservable will be notified upon these changes
  27234. * @returns The onVRDisplayChangedObservable
  27235. */
  27236. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27237. /** @hidden */ prepareVRComponent(): void;
  27238. /** @hidden */ connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27239. /** @hidden */ submitVRFrame(): void;
  27240. /**
  27241. * Call this function to leave webVR mode
  27242. * Will do nothing if webVR is not supported or if there is no webVR device
  27243. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27244. */
  27245. disableVR(): void;
  27246. /**
  27247. * Gets a boolean indicating that the system is in VR mode and is presenting
  27248. * @returns true if VR mode is engaged
  27249. */
  27250. isVRPresenting(): boolean;
  27251. /** @hidden */ requestVRFrame(): void;
  27252. private _disableTouchAction;
  27253. private _rebuildInternalTextures;
  27254. private _rebuildEffects;
  27255. /**
  27256. * Gets a boolean indicating if all created effects are ready
  27257. * @returns true if all effects are ready
  27258. */
  27259. areAllEffectsReady(): boolean;
  27260. private _rebuildBuffers;
  27261. private _initGLContext;
  27262. /**
  27263. * Gets version of the current webGL context
  27264. */
  27265. readonly webGLVersion: number;
  27266. /**
  27267. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27268. */
  27269. readonly isStencilEnable: boolean;
  27270. /** @hidden */ prepareWorkingCanvas(): void;
  27271. /**
  27272. * Reset the texture cache to empty state
  27273. */
  27274. resetTextureCache(): void;
  27275. /**
  27276. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27277. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27278. * @returns true if engine is in deterministic lock step mode
  27279. */
  27280. isDeterministicLockStep(): boolean;
  27281. /**
  27282. * Gets the max steps when engine is running in deterministic lock step
  27283. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27284. * @returns the max steps
  27285. */
  27286. getLockstepMaxSteps(): number;
  27287. /**
  27288. * Gets an object containing information about the current webGL context
  27289. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27290. */
  27291. getGlInfo(): {
  27292. vendor: string;
  27293. renderer: string;
  27294. version: string;
  27295. };
  27296. /**
  27297. * Gets current aspect ratio
  27298. * @param camera defines the camera to use to get the aspect ratio
  27299. * @param useScreen defines if screen size must be used (or the current render target if any)
  27300. * @returns a number defining the aspect ratio
  27301. */
  27302. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27303. /**
  27304. * Gets current screen aspect ratio
  27305. * @returns a number defining the aspect ratio
  27306. */
  27307. getScreenAspectRatio(): number;
  27308. /**
  27309. * Gets the current render width
  27310. * @param useScreen defines if screen size must be used (or the current render target if any)
  27311. * @returns a number defining the current render width
  27312. */
  27313. getRenderWidth(useScreen?: boolean): number;
  27314. /**
  27315. * Gets the current render height
  27316. * @param useScreen defines if screen size must be used (or the current render target if any)
  27317. * @returns a number defining the current render height
  27318. */
  27319. getRenderHeight(useScreen?: boolean): number;
  27320. /**
  27321. * Gets the HTML canvas attached with the current webGL context
  27322. * @returns a HTML canvas
  27323. */
  27324. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27325. /**
  27326. * Gets the client rect of the HTML canvas attached with the current webGL context
  27327. * @returns a client rectanglee
  27328. */
  27329. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27330. /**
  27331. * Defines the hardware scaling level.
  27332. * By default the hardware scaling level is computed from the window device ratio.
  27333. * 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.
  27334. * @param level defines the level to use
  27335. */
  27336. setHardwareScalingLevel(level: number): void;
  27337. /**
  27338. * Gets the current hardware scaling level.
  27339. * By default the hardware scaling level is computed from the window device ratio.
  27340. * 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.
  27341. * @returns a number indicating the current hardware scaling level
  27342. */
  27343. getHardwareScalingLevel(): number;
  27344. /**
  27345. * Gets the list of loaded textures
  27346. * @returns an array containing all loaded textures
  27347. */
  27348. getLoadedTexturesCache(): InternalTexture[];
  27349. /**
  27350. * Gets the object containing all engine capabilities
  27351. * @returns the EngineCapabilities object
  27352. */
  27353. getCaps(): EngineCapabilities;
  27354. /**
  27355. * Gets the current depth function
  27356. * @returns a number defining the depth function
  27357. */
  27358. getDepthFunction(): Nullable<number>;
  27359. /**
  27360. * Sets the current depth function
  27361. * @param depthFunc defines the function to use
  27362. */
  27363. setDepthFunction(depthFunc: number): void;
  27364. /**
  27365. * Sets the current depth function to GREATER
  27366. */
  27367. setDepthFunctionToGreater(): void;
  27368. /**
  27369. * Sets the current depth function to GEQUAL
  27370. */
  27371. setDepthFunctionToGreaterOrEqual(): void;
  27372. /**
  27373. * Sets the current depth function to LESS
  27374. */
  27375. setDepthFunctionToLess(): void;
  27376. private _cachedStencilBuffer;
  27377. private _cachedStencilFunction;
  27378. private _cachedStencilMask;
  27379. private _cachedStencilOperationPass;
  27380. private _cachedStencilOperationFail;
  27381. private _cachedStencilOperationDepthFail;
  27382. private _cachedStencilReference;
  27383. /**
  27384. * Caches the the state of the stencil buffer
  27385. */
  27386. cacheStencilState(): void;
  27387. /**
  27388. * Restores the state of the stencil buffer
  27389. */
  27390. restoreStencilState(): void;
  27391. /**
  27392. * Sets the current depth function to LEQUAL
  27393. */
  27394. setDepthFunctionToLessOrEqual(): void;
  27395. /**
  27396. * Gets a boolean indicating if stencil buffer is enabled
  27397. * @returns the current stencil buffer state
  27398. */
  27399. getStencilBuffer(): boolean;
  27400. /**
  27401. * Enable or disable the stencil buffer
  27402. * @param enable defines if the stencil buffer must be enabled or disabled
  27403. */
  27404. setStencilBuffer(enable: boolean): void;
  27405. /**
  27406. * Gets the current stencil mask
  27407. * @returns a number defining the new stencil mask to use
  27408. */
  27409. getStencilMask(): number;
  27410. /**
  27411. * Sets the current stencil mask
  27412. * @param mask defines the new stencil mask to use
  27413. */
  27414. setStencilMask(mask: number): void;
  27415. /**
  27416. * Gets the current stencil function
  27417. * @returns a number defining the stencil function to use
  27418. */
  27419. getStencilFunction(): number;
  27420. /**
  27421. * Gets the current stencil reference value
  27422. * @returns a number defining the stencil reference value to use
  27423. */
  27424. getStencilFunctionReference(): number;
  27425. /**
  27426. * Gets the current stencil mask
  27427. * @returns a number defining the stencil mask to use
  27428. */
  27429. getStencilFunctionMask(): number;
  27430. /**
  27431. * Sets the current stencil function
  27432. * @param stencilFunc defines the new stencil function to use
  27433. */
  27434. setStencilFunction(stencilFunc: number): void;
  27435. /**
  27436. * Sets the current stencil reference
  27437. * @param reference defines the new stencil reference to use
  27438. */
  27439. setStencilFunctionReference(reference: number): void;
  27440. /**
  27441. * Sets the current stencil mask
  27442. * @param mask defines the new stencil mask to use
  27443. */
  27444. setStencilFunctionMask(mask: number): void;
  27445. /**
  27446. * Gets the current stencil operation when stencil fails
  27447. * @returns a number defining stencil operation to use when stencil fails
  27448. */
  27449. getStencilOperationFail(): number;
  27450. /**
  27451. * Gets the current stencil operation when depth fails
  27452. * @returns a number defining stencil operation to use when depth fails
  27453. */
  27454. getStencilOperationDepthFail(): number;
  27455. /**
  27456. * Gets the current stencil operation when stencil passes
  27457. * @returns a number defining stencil operation to use when stencil passes
  27458. */
  27459. getStencilOperationPass(): number;
  27460. /**
  27461. * Sets the stencil operation to use when stencil fails
  27462. * @param operation defines the stencil operation to use when stencil fails
  27463. */
  27464. setStencilOperationFail(operation: number): void;
  27465. /**
  27466. * Sets the stencil operation to use when depth fails
  27467. * @param operation defines the stencil operation to use when depth fails
  27468. */
  27469. setStencilOperationDepthFail(operation: number): void;
  27470. /**
  27471. * Sets the stencil operation to use when stencil passes
  27472. * @param operation defines the stencil operation to use when stencil passes
  27473. */
  27474. setStencilOperationPass(operation: number): void;
  27475. /**
  27476. * Sets a boolean indicating if the dithering state is enabled or disabled
  27477. * @param value defines the dithering state
  27478. */
  27479. setDitheringState(value: boolean): void;
  27480. /**
  27481. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27482. * @param value defines the rasterizer state
  27483. */
  27484. setRasterizerState(value: boolean): void;
  27485. /**
  27486. * stop executing a render loop function and remove it from the execution array
  27487. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27488. */
  27489. stopRenderLoop(renderFunction?: () => void): void;
  27490. /** @hidden */ renderLoop(): void;
  27491. /**
  27492. * Register and execute a render loop. The engine can have more than one render function
  27493. * @param renderFunction defines the function to continuously execute
  27494. */
  27495. runRenderLoop(renderFunction: () => void): void;
  27496. /**
  27497. * Toggle full screen mode
  27498. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27499. */
  27500. switchFullscreen(requestPointerLock: boolean): void;
  27501. /**
  27502. * Enters full screen mode
  27503. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27504. */
  27505. enterFullscreen(requestPointerLock: boolean): void;
  27506. /**
  27507. * Exits full screen mode
  27508. */
  27509. exitFullscreen(): void;
  27510. /**
  27511. * Clear the current render buffer or the current render target (if any is set up)
  27512. * @param color defines the color to use
  27513. * @param backBuffer defines if the back buffer must be cleared
  27514. * @param depth defines if the depth buffer must be cleared
  27515. * @param stencil defines if the stencil buffer must be cleared
  27516. */
  27517. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27518. /**
  27519. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27520. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27521. * @param y defines the y-coordinate of the corner of the clear rectangle
  27522. * @param width defines the width of the clear rectangle
  27523. * @param height defines the height of the clear rectangle
  27524. * @param clearColor defines the clear color
  27525. */
  27526. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27527. /**
  27528. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27529. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27530. * @param y defines the y-coordinate of the corner of the clear rectangle
  27531. * @param width defines the width of the clear rectangle
  27532. * @param height defines the height of the clear rectangle
  27533. */
  27534. enableScissor(x: number, y: number, width: number, height: number): void;
  27535. /**
  27536. * Disable previously set scissor test rectangle
  27537. */
  27538. disableScissor(): void;
  27539. private _viewportCached;
  27540. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27541. /**
  27542. * Set the WebGL's viewport
  27543. * @param viewport defines the viewport element to be used
  27544. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27545. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27546. */
  27547. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27548. /**
  27549. * Directly set the WebGL Viewport
  27550. * @param x defines the x coordinate of the viewport (in screen space)
  27551. * @param y defines the y coordinate of the viewport (in screen space)
  27552. * @param width defines the width of the viewport (in screen space)
  27553. * @param height defines the height of the viewport (in screen space)
  27554. * @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
  27555. */
  27556. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27557. /**
  27558. * Begin a new frame
  27559. */
  27560. beginFrame(): void;
  27561. /**
  27562. * Enf the current frame
  27563. */
  27564. endFrame(): void;
  27565. /**
  27566. * Resize the view according to the canvas' size
  27567. */
  27568. resize(): void;
  27569. /**
  27570. * Force a specific size of the canvas
  27571. * @param width defines the new canvas' width
  27572. * @param height defines the new canvas' height
  27573. */
  27574. setSize(width: number, height: number): void;
  27575. /**
  27576. * Binds the frame buffer to the specified texture.
  27577. * @param texture The texture to render to or null for the default canvas
  27578. * @param faceIndex The face of the texture to render to in case of cube texture
  27579. * @param requiredWidth The width of the target to render to
  27580. * @param requiredHeight The height of the target to render to
  27581. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27582. * @param depthStencilTexture The depth stencil texture to use to render
  27583. * @param lodLevel defines le lod level to bind to the frame buffer
  27584. */
  27585. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27586. /** @hidden */ bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27587. /**
  27588. * Unbind the current render target texture from the webGL context
  27589. * @param texture defines the render target texture to unbind
  27590. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27591. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27592. */
  27593. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27594. /**
  27595. * Force the mipmap generation for the given render target texture
  27596. * @param texture defines the render target texture to use
  27597. */
  27598. generateMipMapsForCubemap(texture: InternalTexture): void;
  27599. /**
  27600. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27601. */
  27602. flushFramebuffer(): void;
  27603. /**
  27604. * Unbind the current render target and bind the default framebuffer
  27605. */
  27606. restoreDefaultFramebuffer(): void;
  27607. /**
  27608. * Create an uniform buffer
  27609. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27610. * @param elements defines the content of the uniform buffer
  27611. * @returns the webGL uniform buffer
  27612. */
  27613. createUniformBuffer(elements: FloatArray): DataBuffer;
  27614. /**
  27615. * Create a dynamic uniform buffer
  27616. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27617. * @param elements defines the content of the uniform buffer
  27618. * @returns the webGL uniform buffer
  27619. */
  27620. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27621. /**
  27622. * Update an existing uniform buffer
  27623. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27624. * @param uniformBuffer defines the target uniform buffer
  27625. * @param elements defines the content to update
  27626. * @param offset defines the offset in the uniform buffer where update should start
  27627. * @param count defines the size of the data to update
  27628. */
  27629. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27630. private _resetVertexBufferBinding;
  27631. /**
  27632. * Creates a vertex buffer
  27633. * @param data the data for the vertex buffer
  27634. * @returns the new WebGL static buffer
  27635. */
  27636. createVertexBuffer(data: DataArray): DataBuffer;
  27637. /**
  27638. * Creates a dynamic vertex buffer
  27639. * @param data the data for the dynamic vertex buffer
  27640. * @returns the new WebGL dynamic buffer
  27641. */
  27642. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27643. /**
  27644. * Update a dynamic index buffer
  27645. * @param indexBuffer defines the target index buffer
  27646. * @param indices defines the data to update
  27647. * @param offset defines the offset in the target index buffer where update should start
  27648. */
  27649. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27650. /**
  27651. * Updates a dynamic vertex buffer.
  27652. * @param vertexBuffer the vertex buffer to update
  27653. * @param data the data used to update the vertex buffer
  27654. * @param byteOffset the byte offset of the data
  27655. * @param byteLength the byte length of the data
  27656. */
  27657. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27658. private _resetIndexBufferBinding;
  27659. /**
  27660. * Creates a new index buffer
  27661. * @param indices defines the content of the index buffer
  27662. * @param updatable defines if the index buffer must be updatable
  27663. * @returns a new webGL buffer
  27664. */
  27665. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27666. /**
  27667. * Bind a webGL buffer to the webGL context
  27668. * @param buffer defines the buffer to bind
  27669. */
  27670. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27671. /**
  27672. * Bind an uniform buffer to the current webGL context
  27673. * @param buffer defines the buffer to bind
  27674. */
  27675. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27676. /**
  27677. * Bind a buffer to the current webGL context at a given location
  27678. * @param buffer defines the buffer to bind
  27679. * @param location defines the index where to bind the buffer
  27680. */
  27681. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27682. /**
  27683. * Bind a specific block at a given index in a specific shader program
  27684. * @param pipelineContext defines the pipeline context to use
  27685. * @param blockName defines the block name
  27686. * @param index defines the index where to bind the block
  27687. */
  27688. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27689. private bindIndexBuffer;
  27690. private bindBuffer;
  27691. /**
  27692. * update the bound buffer with the given data
  27693. * @param data defines the data to update
  27694. */
  27695. updateArrayBuffer(data: Float32Array): void;
  27696. private _vertexAttribPointer;
  27697. private _bindIndexBufferWithCache;
  27698. private _bindVertexBuffersAttributes;
  27699. /**
  27700. * Records a vertex array object
  27701. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27702. * @param vertexBuffers defines the list of vertex buffers to store
  27703. * @param indexBuffer defines the index buffer to store
  27704. * @param effect defines the effect to store
  27705. * @returns the new vertex array object
  27706. */
  27707. recordVertexArrayObject(vertexBuffers: {
  27708. [key: string]: VertexBuffer;
  27709. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27710. /**
  27711. * Bind a specific vertex array object
  27712. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27713. * @param vertexArrayObject defines the vertex array object to bind
  27714. * @param indexBuffer defines the index buffer to bind
  27715. */
  27716. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27717. /**
  27718. * Bind webGl buffers directly to the webGL context
  27719. * @param vertexBuffer defines the vertex buffer to bind
  27720. * @param indexBuffer defines the index buffer to bind
  27721. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27722. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27723. * @param effect defines the effect associated with the vertex buffer
  27724. */
  27725. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27726. private _unbindVertexArrayObject;
  27727. /**
  27728. * Bind a list of vertex buffers to the webGL context
  27729. * @param vertexBuffers defines the list of vertex buffers to bind
  27730. * @param indexBuffer defines the index buffer to bind
  27731. * @param effect defines the effect associated with the vertex buffers
  27732. */
  27733. bindBuffers(vertexBuffers: {
  27734. [key: string]: Nullable<VertexBuffer>;
  27735. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27736. /**
  27737. * Unbind all instance attributes
  27738. */
  27739. unbindInstanceAttributes(): void;
  27740. /**
  27741. * Release and free the memory of a vertex array object
  27742. * @param vao defines the vertex array object to delete
  27743. */
  27744. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27745. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  27746. /**
  27747. * Creates a webGL buffer to use with instanciation
  27748. * @param capacity defines the size of the buffer
  27749. * @returns the webGL buffer
  27750. */
  27751. createInstancesBuffer(capacity: number): DataBuffer;
  27752. /**
  27753. * Delete a webGL buffer used with instanciation
  27754. * @param buffer defines the webGL buffer to delete
  27755. */
  27756. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27757. /**
  27758. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27759. * @param instancesBuffer defines the webGL buffer to update and bind
  27760. * @param data defines the data to store in the buffer
  27761. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27762. */
  27763. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27764. /**
  27765. * Apply all cached states (depth, culling, stencil and alpha)
  27766. */
  27767. applyStates(): void;
  27768. /**
  27769. * Send a draw order
  27770. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27771. * @param indexStart defines the starting index
  27772. * @param indexCount defines the number of index to draw
  27773. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27774. */
  27775. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27776. /**
  27777. * Draw a list of points
  27778. * @param verticesStart defines the index of first vertex to draw
  27779. * @param verticesCount defines the count of vertices to draw
  27780. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27781. */
  27782. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27783. /**
  27784. * Draw a list of unindexed primitives
  27785. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27786. * @param verticesStart defines the index of first vertex to draw
  27787. * @param verticesCount defines the count of vertices to draw
  27788. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27789. */
  27790. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27791. /**
  27792. * Draw a list of indexed primitives
  27793. * @param fillMode defines the primitive to use
  27794. * @param indexStart defines the starting index
  27795. * @param indexCount defines the number of index to draw
  27796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27797. */
  27798. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27799. /**
  27800. * Draw a list of unindexed primitives
  27801. * @param fillMode defines the primitive to use
  27802. * @param verticesStart defines the index of first vertex to draw
  27803. * @param verticesCount defines the count of vertices to draw
  27804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27805. */
  27806. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27807. private _drawMode;
  27808. /** @hidden */ releaseEffect(effect: Effect): void;
  27809. /** @hidden */ deletePipelineContext(pipelineContext: IPipelineContext): void;
  27810. /**
  27811. * Create a new effect (used to store vertex/fragment shaders)
  27812. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27813. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27814. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27815. * @param samplers defines an array of string used to represent textures
  27816. * @param defines defines the string containing the defines to use to compile the shaders
  27817. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27818. * @param onCompiled defines a function to call when the effect creation is successful
  27819. * @param onError defines a function to call when the effect creation has failed
  27820. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27821. * @returns the new Effect
  27822. */
  27823. 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;
  27824. private _compileShader;
  27825. private _compileRawShader;
  27826. /**
  27827. * Directly creates a webGL program
  27828. * @param pipelineContext defines the pipeline context to attach to
  27829. * @param vertexCode defines the vertex shader code to use
  27830. * @param fragmentCode defines the fragment shader code to use
  27831. * @param context defines the webGL context to use (if not set, the current one will be used)
  27832. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27833. * @returns the new webGL program
  27834. */
  27835. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27836. /**
  27837. * Creates a webGL program
  27838. * @param pipelineContext defines the pipeline context to attach to
  27839. * @param vertexCode defines the vertex shader code to use
  27840. * @param fragmentCode defines the fragment shader code to use
  27841. * @param defines defines the string containing the defines to use to compile the shaders
  27842. * @param context defines the webGL context to use (if not set, the current one will be used)
  27843. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27844. * @returns the new webGL program
  27845. */
  27846. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27847. /**
  27848. * Creates a new pipeline context
  27849. * @returns the new pipeline
  27850. */
  27851. createPipelineContext(): WebGLPipelineContext;
  27852. private _createShaderProgram;
  27853. private _finalizePipelineContext;
  27854. /** @hidden */ preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27855. /** @hidden */ isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27856. /** @hidden */ executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27857. /**
  27858. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27859. * @param pipelineContext defines the pipeline context to use
  27860. * @param uniformsNames defines the list of uniform names
  27861. * @returns an array of webGL uniform locations
  27862. */
  27863. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27864. /**
  27865. * Gets the lsit of active attributes for a given webGL program
  27866. * @param pipelineContext defines the pipeline context to use
  27867. * @param attributesNames defines the list of attribute names to get
  27868. * @returns an array of indices indicating the offset of each attribute
  27869. */
  27870. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27871. /**
  27872. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27873. * @param effect defines the effect to activate
  27874. */
  27875. enableEffect(effect: Nullable<Effect>): void;
  27876. /**
  27877. * Set the value of an uniform to an array of int32
  27878. * @param uniform defines the webGL uniform location where to store the value
  27879. * @param array defines the array of int32 to store
  27880. */
  27881. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27882. /**
  27883. * Set the value of an uniform to an array of int32 (stored as vec2)
  27884. * @param uniform defines the webGL uniform location where to store the value
  27885. * @param array defines the array of int32 to store
  27886. */
  27887. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27888. /**
  27889. * Set the value of an uniform to an array of int32 (stored as vec3)
  27890. * @param uniform defines the webGL uniform location where to store the value
  27891. * @param array defines the array of int32 to store
  27892. */
  27893. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27894. /**
  27895. * Set the value of an uniform to an array of int32 (stored as vec4)
  27896. * @param uniform defines the webGL uniform location where to store the value
  27897. * @param array defines the array of int32 to store
  27898. */
  27899. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27900. /**
  27901. * Set the value of an uniform to an array of float32
  27902. * @param uniform defines the webGL uniform location where to store the value
  27903. * @param array defines the array of float32 to store
  27904. */
  27905. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27906. /**
  27907. * Set the value of an uniform to an array of float32 (stored as vec2)
  27908. * @param uniform defines the webGL uniform location where to store the value
  27909. * @param array defines the array of float32 to store
  27910. */
  27911. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27912. /**
  27913. * Set the value of an uniform to an array of float32 (stored as vec3)
  27914. * @param uniform defines the webGL uniform location where to store the value
  27915. * @param array defines the array of float32 to store
  27916. */
  27917. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27918. /**
  27919. * Set the value of an uniform to an array of float32 (stored as vec4)
  27920. * @param uniform defines the webGL uniform location where to store the value
  27921. * @param array defines the array of float32 to store
  27922. */
  27923. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27924. /**
  27925. * Set the value of an uniform to an array of number
  27926. * @param uniform defines the webGL uniform location where to store the value
  27927. * @param array defines the array of number to store
  27928. */
  27929. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27930. /**
  27931. * Set the value of an uniform to an array of number (stored as vec2)
  27932. * @param uniform defines the webGL uniform location where to store the value
  27933. * @param array defines the array of number to store
  27934. */
  27935. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27936. /**
  27937. * Set the value of an uniform to an array of number (stored as vec3)
  27938. * @param uniform defines the webGL uniform location where to store the value
  27939. * @param array defines the array of number to store
  27940. */
  27941. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27942. /**
  27943. * Set the value of an uniform to an array of number (stored as vec4)
  27944. * @param uniform defines the webGL uniform location where to store the value
  27945. * @param array defines the array of number to store
  27946. */
  27947. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27948. /**
  27949. * Set the value of an uniform to an array of float32 (stored as matrices)
  27950. * @param uniform defines the webGL uniform location where to store the value
  27951. * @param matrices defines the array of float32 to store
  27952. */
  27953. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27954. /**
  27955. * Set the value of an uniform to a matrix
  27956. * @param uniform defines the webGL uniform location where to store the value
  27957. * @param matrix defines the matrix to store
  27958. */
  27959. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27960. /**
  27961. * Set the value of an uniform to a matrix (3x3)
  27962. * @param uniform defines the webGL uniform location where to store the value
  27963. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27964. */
  27965. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27966. /**
  27967. * Set the value of an uniform to a matrix (2x2)
  27968. * @param uniform defines the webGL uniform location where to store the value
  27969. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27970. */
  27971. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27972. /**
  27973. * Set the value of an uniform to a number (int)
  27974. * @param uniform defines the webGL uniform location where to store the value
  27975. * @param value defines the int number to store
  27976. */
  27977. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27978. /**
  27979. * Set the value of an uniform to a number (float)
  27980. * @param uniform defines the webGL uniform location where to store the value
  27981. * @param value defines the float number to store
  27982. */
  27983. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27984. /**
  27985. * Set the value of an uniform to a vec2
  27986. * @param uniform defines the webGL uniform location where to store the value
  27987. * @param x defines the 1st component of the value
  27988. * @param y defines the 2nd component of the value
  27989. */
  27990. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27991. /**
  27992. * Set the value of an uniform to a vec3
  27993. * @param uniform defines the webGL uniform location where to store the value
  27994. * @param x defines the 1st component of the value
  27995. * @param y defines the 2nd component of the value
  27996. * @param z defines the 3rd component of the value
  27997. */
  27998. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27999. /**
  28000. * Set the value of an uniform to a boolean
  28001. * @param uniform defines the webGL uniform location where to store the value
  28002. * @param bool defines the boolean to store
  28003. */
  28004. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28005. /**
  28006. * Set the value of an uniform to a vec4
  28007. * @param uniform defines the webGL uniform location where to store the value
  28008. * @param x defines the 1st component of the value
  28009. * @param y defines the 2nd component of the value
  28010. * @param z defines the 3rd component of the value
  28011. * @param w defines the 4th component of the value
  28012. */
  28013. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28014. /**
  28015. * Set the value of an uniform to a Color3
  28016. * @param uniform defines the webGL uniform location where to store the value
  28017. * @param color3 defines the color to store
  28018. */
  28019. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28020. /**
  28021. * Set the value of an uniform to a Color3 and an alpha value
  28022. * @param uniform defines the webGL uniform location where to store the value
  28023. * @param color3 defines the color to store
  28024. * @param alpha defines the alpha component to store
  28025. */
  28026. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28027. /**
  28028. * Sets a Color4 on a uniform variable
  28029. * @param uniform defines the uniform location
  28030. * @param color4 defines the value to be set
  28031. */
  28032. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28033. /**
  28034. * Set various states to the webGL context
  28035. * @param culling defines backface culling state
  28036. * @param zOffset defines the value to apply to zOffset (0 by default)
  28037. * @param force defines if states must be applied even if cache is up to date
  28038. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28039. */
  28040. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28041. /**
  28042. * Set the z offset to apply to current rendering
  28043. * @param value defines the offset to apply
  28044. */
  28045. setZOffset(value: number): void;
  28046. /**
  28047. * Gets the current value of the zOffset
  28048. * @returns the current zOffset state
  28049. */
  28050. getZOffset(): number;
  28051. /**
  28052. * Enable or disable depth buffering
  28053. * @param enable defines the state to set
  28054. */
  28055. setDepthBuffer(enable: boolean): void;
  28056. /**
  28057. * Gets a boolean indicating if depth writing is enabled
  28058. * @returns the current depth writing state
  28059. */
  28060. getDepthWrite(): boolean;
  28061. /**
  28062. * Enable or disable depth writing
  28063. * @param enable defines the state to set
  28064. */
  28065. setDepthWrite(enable: boolean): void;
  28066. /**
  28067. * Enable or disable color writing
  28068. * @param enable defines the state to set
  28069. */
  28070. setColorWrite(enable: boolean): void;
  28071. /**
  28072. * Gets a boolean indicating if color writing is enabled
  28073. * @returns the current color writing state
  28074. */
  28075. getColorWrite(): boolean;
  28076. /**
  28077. * Sets alpha constants used by some alpha blending modes
  28078. * @param r defines the red component
  28079. * @param g defines the green component
  28080. * @param b defines the blue component
  28081. * @param a defines the alpha component
  28082. */
  28083. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28084. /**
  28085. * Sets the current alpha mode
  28086. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28087. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28088. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28089. */
  28090. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28091. /**
  28092. * Gets the current alpha mode
  28093. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28094. * @returns the current alpha mode
  28095. */
  28096. getAlphaMode(): number;
  28097. /**
  28098. * Clears the list of texture accessible through engine.
  28099. * This can help preventing texture load conflict due to name collision.
  28100. */
  28101. clearInternalTexturesCache(): void;
  28102. /**
  28103. * Force the entire cache to be cleared
  28104. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28105. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28106. */
  28107. wipeCaches(bruteForce?: boolean): void;
  28108. /**
  28109. * Set the compressed texture format to use, based on the formats you have, and the formats
  28110. * supported by the hardware / browser.
  28111. *
  28112. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28113. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28114. * to API arguments needed to compressed textures. This puts the burden on the container
  28115. * generator to house the arcane code for determining these for current & future formats.
  28116. *
  28117. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28118. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28119. *
  28120. * Note: The result of this call is not taken into account when a texture is base64.
  28121. *
  28122. * @param formatsAvailable defines the list of those format families you have created
  28123. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28124. *
  28125. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28126. * @returns The extension selected.
  28127. */
  28128. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28129. /** @hidden */ getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28130. min: number;
  28131. mag: number;
  28132. };
  28133. /** @hidden */ createTexture(): WebGLTexture;
  28134. /**
  28135. * Usually called from Texture.ts.
  28136. * Passed information to create a WebGLTexture
  28137. * @param urlArg defines a value which contains one of the following:
  28138. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28139. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28140. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28141. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28142. * @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)
  28143. * @param scene needed for loading to the correct scene
  28144. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28145. * @param onLoad optional callback to be called upon successful completion
  28146. * @param onError optional callback to be called upon failure
  28147. * @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
  28148. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28149. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28150. * @param forcedExtension defines the extension to use to pick the right loader
  28151. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28152. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28153. */
  28154. 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;
  28155. private _rescaleTexture;
  28156. private _unpackFlipYCached;
  28157. /**
  28158. * In case you are sharing the context with other applications, it might
  28159. * be interested to not cache the unpack flip y state to ensure a consistent
  28160. * value would be set.
  28161. */
  28162. enableUnpackFlipYCached: boolean;
  28163. /** @hidden */ unpackFlipY(value: boolean): void;
  28164. /** @hidden */ getUnpackAlignement(): number;
  28165. /**
  28166. * Creates a dynamic texture
  28167. * @param width defines the width of the texture
  28168. * @param height defines the height of the texture
  28169. * @param generateMipMaps defines if the engine should generate the mip levels
  28170. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28171. * @returns the dynamic texture inside an InternalTexture
  28172. */
  28173. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28174. /**
  28175. * Update the sampling mode of a given texture
  28176. * @param samplingMode defines the required sampling mode
  28177. * @param texture defines the texture to update
  28178. */
  28179. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28180. /**
  28181. * Update the content of a dynamic texture
  28182. * @param texture defines the texture to update
  28183. * @param canvas defines the canvas containing the source
  28184. * @param invertY defines if data must be stored with Y axis inverted
  28185. * @param premulAlpha defines if alpha is stored as premultiplied
  28186. * @param format defines the format of the data
  28187. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28188. */
  28189. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28190. /**
  28191. * Update a video texture
  28192. * @param texture defines the texture to update
  28193. * @param video defines the video element to use
  28194. * @param invertY defines if data must be stored with Y axis inverted
  28195. */
  28196. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28197. /**
  28198. * Updates a depth texture Comparison Mode and Function.
  28199. * If the comparison Function is equal to 0, the mode will be set to none.
  28200. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28201. * @param texture The texture to set the comparison function for
  28202. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28203. */
  28204. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28205. /** @hidden */ setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28206. width: number;
  28207. height: number;
  28208. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28209. /**
  28210. * Creates a depth stencil texture.
  28211. * This is only available in WebGL 2 or with the depth texture extension available.
  28212. * @param size The size of face edge in the texture.
  28213. * @param options The options defining the texture.
  28214. * @returns The texture
  28215. */
  28216. createDepthStencilTexture(size: number | {
  28217. width: number;
  28218. height: number;
  28219. }, options: DepthTextureCreationOptions): InternalTexture;
  28220. /**
  28221. * Creates a depth stencil texture.
  28222. * This is only available in WebGL 2 or with the depth texture extension available.
  28223. * @param size The size of face edge in the texture.
  28224. * @param options The options defining the texture.
  28225. * @returns The texture
  28226. */
  28227. private _createDepthStencilTexture;
  28228. /**
  28229. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28230. * @param renderTarget The render target to set the frame buffer for
  28231. */
  28232. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28233. /**
  28234. * Creates a new render target texture
  28235. * @param size defines the size of the texture
  28236. * @param options defines the options used to create the texture
  28237. * @returns a new render target texture stored in an InternalTexture
  28238. */
  28239. createRenderTargetTexture(size: number | {
  28240. width: number;
  28241. height: number;
  28242. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28243. /** @hidden */ setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28244. /**
  28245. * Updates the sample count of a render target texture
  28246. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28247. * @param texture defines the texture to update
  28248. * @param samples defines the sample count to set
  28249. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28250. */
  28251. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28252. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28253. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28254. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28255. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28256. /**
  28257. * @hidden
  28258. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28259. private _prepareWebGLTextureContinuation;
  28260. private _prepareWebGLTexture;
  28261. /** @hidden */ convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28262. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28263. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28264. private setProgram;
  28265. private _boundUniforms;
  28266. /**
  28267. * Binds an effect to the webGL context
  28268. * @param effect defines the effect to bind
  28269. */
  28270. bindSamplers(effect: Effect): void;
  28271. private _activateCurrentTexture;
  28272. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28273. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28274. /**
  28275. * Sets a texture to the webGL context from a postprocess
  28276. * @param channel defines the channel to use
  28277. * @param postProcess defines the source postprocess
  28278. */
  28279. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28280. /**
  28281. * Binds the output of the passed in post process to the texture channel specified
  28282. * @param channel The channel the texture should be bound to
  28283. * @param postProcess The post process which's output should be bound
  28284. */
  28285. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28286. /**
  28287. * Unbind all textures from the webGL context
  28288. */
  28289. unbindAllTextures(): void;
  28290. /**
  28291. * Sets a texture to the according uniform.
  28292. * @param channel The texture channel
  28293. * @param uniform The uniform to set
  28294. * @param texture The texture to apply
  28295. */
  28296. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28297. /**
  28298. * Sets a depth stencil texture from a render target to the according uniform.
  28299. * @param channel The texture channel
  28300. * @param uniform The uniform to set
  28301. * @param texture The render target texture containing the depth stencil texture to apply
  28302. */
  28303. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28304. private _bindSamplerUniformToChannel;
  28305. private _getTextureWrapMode;
  28306. private _setTexture;
  28307. /**
  28308. * Sets an array of texture to the webGL context
  28309. * @param channel defines the channel where the texture array must be set
  28310. * @param uniform defines the associated uniform location
  28311. * @param textures defines the array of textures to bind
  28312. */
  28313. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28314. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28315. private _setTextureParameterFloat;
  28316. private _setTextureParameterInteger;
  28317. /**
  28318. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28319. * @param x defines the x coordinate of the rectangle where pixels must be read
  28320. * @param y defines the y coordinate of the rectangle where pixels must be read
  28321. * @param width defines the width of the rectangle where pixels must be read
  28322. * @param height defines the height of the rectangle where pixels must be read
  28323. * @returns a Uint8Array containing RGBA colors
  28324. */
  28325. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28326. /**
  28327. * Add an externaly attached data from its key.
  28328. * This method call will fail and return false, if such key already exists.
  28329. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28330. * @param key the unique key that identifies the data
  28331. * @param data the data object to associate to the key for this Engine instance
  28332. * @return true if no such key were already present and the data was added successfully, false otherwise
  28333. */
  28334. addExternalData<T>(key: string, data: T): boolean;
  28335. /**
  28336. * Get an externaly attached data from its key
  28337. * @param key the unique key that identifies the data
  28338. * @return the associated data, if present (can be null), or undefined if not present
  28339. */
  28340. getExternalData<T>(key: string): T;
  28341. /**
  28342. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28343. * @param key the unique key that identifies the data
  28344. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28345. * @return the associated data, can be null if the factory returned null.
  28346. */
  28347. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28348. /**
  28349. * Remove an externaly attached data from the Engine instance
  28350. * @param key the unique key that identifies the data
  28351. * @return true if the data was successfully removed, false if it doesn't exist
  28352. */
  28353. removeExternalData(key: string): boolean;
  28354. /**
  28355. * Unbind all vertex attributes from the webGL context
  28356. */
  28357. unbindAllAttributes(): void;
  28358. /**
  28359. * 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
  28360. */
  28361. releaseEffects(): void;
  28362. /**
  28363. * Dispose and release all associated resources
  28364. */
  28365. dispose(): void;
  28366. /**
  28367. * Display the loading screen
  28368. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28369. */
  28370. displayLoadingUI(): void;
  28371. /**
  28372. * Hide the loading screen
  28373. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28374. */
  28375. hideLoadingUI(): void;
  28376. /**
  28377. * Gets the current loading screen object
  28378. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28379. */
  28380. /**
  28381. * Sets the current loading screen object
  28382. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28383. */
  28384. loadingScreen: ILoadingScreen;
  28385. /**
  28386. * Sets the current loading screen text
  28387. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28388. */
  28389. loadingUIText: string;
  28390. /**
  28391. * Sets the current loading screen background color
  28392. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28393. */
  28394. loadingUIBackgroundColor: string;
  28395. /**
  28396. * Attach a new callback raised when context lost event is fired
  28397. * @param callback defines the callback to call
  28398. */
  28399. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28400. /**
  28401. * Attach a new callback raised when context restored event is fired
  28402. * @param callback defines the callback to call
  28403. */
  28404. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28405. /**
  28406. * Gets the source code of the vertex shader associated with a specific webGL program
  28407. * @param program defines the program to use
  28408. * @returns a string containing the source code of the vertex shader associated with the program
  28409. */
  28410. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28411. /**
  28412. * Gets the source code of the fragment shader associated with a specific webGL program
  28413. * @param program defines the program to use
  28414. * @returns a string containing the source code of the fragment shader associated with the program
  28415. */
  28416. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28417. /**
  28418. * Get the current error code of the webGL context
  28419. * @returns the error code
  28420. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28421. */
  28422. getError(): number;
  28423. /**
  28424. * Gets the current framerate
  28425. * @returns a number representing the framerate
  28426. */
  28427. getFps(): number;
  28428. /**
  28429. * Gets the time spent between current and previous frame
  28430. * @returns a number representing the delta time in ms
  28431. */
  28432. getDeltaTime(): number;
  28433. private _measureFps;
  28434. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28435. private _canRenderToFloatFramebuffer;
  28436. private _canRenderToHalfFloatFramebuffer;
  28437. private _canRenderToFramebuffer;
  28438. /** @hidden */ getWebGLTextureType(type: number): number;
  28439. /** @hidden */ getInternalFormat(format: number): number;
  28440. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28441. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28442. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  28443. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28444. /**
  28445. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28446. * @returns true if the engine can be created
  28447. * @ignorenaming
  28448. */
  28449. static isSupported(): boolean;
  28450. }
  28451. }
  28452. declare module BABYLON {
  28453. /**
  28454. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28455. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28456. */
  28457. export class EffectFallbacks {
  28458. private _defines;
  28459. private _currentRank;
  28460. private _maxRank;
  28461. private _mesh;
  28462. /**
  28463. * Removes the fallback from the bound mesh.
  28464. */
  28465. unBindMesh(): void;
  28466. /**
  28467. * Adds a fallback on the specified property.
  28468. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28469. * @param define The name of the define in the shader
  28470. */
  28471. addFallback(rank: number, define: string): void;
  28472. /**
  28473. * Sets the mesh to use CPU skinning when needing to fallback.
  28474. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28475. * @param mesh The mesh to use the fallbacks.
  28476. */
  28477. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28478. /**
  28479. * Checks to see if more fallbacks are still availible.
  28480. */
  28481. readonly isMoreFallbacks: boolean;
  28482. /**
  28483. * Removes the defines that shoould be removed when falling back.
  28484. * @param currentDefines defines the current define statements for the shader.
  28485. * @param effect defines the current effect we try to compile
  28486. * @returns The resulting defines with defines of the current rank removed.
  28487. */
  28488. reduce(currentDefines: string, effect: Effect): string;
  28489. }
  28490. /**
  28491. * Options to be used when creating an effect.
  28492. */
  28493. export class EffectCreationOptions {
  28494. /**
  28495. * Atrributes that will be used in the shader.
  28496. */
  28497. attributes: string[];
  28498. /**
  28499. * Uniform varible names that will be set in the shader.
  28500. */
  28501. uniformsNames: string[];
  28502. /**
  28503. * Uniform buffer varible names that will be set in the shader.
  28504. */
  28505. uniformBuffersNames: string[];
  28506. /**
  28507. * Sampler texture variable names that will be set in the shader.
  28508. */
  28509. samplers: string[];
  28510. /**
  28511. * Define statements that will be set in the shader.
  28512. */
  28513. defines: any;
  28514. /**
  28515. * Possible fallbacks for this effect to improve performance when needed.
  28516. */
  28517. fallbacks: Nullable<EffectFallbacks>;
  28518. /**
  28519. * Callback that will be called when the shader is compiled.
  28520. */
  28521. onCompiled: Nullable<(effect: Effect) => void>;
  28522. /**
  28523. * Callback that will be called if an error occurs during shader compilation.
  28524. */
  28525. onError: Nullable<(effect: Effect, errors: string) => void>;
  28526. /**
  28527. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28528. */
  28529. indexParameters: any;
  28530. /**
  28531. * Max number of lights that can be used in the shader.
  28532. */
  28533. maxSimultaneousLights: number;
  28534. /**
  28535. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28536. */
  28537. transformFeedbackVaryings: Nullable<string[]>;
  28538. }
  28539. /**
  28540. * Effect containing vertex and fragment shader that can be executed on an object.
  28541. */
  28542. export class Effect implements IDisposable {
  28543. /**
  28544. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28545. */
  28546. static ShadersRepository: string;
  28547. /**
  28548. * Name of the effect.
  28549. */
  28550. name: any;
  28551. /**
  28552. * String container all the define statements that should be set on the shader.
  28553. */
  28554. defines: string;
  28555. /**
  28556. * Callback that will be called when the shader is compiled.
  28557. */
  28558. onCompiled: Nullable<(effect: Effect) => void>;
  28559. /**
  28560. * Callback that will be called if an error occurs during shader compilation.
  28561. */
  28562. onError: Nullable<(effect: Effect, errors: string) => void>;
  28563. /**
  28564. * Callback that will be called when effect is bound.
  28565. */
  28566. onBind: Nullable<(effect: Effect) => void>;
  28567. /**
  28568. * Unique ID of the effect.
  28569. */
  28570. uniqueId: number;
  28571. /**
  28572. * Observable that will be called when the shader is compiled.
  28573. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28574. */
  28575. onCompileObservable: Observable<Effect>;
  28576. /**
  28577. * Observable that will be called if an error occurs during shader compilation.
  28578. */
  28579. onErrorObservable: Observable<Effect>;
  28580. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28581. /**
  28582. * Observable that will be called when effect is bound.
  28583. */
  28584. readonly onBindObservable: Observable<Effect>;
  28585. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28586. private static _uniqueIdSeed;
  28587. private _engine;
  28588. private _uniformBuffersNames;
  28589. private _uniformsNames;
  28590. private _samplerList;
  28591. private _samplers;
  28592. private _isReady;
  28593. private _compilationError;
  28594. private _attributesNames;
  28595. private _attributes;
  28596. private _uniforms;
  28597. /**
  28598. * Key for the effect.
  28599. * @hidden
  28600. */ key: string;
  28601. private _indexParameters;
  28602. private _fallbacks;
  28603. private _vertexSourceCode;
  28604. private _fragmentSourceCode;
  28605. private _vertexSourceCodeOverride;
  28606. private _fragmentSourceCodeOverride;
  28607. private _transformFeedbackVaryings;
  28608. /**
  28609. * Compiled shader to webGL program.
  28610. * @hidden
  28611. */ pipelineContext: IPipelineContext;
  28612. private _valueCache;
  28613. private static _baseCache;
  28614. /**
  28615. * Instantiates an effect.
  28616. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28617. * @param baseName Name of the effect.
  28618. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28619. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28620. * @param samplers List of sampler variables that will be passed to the shader.
  28621. * @param engine Engine to be used to render the effect
  28622. * @param defines Define statements to be added to the shader.
  28623. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28624. * @param onCompiled Callback that will be called when the shader is compiled.
  28625. * @param onError Callback that will be called if an error occurs during shader compilation.
  28626. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28627. */
  28628. 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);
  28629. /**
  28630. * Unique key for this effect
  28631. */
  28632. readonly key: string;
  28633. /**
  28634. * If the effect has been compiled and prepared.
  28635. * @returns if the effect is compiled and prepared.
  28636. */
  28637. isReady(): boolean;
  28638. /**
  28639. * The engine the effect was initialized with.
  28640. * @returns the engine.
  28641. */
  28642. getEngine(): Engine;
  28643. /**
  28644. * The pipeline context for this effect
  28645. * @returns the associated pipeline context
  28646. */
  28647. getPipelineContext(): IPipelineContext;
  28648. /**
  28649. * The set of names of attribute variables for the shader.
  28650. * @returns An array of attribute names.
  28651. */
  28652. getAttributesNames(): string[];
  28653. /**
  28654. * Returns the attribute at the given index.
  28655. * @param index The index of the attribute.
  28656. * @returns The location of the attribute.
  28657. */
  28658. getAttributeLocation(index: number): number;
  28659. /**
  28660. * Returns the attribute based on the name of the variable.
  28661. * @param name of the attribute to look up.
  28662. * @returns the attribute location.
  28663. */
  28664. getAttributeLocationByName(name: string): number;
  28665. /**
  28666. * The number of attributes.
  28667. * @returns the numnber of attributes.
  28668. */
  28669. getAttributesCount(): number;
  28670. /**
  28671. * Gets the index of a uniform variable.
  28672. * @param uniformName of the uniform to look up.
  28673. * @returns the index.
  28674. */
  28675. getUniformIndex(uniformName: string): number;
  28676. /**
  28677. * Returns the attribute based on the name of the variable.
  28678. * @param uniformName of the uniform to look up.
  28679. * @returns the location of the uniform.
  28680. */
  28681. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28682. /**
  28683. * Returns an array of sampler variable names
  28684. * @returns The array of sampler variable neames.
  28685. */
  28686. getSamplers(): string[];
  28687. /**
  28688. * The error from the last compilation.
  28689. * @returns the error string.
  28690. */
  28691. getCompilationError(): string;
  28692. /**
  28693. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28694. * @param func The callback to be used.
  28695. */
  28696. executeWhenCompiled(func: (effect: Effect) => void): void;
  28697. private _checkIsReady;
  28698. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28699. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28700. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28701. private _processShaderConversion;
  28702. private _processIncludes;
  28703. private _processPrecision;
  28704. /**
  28705. * Recompiles the webGL program
  28706. * @param vertexSourceCode The source code for the vertex shader.
  28707. * @param fragmentSourceCode The source code for the fragment shader.
  28708. * @param onCompiled Callback called when completed.
  28709. * @param onError Callback called on error.
  28710. * @hidden
  28711. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28712. /**
  28713. * Prepares the effect
  28714. * @hidden
  28715. */ prepareEffect(): void;
  28716. /**
  28717. * Checks if the effect is supported. (Must be called after compilation)
  28718. */
  28719. readonly isSupported: boolean;
  28720. /**
  28721. * Binds a texture to the engine to be used as output of the shader.
  28722. * @param channel Name of the output variable.
  28723. * @param texture Texture to bind.
  28724. * @hidden
  28725. */ bindTexture(channel: string, texture: InternalTexture): void;
  28726. /**
  28727. * Sets a texture on the engine to be used in the shader.
  28728. * @param channel Name of the sampler variable.
  28729. * @param texture Texture to set.
  28730. */
  28731. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28732. /**
  28733. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28734. * @param channel Name of the sampler variable.
  28735. * @param texture Texture to set.
  28736. */
  28737. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28738. /**
  28739. * Sets an array of textures on the engine to be used in the shader.
  28740. * @param channel Name of the variable.
  28741. * @param textures Textures to set.
  28742. */
  28743. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28744. /**
  28745. * 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)
  28746. * @param channel Name of the sampler variable.
  28747. * @param postProcess Post process to get the input texture from.
  28748. */
  28749. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28750. /**
  28751. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28752. * 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)
  28753. * @param channel Name of the sampler variable.
  28754. * @param postProcess Post process to get the output texture from.
  28755. */
  28756. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28757. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28758. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28759. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28760. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28761. /**
  28762. * Binds a buffer to a uniform.
  28763. * @param buffer Buffer to bind.
  28764. * @param name Name of the uniform variable to bind to.
  28765. */
  28766. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28767. /**
  28768. * Binds block to a uniform.
  28769. * @param blockName Name of the block to bind.
  28770. * @param index Index to bind.
  28771. */
  28772. bindUniformBlock(blockName: string, index: number): void;
  28773. /**
  28774. * Sets an interger value on a uniform variable.
  28775. * @param uniformName Name of the variable.
  28776. * @param value Value to be set.
  28777. * @returns this effect.
  28778. */
  28779. setInt(uniformName: string, value: number): Effect;
  28780. /**
  28781. * Sets an int array on a uniform variable.
  28782. * @param uniformName Name of the variable.
  28783. * @param array array to be set.
  28784. * @returns this effect.
  28785. */
  28786. setIntArray(uniformName: string, array: Int32Array): Effect;
  28787. /**
  28788. * 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)
  28789. * @param uniformName Name of the variable.
  28790. * @param array array to be set.
  28791. * @returns this effect.
  28792. */
  28793. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28794. /**
  28795. * 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)
  28796. * @param uniformName Name of the variable.
  28797. * @param array array to be set.
  28798. * @returns this effect.
  28799. */
  28800. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28801. /**
  28802. * 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)
  28803. * @param uniformName Name of the variable.
  28804. * @param array array to be set.
  28805. * @returns this effect.
  28806. */
  28807. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28808. /**
  28809. * Sets an float array on a uniform variable.
  28810. * @param uniformName Name of the variable.
  28811. * @param array array to be set.
  28812. * @returns this effect.
  28813. */
  28814. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28815. /**
  28816. * 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)
  28817. * @param uniformName Name of the variable.
  28818. * @param array array to be set.
  28819. * @returns this effect.
  28820. */
  28821. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28822. /**
  28823. * 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)
  28824. * @param uniformName Name of the variable.
  28825. * @param array array to be set.
  28826. * @returns this effect.
  28827. */
  28828. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28829. /**
  28830. * 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)
  28831. * @param uniformName Name of the variable.
  28832. * @param array array to be set.
  28833. * @returns this effect.
  28834. */
  28835. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28836. /**
  28837. * Sets an array on a uniform variable.
  28838. * @param uniformName Name of the variable.
  28839. * @param array array to be set.
  28840. * @returns this effect.
  28841. */
  28842. setArray(uniformName: string, array: number[]): Effect;
  28843. /**
  28844. * 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)
  28845. * @param uniformName Name of the variable.
  28846. * @param array array to be set.
  28847. * @returns this effect.
  28848. */
  28849. setArray2(uniformName: string, array: number[]): Effect;
  28850. /**
  28851. * 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)
  28852. * @param uniformName Name of the variable.
  28853. * @param array array to be set.
  28854. * @returns this effect.
  28855. */
  28856. setArray3(uniformName: string, array: number[]): Effect;
  28857. /**
  28858. * 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)
  28859. * @param uniformName Name of the variable.
  28860. * @param array array to be set.
  28861. * @returns this effect.
  28862. */
  28863. setArray4(uniformName: string, array: number[]): Effect;
  28864. /**
  28865. * Sets matrices on a uniform variable.
  28866. * @param uniformName Name of the variable.
  28867. * @param matrices matrices to be set.
  28868. * @returns this effect.
  28869. */
  28870. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28871. /**
  28872. * Sets matrix on a uniform variable.
  28873. * @param uniformName Name of the variable.
  28874. * @param matrix matrix to be set.
  28875. * @returns this effect.
  28876. */
  28877. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28878. /**
  28879. * 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)
  28880. * @param uniformName Name of the variable.
  28881. * @param matrix matrix to be set.
  28882. * @returns this effect.
  28883. */
  28884. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28885. /**
  28886. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28887. * @param uniformName Name of the variable.
  28888. * @param matrix matrix to be set.
  28889. * @returns this effect.
  28890. */
  28891. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28892. /**
  28893. * Sets a float on a uniform variable.
  28894. * @param uniformName Name of the variable.
  28895. * @param value value to be set.
  28896. * @returns this effect.
  28897. */
  28898. setFloat(uniformName: string, value: number): Effect;
  28899. /**
  28900. * Sets a boolean on a uniform variable.
  28901. * @param uniformName Name of the variable.
  28902. * @param bool value to be set.
  28903. * @returns this effect.
  28904. */
  28905. setBool(uniformName: string, bool: boolean): Effect;
  28906. /**
  28907. * Sets a Vector2 on a uniform variable.
  28908. * @param uniformName Name of the variable.
  28909. * @param vector2 vector2 to be set.
  28910. * @returns this effect.
  28911. */
  28912. setVector2(uniformName: string, vector2: Vector2): Effect;
  28913. /**
  28914. * Sets a float2 on a uniform variable.
  28915. * @param uniformName Name of the variable.
  28916. * @param x First float in float2.
  28917. * @param y Second float in float2.
  28918. * @returns this effect.
  28919. */
  28920. setFloat2(uniformName: string, x: number, y: number): Effect;
  28921. /**
  28922. * Sets a Vector3 on a uniform variable.
  28923. * @param uniformName Name of the variable.
  28924. * @param vector3 Value to be set.
  28925. * @returns this effect.
  28926. */
  28927. setVector3(uniformName: string, vector3: Vector3): Effect;
  28928. /**
  28929. * Sets a float3 on a uniform variable.
  28930. * @param uniformName Name of the variable.
  28931. * @param x First float in float3.
  28932. * @param y Second float in float3.
  28933. * @param z Third float in float3.
  28934. * @returns this effect.
  28935. */
  28936. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28937. /**
  28938. * Sets a Vector4 on a uniform variable.
  28939. * @param uniformName Name of the variable.
  28940. * @param vector4 Value to be set.
  28941. * @returns this effect.
  28942. */
  28943. setVector4(uniformName: string, vector4: Vector4): Effect;
  28944. /**
  28945. * Sets a float4 on a uniform variable.
  28946. * @param uniformName Name of the variable.
  28947. * @param x First float in float4.
  28948. * @param y Second float in float4.
  28949. * @param z Third float in float4.
  28950. * @param w Fourth float in float4.
  28951. * @returns this effect.
  28952. */
  28953. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28954. /**
  28955. * Sets a Color3 on a uniform variable.
  28956. * @param uniformName Name of the variable.
  28957. * @param color3 Value to be set.
  28958. * @returns this effect.
  28959. */
  28960. setColor3(uniformName: string, color3: Color3): Effect;
  28961. /**
  28962. * Sets a Color4 on a uniform variable.
  28963. * @param uniformName Name of the variable.
  28964. * @param color3 Value to be set.
  28965. * @param alpha Alpha value to be set.
  28966. * @returns this effect.
  28967. */
  28968. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28969. /**
  28970. * Sets a Color4 on a uniform variable
  28971. * @param uniformName defines the name of the variable
  28972. * @param color4 defines the value to be set
  28973. * @returns this effect.
  28974. */
  28975. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28976. /** Release all associated resources */
  28977. dispose(): void;
  28978. /**
  28979. * This function will add a new shader to the shader store
  28980. * @param name the name of the shader
  28981. * @param pixelShader optional pixel shader content
  28982. * @param vertexShader optional vertex shader content
  28983. */
  28984. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28985. /**
  28986. * Store of each shader (The can be looked up using effect.key)
  28987. */
  28988. static ShadersStore: {
  28989. [key: string]: string;
  28990. };
  28991. /**
  28992. * Store of each included file for a shader (The can be looked up using effect.key)
  28993. */
  28994. static IncludesShadersStore: {
  28995. [key: string]: string;
  28996. };
  28997. /**
  28998. * Resets the cache of effects.
  28999. */
  29000. static ResetCache(): void;
  29001. }
  29002. }
  29003. declare module BABYLON {
  29004. /**
  29005. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29006. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29007. * 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;
  29008. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29009. */
  29010. export class ColorCurves {
  29011. private _dirty;
  29012. private _tempColor;
  29013. private _globalCurve;
  29014. private _highlightsCurve;
  29015. private _midtonesCurve;
  29016. private _shadowsCurve;
  29017. private _positiveCurve;
  29018. private _negativeCurve;
  29019. private _globalHue;
  29020. private _globalDensity;
  29021. private _globalSaturation;
  29022. private _globalExposure;
  29023. /**
  29024. * Gets the global Hue value.
  29025. * 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).
  29026. */
  29027. /**
  29028. * Sets the global Hue value.
  29029. * 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).
  29030. */
  29031. globalHue: number;
  29032. /**
  29033. * Gets the global Density value.
  29034. * 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.
  29035. * Values less than zero provide a filter of opposite hue.
  29036. */
  29037. /**
  29038. * Sets the global Density value.
  29039. * 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.
  29040. * Values less than zero provide a filter of opposite hue.
  29041. */
  29042. globalDensity: number;
  29043. /**
  29044. * Gets the global Saturation value.
  29045. * 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.
  29046. */
  29047. /**
  29048. * Sets the global Saturation value.
  29049. * 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.
  29050. */
  29051. globalSaturation: number;
  29052. /**
  29053. * Gets the global Exposure value.
  29054. * 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.
  29055. */
  29056. /**
  29057. * Sets the global Exposure value.
  29058. * 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.
  29059. */
  29060. globalExposure: number;
  29061. private _highlightsHue;
  29062. private _highlightsDensity;
  29063. private _highlightsSaturation;
  29064. private _highlightsExposure;
  29065. /**
  29066. * Gets the highlights Hue value.
  29067. * 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).
  29068. */
  29069. /**
  29070. * Sets the highlights Hue value.
  29071. * 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).
  29072. */
  29073. highlightsHue: number;
  29074. /**
  29075. * Gets the highlights Density value.
  29076. * 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.
  29077. * Values less than zero provide a filter of opposite hue.
  29078. */
  29079. /**
  29080. * Sets the highlights Density value.
  29081. * 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.
  29082. * Values less than zero provide a filter of opposite hue.
  29083. */
  29084. highlightsDensity: number;
  29085. /**
  29086. * Gets the highlights Saturation value.
  29087. * 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.
  29088. */
  29089. /**
  29090. * Sets the highlights Saturation value.
  29091. * 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.
  29092. */
  29093. highlightsSaturation: number;
  29094. /**
  29095. * Gets the highlights Exposure value.
  29096. * 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.
  29097. */
  29098. /**
  29099. * Sets the highlights Exposure value.
  29100. * 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.
  29101. */
  29102. highlightsExposure: number;
  29103. private _midtonesHue;
  29104. private _midtonesDensity;
  29105. private _midtonesSaturation;
  29106. private _midtonesExposure;
  29107. /**
  29108. * Gets the midtones Hue value.
  29109. * 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).
  29110. */
  29111. /**
  29112. * Sets the midtones Hue value.
  29113. * 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).
  29114. */
  29115. midtonesHue: number;
  29116. /**
  29117. * Gets the midtones Density value.
  29118. * 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.
  29119. * Values less than zero provide a filter of opposite hue.
  29120. */
  29121. /**
  29122. * Sets the midtones Density value.
  29123. * 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.
  29124. * Values less than zero provide a filter of opposite hue.
  29125. */
  29126. midtonesDensity: number;
  29127. /**
  29128. * Gets the midtones Saturation value.
  29129. * 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.
  29130. */
  29131. /**
  29132. * Sets the midtones Saturation value.
  29133. * 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.
  29134. */
  29135. midtonesSaturation: number;
  29136. /**
  29137. * Gets the midtones Exposure value.
  29138. * 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.
  29139. */
  29140. /**
  29141. * Sets the midtones Exposure value.
  29142. * 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.
  29143. */
  29144. midtonesExposure: number;
  29145. private _shadowsHue;
  29146. private _shadowsDensity;
  29147. private _shadowsSaturation;
  29148. private _shadowsExposure;
  29149. /**
  29150. * Gets the shadows Hue value.
  29151. * 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).
  29152. */
  29153. /**
  29154. * Sets the shadows Hue value.
  29155. * 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).
  29156. */
  29157. shadowsHue: number;
  29158. /**
  29159. * Gets the shadows Density value.
  29160. * 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.
  29161. * Values less than zero provide a filter of opposite hue.
  29162. */
  29163. /**
  29164. * Sets the shadows Density value.
  29165. * 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.
  29166. * Values less than zero provide a filter of opposite hue.
  29167. */
  29168. shadowsDensity: number;
  29169. /**
  29170. * Gets the shadows Saturation value.
  29171. * 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.
  29172. */
  29173. /**
  29174. * Sets the shadows Saturation value.
  29175. * 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.
  29176. */
  29177. shadowsSaturation: number;
  29178. /**
  29179. * Gets the shadows Exposure value.
  29180. * 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.
  29181. */
  29182. /**
  29183. * Sets the shadows Exposure value.
  29184. * 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.
  29185. */
  29186. shadowsExposure: number;
  29187. /**
  29188. * Returns the class name
  29189. * @returns The class name
  29190. */
  29191. getClassName(): string;
  29192. /**
  29193. * Binds the color curves to the shader.
  29194. * @param colorCurves The color curve to bind
  29195. * @param effect The effect to bind to
  29196. * @param positiveUniform The positive uniform shader parameter
  29197. * @param neutralUniform The neutral uniform shader parameter
  29198. * @param negativeUniform The negative uniform shader parameter
  29199. */
  29200. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29201. /**
  29202. * Prepare the list of uniforms associated with the ColorCurves effects.
  29203. * @param uniformsList The list of uniforms used in the effect
  29204. */
  29205. static PrepareUniforms(uniformsList: string[]): void;
  29206. /**
  29207. * Returns color grading data based on a hue, density, saturation and exposure value.
  29208. * @param filterHue The hue of the color filter.
  29209. * @param filterDensity The density of the color filter.
  29210. * @param saturation The saturation.
  29211. * @param exposure The exposure.
  29212. * @param result The result data container.
  29213. */
  29214. private getColorGradingDataToRef;
  29215. /**
  29216. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29217. * @param value The input slider value in range [-100,100].
  29218. * @returns Adjusted value.
  29219. */
  29220. private static applyColorGradingSliderNonlinear;
  29221. /**
  29222. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29223. * @param hue The hue (H) input.
  29224. * @param saturation The saturation (S) input.
  29225. * @param brightness The brightness (B) input.
  29226. * @result An RGBA color represented as Vector4.
  29227. */
  29228. private static fromHSBToRef;
  29229. /**
  29230. * Returns a value clamped between min and max
  29231. * @param value The value to clamp
  29232. * @param min The minimum of value
  29233. * @param max The maximum of value
  29234. * @returns The clamped value.
  29235. */
  29236. private static clamp;
  29237. /**
  29238. * Clones the current color curve instance.
  29239. * @return The cloned curves
  29240. */
  29241. clone(): ColorCurves;
  29242. /**
  29243. * Serializes the current color curve instance to a json representation.
  29244. * @return a JSON representation
  29245. */
  29246. serialize(): any;
  29247. /**
  29248. * Parses the color curve from a json representation.
  29249. * @param source the JSON source to parse
  29250. * @return The parsed curves
  29251. */
  29252. static Parse(source: any): ColorCurves;
  29253. }
  29254. }
  29255. declare module BABYLON {
  29256. /**
  29257. * Interface to follow in your material defines to integrate easily the
  29258. * Image proccessing functions.
  29259. * @hidden
  29260. */
  29261. export interface IImageProcessingConfigurationDefines {
  29262. IMAGEPROCESSING: boolean;
  29263. VIGNETTE: boolean;
  29264. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29265. VIGNETTEBLENDMODEOPAQUE: boolean;
  29266. TONEMAPPING: boolean;
  29267. TONEMAPPING_ACES: boolean;
  29268. CONTRAST: boolean;
  29269. EXPOSURE: boolean;
  29270. COLORCURVES: boolean;
  29271. COLORGRADING: boolean;
  29272. COLORGRADING3D: boolean;
  29273. SAMPLER3DGREENDEPTH: boolean;
  29274. SAMPLER3DBGRMAP: boolean;
  29275. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29276. }
  29277. /**
  29278. * @hidden
  29279. */
  29280. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29281. IMAGEPROCESSING: boolean;
  29282. VIGNETTE: boolean;
  29283. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29284. VIGNETTEBLENDMODEOPAQUE: boolean;
  29285. TONEMAPPING: boolean;
  29286. TONEMAPPING_ACES: boolean;
  29287. CONTRAST: boolean;
  29288. COLORCURVES: boolean;
  29289. COLORGRADING: boolean;
  29290. COLORGRADING3D: boolean;
  29291. SAMPLER3DGREENDEPTH: boolean;
  29292. SAMPLER3DBGRMAP: boolean;
  29293. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29294. EXPOSURE: boolean;
  29295. constructor();
  29296. }
  29297. /**
  29298. * This groups together the common properties used for image processing either in direct forward pass
  29299. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29300. * or not.
  29301. */
  29302. export class ImageProcessingConfiguration {
  29303. /**
  29304. * Default tone mapping applied in BabylonJS.
  29305. */
  29306. static readonly TONEMAPPING_STANDARD: number;
  29307. /**
  29308. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29309. * to other engines rendering to increase portability.
  29310. */
  29311. static readonly TONEMAPPING_ACES: number;
  29312. /**
  29313. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29314. */
  29315. colorCurves: Nullable<ColorCurves>;
  29316. private _colorCurvesEnabled;
  29317. /**
  29318. * Gets wether the color curves effect is enabled.
  29319. */
  29320. /**
  29321. * Sets wether the color curves effect is enabled.
  29322. */
  29323. colorCurvesEnabled: boolean;
  29324. private _colorGradingTexture;
  29325. /**
  29326. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29327. */
  29328. /**
  29329. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29330. */
  29331. colorGradingTexture: Nullable<BaseTexture>;
  29332. private _colorGradingEnabled;
  29333. /**
  29334. * Gets wether the color grading effect is enabled.
  29335. */
  29336. /**
  29337. * Sets wether the color grading effect is enabled.
  29338. */
  29339. colorGradingEnabled: boolean;
  29340. private _colorGradingWithGreenDepth;
  29341. /**
  29342. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29343. */
  29344. /**
  29345. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29346. */
  29347. colorGradingWithGreenDepth: boolean;
  29348. private _colorGradingBGR;
  29349. /**
  29350. * Gets wether the color grading texture contains BGR values.
  29351. */
  29352. /**
  29353. * Sets wether the color grading texture contains BGR values.
  29354. */
  29355. colorGradingBGR: boolean;
  29356. /** @hidden */ exposure: number;
  29357. /**
  29358. * Gets the Exposure used in the effect.
  29359. */
  29360. /**
  29361. * Sets the Exposure used in the effect.
  29362. */
  29363. exposure: number;
  29364. private _toneMappingEnabled;
  29365. /**
  29366. * Gets wether the tone mapping effect is enabled.
  29367. */
  29368. /**
  29369. * Sets wether the tone mapping effect is enabled.
  29370. */
  29371. toneMappingEnabled: boolean;
  29372. private _toneMappingType;
  29373. /**
  29374. * Gets the type of tone mapping effect.
  29375. */
  29376. /**
  29377. * Sets the type of tone mapping effect used in BabylonJS.
  29378. */
  29379. toneMappingType: number;
  29380. protected _contrast: number;
  29381. /**
  29382. * Gets the contrast used in the effect.
  29383. */
  29384. /**
  29385. * Sets the contrast used in the effect.
  29386. */
  29387. contrast: number;
  29388. /**
  29389. * Vignette stretch size.
  29390. */
  29391. vignetteStretch: number;
  29392. /**
  29393. * Vignette centre X Offset.
  29394. */
  29395. vignetteCentreX: number;
  29396. /**
  29397. * Vignette centre Y Offset.
  29398. */
  29399. vignetteCentreY: number;
  29400. /**
  29401. * Vignette weight or intensity of the vignette effect.
  29402. */
  29403. vignetteWeight: number;
  29404. /**
  29405. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29406. * if vignetteEnabled is set to true.
  29407. */
  29408. vignetteColor: Color4;
  29409. /**
  29410. * Camera field of view used by the Vignette effect.
  29411. */
  29412. vignetteCameraFov: number;
  29413. private _vignetteBlendMode;
  29414. /**
  29415. * Gets the vignette blend mode allowing different kind of effect.
  29416. */
  29417. /**
  29418. * Sets the vignette blend mode allowing different kind of effect.
  29419. */
  29420. vignetteBlendMode: number;
  29421. private _vignetteEnabled;
  29422. /**
  29423. * Gets wether the vignette effect is enabled.
  29424. */
  29425. /**
  29426. * Sets wether the vignette effect is enabled.
  29427. */
  29428. vignetteEnabled: boolean;
  29429. private _applyByPostProcess;
  29430. /**
  29431. * Gets wether the image processing is applied through a post process or not.
  29432. */
  29433. /**
  29434. * Sets wether the image processing is applied through a post process or not.
  29435. */
  29436. applyByPostProcess: boolean;
  29437. private _isEnabled;
  29438. /**
  29439. * Gets wether the image processing is enabled or not.
  29440. */
  29441. /**
  29442. * Sets wether the image processing is enabled or not.
  29443. */
  29444. isEnabled: boolean;
  29445. /**
  29446. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29447. */
  29448. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29449. /**
  29450. * Method called each time the image processing information changes requires to recompile the effect.
  29451. */
  29452. protected _updateParameters(): void;
  29453. /**
  29454. * Gets the current class name.
  29455. * @return "ImageProcessingConfiguration"
  29456. */
  29457. getClassName(): string;
  29458. /**
  29459. * Prepare the list of uniforms associated with the Image Processing effects.
  29460. * @param uniforms The list of uniforms used in the effect
  29461. * @param defines the list of defines currently in use
  29462. */
  29463. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29464. /**
  29465. * Prepare the list of samplers associated with the Image Processing effects.
  29466. * @param samplersList The list of uniforms used in the effect
  29467. * @param defines the list of defines currently in use
  29468. */
  29469. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29470. /**
  29471. * Prepare the list of defines associated to the shader.
  29472. * @param defines the list of defines to complete
  29473. * @param forPostProcess Define if we are currently in post process mode or not
  29474. */
  29475. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29476. /**
  29477. * Returns true if all the image processing information are ready.
  29478. * @returns True if ready, otherwise, false
  29479. */
  29480. isReady(): boolean;
  29481. /**
  29482. * Binds the image processing to the shader.
  29483. * @param effect The effect to bind to
  29484. * @param aspectRatio Define the current aspect ratio of the effect
  29485. */
  29486. bind(effect: Effect, aspectRatio?: number): void;
  29487. /**
  29488. * Clones the current image processing instance.
  29489. * @return The cloned image processing
  29490. */
  29491. clone(): ImageProcessingConfiguration;
  29492. /**
  29493. * Serializes the current image processing instance to a json representation.
  29494. * @return a JSON representation
  29495. */
  29496. serialize(): any;
  29497. /**
  29498. * Parses the image processing from a json representation.
  29499. * @param source the JSON source to parse
  29500. * @return The parsed image processing
  29501. */
  29502. static Parse(source: any): ImageProcessingConfiguration;
  29503. private static _VIGNETTEMODE_MULTIPLY;
  29504. private static _VIGNETTEMODE_OPAQUE;
  29505. /**
  29506. * Used to apply the vignette as a mix with the pixel color.
  29507. */
  29508. static readonly VIGNETTEMODE_MULTIPLY: number;
  29509. /**
  29510. * Used to apply the vignette as a replacement of the pixel color.
  29511. */
  29512. static readonly VIGNETTEMODE_OPAQUE: number;
  29513. }
  29514. }
  29515. declare module BABYLON {
  29516. /**
  29517. * This represents all the required information to add a fresnel effect on a material:
  29518. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29519. */
  29520. export class FresnelParameters {
  29521. private _isEnabled;
  29522. /**
  29523. * Define if the fresnel effect is enable or not.
  29524. */
  29525. isEnabled: boolean;
  29526. /**
  29527. * Define the color used on edges (grazing angle)
  29528. */
  29529. leftColor: Color3;
  29530. /**
  29531. * Define the color used on center
  29532. */
  29533. rightColor: Color3;
  29534. /**
  29535. * Define bias applied to computed fresnel term
  29536. */
  29537. bias: number;
  29538. /**
  29539. * Defined the power exponent applied to fresnel term
  29540. */
  29541. power: number;
  29542. /**
  29543. * Clones the current fresnel and its valuues
  29544. * @returns a clone fresnel configuration
  29545. */
  29546. clone(): FresnelParameters;
  29547. /**
  29548. * Serializes the current fresnel parameters to a JSON representation.
  29549. * @return the JSON serialization
  29550. */
  29551. serialize(): any;
  29552. /**
  29553. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29554. * @param parsedFresnelParameters Define the JSON representation
  29555. * @returns the parsed parameters
  29556. */
  29557. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29558. }
  29559. }
  29560. declare module BABYLON {
  29561. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29562. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29563. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29564. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29565. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29566. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29567. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29568. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29569. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29570. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29571. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29572. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29573. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29574. /**
  29575. * Decorator used to define property that can be serialized as reference to a camera
  29576. * @param sourceName defines the name of the property to decorate
  29577. */
  29578. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29579. /**
  29580. * Class used to help serialization objects
  29581. */
  29582. export class SerializationHelper {
  29583. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29584. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29585. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29586. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29587. /**
  29588. * Appends the serialized animations from the source animations
  29589. * @param source Source containing the animations
  29590. * @param destination Target to store the animations
  29591. */
  29592. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29593. /**
  29594. * Static function used to serialized a specific entity
  29595. * @param entity defines the entity to serialize
  29596. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29597. * @returns a JSON compatible object representing the serialization of the entity
  29598. */
  29599. static Serialize<T>(entity: T, serializationObject?: any): any;
  29600. /**
  29601. * Creates a new entity from a serialization data object
  29602. * @param creationFunction defines a function used to instanciated the new entity
  29603. * @param source defines the source serialization data
  29604. * @param scene defines the hosting scene
  29605. * @param rootUrl defines the root url for resources
  29606. * @returns a new entity
  29607. */
  29608. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29609. /**
  29610. * Clones an object
  29611. * @param creationFunction defines the function used to instanciate the new object
  29612. * @param source defines the source object
  29613. * @returns the cloned object
  29614. */
  29615. static Clone<T>(creationFunction: () => T, source: T): T;
  29616. /**
  29617. * Instanciates a new object based on a source one (some data will be shared between both object)
  29618. * @param creationFunction defines the function used to instanciate the new object
  29619. * @param source defines the source object
  29620. * @returns the new object
  29621. */
  29622. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29623. }
  29624. }
  29625. declare module BABYLON {
  29626. /**
  29627. * This is the base class of all the camera used in the application.
  29628. * @see http://doc.babylonjs.com/features/cameras
  29629. */
  29630. export class Camera extends Node {
  29631. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29632. /**
  29633. * This is the default projection mode used by the cameras.
  29634. * It helps recreating a feeling of perspective and better appreciate depth.
  29635. * This is the best way to simulate real life cameras.
  29636. */
  29637. static readonly PERSPECTIVE_CAMERA: number;
  29638. /**
  29639. * This helps creating camera with an orthographic mode.
  29640. * 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.
  29641. */
  29642. static readonly ORTHOGRAPHIC_CAMERA: number;
  29643. /**
  29644. * This is the default FOV mode for perspective cameras.
  29645. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29646. */
  29647. static readonly FOVMODE_VERTICAL_FIXED: number;
  29648. /**
  29649. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29650. */
  29651. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29652. /**
  29653. * This specifies ther is no need for a camera rig.
  29654. * Basically only one eye is rendered corresponding to the camera.
  29655. */
  29656. static readonly RIG_MODE_NONE: number;
  29657. /**
  29658. * Simulates a camera Rig with one blue eye and one red eye.
  29659. * This can be use with 3d blue and red glasses.
  29660. */
  29661. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29662. /**
  29663. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29664. */
  29665. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29666. /**
  29667. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29668. */
  29669. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29670. /**
  29671. * Defines that both eyes of the camera will be rendered over under each other.
  29672. */
  29673. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29674. /**
  29675. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29676. */
  29677. static readonly RIG_MODE_VR: number;
  29678. /**
  29679. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29680. */
  29681. static readonly RIG_MODE_WEBVR: number;
  29682. /**
  29683. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29684. */
  29685. static readonly RIG_MODE_CUSTOM: number;
  29686. /**
  29687. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29688. */
  29689. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29690. /**
  29691. * Define the input manager associated with the camera.
  29692. */
  29693. inputs: CameraInputsManager<Camera>;
  29694. /** @hidden */ position: Vector3;
  29695. /**
  29696. * Define the current local position of the camera in the scene
  29697. */
  29698. position: Vector3;
  29699. /**
  29700. * The vector the camera should consider as up.
  29701. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29702. */
  29703. upVector: Vector3;
  29704. /**
  29705. * Define the current limit on the left side for an orthographic camera
  29706. * In scene unit
  29707. */
  29708. orthoLeft: Nullable<number>;
  29709. /**
  29710. * Define the current limit on the right side for an orthographic camera
  29711. * In scene unit
  29712. */
  29713. orthoRight: Nullable<number>;
  29714. /**
  29715. * Define the current limit on the bottom side for an orthographic camera
  29716. * In scene unit
  29717. */
  29718. orthoBottom: Nullable<number>;
  29719. /**
  29720. * Define the current limit on the top side for an orthographic camera
  29721. * In scene unit
  29722. */
  29723. orthoTop: Nullable<number>;
  29724. /**
  29725. * Field Of View is set in Radians. (default is 0.8)
  29726. */
  29727. fov: number;
  29728. /**
  29729. * Define the minimum distance the camera can see from.
  29730. * This is important to note that the depth buffer are not infinite and the closer it starts
  29731. * the more your scene might encounter depth fighting issue.
  29732. */
  29733. minZ: number;
  29734. /**
  29735. * Define the maximum distance the camera can see to.
  29736. * This is important to note that the depth buffer are not infinite and the further it end
  29737. * the more your scene might encounter depth fighting issue.
  29738. */
  29739. maxZ: number;
  29740. /**
  29741. * Define the default inertia of the camera.
  29742. * This helps giving a smooth feeling to the camera movement.
  29743. */
  29744. inertia: number;
  29745. /**
  29746. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29747. */
  29748. mode: number;
  29749. /**
  29750. * Define wether the camera is intermediate.
  29751. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29752. */
  29753. isIntermediate: boolean;
  29754. /**
  29755. * Define the viewport of the camera.
  29756. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29757. */
  29758. viewport: Viewport;
  29759. /**
  29760. * Restricts the camera to viewing objects with the same layerMask.
  29761. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29762. */
  29763. layerMask: number;
  29764. /**
  29765. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29766. */
  29767. fovMode: number;
  29768. /**
  29769. * Rig mode of the camera.
  29770. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29771. * This is normally controlled byt the camera themselves as internal use.
  29772. */
  29773. cameraRigMode: number;
  29774. /**
  29775. * Defines the distance between both "eyes" in case of a RIG
  29776. */
  29777. interaxialDistance: number;
  29778. /**
  29779. * Defines if stereoscopic rendering is done side by side or over under.
  29780. */
  29781. isStereoscopicSideBySide: boolean;
  29782. /**
  29783. * 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
  29784. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29785. * else in the scene.
  29786. */
  29787. customRenderTargets: RenderTargetTexture[];
  29788. /**
  29789. * When set, the camera will render to this render target instead of the default canvas
  29790. */
  29791. outputRenderTarget: Nullable<RenderTargetTexture>;
  29792. /**
  29793. * Observable triggered when the camera view matrix has changed.
  29794. */
  29795. onViewMatrixChangedObservable: Observable<Camera>;
  29796. /**
  29797. * Observable triggered when the camera Projection matrix has changed.
  29798. */
  29799. onProjectionMatrixChangedObservable: Observable<Camera>;
  29800. /**
  29801. * Observable triggered when the inputs have been processed.
  29802. */
  29803. onAfterCheckInputsObservable: Observable<Camera>;
  29804. /**
  29805. * Observable triggered when reset has been called and applied to the camera.
  29806. */
  29807. onRestoreStateObservable: Observable<Camera>;
  29808. /** @hidden */ cameraRigParams: any;
  29809. /** @hidden */ rigCameras: Camera[];
  29810. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29811. protected _webvrViewMatrix: Matrix;
  29812. /** @hidden */ skipRendering: boolean;
  29813. /** @hidden */ projectionMatrix: Matrix;
  29814. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29815. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29816. protected _globalPosition: Vector3;
  29817. /** hidden */ computedViewMatrix: Matrix;
  29818. private _doNotComputeProjectionMatrix;
  29819. private _transformMatrix;
  29820. private _frustumPlanes;
  29821. private _refreshFrustumPlanes;
  29822. private _storedFov;
  29823. private _stateStored;
  29824. /**
  29825. * Instantiates a new camera object.
  29826. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29827. * @see http://doc.babylonjs.com/features/cameras
  29828. * @param name Defines the name of the camera in the scene
  29829. * @param position Defines the position of the camera
  29830. * @param scene Defines the scene the camera belongs too
  29831. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29832. */
  29833. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29834. /**
  29835. * Store current camera state (fov, position, etc..)
  29836. * @returns the camera
  29837. */
  29838. storeState(): Camera;
  29839. /**
  29840. * Restores the camera state values if it has been stored. You must call storeState() first
  29841. */
  29842. protected _restoreStateValues(): boolean;
  29843. /**
  29844. * Restored camera state. You must call storeState() first.
  29845. * @returns true if restored and false otherwise
  29846. */
  29847. restoreState(): boolean;
  29848. /**
  29849. * Gets the class name of the camera.
  29850. * @returns the class name
  29851. */
  29852. getClassName(): string;
  29853. /** @hidden */ protected readonly _isCamera: boolean;
  29854. /**
  29855. * Gets a string representation of the camera useful for debug purpose.
  29856. * @param fullDetails Defines that a more verboe level of logging is required
  29857. * @returns the string representation
  29858. */
  29859. toString(fullDetails?: boolean): string;
  29860. /**
  29861. * Gets the current world space position of the camera.
  29862. */
  29863. readonly globalPosition: Vector3;
  29864. /**
  29865. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29866. * @returns the active meshe list
  29867. */
  29868. getActiveMeshes(): SmartArray<AbstractMesh>;
  29869. /**
  29870. * Check wether a mesh is part of the current active mesh list of the camera
  29871. * @param mesh Defines the mesh to check
  29872. * @returns true if active, false otherwise
  29873. */
  29874. isActiveMesh(mesh: Mesh): boolean;
  29875. /**
  29876. * Is this camera ready to be used/rendered
  29877. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29878. * @return true if the camera is ready
  29879. */
  29880. isReady(completeCheck?: boolean): boolean;
  29881. /** @hidden */ initCache(): void;
  29882. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29883. /** @hidden */ isSynchronized(): boolean;
  29884. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29885. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29886. /**
  29887. * Attach the input controls to a specific dom element to get the input from.
  29888. * @param element Defines the element the controls should be listened from
  29889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29890. */
  29891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29892. /**
  29893. * Detach the current controls from the specified dom element.
  29894. * @param element Defines the element to stop listening the inputs from
  29895. */
  29896. detachControl(element: HTMLElement): void;
  29897. /**
  29898. * Update the camera state according to the different inputs gathered during the frame.
  29899. */
  29900. update(): void;
  29901. /** @hidden */ checkInputs(): void;
  29902. /** @hidden */
  29903. readonly rigCameras: Camera[];
  29904. /**
  29905. * Gets the post process used by the rig cameras
  29906. */
  29907. readonly rigPostProcess: Nullable<PostProcess>;
  29908. /**
  29909. * Internal, gets the first post proces.
  29910. * @returns the first post process to be run on this camera.
  29911. */ getFirstPostProcess(): Nullable<PostProcess>;
  29912. private _cascadePostProcessesToRigCams;
  29913. /**
  29914. * Attach a post process to the camera.
  29915. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29916. * @param postProcess The post process to attach to the camera
  29917. * @param insertAt The position of the post process in case several of them are in use in the scene
  29918. * @returns the position the post process has been inserted at
  29919. */
  29920. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29921. /**
  29922. * Detach a post process to the camera.
  29923. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29924. * @param postProcess The post process to detach from the camera
  29925. */
  29926. detachPostProcess(postProcess: PostProcess): void;
  29927. /**
  29928. * Gets the current world matrix of the camera
  29929. */
  29930. getWorldMatrix(): Matrix;
  29931. /** @hidden */ getViewMatrix(): Matrix;
  29932. /**
  29933. * Gets the current view matrix of the camera.
  29934. * @param force forces the camera to recompute the matrix without looking at the cached state
  29935. * @returns the view matrix
  29936. */
  29937. getViewMatrix(force?: boolean): Matrix;
  29938. /**
  29939. * Freeze the projection matrix.
  29940. * It will prevent the cache check of the camera projection compute and can speed up perf
  29941. * if no parameter of the camera are meant to change
  29942. * @param projection Defines manually a projection if necessary
  29943. */
  29944. freezeProjectionMatrix(projection?: Matrix): void;
  29945. /**
  29946. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29947. */
  29948. unfreezeProjectionMatrix(): void;
  29949. /**
  29950. * Gets the current projection matrix of the camera.
  29951. * @param force forces the camera to recompute the matrix without looking at the cached state
  29952. * @returns the projection matrix
  29953. */
  29954. getProjectionMatrix(force?: boolean): Matrix;
  29955. /**
  29956. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29957. * @returns a Matrix
  29958. */
  29959. getTransformationMatrix(): Matrix;
  29960. private _updateFrustumPlanes;
  29961. /**
  29962. * Checks if a cullable object (mesh...) is in the camera frustum
  29963. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29964. * @param target The object to check
  29965. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29966. * @returns true if the object is in frustum otherwise false
  29967. */
  29968. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29969. /**
  29970. * Checks if a cullable object (mesh...) is in the camera frustum
  29971. * Unlike isInFrustum this cheks the full bounding box
  29972. * @param target The object to check
  29973. * @returns true if the object is in frustum otherwise false
  29974. */
  29975. isCompletelyInFrustum(target: ICullable): boolean;
  29976. /**
  29977. * Gets a ray in the forward direction from the camera.
  29978. * @param length Defines the length of the ray to create
  29979. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29980. * @param origin Defines the start point of the ray which defaults to the camera position
  29981. * @returns the forward ray
  29982. */
  29983. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29984. /**
  29985. * Releases resources associated with this node.
  29986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29988. */
  29989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29990. /** @hidden */ isLeftCamera: boolean;
  29991. /**
  29992. * Gets the left camera of a rig setup in case of Rigged Camera
  29993. */
  29994. readonly isLeftCamera: boolean;
  29995. /** @hidden */ isRightCamera: boolean;
  29996. /**
  29997. * Gets the right camera of a rig setup in case of Rigged Camera
  29998. */
  29999. readonly isRightCamera: boolean;
  30000. /**
  30001. * Gets the left camera of a rig setup in case of Rigged Camera
  30002. */
  30003. readonly leftCamera: Nullable<FreeCamera>;
  30004. /**
  30005. * Gets the right camera of a rig setup in case of Rigged Camera
  30006. */
  30007. readonly rightCamera: Nullable<FreeCamera>;
  30008. /**
  30009. * Gets the left camera target of a rig setup in case of Rigged Camera
  30010. * @returns the target position
  30011. */
  30012. getLeftTarget(): Nullable<Vector3>;
  30013. /**
  30014. * Gets the right camera target of a rig setup in case of Rigged Camera
  30015. * @returns the target position
  30016. */
  30017. getRightTarget(): Nullable<Vector3>;
  30018. /**
  30019. * @hidden
  30020. */
  30021. setCameraRigMode(mode: number, rigParams: any): void;
  30022. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30023. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30024. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30025. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30026. /** @hidden */ getVRProjectionMatrix(): Matrix;
  30027. protected _updateCameraRotationMatrix(): void;
  30028. protected _updateWebVRCameraRotationMatrix(): void;
  30029. /**
  30030. * This function MUST be overwritten by the different WebVR cameras available.
  30031. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30032. * @hidden
  30033. */ getWebVRProjectionMatrix(): Matrix;
  30034. /**
  30035. * This function MUST be overwritten by the different WebVR cameras available.
  30036. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30037. * @hidden
  30038. */ getWebVRViewMatrix(): Matrix;
  30039. /** @hidden */
  30040. setCameraRigParameter(name: string, value: any): void;
  30041. /**
  30042. * needs to be overridden by children so sub has required properties to be copied
  30043. * @hidden
  30044. */
  30045. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30046. /**
  30047. * May need to be overridden by children
  30048. * @hidden
  30049. */ updateRigCameras(): void;
  30050. /** @hidden */ setupInputs(): void;
  30051. /**
  30052. * Serialiaze the camera setup to a json represention
  30053. * @returns the JSON representation
  30054. */
  30055. serialize(): any;
  30056. /**
  30057. * Clones the current camera.
  30058. * @param name The cloned camera name
  30059. * @returns the cloned camera
  30060. */
  30061. clone(name: string): Camera;
  30062. /**
  30063. * Gets the direction of the camera relative to a given local axis.
  30064. * @param localAxis Defines the reference axis to provide a relative direction.
  30065. * @return the direction
  30066. */
  30067. getDirection(localAxis: Vector3): Vector3;
  30068. /**
  30069. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30070. * @param localAxis Defines the reference axis to provide a relative direction.
  30071. * @param result Defines the vector to store the result in
  30072. */
  30073. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30074. /**
  30075. * Gets a camera constructor for a given camera type
  30076. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30077. * @param name The name of the camera the result will be able to instantiate
  30078. * @param scene The scene the result will construct the camera in
  30079. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30080. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30081. * @returns a factory method to construc the camera
  30082. */
  30083. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30084. /**
  30085. * Compute the world matrix of the camera.
  30086. * @returns the camera workd matrix
  30087. */
  30088. computeWorldMatrix(): Matrix;
  30089. /**
  30090. * Parse a JSON and creates the camera from the parsed information
  30091. * @param parsedCamera The JSON to parse
  30092. * @param scene The scene to instantiate the camera in
  30093. * @returns the newly constructed camera
  30094. */
  30095. static Parse(parsedCamera: any, scene: Scene): Camera;
  30096. }
  30097. }
  30098. declare module BABYLON {
  30099. /**
  30100. * Interface for any object that can request an animation frame
  30101. */
  30102. export interface ICustomAnimationFrameRequester {
  30103. /**
  30104. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30105. */
  30106. renderFunction?: Function;
  30107. /**
  30108. * Called to request the next frame to render to
  30109. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30110. */
  30111. requestAnimationFrame: Function;
  30112. /**
  30113. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30114. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30115. */
  30116. requestID?: number;
  30117. }
  30118. /**
  30119. * Interface containing an array of animations
  30120. */
  30121. export interface IAnimatable {
  30122. /**
  30123. * Array of animations
  30124. */
  30125. animations: Nullable<Array<Animation>>;
  30126. }
  30127. /** Interface used by value gradients (color, factor, ...) */
  30128. export interface IValueGradient {
  30129. /**
  30130. * Gets or sets the gradient value (between 0 and 1)
  30131. */
  30132. gradient: number;
  30133. }
  30134. /** Class used to store color4 gradient */
  30135. export class ColorGradient implements IValueGradient {
  30136. /**
  30137. * Gets or sets the gradient value (between 0 and 1)
  30138. */
  30139. gradient: number;
  30140. /**
  30141. * Gets or sets first associated color
  30142. */
  30143. color1: Color4;
  30144. /**
  30145. * Gets or sets second associated color
  30146. */
  30147. color2?: Color4;
  30148. /**
  30149. * Will get a color picked randomly between color1 and color2.
  30150. * If color2 is undefined then color1 will be used
  30151. * @param result defines the target Color4 to store the result in
  30152. */
  30153. getColorToRef(result: Color4): void;
  30154. }
  30155. /** Class used to store color 3 gradient */
  30156. export class Color3Gradient implements IValueGradient {
  30157. /**
  30158. * Gets or sets the gradient value (between 0 and 1)
  30159. */
  30160. gradient: number;
  30161. /**
  30162. * Gets or sets the associated color
  30163. */
  30164. color: Color3;
  30165. }
  30166. /** Class used to store factor gradient */
  30167. export class FactorGradient implements IValueGradient {
  30168. /**
  30169. * Gets or sets the gradient value (between 0 and 1)
  30170. */
  30171. gradient: number;
  30172. /**
  30173. * Gets or sets first associated factor
  30174. */
  30175. factor1: number;
  30176. /**
  30177. * Gets or sets second associated factor
  30178. */
  30179. factor2?: number;
  30180. /**
  30181. * Will get a number picked randomly between factor1 and factor2.
  30182. * If factor2 is undefined then factor1 will be used
  30183. * @returns the picked number
  30184. */
  30185. getFactor(): number;
  30186. }
  30187. /**
  30188. * @ignore
  30189. * Application error to support additional information when loading a file
  30190. */
  30191. export class LoadFileError extends Error {
  30192. /** defines the optional web request */
  30193. request?: WebRequest | undefined;
  30194. private static _setPrototypeOf;
  30195. /**
  30196. * Creates a new LoadFileError
  30197. * @param message defines the message of the error
  30198. * @param request defines the optional web request
  30199. */
  30200. constructor(message: string,
  30201. /** defines the optional web request */
  30202. request?: WebRequest | undefined);
  30203. }
  30204. /**
  30205. * Class used to define a retry strategy when error happens while loading assets
  30206. */
  30207. export class RetryStrategy {
  30208. /**
  30209. * Function used to defines an exponential back off strategy
  30210. * @param maxRetries defines the maximum number of retries (3 by default)
  30211. * @param baseInterval defines the interval between retries
  30212. * @returns the strategy function to use
  30213. */
  30214. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30215. }
  30216. /**
  30217. * File request interface
  30218. */
  30219. export interface IFileRequest {
  30220. /**
  30221. * Raised when the request is complete (success or error).
  30222. */
  30223. onCompleteObservable: Observable<IFileRequest>;
  30224. /**
  30225. * Aborts the request for a file.
  30226. */
  30227. abort: () => void;
  30228. }
  30229. /**
  30230. * Class containing a set of static utilities functions
  30231. */
  30232. export class Tools {
  30233. /**
  30234. * Gets or sets the base URL to use to load assets
  30235. */
  30236. static BaseUrl: string;
  30237. /**
  30238. * Enable/Disable Custom HTTP Request Headers globally.
  30239. * default = false
  30240. * @see CustomRequestHeaders
  30241. */
  30242. static UseCustomRequestHeaders: boolean;
  30243. /**
  30244. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30245. * i.e. when loading files, where the server/service expects an Authorization header
  30246. */
  30247. static CustomRequestHeaders: {
  30248. [key: string]: string;
  30249. };
  30250. /**
  30251. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30252. */
  30253. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30254. /**
  30255. * Default behaviour for cors in the application.
  30256. * It can be a string if the expected behavior is identical in the entire app.
  30257. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30258. */
  30259. static CorsBehavior: string | ((url: string | string[]) => string);
  30260. /**
  30261. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30262. * @ignorenaming
  30263. */
  30264. static UseFallbackTexture: boolean;
  30265. /**
  30266. * Use this object to register external classes like custom textures or material
  30267. * to allow the laoders to instantiate them
  30268. */
  30269. static RegisteredExternalClasses: {
  30270. [key: string]: Object;
  30271. };
  30272. /**
  30273. * Texture content used if a texture cannot loaded
  30274. * @ignorenaming
  30275. */
  30276. static fallbackTexture: string;
  30277. /**
  30278. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30279. * @param u defines the coordinate on X axis
  30280. * @param v defines the coordinate on Y axis
  30281. * @param width defines the width of the source data
  30282. * @param height defines the height of the source data
  30283. * @param pixels defines the source byte array
  30284. * @param color defines the output color
  30285. */
  30286. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30287. /**
  30288. * Interpolates between a and b via alpha
  30289. * @param a The lower value (returned when alpha = 0)
  30290. * @param b The upper value (returned when alpha = 1)
  30291. * @param alpha The interpolation-factor
  30292. * @return The mixed value
  30293. */
  30294. static Mix(a: number, b: number, alpha: number): number;
  30295. /**
  30296. * Tries to instantiate a new object from a given class name
  30297. * @param className defines the class name to instantiate
  30298. * @returns the new object or null if the system was not able to do the instantiation
  30299. */
  30300. static Instantiate(className: string): any;
  30301. /**
  30302. * Provides a slice function that will work even on IE
  30303. * @param data defines the array to slice
  30304. * @param start defines the start of the data (optional)
  30305. * @param end defines the end of the data (optional)
  30306. * @returns the new sliced array
  30307. */
  30308. static Slice<T>(data: T, start?: number, end?: number): T;
  30309. /**
  30310. * Polyfill for setImmediate
  30311. * @param action defines the action to execute after the current execution block
  30312. */
  30313. static SetImmediate(action: () => void): void;
  30314. /**
  30315. * Function indicating if a number is an exponent of 2
  30316. * @param value defines the value to test
  30317. * @returns true if the value is an exponent of 2
  30318. */
  30319. static IsExponentOfTwo(value: number): boolean;
  30320. private static _tmpFloatArray;
  30321. /**
  30322. * Returns the nearest 32-bit single precision float representation of a Number
  30323. * @param value A Number. If the parameter is of a different type, it will get converted
  30324. * to a number or to NaN if it cannot be converted
  30325. * @returns number
  30326. */
  30327. static FloatRound(value: number): number;
  30328. /**
  30329. * Find the next highest power of two.
  30330. * @param x Number to start search from.
  30331. * @return Next highest power of two.
  30332. */
  30333. static CeilingPOT(x: number): number;
  30334. /**
  30335. * Find the next lowest power of two.
  30336. * @param x Number to start search from.
  30337. * @return Next lowest power of two.
  30338. */
  30339. static FloorPOT(x: number): number;
  30340. /**
  30341. * Find the nearest power of two.
  30342. * @param x Number to start search from.
  30343. * @return Next nearest power of two.
  30344. */
  30345. static NearestPOT(x: number): number;
  30346. /**
  30347. * Get the closest exponent of two
  30348. * @param value defines the value to approximate
  30349. * @param max defines the maximum value to return
  30350. * @param mode defines how to define the closest value
  30351. * @returns closest exponent of two of the given value
  30352. */
  30353. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30354. /**
  30355. * Extracts the filename from a path
  30356. * @param path defines the path to use
  30357. * @returns the filename
  30358. */
  30359. static GetFilename(path: string): string;
  30360. /**
  30361. * Extracts the "folder" part of a path (everything before the filename).
  30362. * @param uri The URI to extract the info from
  30363. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30364. * @returns The "folder" part of the path
  30365. */
  30366. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30367. /**
  30368. * Extracts text content from a DOM element hierarchy
  30369. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30370. */
  30371. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30372. /**
  30373. * Convert an angle in radians to degrees
  30374. * @param angle defines the angle to convert
  30375. * @returns the angle in degrees
  30376. */
  30377. static ToDegrees(angle: number): number;
  30378. /**
  30379. * Convert an angle in degrees to radians
  30380. * @param angle defines the angle to convert
  30381. * @returns the angle in radians
  30382. */
  30383. static ToRadians(angle: number): number;
  30384. /**
  30385. * Encode a buffer to a base64 string
  30386. * @param buffer defines the buffer to encode
  30387. * @returns the encoded string
  30388. */
  30389. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30390. /**
  30391. * Extracts minimum and maximum values from a list of indexed positions
  30392. * @param positions defines the positions to use
  30393. * @param indices defines the indices to the positions
  30394. * @param indexStart defines the start index
  30395. * @param indexCount defines the end index
  30396. * @param bias defines bias value to add to the result
  30397. * @return minimum and maximum values
  30398. */
  30399. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30400. minimum: Vector3;
  30401. maximum: Vector3;
  30402. };
  30403. /**
  30404. * Extracts minimum and maximum values from a list of positions
  30405. * @param positions defines the positions to use
  30406. * @param start defines the start index in the positions array
  30407. * @param count defines the number of positions to handle
  30408. * @param bias defines bias value to add to the result
  30409. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30410. * @return minimum and maximum values
  30411. */
  30412. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30413. minimum: Vector3;
  30414. maximum: Vector3;
  30415. };
  30416. /**
  30417. * Returns an array if obj is not an array
  30418. * @param obj defines the object to evaluate as an array
  30419. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30420. * @returns either obj directly if obj is an array or a new array containing obj
  30421. */
  30422. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30423. /**
  30424. * Gets the pointer prefix to use
  30425. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30426. */
  30427. static GetPointerPrefix(): string;
  30428. /**
  30429. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30430. * @param func - the function to be called
  30431. * @param requester - the object that will request the next frame. Falls back to window.
  30432. * @returns frame number
  30433. */
  30434. static QueueNewFrame(func: () => void, requester?: any): number;
  30435. /**
  30436. * Ask the browser to promote the current element to fullscreen rendering mode
  30437. * @param element defines the DOM element to promote
  30438. */
  30439. static RequestFullscreen(element: HTMLElement): void;
  30440. /**
  30441. * Asks the browser to exit fullscreen mode
  30442. */
  30443. static ExitFullscreen(): void;
  30444. /**
  30445. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30446. * @param url define the url we are trying
  30447. * @param element define the dom element where to configure the cors policy
  30448. */
  30449. static SetCorsBehavior(url: string | string[], element: {
  30450. crossOrigin: string | null;
  30451. }): void;
  30452. /**
  30453. * Removes unwanted characters from an url
  30454. * @param url defines the url to clean
  30455. * @returns the cleaned url
  30456. */
  30457. static CleanUrl(url: string): string;
  30458. /**
  30459. * Gets or sets a function used to pre-process url before using them to load assets
  30460. */
  30461. static PreprocessUrl: (url: string) => string;
  30462. /**
  30463. * Loads an image as an HTMLImageElement.
  30464. * @param input url string, ArrayBuffer, or Blob to load
  30465. * @param onLoad callback called when the image successfully loads
  30466. * @param onError callback called when the image fails to load
  30467. * @param offlineProvider offline provider for caching
  30468. * @returns the HTMLImageElement of the loaded image
  30469. */
  30470. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30471. /**
  30472. * Loads a file
  30473. * @param url url string, ArrayBuffer, or Blob to load
  30474. * @param onSuccess callback called when the file successfully loads
  30475. * @param onProgress callback called while file is loading (if the server supports this mode)
  30476. * @param offlineProvider defines the offline provider for caching
  30477. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30478. * @param onError callback called when the file fails to load
  30479. * @returns a file request object
  30480. */
  30481. 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;
  30482. /**
  30483. * Load a script (identified by an url). When the url returns, the
  30484. * content of this file is added into a new script element, attached to the DOM (body element)
  30485. * @param scriptUrl defines the url of the script to laod
  30486. * @param onSuccess defines the callback called when the script is loaded
  30487. * @param onError defines the callback to call if an error occurs
  30488. * @param scriptId defines the id of the script element
  30489. */
  30490. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30491. /**
  30492. * Load an asynchronous script (identified by an url). When the url returns, the
  30493. * content of this file is added into a new script element, attached to the DOM (body element)
  30494. * @param scriptUrl defines the url of the script to laod
  30495. * @param scriptId defines the id of the script element
  30496. * @returns a promise request object
  30497. */
  30498. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30499. /**
  30500. * Loads a file from a blob
  30501. * @param fileToLoad defines the blob to use
  30502. * @param callback defines the callback to call when data is loaded
  30503. * @param progressCallback defines the callback to call during loading process
  30504. * @returns a file request object
  30505. */
  30506. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30507. /**
  30508. * Loads a file
  30509. * @param fileToLoad defines the file to load
  30510. * @param callback defines the callback to call when data is loaded
  30511. * @param progressCallBack defines the callback to call during loading process
  30512. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30513. * @returns a file request object
  30514. */
  30515. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30516. /**
  30517. * Creates a data url from a given string content
  30518. * @param content defines the content to convert
  30519. * @returns the new data url link
  30520. */
  30521. static FileAsURL(content: string): string;
  30522. /**
  30523. * Format the given number to a specific decimal format
  30524. * @param value defines the number to format
  30525. * @param decimals defines the number of decimals to use
  30526. * @returns the formatted string
  30527. */
  30528. static Format(value: number, decimals?: number): string;
  30529. /**
  30530. * Checks if a given vector is inside a specific range
  30531. * @param v defines the vector to test
  30532. * @param min defines the minimum range
  30533. * @param max defines the maximum range
  30534. */
  30535. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30536. /**
  30537. * Tries to copy an object by duplicating every property
  30538. * @param source defines the source object
  30539. * @param destination defines the target object
  30540. * @param doNotCopyList defines a list of properties to avoid
  30541. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30542. */
  30543. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30544. /**
  30545. * Gets a boolean indicating if the given object has no own property
  30546. * @param obj defines the object to test
  30547. * @returns true if object has no own property
  30548. */
  30549. static IsEmpty(obj: any): boolean;
  30550. /**
  30551. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30552. * @param str Source string
  30553. * @param suffix Suffix to search for in the source string
  30554. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30555. */
  30556. static EndsWith(str: string, suffix: string): boolean;
  30557. /**
  30558. * Function used to register events at window level
  30559. * @param events defines the events to register
  30560. */
  30561. static RegisterTopRootEvents(events: {
  30562. name: string;
  30563. handler: Nullable<(e: FocusEvent) => any>;
  30564. }[]): void;
  30565. /**
  30566. * Function used to unregister events from window level
  30567. * @param events defines the events to unregister
  30568. */
  30569. static UnregisterTopRootEvents(events: {
  30570. name: string;
  30571. handler: Nullable<(e: FocusEvent) => any>;
  30572. }[]): void;
  30573. /**
  30574. * @ignore
  30575. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30576. /**
  30577. * Dumps the current bound framebuffer
  30578. * @param width defines the rendering width
  30579. * @param height defines the rendering height
  30580. * @param engine defines the hosting engine
  30581. * @param successCallback defines the callback triggered once the data are available
  30582. * @param mimeType defines the mime type of the result
  30583. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30584. */
  30585. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30586. /**
  30587. * Converts the canvas data to blob.
  30588. * This acts as a polyfill for browsers not supporting the to blob function.
  30589. * @param canvas Defines the canvas to extract the data from
  30590. * @param successCallback Defines the callback triggered once the data are available
  30591. * @param mimeType Defines the mime type of the result
  30592. */
  30593. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30594. /**
  30595. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30596. * @param successCallback defines the callback triggered once the data are available
  30597. * @param mimeType defines the mime type of the result
  30598. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30599. */
  30600. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30601. /**
  30602. * Downloads a blob in the browser
  30603. * @param blob defines the blob to download
  30604. * @param fileName defines the name of the downloaded file
  30605. */
  30606. static Download(blob: Blob, fileName: string): void;
  30607. /**
  30608. * Captures a screenshot of the current rendering
  30609. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30610. * @param engine defines the rendering engine
  30611. * @param camera defines the source camera
  30612. * @param size This parameter can be set to a single number or to an object with the
  30613. * following (optional) properties: precision, width, height. If a single number is passed,
  30614. * it will be used for both width and height. If an object is passed, the screenshot size
  30615. * will be derived from the parameters. The precision property is a multiplier allowing
  30616. * rendering at a higher or lower resolution
  30617. * @param successCallback defines the callback receives a single parameter which contains the
  30618. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30619. * src parameter of an <img> to display it
  30620. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30621. * Check your browser for supported MIME types
  30622. */
  30623. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30624. /**
  30625. * Generates an image screenshot from the specified camera.
  30626. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30627. * @param engine The engine to use for rendering
  30628. * @param camera The camera to use for rendering
  30629. * @param size This parameter can be set to a single number or to an object with the
  30630. * following (optional) properties: precision, width, height. If a single number is passed,
  30631. * it will be used for both width and height. If an object is passed, the screenshot size
  30632. * will be derived from the parameters. The precision property is a multiplier allowing
  30633. * rendering at a higher or lower resolution
  30634. * @param successCallback The callback receives a single parameter which contains the
  30635. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30636. * src parameter of an <img> to display it
  30637. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30638. * Check your browser for supported MIME types
  30639. * @param samples Texture samples (default: 1)
  30640. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30641. * @param fileName A name for for the downloaded file.
  30642. */
  30643. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30644. /**
  30645. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30646. * Be aware Math.random() could cause collisions, but:
  30647. * "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"
  30648. * @returns a pseudo random id
  30649. */
  30650. static RandomId(): string;
  30651. /**
  30652. * Test if the given uri is a base64 string
  30653. * @param uri The uri to test
  30654. * @return True if the uri is a base64 string or false otherwise
  30655. */
  30656. static IsBase64(uri: string): boolean;
  30657. /**
  30658. * Decode the given base64 uri.
  30659. * @param uri The uri to decode
  30660. * @return The decoded base64 data.
  30661. */
  30662. static DecodeBase64(uri: string): ArrayBuffer;
  30663. /**
  30664. * Gets the absolute url.
  30665. * @param url the input url
  30666. * @return the absolute url
  30667. */
  30668. static GetAbsoluteUrl(url: string): string;
  30669. /**
  30670. * No log
  30671. */
  30672. static readonly NoneLogLevel: number;
  30673. /**
  30674. * Only message logs
  30675. */
  30676. static readonly MessageLogLevel: number;
  30677. /**
  30678. * Only warning logs
  30679. */
  30680. static readonly WarningLogLevel: number;
  30681. /**
  30682. * Only error logs
  30683. */
  30684. static readonly ErrorLogLevel: number;
  30685. /**
  30686. * All logs
  30687. */
  30688. static readonly AllLogLevel: number;
  30689. /**
  30690. * Gets a value indicating the number of loading errors
  30691. * @ignorenaming
  30692. */
  30693. static readonly errorsCount: number;
  30694. /**
  30695. * Callback called when a new log is added
  30696. */
  30697. static OnNewCacheEntry: (entry: string) => void;
  30698. /**
  30699. * Log a message to the console
  30700. * @param message defines the message to log
  30701. */
  30702. static Log(message: string): void;
  30703. /**
  30704. * Write a warning message to the console
  30705. * @param message defines the message to log
  30706. */
  30707. static Warn(message: string): void;
  30708. /**
  30709. * Write an error message to the console
  30710. * @param message defines the message to log
  30711. */
  30712. static Error(message: string): void;
  30713. /**
  30714. * Gets current log cache (list of logs)
  30715. */
  30716. static readonly LogCache: string;
  30717. /**
  30718. * Clears the log cache
  30719. */
  30720. static ClearLogCache(): void;
  30721. /**
  30722. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30723. */
  30724. static LogLevels: number;
  30725. /**
  30726. * Checks if the loaded document was accessed via `file:`-Protocol.
  30727. * @returns boolean
  30728. */
  30729. static IsFileURL(): boolean;
  30730. /**
  30731. * Checks if the window object exists
  30732. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30733. */
  30734. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30735. /**
  30736. * No performance log
  30737. */
  30738. static readonly PerformanceNoneLogLevel: number;
  30739. /**
  30740. * Use user marks to log performance
  30741. */
  30742. static readonly PerformanceUserMarkLogLevel: number;
  30743. /**
  30744. * Log performance to the console
  30745. */
  30746. static readonly PerformanceConsoleLogLevel: number;
  30747. private static _performance;
  30748. /**
  30749. * Sets the current performance log level
  30750. */
  30751. static PerformanceLogLevel: number;
  30752. private static _StartPerformanceCounterDisabled;
  30753. private static _EndPerformanceCounterDisabled;
  30754. private static _StartUserMark;
  30755. private static _EndUserMark;
  30756. private static _StartPerformanceConsole;
  30757. private static _EndPerformanceConsole;
  30758. /**
  30759. * Starts a performance counter
  30760. */
  30761. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30762. /**
  30763. * Ends a specific performance coutner
  30764. */
  30765. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30766. /**
  30767. * Gets either window.performance.now() if supported or Date.now() else
  30768. */
  30769. static readonly Now: number;
  30770. /**
  30771. * This method will return the name of the class used to create the instance of the given object.
  30772. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30773. * @param object the object to get the class name from
  30774. * @param isType defines if the object is actually a type
  30775. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30776. */
  30777. static GetClassName(object: any, isType?: boolean): string;
  30778. /**
  30779. * Gets the first element of an array satisfying a given predicate
  30780. * @param array defines the array to browse
  30781. * @param predicate defines the predicate to use
  30782. * @returns null if not found or the element
  30783. */
  30784. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30785. /**
  30786. * This method will return the name of the full name of the class, including its owning module (if any).
  30787. * 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).
  30788. * @param object the object to get the class name from
  30789. * @param isType defines if the object is actually a type
  30790. * @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.
  30791. * @ignorenaming
  30792. */
  30793. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30794. /**
  30795. * Returns a promise that resolves after the given amount of time.
  30796. * @param delay Number of milliseconds to delay
  30797. * @returns Promise that resolves after the given amount of time
  30798. */
  30799. static DelayAsync(delay: number): Promise<void>;
  30800. /**
  30801. * Gets the current gradient from an array of IValueGradient
  30802. * @param ratio defines the current ratio to get
  30803. * @param gradients defines the array of IValueGradient
  30804. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30805. */
  30806. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30807. }
  30808. /**
  30809. * This class is used to track a performance counter which is number based.
  30810. * The user has access to many properties which give statistics of different nature.
  30811. *
  30812. * The implementer can track two kinds of Performance Counter: time and count.
  30813. * 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.
  30814. * 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.
  30815. */
  30816. export class PerfCounter {
  30817. /**
  30818. * Gets or sets a global boolean to turn on and off all the counters
  30819. */
  30820. static Enabled: boolean;
  30821. /**
  30822. * Returns the smallest value ever
  30823. */
  30824. readonly min: number;
  30825. /**
  30826. * Returns the biggest value ever
  30827. */
  30828. readonly max: number;
  30829. /**
  30830. * Returns the average value since the performance counter is running
  30831. */
  30832. readonly average: number;
  30833. /**
  30834. * Returns the average value of the last second the counter was monitored
  30835. */
  30836. readonly lastSecAverage: number;
  30837. /**
  30838. * Returns the current value
  30839. */
  30840. readonly current: number;
  30841. /**
  30842. * Gets the accumulated total
  30843. */
  30844. readonly total: number;
  30845. /**
  30846. * Gets the total value count
  30847. */
  30848. readonly count: number;
  30849. /**
  30850. * Creates a new counter
  30851. */
  30852. constructor();
  30853. /**
  30854. * Call this method to start monitoring a new frame.
  30855. * 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.
  30856. */
  30857. fetchNewFrame(): void;
  30858. /**
  30859. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30860. * @param newCount the count value to add to the monitored count
  30861. * @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.
  30862. */
  30863. addCount(newCount: number, fetchResult: boolean): void;
  30864. /**
  30865. * Start monitoring this performance counter
  30866. */
  30867. beginMonitoring(): void;
  30868. /**
  30869. * Compute the time lapsed since the previous beginMonitoring() call.
  30870. * @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
  30871. */
  30872. endMonitoring(newFrame?: boolean): void;
  30873. private _fetchResult;
  30874. private _startMonitoringTime;
  30875. private _min;
  30876. private _max;
  30877. private _average;
  30878. private _current;
  30879. private _totalValueCount;
  30880. private _totalAccumulated;
  30881. private _lastSecAverage;
  30882. private _lastSecAccumulated;
  30883. private _lastSecTime;
  30884. private _lastSecValueCount;
  30885. }
  30886. /**
  30887. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30888. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30889. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30890. * @param name The name of the class, case should be preserved
  30891. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30892. */
  30893. export function className(name: string, module?: string): (target: Object) => void;
  30894. /**
  30895. * An implementation of a loop for asynchronous functions.
  30896. */
  30897. export class AsyncLoop {
  30898. /**
  30899. * Defines the number of iterations for the loop
  30900. */
  30901. iterations: number;
  30902. /**
  30903. * Defines the current index of the loop.
  30904. */
  30905. index: number;
  30906. private _done;
  30907. private _fn;
  30908. private _successCallback;
  30909. /**
  30910. * Constructor.
  30911. * @param iterations the number of iterations.
  30912. * @param func the function to run each iteration
  30913. * @param successCallback the callback that will be called upon succesful execution
  30914. * @param offset starting offset.
  30915. */
  30916. constructor(
  30917. /**
  30918. * Defines the number of iterations for the loop
  30919. */
  30920. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30921. /**
  30922. * Execute the next iteration. Must be called after the last iteration was finished.
  30923. */
  30924. executeNext(): void;
  30925. /**
  30926. * Break the loop and run the success callback.
  30927. */
  30928. breakLoop(): void;
  30929. /**
  30930. * Create and run an async loop.
  30931. * @param iterations the number of iterations.
  30932. * @param fn the function to run each iteration
  30933. * @param successCallback the callback that will be called upon succesful execution
  30934. * @param offset starting offset.
  30935. * @returns the created async loop object
  30936. */
  30937. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30938. /**
  30939. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30940. * @param iterations total number of iterations
  30941. * @param syncedIterations number of synchronous iterations in each async iteration.
  30942. * @param fn the function to call each iteration.
  30943. * @param callback a success call back that will be called when iterating stops.
  30944. * @param breakFunction a break condition (optional)
  30945. * @param timeout timeout settings for the setTimeout function. default - 0.
  30946. * @returns the created async loop object
  30947. */
  30948. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30949. }
  30950. }
  30951. declare module BABYLON {
  30952. /** @hidden */
  30953. export interface ICollisionCoordinator {
  30954. createCollider(): Collider;
  30955. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30956. init(scene: Scene): void;
  30957. }
  30958. /** @hidden */
  30959. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30960. private _scene;
  30961. private _scaledPosition;
  30962. private _scaledVelocity;
  30963. private _finalPosition;
  30964. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30965. createCollider(): Collider;
  30966. init(scene: Scene): void;
  30967. private _collideWithWorld;
  30968. }
  30969. }
  30970. declare module BABYLON {
  30971. /**
  30972. * Class used to manage all inputs for the scene.
  30973. */
  30974. export class InputManager {
  30975. /** The distance in pixel that you have to move to prevent some events */
  30976. static DragMovementThreshold: number;
  30977. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  30978. static LongPressDelay: number;
  30979. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  30980. static DoubleClickDelay: number;
  30981. /** If you need to check double click without raising a single click at first click, enable this flag */
  30982. static ExclusiveDoubleClickMode: boolean;
  30983. private _wheelEventName;
  30984. private _onPointerMove;
  30985. private _onPointerDown;
  30986. private _onPointerUp;
  30987. private _initClickEvent;
  30988. private _initActionManager;
  30989. private _delayedSimpleClick;
  30990. private _delayedSimpleClickTimeout;
  30991. private _previousDelayedSimpleClickTimeout;
  30992. private _meshPickProceed;
  30993. private _previousButtonPressed;
  30994. private _currentPickResult;
  30995. private _previousPickResult;
  30996. private _totalPointersPressed;
  30997. private _doubleClickOccured;
  30998. private _pointerOverMesh;
  30999. private _pickedDownMesh;
  31000. private _pickedUpMesh;
  31001. private _pointerX;
  31002. private _pointerY;
  31003. private _unTranslatedPointerX;
  31004. private _unTranslatedPointerY;
  31005. private _startingPointerPosition;
  31006. private _previousStartingPointerPosition;
  31007. private _startingPointerTime;
  31008. private _previousStartingPointerTime;
  31009. private _pointerCaptures;
  31010. private _onKeyDown;
  31011. private _onKeyUp;
  31012. private _onCanvasFocusObserver;
  31013. private _onCanvasBlurObserver;
  31014. private _scene;
  31015. /**
  31016. * Creates a new InputManager
  31017. * @param scene defines the hosting scene
  31018. */
  31019. constructor(scene: Scene);
  31020. /**
  31021. * Gets the mesh that is currently under the pointer
  31022. */
  31023. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31024. /**
  31025. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31026. */
  31027. readonly unTranslatedPointer: Vector2;
  31028. /**
  31029. * Gets or sets the current on-screen X position of the pointer
  31030. */
  31031. pointerX: number;
  31032. /**
  31033. * Gets or sets the current on-screen Y position of the pointer
  31034. */
  31035. pointerY: number;
  31036. private _updatePointerPosition;
  31037. private _processPointerMove;
  31038. private _setRayOnPointerInfo;
  31039. private _checkPrePointerObservable;
  31040. /**
  31041. * Use this method to simulate a pointer move on a mesh
  31042. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31043. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31044. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31045. */
  31046. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31047. /**
  31048. * Use this method to simulate a pointer down on a mesh
  31049. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31050. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31051. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31052. */
  31053. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31054. private _processPointerDown;
  31055. /** @hidden */ isPointerSwiping(): boolean;
  31056. /**
  31057. * Use this method to simulate a pointer up on a mesh
  31058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31061. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31062. */
  31063. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31064. private _processPointerUp;
  31065. /**
  31066. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31067. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31068. * @returns true if the pointer was captured
  31069. */
  31070. isPointerCaptured(pointerId?: number): boolean;
  31071. /**
  31072. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31073. * @param attachUp defines if you want to attach events to pointerup
  31074. * @param attachDown defines if you want to attach events to pointerdown
  31075. * @param attachMove defines if you want to attach events to pointermove
  31076. */
  31077. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31078. /**
  31079. * Detaches all event handlers
  31080. */
  31081. detachControl(): void;
  31082. /**
  31083. * Force the value of meshUnderPointer
  31084. * @param mesh defines the mesh to use
  31085. */
  31086. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31087. /**
  31088. * Gets the mesh under the pointer
  31089. * @returns a Mesh or null if no mesh is under the pointer
  31090. */
  31091. getPointerOverMesh(): Nullable<AbstractMesh>;
  31092. }
  31093. }
  31094. declare module BABYLON {
  31095. /**
  31096. * This class defines the direct association between an animation and a target
  31097. */
  31098. export class TargetedAnimation {
  31099. /**
  31100. * Animation to perform
  31101. */
  31102. animation: Animation;
  31103. /**
  31104. * Target to animate
  31105. */
  31106. target: any;
  31107. }
  31108. /**
  31109. * Use this class to create coordinated animations on multiple targets
  31110. */
  31111. export class AnimationGroup implements IDisposable {
  31112. /** The name of the animation group */
  31113. name: string;
  31114. private _scene;
  31115. private _targetedAnimations;
  31116. private _animatables;
  31117. private _from;
  31118. private _to;
  31119. private _isStarted;
  31120. private _isPaused;
  31121. private _speedRatio;
  31122. /**
  31123. * Gets or sets the unique id of the node
  31124. */
  31125. uniqueId: number;
  31126. /**
  31127. * This observable will notify when one animation have ended
  31128. */
  31129. onAnimationEndObservable: Observable<TargetedAnimation>;
  31130. /**
  31131. * Observer raised when one animation loops
  31132. */
  31133. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31134. /**
  31135. * This observable will notify when all animations have ended.
  31136. */
  31137. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31138. /**
  31139. * This observable will notify when all animations have paused.
  31140. */
  31141. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31142. /**
  31143. * This observable will notify when all animations are playing.
  31144. */
  31145. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31146. /**
  31147. * Gets the first frame
  31148. */
  31149. readonly from: number;
  31150. /**
  31151. * Gets the last frame
  31152. */
  31153. readonly to: number;
  31154. /**
  31155. * Define if the animations are started
  31156. */
  31157. readonly isStarted: boolean;
  31158. /**
  31159. * Gets a value indicating that the current group is playing
  31160. */
  31161. readonly isPlaying: boolean;
  31162. /**
  31163. * Gets or sets the speed ratio to use for all animations
  31164. */
  31165. /**
  31166. * Gets or sets the speed ratio to use for all animations
  31167. */
  31168. speedRatio: number;
  31169. /**
  31170. * Gets the targeted animations for this animation group
  31171. */
  31172. readonly targetedAnimations: Array<TargetedAnimation>;
  31173. /**
  31174. * returning the list of animatables controlled by this animation group.
  31175. */
  31176. readonly animatables: Array<Animatable>;
  31177. /**
  31178. * Instantiates a new Animation Group.
  31179. * This helps managing several animations at once.
  31180. * @see http://doc.babylonjs.com/how_to/group
  31181. * @param name Defines the name of the group
  31182. * @param scene Defines the scene the group belongs to
  31183. */
  31184. constructor(
  31185. /** The name of the animation group */
  31186. name: string, scene?: Nullable<Scene>);
  31187. /**
  31188. * Add an animation (with its target) in the group
  31189. * @param animation defines the animation we want to add
  31190. * @param target defines the target of the animation
  31191. * @returns the TargetedAnimation object
  31192. */
  31193. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31194. /**
  31195. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31196. * It can add constant keys at begin or end
  31197. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31198. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31199. * @returns the animation group
  31200. */
  31201. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31202. /**
  31203. * Start all animations on given targets
  31204. * @param loop defines if animations must loop
  31205. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31206. * @param from defines the from key (optional)
  31207. * @param to defines the to key (optional)
  31208. * @returns the current animation group
  31209. */
  31210. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31211. /**
  31212. * Pause all animations
  31213. * @returns the animation group
  31214. */
  31215. pause(): AnimationGroup;
  31216. /**
  31217. * Play all animations to initial state
  31218. * This function will start() the animations if they were not started or will restart() them if they were paused
  31219. * @param loop defines if animations must loop
  31220. * @returns the animation group
  31221. */
  31222. play(loop?: boolean): AnimationGroup;
  31223. /**
  31224. * Reset all animations to initial state
  31225. * @returns the animation group
  31226. */
  31227. reset(): AnimationGroup;
  31228. /**
  31229. * Restart animations from key 0
  31230. * @returns the animation group
  31231. */
  31232. restart(): AnimationGroup;
  31233. /**
  31234. * Stop all animations
  31235. * @returns the animation group
  31236. */
  31237. stop(): AnimationGroup;
  31238. /**
  31239. * Set animation weight for all animatables
  31240. * @param weight defines the weight to use
  31241. * @return the animationGroup
  31242. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31243. */
  31244. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31245. /**
  31246. * Synchronize and normalize all animatables with a source animatable
  31247. * @param root defines the root animatable to synchronize with
  31248. * @return the animationGroup
  31249. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31250. */
  31251. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31252. /**
  31253. * Goes to a specific frame in this animation group
  31254. * @param frame the frame number to go to
  31255. * @return the animationGroup
  31256. */
  31257. goToFrame(frame: number): AnimationGroup;
  31258. /**
  31259. * Dispose all associated resources
  31260. */
  31261. dispose(): void;
  31262. private _checkAnimationGroupEnded;
  31263. /**
  31264. * Clone the current animation group and returns a copy
  31265. * @param newName defines the name of the new group
  31266. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31267. * @returns the new aniamtion group
  31268. */
  31269. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31270. /**
  31271. * Returns a new AnimationGroup object parsed from the source provided.
  31272. * @param parsedAnimationGroup defines the source
  31273. * @param scene defines the scene that will receive the animationGroup
  31274. * @returns a new AnimationGroup
  31275. */
  31276. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31277. /**
  31278. * Returns the string "AnimationGroup"
  31279. * @returns "AnimationGroup"
  31280. */
  31281. getClassName(): string;
  31282. /**
  31283. * Creates a detailled string about the object
  31284. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31285. * @returns a string representing the object
  31286. */
  31287. toString(fullDetails?: boolean): string;
  31288. }
  31289. }
  31290. declare module BABYLON {
  31291. /**
  31292. * Define an interface for all classes that will hold resources
  31293. */
  31294. export interface IDisposable {
  31295. /**
  31296. * Releases all held resources
  31297. */
  31298. dispose(): void;
  31299. }
  31300. /** Interface defining initialization parameters for Scene class */
  31301. export interface SceneOptions {
  31302. /**
  31303. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31304. * It will improve performance when the number of geometries becomes important.
  31305. */
  31306. useGeometryUniqueIdsMap?: boolean;
  31307. /**
  31308. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31309. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31310. */
  31311. useMaterialMeshMap?: boolean;
  31312. /**
  31313. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31314. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31315. */
  31316. useClonedMeshhMap?: boolean;
  31317. }
  31318. /**
  31319. * Represents a scene to be rendered by the engine.
  31320. * @see http://doc.babylonjs.com/features/scene
  31321. */
  31322. export class Scene extends AbstractScene implements IAnimatable {
  31323. private static _uniqueIdCounter;
  31324. /** The fog is deactivated */
  31325. static readonly FOGMODE_NONE: number;
  31326. /** The fog density is following an exponential function */
  31327. static readonly FOGMODE_EXP: number;
  31328. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31329. static readonly FOGMODE_EXP2: number;
  31330. /** The fog density is following a linear function. */
  31331. static readonly FOGMODE_LINEAR: number;
  31332. /**
  31333. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31334. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31335. */
  31336. static MinDeltaTime: number;
  31337. /**
  31338. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31339. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31340. */
  31341. static MaxDeltaTime: number;
  31342. /**
  31343. * Factory used to create the default material.
  31344. * @param name The name of the material to create
  31345. * @param scene The scene to create the material for
  31346. * @returns The default material
  31347. */
  31348. static DefaultMaterialFactory(scene: Scene): Material;
  31349. /**
  31350. * Factory used to create the a collision coordinator.
  31351. * @returns The collision coordinator
  31352. */
  31353. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31354. /** @hidden */ inputManager: InputManager;
  31355. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31356. cameraToUseForPointers: Nullable<Camera>;
  31357. /** @hidden */ protected readonly _isScene: boolean;
  31358. /**
  31359. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31360. */
  31361. autoClear: boolean;
  31362. /**
  31363. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31364. */
  31365. autoClearDepthAndStencil: boolean;
  31366. /**
  31367. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31368. */
  31369. clearColor: Color4;
  31370. /**
  31371. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31372. */
  31373. ambientColor: Color3;
  31374. /**
  31375. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31376. * It should only be one of the following (if not the default embedded one):
  31377. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31378. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31379. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31380. * The material properties need to be setup according to the type of texture in use.
  31381. */
  31382. environmentBRDFTexture: BaseTexture;
  31383. /** @hidden */
  31384. protected _environmentTexture: Nullable<BaseTexture>;
  31385. /**
  31386. * Texture used in all pbr material as the reflection texture.
  31387. * As in the majority of the scene they are the same (exception for multi room and so on),
  31388. * this is easier to reference from here than from all the materials.
  31389. */
  31390. /**
  31391. * Texture used in all pbr material as the reflection texture.
  31392. * As in the majority of the scene they are the same (exception for multi room and so on),
  31393. * this is easier to set here than in all the materials.
  31394. */
  31395. environmentTexture: Nullable<BaseTexture>;
  31396. /** @hidden */
  31397. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31398. /**
  31399. * Default image processing configuration used either in the rendering
  31400. * Forward main pass or through the imageProcessingPostProcess if present.
  31401. * As in the majority of the scene they are the same (exception for multi camera),
  31402. * this is easier to reference from here than from all the materials and post process.
  31403. *
  31404. * No setter as we it is a shared configuration, you can set the values instead.
  31405. */
  31406. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31407. private _forceWireframe;
  31408. /**
  31409. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31410. */
  31411. forceWireframe: boolean;
  31412. private _forcePointsCloud;
  31413. /**
  31414. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31415. */
  31416. forcePointsCloud: boolean;
  31417. /**
  31418. * Gets or sets the active clipplane 1
  31419. */
  31420. clipPlane: Nullable<Plane>;
  31421. /**
  31422. * Gets or sets the active clipplane 2
  31423. */
  31424. clipPlane2: Nullable<Plane>;
  31425. /**
  31426. * Gets or sets the active clipplane 3
  31427. */
  31428. clipPlane3: Nullable<Plane>;
  31429. /**
  31430. * Gets or sets the active clipplane 4
  31431. */
  31432. clipPlane4: Nullable<Plane>;
  31433. /**
  31434. * Gets or sets a boolean indicating if animations are enabled
  31435. */
  31436. animationsEnabled: boolean;
  31437. private _animationPropertiesOverride;
  31438. /**
  31439. * Gets or sets the animation properties override
  31440. */
  31441. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31442. /**
  31443. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31444. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31445. */
  31446. useConstantAnimationDeltaTime: boolean;
  31447. /**
  31448. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31449. * Please note that it requires to run a ray cast through the scene on every frame
  31450. */
  31451. constantlyUpdateMeshUnderPointer: boolean;
  31452. /**
  31453. * Defines the HTML cursor to use when hovering over interactive elements
  31454. */
  31455. hoverCursor: string;
  31456. /**
  31457. * Defines the HTML default cursor to use (empty by default)
  31458. */
  31459. defaultCursor: string;
  31460. /**
  31461. * This is used to call preventDefault() on pointer down
  31462. * in order to block unwanted artifacts like system double clicks
  31463. */
  31464. preventDefaultOnPointerDown: boolean;
  31465. /**
  31466. * This is used to call preventDefault() on pointer up
  31467. * in order to block unwanted artifacts like system double clicks
  31468. */
  31469. preventDefaultOnPointerUp: boolean;
  31470. /**
  31471. * Gets or sets user defined metadata
  31472. */
  31473. metadata: any;
  31474. /**
  31475. * For internal use only. Please do not use.
  31476. */
  31477. reservedDataStore: any;
  31478. /**
  31479. * Gets the name of the plugin used to load this scene (null by default)
  31480. */
  31481. loadingPluginName: string;
  31482. /**
  31483. * Use this array to add regular expressions used to disable offline support for specific urls
  31484. */
  31485. disableOfflineSupportExceptionRules: RegExp[];
  31486. /**
  31487. * An event triggered when the scene is disposed.
  31488. */
  31489. onDisposeObservable: Observable<Scene>;
  31490. private _onDisposeObserver;
  31491. /** Sets a function to be executed when this scene is disposed. */
  31492. onDispose: () => void;
  31493. /**
  31494. * An event triggered before rendering the scene (right after animations and physics)
  31495. */
  31496. onBeforeRenderObservable: Observable<Scene>;
  31497. private _onBeforeRenderObserver;
  31498. /** Sets a function to be executed before rendering this scene */
  31499. beforeRender: Nullable<() => void>;
  31500. /**
  31501. * An event triggered after rendering the scene
  31502. */
  31503. onAfterRenderObservable: Observable<Scene>;
  31504. private _onAfterRenderObserver;
  31505. /** Sets a function to be executed after rendering this scene */
  31506. afterRender: Nullable<() => void>;
  31507. /**
  31508. * An event triggered before animating the scene
  31509. */
  31510. onBeforeAnimationsObservable: Observable<Scene>;
  31511. /**
  31512. * An event triggered after animations processing
  31513. */
  31514. onAfterAnimationsObservable: Observable<Scene>;
  31515. /**
  31516. * An event triggered before draw calls are ready to be sent
  31517. */
  31518. onBeforeDrawPhaseObservable: Observable<Scene>;
  31519. /**
  31520. * An event triggered after draw calls have been sent
  31521. */
  31522. onAfterDrawPhaseObservable: Observable<Scene>;
  31523. /**
  31524. * An event triggered when the scene is ready
  31525. */
  31526. onReadyObservable: Observable<Scene>;
  31527. /**
  31528. * An event triggered before rendering a camera
  31529. */
  31530. onBeforeCameraRenderObservable: Observable<Camera>;
  31531. private _onBeforeCameraRenderObserver;
  31532. /** Sets a function to be executed before rendering a camera*/
  31533. beforeCameraRender: () => void;
  31534. /**
  31535. * An event triggered after rendering a camera
  31536. */
  31537. onAfterCameraRenderObservable: Observable<Camera>;
  31538. private _onAfterCameraRenderObserver;
  31539. /** Sets a function to be executed after rendering a camera*/
  31540. afterCameraRender: () => void;
  31541. /**
  31542. * An event triggered when active meshes evaluation is about to start
  31543. */
  31544. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31545. /**
  31546. * An event triggered when active meshes evaluation is done
  31547. */
  31548. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31549. /**
  31550. * An event triggered when particles rendering is about to start
  31551. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31552. */
  31553. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31554. /**
  31555. * An event triggered when particles rendering is done
  31556. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31557. */
  31558. onAfterParticlesRenderingObservable: Observable<Scene>;
  31559. /**
  31560. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31561. */
  31562. onDataLoadedObservable: Observable<Scene>;
  31563. /**
  31564. * An event triggered when a camera is created
  31565. */
  31566. onNewCameraAddedObservable: Observable<Camera>;
  31567. /**
  31568. * An event triggered when a camera is removed
  31569. */
  31570. onCameraRemovedObservable: Observable<Camera>;
  31571. /**
  31572. * An event triggered when a light is created
  31573. */
  31574. onNewLightAddedObservable: Observable<Light>;
  31575. /**
  31576. * An event triggered when a light is removed
  31577. */
  31578. onLightRemovedObservable: Observable<Light>;
  31579. /**
  31580. * An event triggered when a geometry is created
  31581. */
  31582. onNewGeometryAddedObservable: Observable<Geometry>;
  31583. /**
  31584. * An event triggered when a geometry is removed
  31585. */
  31586. onGeometryRemovedObservable: Observable<Geometry>;
  31587. /**
  31588. * An event triggered when a transform node is created
  31589. */
  31590. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31591. /**
  31592. * An event triggered when a transform node is removed
  31593. */
  31594. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31595. /**
  31596. * An event triggered when a mesh is created
  31597. */
  31598. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31599. /**
  31600. * An event triggered when a mesh is removed
  31601. */
  31602. onMeshRemovedObservable: Observable<AbstractMesh>;
  31603. /**
  31604. * An event triggered when a skeleton is created
  31605. */
  31606. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31607. /**
  31608. * An event triggered when a skeleton is removed
  31609. */
  31610. onSkeletonRemovedObservable: Observable<Skeleton>;
  31611. /**
  31612. * An event triggered when a material is created
  31613. */
  31614. onNewMaterialAddedObservable: Observable<Material>;
  31615. /**
  31616. * An event triggered when a material is removed
  31617. */
  31618. onMaterialRemovedObservable: Observable<Material>;
  31619. /**
  31620. * An event triggered when a texture is created
  31621. */
  31622. onNewTextureAddedObservable: Observable<BaseTexture>;
  31623. /**
  31624. * An event triggered when a texture is removed
  31625. */
  31626. onTextureRemovedObservable: Observable<BaseTexture>;
  31627. /**
  31628. * An event triggered when render targets are about to be rendered
  31629. * Can happen multiple times per frame.
  31630. */
  31631. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31632. /**
  31633. * An event triggered when render targets were rendered.
  31634. * Can happen multiple times per frame.
  31635. */
  31636. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31637. /**
  31638. * An event triggered before calculating deterministic simulation step
  31639. */
  31640. onBeforeStepObservable: Observable<Scene>;
  31641. /**
  31642. * An event triggered after calculating deterministic simulation step
  31643. */
  31644. onAfterStepObservable: Observable<Scene>;
  31645. /**
  31646. * An event triggered when the activeCamera property is updated
  31647. */
  31648. onActiveCameraChanged: Observable<Scene>;
  31649. /**
  31650. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31651. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31652. * 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)
  31653. */
  31654. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31655. /**
  31656. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31657. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31658. * 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)
  31659. */
  31660. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31661. /**
  31662. * This Observable will when a mesh has been imported into the scene.
  31663. */
  31664. onMeshImportedObservable: Observable<AbstractMesh>;
  31665. /**
  31666. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31667. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31668. */
  31669. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31670. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31671. /**
  31672. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31673. */
  31674. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31675. /**
  31676. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31677. */
  31678. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31679. /**
  31680. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31681. */
  31682. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31683. /** Callback called when a pointer move is detected */
  31684. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31685. /** Callback called when a pointer down is detected */
  31686. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31687. /** Callback called when a pointer up is detected */
  31688. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31689. /** Callback called when a pointer pick is detected */
  31690. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31691. /**
  31692. * 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).
  31693. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31694. */
  31695. onPrePointerObservable: Observable<PointerInfoPre>;
  31696. /**
  31697. * Observable event triggered each time an input event is received from the rendering canvas
  31698. */
  31699. onPointerObservable: Observable<PointerInfo>;
  31700. /**
  31701. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31702. */
  31703. readonly unTranslatedPointer: Vector2;
  31704. /**
  31705. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  31706. */
  31707. static DragMovementThreshold: number;
  31708. /**
  31709. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  31710. */
  31711. static LongPressDelay: number;
  31712. /**
  31713. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  31714. */
  31715. static DoubleClickDelay: number;
  31716. /** If you need to check double click without raising a single click at first click, enable this flag */
  31717. static ExclusiveDoubleClickMode: boolean;
  31718. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31719. /**
  31720. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31721. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31722. */
  31723. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31724. /**
  31725. * Observable event triggered each time an keyboard event is received from the hosting window
  31726. */
  31727. onKeyboardObservable: Observable<KeyboardInfo>;
  31728. private _useRightHandedSystem;
  31729. /**
  31730. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31731. */
  31732. useRightHandedSystem: boolean;
  31733. private _timeAccumulator;
  31734. private _currentStepId;
  31735. private _currentInternalStep;
  31736. /**
  31737. * Sets the step Id used by deterministic lock step
  31738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31739. * @param newStepId defines the step Id
  31740. */
  31741. setStepId(newStepId: number): void;
  31742. /**
  31743. * Gets the step Id used by deterministic lock step
  31744. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31745. * @returns the step Id
  31746. */
  31747. getStepId(): number;
  31748. /**
  31749. * Gets the internal step used by deterministic lock step
  31750. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31751. * @returns the internal step
  31752. */
  31753. getInternalStep(): number;
  31754. private _fogEnabled;
  31755. /**
  31756. * Gets or sets a boolean indicating if fog is enabled on this scene
  31757. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31758. * (Default is true)
  31759. */
  31760. fogEnabled: boolean;
  31761. private _fogMode;
  31762. /**
  31763. * Gets or sets the fog mode to use
  31764. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31765. * | mode | value |
  31766. * | --- | --- |
  31767. * | FOGMODE_NONE | 0 |
  31768. * | FOGMODE_EXP | 1 |
  31769. * | FOGMODE_EXP2 | 2 |
  31770. * | FOGMODE_LINEAR | 3 |
  31771. */
  31772. fogMode: number;
  31773. /**
  31774. * Gets or sets the fog color to use
  31775. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31776. * (Default is Color3(0.2, 0.2, 0.3))
  31777. */
  31778. fogColor: Color3;
  31779. /**
  31780. * Gets or sets the fog density to use
  31781. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31782. * (Default is 0.1)
  31783. */
  31784. fogDensity: number;
  31785. /**
  31786. * Gets or sets the fog start distance to use
  31787. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31788. * (Default is 0)
  31789. */
  31790. fogStart: number;
  31791. /**
  31792. * Gets or sets the fog end distance to use
  31793. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31794. * (Default is 1000)
  31795. */
  31796. fogEnd: number;
  31797. private _shadowsEnabled;
  31798. /**
  31799. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31800. */
  31801. shadowsEnabled: boolean;
  31802. private _lightsEnabled;
  31803. /**
  31804. * Gets or sets a boolean indicating if lights are enabled on this scene
  31805. */
  31806. lightsEnabled: boolean;
  31807. /** All of the active cameras added to this scene. */
  31808. activeCameras: Camera[];
  31809. /** @hidden */ activeCamera: Nullable<Camera>;
  31810. /** Gets or sets the current active camera */
  31811. activeCamera: Nullable<Camera>;
  31812. private _defaultMaterial;
  31813. /** The default material used on meshes when no material is affected */
  31814. /** The default material used on meshes when no material is affected */
  31815. defaultMaterial: Material;
  31816. private _texturesEnabled;
  31817. /**
  31818. * Gets or sets a boolean indicating if textures are enabled on this scene
  31819. */
  31820. texturesEnabled: boolean;
  31821. /**
  31822. * Gets or sets a boolean indicating if particles are enabled on this scene
  31823. */
  31824. particlesEnabled: boolean;
  31825. /**
  31826. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31827. */
  31828. spritesEnabled: boolean;
  31829. private _skeletonsEnabled;
  31830. /**
  31831. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31832. */
  31833. skeletonsEnabled: boolean;
  31834. /**
  31835. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31836. */
  31837. lensFlaresEnabled: boolean;
  31838. /**
  31839. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31840. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31841. */
  31842. collisionsEnabled: boolean;
  31843. private _collisionCoordinator;
  31844. /** @hidden */
  31845. readonly collisionCoordinator: ICollisionCoordinator;
  31846. /**
  31847. * Defines the gravity applied to this scene (used only for collisions)
  31848. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31849. */
  31850. gravity: Vector3;
  31851. /**
  31852. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31853. */
  31854. postProcessesEnabled: boolean;
  31855. /**
  31856. * The list of postprocesses added to the scene
  31857. */
  31858. postProcesses: PostProcess[];
  31859. /**
  31860. * Gets the current postprocess manager
  31861. */
  31862. postProcessManager: PostProcessManager;
  31863. /**
  31864. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31865. */
  31866. renderTargetsEnabled: boolean;
  31867. /**
  31868. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31869. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31870. */
  31871. dumpNextRenderTargets: boolean;
  31872. /**
  31873. * The list of user defined render targets added to the scene
  31874. */
  31875. customRenderTargets: RenderTargetTexture[];
  31876. /**
  31877. * Defines if texture loading must be delayed
  31878. * If true, textures will only be loaded when they need to be rendered
  31879. */
  31880. useDelayedTextureLoading: boolean;
  31881. /**
  31882. * Gets the list of meshes imported to the scene through SceneLoader
  31883. */
  31884. importedMeshesFiles: String[];
  31885. /**
  31886. * Gets or sets a boolean indicating if probes are enabled on this scene
  31887. */
  31888. probesEnabled: boolean;
  31889. /**
  31890. * Gets or sets the current offline provider to use to store scene data
  31891. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31892. */
  31893. offlineProvider: IOfflineProvider;
  31894. /**
  31895. * Gets or sets the action manager associated with the scene
  31896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31897. */
  31898. actionManager: AbstractActionManager;
  31899. private _meshesForIntersections;
  31900. /**
  31901. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31902. */
  31903. proceduralTexturesEnabled: boolean;
  31904. private _engine;
  31905. private _totalVertices;
  31906. /** @hidden */ activeIndices: PerfCounter;
  31907. /** @hidden */ activeParticles: PerfCounter;
  31908. /** @hidden */ activeBones: PerfCounter;
  31909. private _animationRatio;
  31910. /** @hidden */ animationTimeLast: number;
  31911. /** @hidden */ animationTime: number;
  31912. /**
  31913. * Gets or sets a general scale for animation speed
  31914. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31915. */
  31916. animationTimeScale: number;
  31917. /** @hidden */ cachedMaterial: Nullable<Material>;
  31918. /** @hidden */ cachedEffect: Nullable<Effect>;
  31919. /** @hidden */ cachedVisibility: Nullable<number>;
  31920. private _renderId;
  31921. private _frameId;
  31922. private _executeWhenReadyTimeoutId;
  31923. private _intermediateRendering;
  31924. private _viewUpdateFlag;
  31925. private _projectionUpdateFlag;
  31926. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31927. private _activeRequests;
  31928. /** @hidden */ pendingData: any[];
  31929. private _isDisposed;
  31930. /**
  31931. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31932. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31933. */
  31934. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31935. private _activeMeshes;
  31936. private _processedMaterials;
  31937. private _renderTargets;
  31938. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31939. private _activeSkeletons;
  31940. private _softwareSkinnedMeshes;
  31941. private _renderingManager;
  31942. /** @hidden */ activeAnimatables: Animatable[];
  31943. private _transformMatrix;
  31944. private _sceneUbo;
  31945. /** @hidden */ viewMatrix: Matrix;
  31946. private _projectionMatrix;
  31947. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31948. /** @hidden */ frustumPlanes: Plane[];
  31949. /**
  31950. * Gets the list of frustum planes (built from the active camera)
  31951. */
  31952. readonly frustumPlanes: Plane[];
  31953. /**
  31954. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31955. * This is useful if there are more lights that the maximum simulteanous authorized
  31956. */
  31957. requireLightSorting: boolean;
  31958. /** @hidden */
  31959. readonly useMaterialMeshMap: boolean;
  31960. /** @hidden */
  31961. readonly useClonedMeshhMap: boolean;
  31962. private _externalData;
  31963. private _uid;
  31964. /**
  31965. * @hidden
  31966. * Backing store of defined scene components.
  31967. */ components: ISceneComponent[];
  31968. /**
  31969. * @hidden
  31970. * Backing store of defined scene components.
  31971. */ serializableComponents: ISceneSerializableComponent[];
  31972. /**
  31973. * List of components to register on the next registration step.
  31974. */
  31975. private _transientComponents;
  31976. /**
  31977. * Registers the transient components if needed.
  31978. */
  31979. private _registerTransientComponents;
  31980. /**
  31981. * @hidden
  31982. * Add a component to the scene.
  31983. * Note that the ccomponent could be registered on th next frame if this is called after
  31984. * the register component stage.
  31985. * @param component Defines the component to add to the scene
  31986. */ addComponent(component: ISceneComponent): void;
  31987. /**
  31988. * @hidden
  31989. * Gets a component from the scene.
  31990. * @param name defines the name of the component to retrieve
  31991. * @returns the component or null if not present
  31992. */ getComponent(name: string): Nullable<ISceneComponent>;
  31993. /**
  31994. * @hidden
  31995. * Defines the actions happening before camera updates.
  31996. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31997. /**
  31998. * @hidden
  31999. * Defines the actions happening before clear the canvas.
  32000. */ beforeClearStage: Stage<SimpleStageAction>;
  32001. /**
  32002. * @hidden
  32003. * Defines the actions when collecting render targets for the frame.
  32004. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32005. /**
  32006. * @hidden
  32007. * Defines the actions happening for one camera in the frame.
  32008. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32009. /**
  32010. * @hidden
  32011. * Defines the actions happening during the per mesh ready checks.
  32012. */ isReadyForMeshStage: Stage<MeshStageAction>;
  32013. /**
  32014. * @hidden
  32015. * Defines the actions happening before evaluate active mesh checks.
  32016. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32017. /**
  32018. * @hidden
  32019. * Defines the actions happening during the evaluate sub mesh checks.
  32020. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32021. /**
  32022. * @hidden
  32023. * Defines the actions happening during the active mesh stage.
  32024. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  32025. /**
  32026. * @hidden
  32027. * Defines the actions happening during the per camera render target step.
  32028. */ cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32029. /**
  32030. * @hidden
  32031. * Defines the actions happening just before the active camera is drawing.
  32032. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  32033. /**
  32034. * @hidden
  32035. * Defines the actions happening just before a render target is drawing.
  32036. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32037. /**
  32038. * @hidden
  32039. * Defines the actions happening just before a rendering group is drawing.
  32040. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32041. /**
  32042. * @hidden
  32043. * Defines the actions happening just before a mesh is drawing.
  32044. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32045. /**
  32046. * @hidden
  32047. * Defines the actions happening just after a mesh has been drawn.
  32048. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32049. /**
  32050. * @hidden
  32051. * Defines the actions happening just after a rendering group has been drawn.
  32052. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32053. /**
  32054. * @hidden
  32055. * Defines the actions happening just after the active camera has been drawn.
  32056. */ afterCameraDrawStage: Stage<CameraStageAction>;
  32057. /**
  32058. * @hidden
  32059. * Defines the actions happening just after a render target has been drawn.
  32060. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32061. /**
  32062. * @hidden
  32063. * Defines the actions happening just after rendering all cameras and computing intersections.
  32064. */ afterRenderStage: Stage<SimpleStageAction>;
  32065. /**
  32066. * @hidden
  32067. * Defines the actions happening when a pointer move event happens.
  32068. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  32069. /**
  32070. * @hidden
  32071. * Defines the actions happening when a pointer down event happens.
  32072. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  32073. /**
  32074. * @hidden
  32075. * Defines the actions happening when a pointer up event happens.
  32076. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  32077. /**
  32078. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32079. */
  32080. private geometriesByUniqueId;
  32081. /**
  32082. * Creates a new Scene
  32083. * @param engine defines the engine to use to render this scene
  32084. * @param options defines the scene options
  32085. */
  32086. constructor(engine: Engine, options?: SceneOptions);
  32087. /**
  32088. * Gets a string idenfifying the name of the class
  32089. * @returns "Scene" string
  32090. */
  32091. getClassName(): string;
  32092. private _defaultMeshCandidates;
  32093. /**
  32094. * @hidden
  32095. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32096. private _defaultSubMeshCandidates;
  32097. /**
  32098. * @hidden
  32099. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32100. /**
  32101. * Sets the default candidate providers for the scene.
  32102. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32103. * and getCollidingSubMeshCandidates to their default function
  32104. */
  32105. setDefaultCandidateProviders(): void;
  32106. /**
  32107. * Gets the mesh that is currently under the pointer
  32108. */
  32109. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32110. /**
  32111. * Gets or sets the current on-screen X position of the pointer
  32112. */
  32113. pointerX: number;
  32114. /**
  32115. * Gets or sets the current on-screen Y position of the pointer
  32116. */
  32117. pointerY: number;
  32118. /**
  32119. * Gets the cached material (ie. the latest rendered one)
  32120. * @returns the cached material
  32121. */
  32122. getCachedMaterial(): Nullable<Material>;
  32123. /**
  32124. * Gets the cached effect (ie. the latest rendered one)
  32125. * @returns the cached effect
  32126. */
  32127. getCachedEffect(): Nullable<Effect>;
  32128. /**
  32129. * Gets the cached visibility state (ie. the latest rendered one)
  32130. * @returns the cached visibility state
  32131. */
  32132. getCachedVisibility(): Nullable<number>;
  32133. /**
  32134. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32135. * @param material defines the current material
  32136. * @param effect defines the current effect
  32137. * @param visibility defines the current visibility state
  32138. * @returns true if one parameter is not cached
  32139. */
  32140. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32141. /**
  32142. * Gets the engine associated with the scene
  32143. * @returns an Engine
  32144. */
  32145. getEngine(): Engine;
  32146. /**
  32147. * Gets the total number of vertices rendered per frame
  32148. * @returns the total number of vertices rendered per frame
  32149. */
  32150. getTotalVertices(): number;
  32151. /**
  32152. * Gets the performance counter for total vertices
  32153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32154. */
  32155. readonly totalVerticesPerfCounter: PerfCounter;
  32156. /**
  32157. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32158. * @returns the total number of active indices rendered per frame
  32159. */
  32160. getActiveIndices(): number;
  32161. /**
  32162. * Gets the performance counter for active indices
  32163. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32164. */
  32165. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32166. /**
  32167. * Gets the total number of active particles rendered per frame
  32168. * @returns the total number of active particles rendered per frame
  32169. */
  32170. getActiveParticles(): number;
  32171. /**
  32172. * Gets the performance counter for active particles
  32173. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32174. */
  32175. readonly activeParticlesPerfCounter: PerfCounter;
  32176. /**
  32177. * Gets the total number of active bones rendered per frame
  32178. * @returns the total number of active bones rendered per frame
  32179. */
  32180. getActiveBones(): number;
  32181. /**
  32182. * Gets the performance counter for active bones
  32183. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32184. */
  32185. readonly activeBonesPerfCounter: PerfCounter;
  32186. /**
  32187. * Gets the array of active meshes
  32188. * @returns an array of AbstractMesh
  32189. */
  32190. getActiveMeshes(): SmartArray<AbstractMesh>;
  32191. /**
  32192. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32193. * @returns a number
  32194. */
  32195. getAnimationRatio(): number;
  32196. /**
  32197. * Gets an unique Id for the current render phase
  32198. * @returns a number
  32199. */
  32200. getRenderId(): number;
  32201. /**
  32202. * Gets an unique Id for the current frame
  32203. * @returns a number
  32204. */
  32205. getFrameId(): number;
  32206. /** Call this function if you want to manually increment the render Id*/
  32207. incrementRenderId(): void;
  32208. private _createUbo;
  32209. /**
  32210. * Use this method to simulate a pointer move on a mesh
  32211. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32212. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32213. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32214. * @returns the current scene
  32215. */
  32216. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32217. /**
  32218. * Use this method to simulate a pointer down on a mesh
  32219. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32220. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32221. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32222. * @returns the current scene
  32223. */
  32224. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32225. /**
  32226. * Use this method to simulate a pointer up on a mesh
  32227. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32228. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32229. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32230. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32231. * @returns the current scene
  32232. */
  32233. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32234. /**
  32235. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32236. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32237. * @returns true if the pointer was captured
  32238. */
  32239. isPointerCaptured(pointerId?: number): boolean;
  32240. /**
  32241. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32242. * @param attachUp defines if you want to attach events to pointerup
  32243. * @param attachDown defines if you want to attach events to pointerdown
  32244. * @param attachMove defines if you want to attach events to pointermove
  32245. */
  32246. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32247. /** Detaches all event handlers*/
  32248. detachControl(): void;
  32249. /**
  32250. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32251. * Delay loaded resources are not taking in account
  32252. * @return true if all required resources are ready
  32253. */
  32254. isReady(): boolean;
  32255. /** Resets all cached information relative to material (including effect and visibility) */
  32256. resetCachedMaterial(): void;
  32257. /**
  32258. * Registers a function to be called before every frame render
  32259. * @param func defines the function to register
  32260. */
  32261. registerBeforeRender(func: () => void): void;
  32262. /**
  32263. * Unregisters a function called before every frame render
  32264. * @param func defines the function to unregister
  32265. */
  32266. unregisterBeforeRender(func: () => void): void;
  32267. /**
  32268. * Registers a function to be called after every frame render
  32269. * @param func defines the function to register
  32270. */
  32271. registerAfterRender(func: () => void): void;
  32272. /**
  32273. * Unregisters a function called after every frame render
  32274. * @param func defines the function to unregister
  32275. */
  32276. unregisterAfterRender(func: () => void): void;
  32277. private _executeOnceBeforeRender;
  32278. /**
  32279. * The provided function will run before render once and will be disposed afterwards.
  32280. * A timeout delay can be provided so that the function will be executed in N ms.
  32281. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32282. * @param func The function to be executed.
  32283. * @param timeout optional delay in ms
  32284. */
  32285. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32286. /** @hidden */ addPendingData(data: any): void;
  32287. /** @hidden */ removePendingData(data: any): void;
  32288. /**
  32289. * Returns the number of items waiting to be loaded
  32290. * @returns the number of items waiting to be loaded
  32291. */
  32292. getWaitingItemsCount(): number;
  32293. /**
  32294. * Returns a boolean indicating if the scene is still loading data
  32295. */
  32296. readonly isLoading: boolean;
  32297. /**
  32298. * Registers a function to be executed when the scene is ready
  32299. * @param {Function} func - the function to be executed
  32300. */
  32301. executeWhenReady(func: () => void): void;
  32302. /**
  32303. * Returns a promise that resolves when the scene is ready
  32304. * @returns A promise that resolves when the scene is ready
  32305. */
  32306. whenReadyAsync(): Promise<void>;
  32307. /** @hidden */ checkIsReady(): void;
  32308. /**
  32309. * Gets all animatable attached to the scene
  32310. */
  32311. readonly animatables: Animatable[];
  32312. /**
  32313. * Resets the last animation time frame.
  32314. * Useful to override when animations start running when loading a scene for the first time.
  32315. */
  32316. resetLastAnimationTimeFrame(): void;
  32317. /**
  32318. * Gets the current view matrix
  32319. * @returns a Matrix
  32320. */
  32321. getViewMatrix(): Matrix;
  32322. /**
  32323. * Gets the current projection matrix
  32324. * @returns a Matrix
  32325. */
  32326. getProjectionMatrix(): Matrix;
  32327. /**
  32328. * Gets the current transform matrix
  32329. * @returns a Matrix made of View * Projection
  32330. */
  32331. getTransformMatrix(): Matrix;
  32332. /**
  32333. * Sets the current transform matrix
  32334. * @param viewL defines the View matrix to use
  32335. * @param projectionL defines the Projection matrix to use
  32336. * @param viewR defines the right View matrix to use (if provided)
  32337. * @param projectionR defines the right Projection matrix to use (if provided)
  32338. */
  32339. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32340. /**
  32341. * Gets the uniform buffer used to store scene data
  32342. * @returns a UniformBuffer
  32343. */
  32344. getSceneUniformBuffer(): UniformBuffer;
  32345. /**
  32346. * Gets an unique (relatively to the current scene) Id
  32347. * @returns an unique number for the scene
  32348. */
  32349. getUniqueId(): number;
  32350. /**
  32351. * Add a mesh to the list of scene's meshes
  32352. * @param newMesh defines the mesh to add
  32353. * @param recursive if all child meshes should also be added to the scene
  32354. */
  32355. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32356. /**
  32357. * Remove a mesh for the list of scene's meshes
  32358. * @param toRemove defines the mesh to remove
  32359. * @param recursive if all child meshes should also be removed from the scene
  32360. * @returns the index where the mesh was in the mesh list
  32361. */
  32362. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32363. /**
  32364. * Add a transform node to the list of scene's transform nodes
  32365. * @param newTransformNode defines the transform node to add
  32366. */
  32367. addTransformNode(newTransformNode: TransformNode): void;
  32368. /**
  32369. * Remove a transform node for the list of scene's transform nodes
  32370. * @param toRemove defines the transform node to remove
  32371. * @returns the index where the transform node was in the transform node list
  32372. */
  32373. removeTransformNode(toRemove: TransformNode): number;
  32374. /**
  32375. * Remove a skeleton for the list of scene's skeletons
  32376. * @param toRemove defines the skeleton to remove
  32377. * @returns the index where the skeleton was in the skeleton list
  32378. */
  32379. removeSkeleton(toRemove: Skeleton): number;
  32380. /**
  32381. * Remove a morph target for the list of scene's morph targets
  32382. * @param toRemove defines the morph target to remove
  32383. * @returns the index where the morph target was in the morph target list
  32384. */
  32385. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32386. /**
  32387. * Remove a light for the list of scene's lights
  32388. * @param toRemove defines the light to remove
  32389. * @returns the index where the light was in the light list
  32390. */
  32391. removeLight(toRemove: Light): number;
  32392. /**
  32393. * Remove a camera for the list of scene's cameras
  32394. * @param toRemove defines the camera to remove
  32395. * @returns the index where the camera was in the camera list
  32396. */
  32397. removeCamera(toRemove: Camera): number;
  32398. /**
  32399. * Remove a particle system for the list of scene's particle systems
  32400. * @param toRemove defines the particle system to remove
  32401. * @returns the index where the particle system was in the particle system list
  32402. */
  32403. removeParticleSystem(toRemove: IParticleSystem): number;
  32404. /**
  32405. * Remove a animation for the list of scene's animations
  32406. * @param toRemove defines the animation to remove
  32407. * @returns the index where the animation was in the animation list
  32408. */
  32409. removeAnimation(toRemove: Animation): number;
  32410. /**
  32411. * Will stop the animation of the given target
  32412. * @param target - the target
  32413. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32414. * @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)
  32415. */
  32416. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32417. /**
  32418. * Removes the given animation group from this scene.
  32419. * @param toRemove The animation group to remove
  32420. * @returns The index of the removed animation group
  32421. */
  32422. removeAnimationGroup(toRemove: AnimationGroup): number;
  32423. /**
  32424. * Removes the given multi-material from this scene.
  32425. * @param toRemove The multi-material to remove
  32426. * @returns The index of the removed multi-material
  32427. */
  32428. removeMultiMaterial(toRemove: MultiMaterial): number;
  32429. /**
  32430. * Removes the given material from this scene.
  32431. * @param toRemove The material to remove
  32432. * @returns The index of the removed material
  32433. */
  32434. removeMaterial(toRemove: Material): number;
  32435. /**
  32436. * Removes the given action manager from this scene.
  32437. * @param toRemove The action manager to remove
  32438. * @returns The index of the removed action manager
  32439. */
  32440. removeActionManager(toRemove: AbstractActionManager): number;
  32441. /**
  32442. * Removes the given texture from this scene.
  32443. * @param toRemove The texture to remove
  32444. * @returns The index of the removed texture
  32445. */
  32446. removeTexture(toRemove: BaseTexture): number;
  32447. /**
  32448. * Adds the given light to this scene
  32449. * @param newLight The light to add
  32450. */
  32451. addLight(newLight: Light): void;
  32452. /**
  32453. * Sorts the list list based on light priorities
  32454. */
  32455. sortLightsByPriority(): void;
  32456. /**
  32457. * Adds the given camera to this scene
  32458. * @param newCamera The camera to add
  32459. */
  32460. addCamera(newCamera: Camera): void;
  32461. /**
  32462. * Adds the given skeleton to this scene
  32463. * @param newSkeleton The skeleton to add
  32464. */
  32465. addSkeleton(newSkeleton: Skeleton): void;
  32466. /**
  32467. * Adds the given particle system to this scene
  32468. * @param newParticleSystem The particle system to add
  32469. */
  32470. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32471. /**
  32472. * Adds the given animation to this scene
  32473. * @param newAnimation The animation to add
  32474. */
  32475. addAnimation(newAnimation: Animation): void;
  32476. /**
  32477. * Adds the given animation group to this scene.
  32478. * @param newAnimationGroup The animation group to add
  32479. */
  32480. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32481. /**
  32482. * Adds the given multi-material to this scene
  32483. * @param newMultiMaterial The multi-material to add
  32484. */
  32485. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32486. /**
  32487. * Adds the given material to this scene
  32488. * @param newMaterial The material to add
  32489. */
  32490. addMaterial(newMaterial: Material): void;
  32491. /**
  32492. * Adds the given morph target to this scene
  32493. * @param newMorphTargetManager The morph target to add
  32494. */
  32495. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32496. /**
  32497. * Adds the given geometry to this scene
  32498. * @param newGeometry The geometry to add
  32499. */
  32500. addGeometry(newGeometry: Geometry): void;
  32501. /**
  32502. * Adds the given action manager to this scene
  32503. * @param newActionManager The action manager to add
  32504. */
  32505. addActionManager(newActionManager: AbstractActionManager): void;
  32506. /**
  32507. * Adds the given texture to this scene.
  32508. * @param newTexture The texture to add
  32509. */
  32510. addTexture(newTexture: BaseTexture): void;
  32511. /**
  32512. * Switch active camera
  32513. * @param newCamera defines the new active camera
  32514. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32515. */
  32516. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32517. /**
  32518. * sets the active camera of the scene using its ID
  32519. * @param id defines the camera's ID
  32520. * @return the new active camera or null if none found.
  32521. */
  32522. setActiveCameraByID(id: string): Nullable<Camera>;
  32523. /**
  32524. * sets the active camera of the scene using its name
  32525. * @param name defines the camera's name
  32526. * @returns the new active camera or null if none found.
  32527. */
  32528. setActiveCameraByName(name: string): Nullable<Camera>;
  32529. /**
  32530. * get an animation group using its name
  32531. * @param name defines the material's name
  32532. * @return the animation group or null if none found.
  32533. */
  32534. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32535. /**
  32536. * Get a material using its unique id
  32537. * @param uniqueId defines the material's unique id
  32538. * @return the material or null if none found.
  32539. */
  32540. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32541. /**
  32542. * get a material using its id
  32543. * @param id defines the material's ID
  32544. * @return the material or null if none found.
  32545. */
  32546. getMaterialByID(id: string): Nullable<Material>;
  32547. /**
  32548. * Gets a material using its name
  32549. * @param name defines the material's name
  32550. * @return the material or null if none found.
  32551. */
  32552. getMaterialByName(name: string): Nullable<Material>;
  32553. /**
  32554. * Gets a camera using its id
  32555. * @param id defines the id to look for
  32556. * @returns the camera or null if not found
  32557. */
  32558. getCameraByID(id: string): Nullable<Camera>;
  32559. /**
  32560. * Gets a camera using its unique id
  32561. * @param uniqueId defines the unique id to look for
  32562. * @returns the camera or null if not found
  32563. */
  32564. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32565. /**
  32566. * Gets a camera using its name
  32567. * @param name defines the camera's name
  32568. * @return the camera or null if none found.
  32569. */
  32570. getCameraByName(name: string): Nullable<Camera>;
  32571. /**
  32572. * Gets a bone using its id
  32573. * @param id defines the bone's id
  32574. * @return the bone or null if not found
  32575. */
  32576. getBoneByID(id: string): Nullable<Bone>;
  32577. /**
  32578. * Gets a bone using its id
  32579. * @param name defines the bone's name
  32580. * @return the bone or null if not found
  32581. */
  32582. getBoneByName(name: string): Nullable<Bone>;
  32583. /**
  32584. * Gets a light node using its name
  32585. * @param name defines the the light's name
  32586. * @return the light or null if none found.
  32587. */
  32588. getLightByName(name: string): Nullable<Light>;
  32589. /**
  32590. * Gets a light node using its id
  32591. * @param id defines the light's id
  32592. * @return the light or null if none found.
  32593. */
  32594. getLightByID(id: string): Nullable<Light>;
  32595. /**
  32596. * Gets a light node using its scene-generated unique ID
  32597. * @param uniqueId defines the light's unique id
  32598. * @return the light or null if none found.
  32599. */
  32600. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32601. /**
  32602. * Gets a particle system by id
  32603. * @param id defines the particle system id
  32604. * @return the corresponding system or null if none found
  32605. */
  32606. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32607. /**
  32608. * Gets a geometry using its ID
  32609. * @param id defines the geometry's id
  32610. * @return the geometry or null if none found.
  32611. */
  32612. getGeometryByID(id: string): Nullable<Geometry>;
  32613. private _getGeometryByUniqueID;
  32614. /**
  32615. * Add a new geometry to this scene
  32616. * @param geometry defines the geometry to be added to the scene.
  32617. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32618. * @return a boolean defining if the geometry was added or not
  32619. */
  32620. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32621. /**
  32622. * Removes an existing geometry
  32623. * @param geometry defines the geometry to be removed from the scene
  32624. * @return a boolean defining if the geometry was removed or not
  32625. */
  32626. removeGeometry(geometry: Geometry): boolean;
  32627. /**
  32628. * Gets the list of geometries attached to the scene
  32629. * @returns an array of Geometry
  32630. */
  32631. getGeometries(): Geometry[];
  32632. /**
  32633. * Gets the first added mesh found of a given ID
  32634. * @param id defines the id to search for
  32635. * @return the mesh found or null if not found at all
  32636. */
  32637. getMeshByID(id: string): Nullable<AbstractMesh>;
  32638. /**
  32639. * Gets a list of meshes using their id
  32640. * @param id defines the id to search for
  32641. * @returns a list of meshes
  32642. */
  32643. getMeshesByID(id: string): Array<AbstractMesh>;
  32644. /**
  32645. * Gets the first added transform node found of a given ID
  32646. * @param id defines the id to search for
  32647. * @return the found transform node or null if not found at all.
  32648. */
  32649. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32650. /**
  32651. * Gets a transform node with its auto-generated unique id
  32652. * @param uniqueId efines the unique id to search for
  32653. * @return the found transform node or null if not found at all.
  32654. */
  32655. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32656. /**
  32657. * Gets a list of transform nodes using their id
  32658. * @param id defines the id to search for
  32659. * @returns a list of transform nodes
  32660. */
  32661. getTransformNodesByID(id: string): Array<TransformNode>;
  32662. /**
  32663. * Gets a mesh with its auto-generated unique id
  32664. * @param uniqueId defines the unique id to search for
  32665. * @return the found mesh or null if not found at all.
  32666. */
  32667. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32668. /**
  32669. * Gets a the last added mesh using a given id
  32670. * @param id defines the id to search for
  32671. * @return the found mesh or null if not found at all.
  32672. */
  32673. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32674. /**
  32675. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32676. * @param id defines the id to search for
  32677. * @return the found node or null if not found at all
  32678. */
  32679. getLastEntryByID(id: string): Nullable<Node>;
  32680. /**
  32681. * Gets a node (Mesh, Camera, Light) using a given id
  32682. * @param id defines the id to search for
  32683. * @return the found node or null if not found at all
  32684. */
  32685. getNodeByID(id: string): Nullable<Node>;
  32686. /**
  32687. * Gets a node (Mesh, Camera, Light) using a given name
  32688. * @param name defines the name to search for
  32689. * @return the found node or null if not found at all.
  32690. */
  32691. getNodeByName(name: string): Nullable<Node>;
  32692. /**
  32693. * Gets a mesh using a given name
  32694. * @param name defines the name to search for
  32695. * @return the found mesh or null if not found at all.
  32696. */
  32697. getMeshByName(name: string): Nullable<AbstractMesh>;
  32698. /**
  32699. * Gets a transform node using a given name
  32700. * @param name defines the name to search for
  32701. * @return the found transform node or null if not found at all.
  32702. */
  32703. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32704. /**
  32705. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32706. * @param id defines the id to search for
  32707. * @return the found skeleton or null if not found at all.
  32708. */
  32709. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32710. /**
  32711. * Gets a skeleton using a given auto generated unique id
  32712. * @param uniqueId defines the unique id to search for
  32713. * @return the found skeleton or null if not found at all.
  32714. */
  32715. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32716. /**
  32717. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32718. * @param id defines the id to search for
  32719. * @return the found skeleton or null if not found at all.
  32720. */
  32721. getSkeletonById(id: string): Nullable<Skeleton>;
  32722. /**
  32723. * Gets a skeleton using a given name
  32724. * @param name defines the name to search for
  32725. * @return the found skeleton or null if not found at all.
  32726. */
  32727. getSkeletonByName(name: string): Nullable<Skeleton>;
  32728. /**
  32729. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32730. * @param id defines the id to search for
  32731. * @return the found morph target manager or null if not found at all.
  32732. */
  32733. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32734. /**
  32735. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32736. * @param id defines the id to search for
  32737. * @return the found morph target or null if not found at all.
  32738. */
  32739. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32740. /**
  32741. * Gets a boolean indicating if the given mesh is active
  32742. * @param mesh defines the mesh to look for
  32743. * @returns true if the mesh is in the active list
  32744. */
  32745. isActiveMesh(mesh: AbstractMesh): boolean;
  32746. /**
  32747. * Return a unique id as a string which can serve as an identifier for the scene
  32748. */
  32749. readonly uid: string;
  32750. /**
  32751. * Add an externaly attached data from its key.
  32752. * This method call will fail and return false, if such key already exists.
  32753. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32754. * @param key the unique key that identifies the data
  32755. * @param data the data object to associate to the key for this Engine instance
  32756. * @return true if no such key were already present and the data was added successfully, false otherwise
  32757. */
  32758. addExternalData<T>(key: string, data: T): boolean;
  32759. /**
  32760. * Get an externaly attached data from its key
  32761. * @param key the unique key that identifies the data
  32762. * @return the associated data, if present (can be null), or undefined if not present
  32763. */
  32764. getExternalData<T>(key: string): Nullable<T>;
  32765. /**
  32766. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32767. * @param key the unique key that identifies the data
  32768. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32769. * @return the associated data, can be null if the factory returned null.
  32770. */
  32771. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32772. /**
  32773. * Remove an externaly attached data from the Engine instance
  32774. * @param key the unique key that identifies the data
  32775. * @return true if the data was successfully removed, false if it doesn't exist
  32776. */
  32777. removeExternalData(key: string): boolean;
  32778. private _evaluateSubMesh;
  32779. /**
  32780. * Clear the processed materials smart array preventing retention point in material dispose.
  32781. */
  32782. freeProcessedMaterials(): void;
  32783. private _preventFreeActiveMeshesAndRenderingGroups;
  32784. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32785. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32786. * when disposing several meshes in a row or a hierarchy of meshes.
  32787. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32788. */
  32789. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32790. /**
  32791. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32792. */
  32793. freeActiveMeshes(): void;
  32794. /**
  32795. * Clear the info related to rendering groups preventing retention points during dispose.
  32796. */
  32797. freeRenderingGroups(): void;
  32798. /** @hidden */ isInIntermediateRendering(): boolean;
  32799. /**
  32800. * Lambda returning the list of potentially active meshes.
  32801. */
  32802. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32803. /**
  32804. * Lambda returning the list of potentially active sub meshes.
  32805. */
  32806. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32807. /**
  32808. * Lambda returning the list of potentially intersecting sub meshes.
  32809. */
  32810. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32811. /**
  32812. * Lambda returning the list of potentially colliding sub meshes.
  32813. */
  32814. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32815. private _activeMeshesFrozen;
  32816. /**
  32817. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32818. * @returns the current scene
  32819. */
  32820. freezeActiveMeshes(): Scene;
  32821. /**
  32822. * Use this function to restart evaluating active meshes on every frame
  32823. * @returns the current scene
  32824. */
  32825. unfreezeActiveMeshes(): Scene;
  32826. private _evaluateActiveMeshes;
  32827. private _activeMesh;
  32828. /**
  32829. * Update the transform matrix to update from the current active camera
  32830. * @param force defines a boolean used to force the update even if cache is up to date
  32831. */
  32832. updateTransformMatrix(force?: boolean): void;
  32833. private _bindFrameBuffer;
  32834. /** @hidden */ allowPostProcessClearColor: boolean;
  32835. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32836. private _processSubCameras;
  32837. private _checkIntersections;
  32838. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32839. /**
  32840. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32841. */
  32842. getDeterministicFrameTime: () => number;
  32843. /** @hidden */ animate(): void;
  32844. /** Execute all animations (for a frame) */
  32845. animate(): void;
  32846. /**
  32847. * Render the scene
  32848. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32849. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32850. */
  32851. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32852. /**
  32853. * Freeze all materials
  32854. * A frozen material will not be updatable but should be faster to render
  32855. */
  32856. freezeMaterials(): void;
  32857. /**
  32858. * Unfreeze all materials
  32859. * A frozen material will not be updatable but should be faster to render
  32860. */
  32861. unfreezeMaterials(): void;
  32862. /**
  32863. * Releases all held ressources
  32864. */
  32865. dispose(): void;
  32866. /**
  32867. * Gets if the scene is already disposed
  32868. */
  32869. readonly isDisposed: boolean;
  32870. /**
  32871. * Call this function to reduce memory footprint of the scene.
  32872. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32873. */
  32874. clearCachedVertexData(): void;
  32875. /**
  32876. * This function will remove the local cached buffer data from texture.
  32877. * It will save memory but will prevent the texture from being rebuilt
  32878. */
  32879. cleanCachedTextureBuffer(): void;
  32880. /**
  32881. * Get the world extend vectors with an optional filter
  32882. *
  32883. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32884. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32885. */
  32886. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32887. min: Vector3;
  32888. max: Vector3;
  32889. };
  32890. /**
  32891. * Creates a ray that can be used to pick in the scene
  32892. * @param x defines the x coordinate of the origin (on-screen)
  32893. * @param y defines the y coordinate of the origin (on-screen)
  32894. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32895. * @param camera defines the camera to use for the picking
  32896. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32897. * @returns a Ray
  32898. */
  32899. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32900. /**
  32901. * Creates a ray that can be used to pick in the scene
  32902. * @param x defines the x coordinate of the origin (on-screen)
  32903. * @param y defines the y coordinate of the origin (on-screen)
  32904. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32905. * @param result defines the ray where to store the picking ray
  32906. * @param camera defines the camera to use for the picking
  32907. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32908. * @returns the current scene
  32909. */
  32910. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32911. /**
  32912. * Creates a ray that can be used to pick in the scene
  32913. * @param x defines the x coordinate of the origin (on-screen)
  32914. * @param y defines the y coordinate of the origin (on-screen)
  32915. * @param camera defines the camera to use for the picking
  32916. * @returns a Ray
  32917. */
  32918. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32919. /**
  32920. * Creates a ray that can be used to pick in the scene
  32921. * @param x defines the x coordinate of the origin (on-screen)
  32922. * @param y defines the y coordinate of the origin (on-screen)
  32923. * @param result defines the ray where to store the picking ray
  32924. * @param camera defines the camera to use for the picking
  32925. * @returns the current scene
  32926. */
  32927. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32928. /** Launch a ray to try to pick a mesh in the scene
  32929. * @param x position on screen
  32930. * @param y position on screen
  32931. * @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
  32932. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32933. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32934. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32935. * @returns a PickingInfo
  32936. */
  32937. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32938. /** Use the given ray to pick a mesh in the scene
  32939. * @param ray The ray to use to pick meshes
  32940. * @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
  32941. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32942. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32943. * @returns a PickingInfo
  32944. */
  32945. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32946. /**
  32947. * Launch a ray to try to pick a mesh in the scene
  32948. * @param x X position on screen
  32949. * @param y Y position on screen
  32950. * @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
  32951. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32952. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32953. * @returns an array of PickingInfo
  32954. */
  32955. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32956. /**
  32957. * Launch a ray to try to pick a mesh in the scene
  32958. * @param ray Ray to use
  32959. * @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
  32960. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32961. * @returns an array of PickingInfo
  32962. */
  32963. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32964. /**
  32965. * Force the value of meshUnderPointer
  32966. * @param mesh defines the mesh to use
  32967. */
  32968. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32969. /**
  32970. * Gets the mesh under the pointer
  32971. * @returns a Mesh or null if no mesh is under the pointer
  32972. */
  32973. getPointerOverMesh(): Nullable<AbstractMesh>;
  32974. /** @hidden */ rebuildGeometries(): void;
  32975. /** @hidden */ rebuildTextures(): void;
  32976. private _getByTags;
  32977. /**
  32978. * Get a list of meshes by tags
  32979. * @param tagsQuery defines the tags query to use
  32980. * @param forEach defines a predicate used to filter results
  32981. * @returns an array of Mesh
  32982. */
  32983. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32984. /**
  32985. * Get a list of cameras by tags
  32986. * @param tagsQuery defines the tags query to use
  32987. * @param forEach defines a predicate used to filter results
  32988. * @returns an array of Camera
  32989. */
  32990. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32991. /**
  32992. * Get a list of lights by tags
  32993. * @param tagsQuery defines the tags query to use
  32994. * @param forEach defines a predicate used to filter results
  32995. * @returns an array of Light
  32996. */
  32997. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32998. /**
  32999. * Get a list of materials by tags
  33000. * @param tagsQuery defines the tags query to use
  33001. * @param forEach defines a predicate used to filter results
  33002. * @returns an array of Material
  33003. */
  33004. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33005. /**
  33006. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33007. * This allowed control for front to back rendering or reversly depending of the special needs.
  33008. *
  33009. * @param renderingGroupId The rendering group id corresponding to its index
  33010. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33011. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33012. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33013. */
  33014. 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;
  33015. /**
  33016. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33017. *
  33018. * @param renderingGroupId The rendering group id corresponding to its index
  33019. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33020. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33021. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33022. */
  33023. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33024. /**
  33025. * Gets the current auto clear configuration for one rendering group of the rendering
  33026. * manager.
  33027. * @param index the rendering group index to get the information for
  33028. * @returns The auto clear setup for the requested rendering group
  33029. */
  33030. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33031. private _blockMaterialDirtyMechanism;
  33032. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33033. blockMaterialDirtyMechanism: boolean;
  33034. /**
  33035. * Will flag all materials as dirty to trigger new shader compilation
  33036. * @param flag defines the flag used to specify which material part must be marked as dirty
  33037. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33038. */
  33039. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33040. /** @hidden */ loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33041. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33042. }
  33043. }
  33044. declare module BABYLON {
  33045. /**
  33046. * Set of assets to keep when moving a scene into an asset container.
  33047. */
  33048. export class KeepAssets extends AbstractScene {
  33049. }
  33050. /**
  33051. * Container with a set of assets that can be added or removed from a scene.
  33052. */
  33053. export class AssetContainer extends AbstractScene {
  33054. /**
  33055. * The scene the AssetContainer belongs to.
  33056. */
  33057. scene: Scene;
  33058. /**
  33059. * Instantiates an AssetContainer.
  33060. * @param scene The scene the AssetContainer belongs to.
  33061. */
  33062. constructor(scene: Scene);
  33063. /**
  33064. * Adds all the assets from the container to the scene.
  33065. */
  33066. addAllToScene(): void;
  33067. /**
  33068. * Removes all the assets in the container from the scene
  33069. */
  33070. removeAllFromScene(): void;
  33071. /**
  33072. * Disposes all the assets in the container
  33073. */
  33074. dispose(): void;
  33075. private _moveAssets;
  33076. /**
  33077. * Removes all the assets contained in the scene and adds them to the container.
  33078. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33079. */
  33080. moveAllFromScene(keepAssets?: KeepAssets): void;
  33081. /**
  33082. * 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.
  33083. * @returns the root mesh
  33084. */
  33085. createRootMesh(): Mesh;
  33086. }
  33087. }
  33088. declare module BABYLON {
  33089. /**
  33090. * Defines how the parser contract is defined.
  33091. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33092. */
  33093. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33094. /**
  33095. * Defines how the individual parser contract is defined.
  33096. * These parser can parse an individual asset
  33097. */
  33098. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33099. /**
  33100. * Base class of the scene acting as a container for the different elements composing a scene.
  33101. * This class is dynamically extended by the different components of the scene increasing
  33102. * flexibility and reducing coupling
  33103. */
  33104. export abstract class AbstractScene {
  33105. /**
  33106. * Stores the list of available parsers in the application.
  33107. */
  33108. private static _BabylonFileParsers;
  33109. /**
  33110. * Stores the list of available individual parsers in the application.
  33111. */
  33112. private static _IndividualBabylonFileParsers;
  33113. /**
  33114. * Adds a parser in the list of available ones
  33115. * @param name Defines the name of the parser
  33116. * @param parser Defines the parser to add
  33117. */
  33118. static AddParser(name: string, parser: BabylonFileParser): void;
  33119. /**
  33120. * Gets a general parser from the list of avaialble ones
  33121. * @param name Defines the name of the parser
  33122. * @returns the requested parser or null
  33123. */
  33124. static GetParser(name: string): Nullable<BabylonFileParser>;
  33125. /**
  33126. * Adds n individual parser in the list of available ones
  33127. * @param name Defines the name of the parser
  33128. * @param parser Defines the parser to add
  33129. */
  33130. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33131. /**
  33132. * Gets an individual parser from the list of avaialble ones
  33133. * @param name Defines the name of the parser
  33134. * @returns the requested parser or null
  33135. */
  33136. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33137. /**
  33138. * Parser json data and populate both a scene and its associated container object
  33139. * @param jsonData Defines the data to parse
  33140. * @param scene Defines the scene to parse the data for
  33141. * @param container Defines the container attached to the parsing sequence
  33142. * @param rootUrl Defines the root url of the data
  33143. */
  33144. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33145. /**
  33146. * Gets the list of root nodes (ie. nodes with no parent)
  33147. */
  33148. rootNodes: Node[];
  33149. /** All of the cameras added to this scene
  33150. * @see http://doc.babylonjs.com/babylon101/cameras
  33151. */
  33152. cameras: Camera[];
  33153. /**
  33154. * All of the lights added to this scene
  33155. * @see http://doc.babylonjs.com/babylon101/lights
  33156. */
  33157. lights: Light[];
  33158. /**
  33159. * All of the (abstract) meshes added to this scene
  33160. */
  33161. meshes: AbstractMesh[];
  33162. /**
  33163. * The list of skeletons added to the scene
  33164. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33165. */
  33166. skeletons: Skeleton[];
  33167. /**
  33168. * All of the particle systems added to this scene
  33169. * @see http://doc.babylonjs.com/babylon101/particles
  33170. */
  33171. particleSystems: IParticleSystem[];
  33172. /**
  33173. * Gets a list of Animations associated with the scene
  33174. */
  33175. animations: Animation[];
  33176. /**
  33177. * All of the animation groups added to this scene
  33178. * @see http://doc.babylonjs.com/how_to/group
  33179. */
  33180. animationGroups: AnimationGroup[];
  33181. /**
  33182. * All of the multi-materials added to this scene
  33183. * @see http://doc.babylonjs.com/how_to/multi_materials
  33184. */
  33185. multiMaterials: MultiMaterial[];
  33186. /**
  33187. * All of the materials added to this scene
  33188. * In the context of a Scene, it is not supposed to be modified manually.
  33189. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33190. * Note also that the order of the Material wihin the array is not significant and might change.
  33191. * @see http://doc.babylonjs.com/babylon101/materials
  33192. */
  33193. materials: Material[];
  33194. /**
  33195. * The list of morph target managers added to the scene
  33196. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33197. */
  33198. morphTargetManagers: MorphTargetManager[];
  33199. /**
  33200. * The list of geometries used in the scene.
  33201. */
  33202. geometries: Geometry[];
  33203. /**
  33204. * All of the tranform nodes added to this scene
  33205. * In the context of a Scene, it is not supposed to be modified manually.
  33206. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33207. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33208. * @see http://doc.babylonjs.com/how_to/transformnode
  33209. */
  33210. transformNodes: TransformNode[];
  33211. /**
  33212. * ActionManagers available on the scene.
  33213. */
  33214. actionManagers: AbstractActionManager[];
  33215. /**
  33216. * Textures to keep.
  33217. */
  33218. textures: BaseTexture[];
  33219. /**
  33220. * Environment texture for the scene
  33221. */
  33222. environmentTexture: Nullable<BaseTexture>;
  33223. }
  33224. }
  33225. declare module BABYLON {
  33226. /**
  33227. * Defines a sound that can be played in the application.
  33228. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33229. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33230. */
  33231. export class Sound {
  33232. /**
  33233. * The name of the sound in the scene.
  33234. */
  33235. name: string;
  33236. /**
  33237. * Does the sound autoplay once loaded.
  33238. */
  33239. autoplay: boolean;
  33240. /**
  33241. * Does the sound loop after it finishes playing once.
  33242. */
  33243. loop: boolean;
  33244. /**
  33245. * Does the sound use a custom attenuation curve to simulate the falloff
  33246. * happening when the source gets further away from the camera.
  33247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33248. */
  33249. useCustomAttenuation: boolean;
  33250. /**
  33251. * The sound track id this sound belongs to.
  33252. */
  33253. soundTrackId: number;
  33254. /**
  33255. * Is this sound currently played.
  33256. */
  33257. isPlaying: boolean;
  33258. /**
  33259. * Is this sound currently paused.
  33260. */
  33261. isPaused: boolean;
  33262. /**
  33263. * Does this sound enables spatial sound.
  33264. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33265. */
  33266. spatialSound: boolean;
  33267. /**
  33268. * Define the reference distance the sound should be heard perfectly.
  33269. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33270. */
  33271. refDistance: number;
  33272. /**
  33273. * Define the roll off factor of spatial sounds.
  33274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33275. */
  33276. rolloffFactor: number;
  33277. /**
  33278. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33279. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33280. */
  33281. maxDistance: number;
  33282. /**
  33283. * Define the distance attenuation model the sound will follow.
  33284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33285. */
  33286. distanceModel: string;
  33287. /**
  33288. * @hidden
  33289. * Back Compat
  33290. **/
  33291. onended: () => any;
  33292. /**
  33293. * Observable event when the current playing sound finishes.
  33294. */
  33295. onEndedObservable: Observable<Sound>;
  33296. private _panningModel;
  33297. private _playbackRate;
  33298. private _streaming;
  33299. private _startTime;
  33300. private _startOffset;
  33301. private _position;
  33302. /** @hidden */ positionInEmitterSpace: boolean;
  33303. private _localDirection;
  33304. private _volume;
  33305. private _isReadyToPlay;
  33306. private _isDirectional;
  33307. private _readyToPlayCallback;
  33308. private _audioBuffer;
  33309. private _soundSource;
  33310. private _streamingSource;
  33311. private _soundPanner;
  33312. private _soundGain;
  33313. private _inputAudioNode;
  33314. private _outputAudioNode;
  33315. private _coneInnerAngle;
  33316. private _coneOuterAngle;
  33317. private _coneOuterGain;
  33318. private _scene;
  33319. private _connectedTransformNode;
  33320. private _customAttenuationFunction;
  33321. private _registerFunc;
  33322. private _isOutputConnected;
  33323. private _htmlAudioElement;
  33324. private _urlType;
  33325. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33326. /**
  33327. * Create a sound and attach it to a scene
  33328. * @param name Name of your sound
  33329. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33330. * @param scene defines the scene the sound belongs to
  33331. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33332. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33333. */
  33334. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33335. /**
  33336. * Release the sound and its associated resources
  33337. */
  33338. dispose(): void;
  33339. /**
  33340. * Gets if the sounds is ready to be played or not.
  33341. * @returns true if ready, otherwise false
  33342. */
  33343. isReady(): boolean;
  33344. private _soundLoaded;
  33345. /**
  33346. * Sets the data of the sound from an audiobuffer
  33347. * @param audioBuffer The audioBuffer containing the data
  33348. */
  33349. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33350. /**
  33351. * Updates the current sounds options such as maxdistance, loop...
  33352. * @param options A JSON object containing values named as the object properties
  33353. */
  33354. updateOptions(options: any): void;
  33355. private _createSpatialParameters;
  33356. private _updateSpatialParameters;
  33357. /**
  33358. * Switch the panning model to HRTF:
  33359. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33361. */
  33362. switchPanningModelToHRTF(): void;
  33363. /**
  33364. * Switch the panning model to Equal Power:
  33365. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33367. */
  33368. switchPanningModelToEqualPower(): void;
  33369. private _switchPanningModel;
  33370. /**
  33371. * Connect this sound to a sound track audio node like gain...
  33372. * @param soundTrackAudioNode the sound track audio node to connect to
  33373. */
  33374. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33375. /**
  33376. * Transform this sound into a directional source
  33377. * @param coneInnerAngle Size of the inner cone in degree
  33378. * @param coneOuterAngle Size of the outer cone in degree
  33379. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33380. */
  33381. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33382. /**
  33383. * Gets or sets the inner angle for the directional cone.
  33384. */
  33385. /**
  33386. * Gets or sets the inner angle for the directional cone.
  33387. */
  33388. directionalConeInnerAngle: number;
  33389. /**
  33390. * Gets or sets the outer angle for the directional cone.
  33391. */
  33392. /**
  33393. * Gets or sets the outer angle for the directional cone.
  33394. */
  33395. directionalConeOuterAngle: number;
  33396. /**
  33397. * Sets the position of the emitter if spatial sound is enabled
  33398. * @param newPosition Defines the new posisiton
  33399. */
  33400. setPosition(newPosition: Vector3): void;
  33401. /**
  33402. * Sets the local direction of the emitter if spatial sound is enabled
  33403. * @param newLocalDirection Defines the new local direction
  33404. */
  33405. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33406. private _updateDirection;
  33407. /** @hidden */
  33408. updateDistanceFromListener(): void;
  33409. /**
  33410. * Sets a new custom attenuation function for the sound.
  33411. * @param callback Defines the function used for the attenuation
  33412. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33413. */
  33414. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33415. /**
  33416. * Play the sound
  33417. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33418. * @param offset (optional) Start the sound setting it at a specific time
  33419. */
  33420. play(time?: number, offset?: number): void;
  33421. private _onended;
  33422. /**
  33423. * Stop the sound
  33424. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33425. */
  33426. stop(time?: number): void;
  33427. /**
  33428. * Put the sound in pause
  33429. */
  33430. pause(): void;
  33431. /**
  33432. * Sets a dedicated volume for this sounds
  33433. * @param newVolume Define the new volume of the sound
  33434. * @param time Define in how long the sound should be at this value
  33435. */
  33436. setVolume(newVolume: number, time?: number): void;
  33437. /**
  33438. * Set the sound play back rate
  33439. * @param newPlaybackRate Define the playback rate the sound should be played at
  33440. */
  33441. setPlaybackRate(newPlaybackRate: number): void;
  33442. /**
  33443. * Gets the volume of the sound.
  33444. * @returns the volume of the sound
  33445. */
  33446. getVolume(): number;
  33447. /**
  33448. * Attach the sound to a dedicated mesh
  33449. * @param transformNode The transform node to connect the sound with
  33450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33451. */
  33452. attachToMesh(transformNode: TransformNode): void;
  33453. /**
  33454. * Detach the sound from the previously attached mesh
  33455. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33456. */
  33457. detachFromMesh(): void;
  33458. private _onRegisterAfterWorldMatrixUpdate;
  33459. /**
  33460. * Clone the current sound in the scene.
  33461. * @returns the new sound clone
  33462. */
  33463. clone(): Nullable<Sound>;
  33464. /**
  33465. * Gets the current underlying audio buffer containing the data
  33466. * @returns the audio buffer
  33467. */
  33468. getAudioBuffer(): Nullable<AudioBuffer>;
  33469. /**
  33470. * Serializes the Sound in a JSON representation
  33471. * @returns the JSON representation of the sound
  33472. */
  33473. serialize(): any;
  33474. /**
  33475. * Parse a JSON representation of a sound to innstantiate in a given scene
  33476. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33477. * @param scene Define the scene the new parsed sound should be created in
  33478. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33479. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33480. * @returns the newly parsed sound
  33481. */
  33482. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33483. }
  33484. }
  33485. declare module BABYLON {
  33486. /**
  33487. * This defines an action helpful to play a defined sound on a triggered action.
  33488. */
  33489. export class PlaySoundAction extends Action {
  33490. private _sound;
  33491. /**
  33492. * Instantiate the action
  33493. * @param triggerOptions defines the trigger options
  33494. * @param sound defines the sound to play
  33495. * @param condition defines the trigger related conditions
  33496. */
  33497. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33498. /** @hidden */ prepare(): void;
  33499. /**
  33500. * Execute the action and play the sound.
  33501. */
  33502. execute(): void;
  33503. /**
  33504. * Serializes the actions and its related information.
  33505. * @param parent defines the object to serialize in
  33506. * @returns the serialized object
  33507. */
  33508. serialize(parent: any): any;
  33509. }
  33510. /**
  33511. * This defines an action helpful to stop a defined sound on a triggered action.
  33512. */
  33513. export class StopSoundAction extends Action {
  33514. private _sound;
  33515. /**
  33516. * Instantiate the action
  33517. * @param triggerOptions defines the trigger options
  33518. * @param sound defines the sound to stop
  33519. * @param condition defines the trigger related conditions
  33520. */
  33521. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33522. /** @hidden */ prepare(): void;
  33523. /**
  33524. * Execute the action and stop the sound.
  33525. */
  33526. execute(): void;
  33527. /**
  33528. * Serializes the actions and its related information.
  33529. * @param parent defines the object to serialize in
  33530. * @returns the serialized object
  33531. */
  33532. serialize(parent: any): any;
  33533. }
  33534. }
  33535. declare module BABYLON {
  33536. /**
  33537. * This defines an action responsible to change the value of a property
  33538. * by interpolating between its current value and the newly set one once triggered.
  33539. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33540. */
  33541. export class InterpolateValueAction extends Action {
  33542. /**
  33543. * Defines the path of the property where the value should be interpolated
  33544. */
  33545. propertyPath: string;
  33546. /**
  33547. * Defines the target value at the end of the interpolation.
  33548. */
  33549. value: any;
  33550. /**
  33551. * Defines the time it will take for the property to interpolate to the value.
  33552. */
  33553. duration: number;
  33554. /**
  33555. * Defines if the other scene animations should be stopped when the action has been triggered
  33556. */
  33557. stopOtherAnimations?: boolean;
  33558. /**
  33559. * Defines a callback raised once the interpolation animation has been done.
  33560. */
  33561. onInterpolationDone?: () => void;
  33562. /**
  33563. * Observable triggered once the interpolation animation has been done.
  33564. */
  33565. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33566. private _target;
  33567. private _effectiveTarget;
  33568. private _property;
  33569. /**
  33570. * Instantiate the action
  33571. * @param triggerOptions defines the trigger options
  33572. * @param target defines the object containing the value to interpolate
  33573. * @param propertyPath defines the path to the property in the target object
  33574. * @param value defines the target value at the end of the interpolation
  33575. * @param duration deines the time it will take for the property to interpolate to the value.
  33576. * @param condition defines the trigger related conditions
  33577. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33578. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33579. */
  33580. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33581. /** @hidden */ prepare(): void;
  33582. /**
  33583. * Execute the action starts the value interpolation.
  33584. */
  33585. execute(): void;
  33586. /**
  33587. * Serializes the actions and its related information.
  33588. * @param parent defines the object to serialize in
  33589. * @returns the serialized object
  33590. */
  33591. serialize(parent: any): any;
  33592. }
  33593. }
  33594. declare module BABYLON {
  33595. /**
  33596. * Options allowed during the creation of a sound track.
  33597. */
  33598. export interface ISoundTrackOptions {
  33599. /**
  33600. * The volume the sound track should take during creation
  33601. */
  33602. volume?: number;
  33603. /**
  33604. * Define if the sound track is the main sound track of the scene
  33605. */
  33606. mainTrack?: boolean;
  33607. }
  33608. /**
  33609. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33610. * It will be also used in a future release to apply effects on a specific track.
  33611. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33612. */
  33613. export class SoundTrack {
  33614. /**
  33615. * The unique identifier of the sound track in the scene.
  33616. */
  33617. id: number;
  33618. /**
  33619. * The list of sounds included in the sound track.
  33620. */
  33621. soundCollection: Array<Sound>;
  33622. private _outputAudioNode;
  33623. private _scene;
  33624. private _isMainTrack;
  33625. private _connectedAnalyser;
  33626. private _options;
  33627. private _isInitialized;
  33628. /**
  33629. * Creates a new sound track.
  33630. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33631. * @param scene Define the scene the sound track belongs to
  33632. * @param options
  33633. */
  33634. constructor(scene: Scene, options?: ISoundTrackOptions);
  33635. private _initializeSoundTrackAudioGraph;
  33636. /**
  33637. * Release the sound track and its associated resources
  33638. */
  33639. dispose(): void;
  33640. /**
  33641. * Adds a sound to this sound track
  33642. * @param sound define the cound to add
  33643. * @ignoreNaming
  33644. */
  33645. AddSound(sound: Sound): void;
  33646. /**
  33647. * Removes a sound to this sound track
  33648. * @param sound define the cound to remove
  33649. * @ignoreNaming
  33650. */
  33651. RemoveSound(sound: Sound): void;
  33652. /**
  33653. * Set a global volume for the full sound track.
  33654. * @param newVolume Define the new volume of the sound track
  33655. */
  33656. setVolume(newVolume: number): void;
  33657. /**
  33658. * Switch the panning model to HRTF:
  33659. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33660. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33661. */
  33662. switchPanningModelToHRTF(): void;
  33663. /**
  33664. * Switch the panning model to Equal Power:
  33665. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33666. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33667. */
  33668. switchPanningModelToEqualPower(): void;
  33669. /**
  33670. * Connect the sound track to an audio analyser allowing some amazing
  33671. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33673. * @param analyser The analyser to connect to the engine
  33674. */
  33675. connectToAnalyser(analyser: Analyser): void;
  33676. }
  33677. }
  33678. declare module BABYLON {
  33679. interface AbstractScene {
  33680. /**
  33681. * The list of sounds used in the scene.
  33682. */
  33683. sounds: Nullable<Array<Sound>>;
  33684. }
  33685. interface Scene {
  33686. /**
  33687. * @hidden
  33688. * Backing field
  33689. */ mainSoundTrack: SoundTrack;
  33690. /**
  33691. * The main sound track played by the scene.
  33692. * It cotains your primary collection of sounds.
  33693. */
  33694. mainSoundTrack: SoundTrack;
  33695. /**
  33696. * The list of sound tracks added to the scene
  33697. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33698. */
  33699. soundTracks: Nullable<Array<SoundTrack>>;
  33700. /**
  33701. * Gets a sound using a given name
  33702. * @param name defines the name to search for
  33703. * @return the found sound or null if not found at all.
  33704. */
  33705. getSoundByName(name: string): Nullable<Sound>;
  33706. /**
  33707. * Gets or sets if audio support is enabled
  33708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33709. */
  33710. audioEnabled: boolean;
  33711. /**
  33712. * Gets or sets if audio will be output to headphones
  33713. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33714. */
  33715. headphone: boolean;
  33716. }
  33717. /**
  33718. * Defines the sound scene component responsible to manage any sounds
  33719. * in a given scene.
  33720. */
  33721. export class AudioSceneComponent implements ISceneSerializableComponent {
  33722. /**
  33723. * The component name helpfull to identify the component in the list of scene components.
  33724. */
  33725. readonly name: string;
  33726. /**
  33727. * The scene the component belongs to.
  33728. */
  33729. scene: Scene;
  33730. private _audioEnabled;
  33731. /**
  33732. * Gets whether audio is enabled or not.
  33733. * Please use related enable/disable method to switch state.
  33734. */
  33735. readonly audioEnabled: boolean;
  33736. private _headphone;
  33737. /**
  33738. * Gets whether audio is outputing to headphone or not.
  33739. * Please use the according Switch methods to change output.
  33740. */
  33741. readonly headphone: boolean;
  33742. /**
  33743. * Creates a new instance of the component for the given scene
  33744. * @param scene Defines the scene to register the component in
  33745. */
  33746. constructor(scene: Scene);
  33747. /**
  33748. * Registers the component in a given scene
  33749. */
  33750. register(): void;
  33751. /**
  33752. * Rebuilds the elements related to this component in case of
  33753. * context lost for instance.
  33754. */
  33755. rebuild(): void;
  33756. /**
  33757. * Serializes the component data to the specified json object
  33758. * @param serializationObject The object to serialize to
  33759. */
  33760. serialize(serializationObject: any): void;
  33761. /**
  33762. * Adds all the element from the container to the scene
  33763. * @param container the container holding the elements
  33764. */
  33765. addFromContainer(container: AbstractScene): void;
  33766. /**
  33767. * Removes all the elements in the container from the scene
  33768. * @param container contains the elements to remove
  33769. * @param dispose if the removed element should be disposed (default: false)
  33770. */
  33771. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33772. /**
  33773. * Disposes the component and the associated ressources.
  33774. */
  33775. dispose(): void;
  33776. /**
  33777. * Disables audio in the associated scene.
  33778. */
  33779. disableAudio(): void;
  33780. /**
  33781. * Enables audio in the associated scene.
  33782. */
  33783. enableAudio(): void;
  33784. /**
  33785. * Switch audio to headphone output.
  33786. */
  33787. switchAudioModeForHeadphones(): void;
  33788. /**
  33789. * Switch audio to normal speakers.
  33790. */
  33791. switchAudioModeForNormalSpeakers(): void;
  33792. private _afterRender;
  33793. }
  33794. }
  33795. declare module BABYLON {
  33796. /**
  33797. * Wraps one or more Sound objects and selects one with random weight for playback.
  33798. */
  33799. export class WeightedSound {
  33800. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33801. loop: boolean;
  33802. private _coneInnerAngle;
  33803. private _coneOuterAngle;
  33804. private _volume;
  33805. /** A Sound is currently playing. */
  33806. isPlaying: boolean;
  33807. /** A Sound is currently paused. */
  33808. isPaused: boolean;
  33809. private _sounds;
  33810. private _weights;
  33811. private _currentIndex?;
  33812. /**
  33813. * Creates a new WeightedSound from the list of sounds given.
  33814. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33815. * @param sounds Array of Sounds that will be selected from.
  33816. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33817. */
  33818. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33819. /**
  33820. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33821. */
  33822. /**
  33823. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33824. */
  33825. directionalConeInnerAngle: number;
  33826. /**
  33827. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33828. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33829. */
  33830. /**
  33831. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33832. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33833. */
  33834. directionalConeOuterAngle: number;
  33835. /**
  33836. * Playback volume.
  33837. */
  33838. /**
  33839. * Playback volume.
  33840. */
  33841. volume: number;
  33842. private _onended;
  33843. /**
  33844. * Suspend playback
  33845. */
  33846. pause(): void;
  33847. /**
  33848. * Stop playback
  33849. */
  33850. stop(): void;
  33851. /**
  33852. * Start playback.
  33853. * @param startOffset Position the clip head at a specific time in seconds.
  33854. */
  33855. play(startOffset?: number): void;
  33856. }
  33857. }
  33858. declare module BABYLON {
  33859. /**
  33860. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33861. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33862. */
  33863. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33864. /**
  33865. * Gets the name of the behavior.
  33866. */
  33867. readonly name: string;
  33868. /**
  33869. * The easing function used by animations
  33870. */
  33871. static EasingFunction: BackEase;
  33872. /**
  33873. * The easing mode used by animations
  33874. */
  33875. static EasingMode: number;
  33876. /**
  33877. * The duration of the animation, in milliseconds
  33878. */
  33879. transitionDuration: number;
  33880. /**
  33881. * Length of the distance animated by the transition when lower radius is reached
  33882. */
  33883. lowerRadiusTransitionRange: number;
  33884. /**
  33885. * Length of the distance animated by the transition when upper radius is reached
  33886. */
  33887. upperRadiusTransitionRange: number;
  33888. private _autoTransitionRange;
  33889. /**
  33890. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33891. */
  33892. /**
  33893. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33894. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33895. */
  33896. autoTransitionRange: boolean;
  33897. private _attachedCamera;
  33898. private _onAfterCheckInputsObserver;
  33899. private _onMeshTargetChangedObserver;
  33900. /**
  33901. * Initializes the behavior.
  33902. */
  33903. init(): void;
  33904. /**
  33905. * Attaches the behavior to its arc rotate camera.
  33906. * @param camera Defines the camera to attach the behavior to
  33907. */
  33908. attach(camera: ArcRotateCamera): void;
  33909. /**
  33910. * Detaches the behavior from its current arc rotate camera.
  33911. */
  33912. detach(): void;
  33913. private _radiusIsAnimating;
  33914. private _radiusBounceTransition;
  33915. private _animatables;
  33916. private _cachedWheelPrecision;
  33917. /**
  33918. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33919. * @param radiusLimit The limit to check against.
  33920. * @return Bool to indicate if at limit.
  33921. */
  33922. private _isRadiusAtLimit;
  33923. /**
  33924. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33925. * @param radiusDelta The delta by which to animate to. Can be negative.
  33926. */
  33927. private _applyBoundRadiusAnimation;
  33928. /**
  33929. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33930. */
  33931. protected _clearAnimationLocks(): void;
  33932. /**
  33933. * Stops and removes all animations that have been applied to the camera
  33934. */
  33935. stopAllAnimations(): void;
  33936. }
  33937. }
  33938. declare module BABYLON {
  33939. /**
  33940. * 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.
  33941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33942. */
  33943. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33944. /**
  33945. * Gets the name of the behavior.
  33946. */
  33947. readonly name: string;
  33948. private _mode;
  33949. private _radiusScale;
  33950. private _positionScale;
  33951. private _defaultElevation;
  33952. private _elevationReturnTime;
  33953. private _elevationReturnWaitTime;
  33954. private _zoomStopsAnimation;
  33955. private _framingTime;
  33956. /**
  33957. * The easing function used by animations
  33958. */
  33959. static EasingFunction: ExponentialEase;
  33960. /**
  33961. * The easing mode used by animations
  33962. */
  33963. static EasingMode: number;
  33964. /**
  33965. * Sets the current mode used by the behavior
  33966. */
  33967. /**
  33968. * Gets current mode used by the behavior.
  33969. */
  33970. mode: number;
  33971. /**
  33972. * Sets the scale applied to the radius (1 by default)
  33973. */
  33974. /**
  33975. * Gets the scale applied to the radius
  33976. */
  33977. radiusScale: number;
  33978. /**
  33979. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33980. */
  33981. /**
  33982. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33983. */
  33984. positionScale: number;
  33985. /**
  33986. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33987. * behaviour is triggered, in radians.
  33988. */
  33989. /**
  33990. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33991. * behaviour is triggered, in radians.
  33992. */
  33993. defaultElevation: number;
  33994. /**
  33995. * Sets the time (in milliseconds) taken to return to the default beta position.
  33996. * Negative value indicates camera should not return to default.
  33997. */
  33998. /**
  33999. * Gets the time (in milliseconds) taken to return to the default beta position.
  34000. * Negative value indicates camera should not return to default.
  34001. */
  34002. elevationReturnTime: number;
  34003. /**
  34004. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34005. */
  34006. /**
  34007. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34008. */
  34009. elevationReturnWaitTime: number;
  34010. /**
  34011. * Sets the flag that indicates if user zooming should stop animation.
  34012. */
  34013. /**
  34014. * Gets the flag that indicates if user zooming should stop animation.
  34015. */
  34016. zoomStopsAnimation: boolean;
  34017. /**
  34018. * Sets the transition time when framing the mesh, in milliseconds
  34019. */
  34020. /**
  34021. * Gets the transition time when framing the mesh, in milliseconds
  34022. */
  34023. framingTime: number;
  34024. /**
  34025. * Define if the behavior should automatically change the configured
  34026. * camera limits and sensibilities.
  34027. */
  34028. autoCorrectCameraLimitsAndSensibility: boolean;
  34029. private _onPrePointerObservableObserver;
  34030. private _onAfterCheckInputsObserver;
  34031. private _onMeshTargetChangedObserver;
  34032. private _attachedCamera;
  34033. private _isPointerDown;
  34034. private _lastInteractionTime;
  34035. /**
  34036. * Initializes the behavior.
  34037. */
  34038. init(): void;
  34039. /**
  34040. * Attaches the behavior to its arc rotate camera.
  34041. * @param camera Defines the camera to attach the behavior to
  34042. */
  34043. attach(camera: ArcRotateCamera): void;
  34044. /**
  34045. * Detaches the behavior from its current arc rotate camera.
  34046. */
  34047. detach(): void;
  34048. private _animatables;
  34049. private _betaIsAnimating;
  34050. private _betaTransition;
  34051. private _radiusTransition;
  34052. private _vectorTransition;
  34053. /**
  34054. * Targets the given mesh and updates zoom level accordingly.
  34055. * @param mesh The mesh to target.
  34056. * @param radius Optional. If a cached radius position already exists, overrides default.
  34057. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34058. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34059. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34060. */
  34061. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34062. /**
  34063. * Targets the given mesh with its children and updates zoom level accordingly.
  34064. * @param mesh The mesh to target.
  34065. * @param radius Optional. If a cached radius position already exists, overrides default.
  34066. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34067. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34068. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34069. */
  34070. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34071. /**
  34072. * Targets the given meshes with their children and updates zoom level accordingly.
  34073. * @param meshes The mesh to target.
  34074. * @param radius Optional. If a cached radius position already exists, overrides default.
  34075. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34076. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34077. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34078. */
  34079. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34080. /**
  34081. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34082. * @param minimumWorld Determines the smaller position of the bounding box extend
  34083. * @param maximumWorld Determines the bigger position of the bounding box extend
  34084. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34085. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34086. */
  34087. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34088. /**
  34089. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34090. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34091. * frustum width.
  34092. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34093. * to fully enclose the mesh in the viewing frustum.
  34094. */
  34095. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34096. /**
  34097. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34098. * is automatically returned to its default position (expected to be above ground plane).
  34099. */
  34100. private _maintainCameraAboveGround;
  34101. /**
  34102. * Returns the frustum slope based on the canvas ratio and camera FOV
  34103. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34104. */
  34105. private _getFrustumSlope;
  34106. /**
  34107. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34108. */
  34109. private _clearAnimationLocks;
  34110. /**
  34111. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34112. */
  34113. private _applyUserInteraction;
  34114. /**
  34115. * Stops and removes all animations that have been applied to the camera
  34116. */
  34117. stopAllAnimations(): void;
  34118. /**
  34119. * Gets a value indicating if the user is moving the camera
  34120. */
  34121. readonly isUserIsMoving: boolean;
  34122. /**
  34123. * The camera can move all the way towards the mesh.
  34124. */
  34125. static IgnoreBoundsSizeMode: number;
  34126. /**
  34127. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34128. */
  34129. static FitFrustumSidesMode: number;
  34130. }
  34131. }
  34132. declare module BABYLON {
  34133. /**
  34134. * Base class for Camera Pointer Inputs.
  34135. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34136. * for example usage.
  34137. */
  34138. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34139. /**
  34140. * Defines the camera the input is attached to.
  34141. */
  34142. abstract camera: Camera;
  34143. /**
  34144. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34145. */
  34146. protected _altKey: boolean;
  34147. protected _ctrlKey: boolean;
  34148. protected _metaKey: boolean;
  34149. protected _shiftKey: boolean;
  34150. /**
  34151. * Which mouse buttons were pressed at time of last mouse event.
  34152. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34153. */
  34154. protected _buttonsPressed: number;
  34155. /**
  34156. * Defines the buttons associated with the input to handle camera move.
  34157. */
  34158. buttons: number[];
  34159. /**
  34160. * Attach the input controls to a specific dom element to get the input from.
  34161. * @param element Defines the element the controls should be listened from
  34162. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34163. */
  34164. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34165. /**
  34166. * Detach the current controls from the specified dom element.
  34167. * @param element Defines the element to stop listening the inputs from
  34168. */
  34169. detachControl(element: Nullable<HTMLElement>): void;
  34170. /**
  34171. * Gets the class name of the current input.
  34172. * @returns the class name
  34173. */
  34174. getClassName(): string;
  34175. /**
  34176. * Get the friendly name associated with the input class.
  34177. * @returns the input friendly name
  34178. */
  34179. getSimpleName(): string;
  34180. /**
  34181. * Called on pointer POINTERDOUBLETAP event.
  34182. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34183. */
  34184. protected onDoubleTap(type: string): void;
  34185. /**
  34186. * Called on pointer POINTERMOVE event if only a single touch is active.
  34187. * Override this method to provide functionality.
  34188. */
  34189. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34190. /**
  34191. * Called on pointer POINTERMOVE event if multiple touches are active.
  34192. * Override this method to provide functionality.
  34193. */
  34194. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34195. /**
  34196. * Called on JS contextmenu event.
  34197. * Override this method to provide functionality.
  34198. */
  34199. protected onContextMenu(evt: PointerEvent): void;
  34200. /**
  34201. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34202. * press.
  34203. * Override this method to provide functionality.
  34204. */
  34205. protected onButtonDown(evt: PointerEvent): void;
  34206. /**
  34207. * Called each time a new POINTERUP event occurs. Ie, for each button
  34208. * release.
  34209. * Override this method to provide functionality.
  34210. */
  34211. protected onButtonUp(evt: PointerEvent): void;
  34212. /**
  34213. * Called when window becomes inactive.
  34214. * Override this method to provide functionality.
  34215. */
  34216. protected onLostFocus(): void;
  34217. private _pointerInput;
  34218. private _observer;
  34219. private _onLostFocus;
  34220. private pointA;
  34221. private pointB;
  34222. }
  34223. }
  34224. declare module BABYLON {
  34225. /**
  34226. * Manage the pointers inputs to control an arc rotate camera.
  34227. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34228. */
  34229. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34230. /**
  34231. * Defines the camera the input is attached to.
  34232. */
  34233. camera: ArcRotateCamera;
  34234. /**
  34235. * Gets the class name of the current input.
  34236. * @returns the class name
  34237. */
  34238. getClassName(): string;
  34239. /**
  34240. * Defines the buttons associated with the input to handle camera move.
  34241. */
  34242. buttons: number[];
  34243. /**
  34244. * Defines the pointer angular sensibility along the X axis or how fast is
  34245. * the camera rotating.
  34246. */
  34247. angularSensibilityX: number;
  34248. /**
  34249. * Defines the pointer angular sensibility along the Y axis or how fast is
  34250. * the camera rotating.
  34251. */
  34252. angularSensibilityY: number;
  34253. /**
  34254. * Defines the pointer pinch precision or how fast is the camera zooming.
  34255. */
  34256. pinchPrecision: number;
  34257. /**
  34258. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34259. * from 0.
  34260. * It defines the percentage of current camera.radius to use as delta when
  34261. * pinch zoom is used.
  34262. */
  34263. pinchDeltaPercentage: number;
  34264. /**
  34265. * Defines the pointer panning sensibility or how fast is the camera moving.
  34266. */
  34267. panningSensibility: number;
  34268. /**
  34269. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34270. */
  34271. multiTouchPanning: boolean;
  34272. /**
  34273. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34274. * zoom (pinch) through multitouch.
  34275. */
  34276. multiTouchPanAndZoom: boolean;
  34277. /**
  34278. * Revers pinch action direction.
  34279. */
  34280. pinchInwards: boolean;
  34281. private _isPanClick;
  34282. private _twoFingerActivityCount;
  34283. private _isPinching;
  34284. /**
  34285. * Called on pointer POINTERMOVE event if only a single touch is active.
  34286. */
  34287. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34288. /**
  34289. * Called on pointer POINTERDOUBLETAP event.
  34290. */
  34291. protected onDoubleTap(type: string): void;
  34292. /**
  34293. * Called on pointer POINTERMOVE event if multiple touches are active.
  34294. */
  34295. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34296. /**
  34297. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34298. * press.
  34299. */
  34300. protected onButtonDown(evt: PointerEvent): void;
  34301. /**
  34302. * Called each time a new POINTERUP event occurs. Ie, for each button
  34303. * release.
  34304. */
  34305. protected onButtonUp(evt: PointerEvent): void;
  34306. /**
  34307. * Called when window becomes inactive.
  34308. */
  34309. protected onLostFocus(): void;
  34310. }
  34311. }
  34312. declare module BABYLON {
  34313. /**
  34314. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34315. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34316. */
  34317. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34318. /**
  34319. * Defines the camera the input is attached to.
  34320. */
  34321. camera: ArcRotateCamera;
  34322. /**
  34323. * Defines the list of key codes associated with the up action (increase alpha)
  34324. */
  34325. keysUp: number[];
  34326. /**
  34327. * Defines the list of key codes associated with the down action (decrease alpha)
  34328. */
  34329. keysDown: number[];
  34330. /**
  34331. * Defines the list of key codes associated with the left action (increase beta)
  34332. */
  34333. keysLeft: number[];
  34334. /**
  34335. * Defines the list of key codes associated with the right action (decrease beta)
  34336. */
  34337. keysRight: number[];
  34338. /**
  34339. * Defines the list of key codes associated with the reset action.
  34340. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34341. */
  34342. keysReset: number[];
  34343. /**
  34344. * Defines the panning sensibility of the inputs.
  34345. * (How fast is the camera paning)
  34346. */
  34347. panningSensibility: number;
  34348. /**
  34349. * Defines the zooming sensibility of the inputs.
  34350. * (How fast is the camera zooming)
  34351. */
  34352. zoomingSensibility: number;
  34353. /**
  34354. * Defines wether maintaining the alt key down switch the movement mode from
  34355. * orientation to zoom.
  34356. */
  34357. useAltToZoom: boolean;
  34358. /**
  34359. * Rotation speed of the camera
  34360. */
  34361. angularSpeed: number;
  34362. private _keys;
  34363. private _ctrlPressed;
  34364. private _altPressed;
  34365. private _onCanvasBlurObserver;
  34366. private _onKeyboardObserver;
  34367. private _engine;
  34368. private _scene;
  34369. /**
  34370. * Attach the input controls to a specific dom element to get the input from.
  34371. * @param element Defines the element the controls should be listened from
  34372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34373. */
  34374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34375. /**
  34376. * Detach the current controls from the specified dom element.
  34377. * @param element Defines the element to stop listening the inputs from
  34378. */
  34379. detachControl(element: Nullable<HTMLElement>): void;
  34380. /**
  34381. * Update the current camera state depending on the inputs that have been used this frame.
  34382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34383. */
  34384. checkInputs(): void;
  34385. /**
  34386. * Gets the class name of the current intput.
  34387. * @returns the class name
  34388. */
  34389. getClassName(): string;
  34390. /**
  34391. * Get the friendly name associated with the input class.
  34392. * @returns the input friendly name
  34393. */
  34394. getSimpleName(): string;
  34395. }
  34396. }
  34397. declare module BABYLON {
  34398. /**
  34399. * Manage the mouse wheel inputs to control an arc rotate camera.
  34400. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34401. */
  34402. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34403. /**
  34404. * Defines the camera the input is attached to.
  34405. */
  34406. camera: ArcRotateCamera;
  34407. /**
  34408. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34409. */
  34410. wheelPrecision: number;
  34411. /**
  34412. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34413. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34414. */
  34415. wheelDeltaPercentage: number;
  34416. private _wheel;
  34417. private _observer;
  34418. private computeDeltaFromMouseWheelLegacyEvent;
  34419. /**
  34420. * Attach the input controls to a specific dom element to get the input from.
  34421. * @param element Defines the element the controls should be listened from
  34422. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34423. */
  34424. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34425. /**
  34426. * Detach the current controls from the specified dom element.
  34427. * @param element Defines the element to stop listening the inputs from
  34428. */
  34429. detachControl(element: Nullable<HTMLElement>): void;
  34430. /**
  34431. * Gets the class name of the current intput.
  34432. * @returns the class name
  34433. */
  34434. getClassName(): string;
  34435. /**
  34436. * Get the friendly name associated with the input class.
  34437. * @returns the input friendly name
  34438. */
  34439. getSimpleName(): string;
  34440. }
  34441. }
  34442. declare module BABYLON {
  34443. /**
  34444. * Default Inputs manager for the ArcRotateCamera.
  34445. * It groups all the default supported inputs for ease of use.
  34446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34447. */
  34448. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34449. /**
  34450. * Instantiates a new ArcRotateCameraInputsManager.
  34451. * @param camera Defines the camera the inputs belong to
  34452. */
  34453. constructor(camera: ArcRotateCamera);
  34454. /**
  34455. * Add mouse wheel input support to the input manager.
  34456. * @returns the current input manager
  34457. */
  34458. addMouseWheel(): ArcRotateCameraInputsManager;
  34459. /**
  34460. * Add pointers input support to the input manager.
  34461. * @returns the current input manager
  34462. */
  34463. addPointers(): ArcRotateCameraInputsManager;
  34464. /**
  34465. * Add keyboard input support to the input manager.
  34466. * @returns the current input manager
  34467. */
  34468. addKeyboard(): ArcRotateCameraInputsManager;
  34469. }
  34470. }
  34471. declare module BABYLON {
  34472. /**
  34473. * This represents an orbital type of camera.
  34474. *
  34475. * 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.
  34476. * 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.
  34477. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34478. */
  34479. export class ArcRotateCamera extends TargetCamera {
  34480. /**
  34481. * Defines the rotation angle of the camera along the longitudinal axis.
  34482. */
  34483. alpha: number;
  34484. /**
  34485. * Defines the rotation angle of the camera along the latitudinal axis.
  34486. */
  34487. beta: number;
  34488. /**
  34489. * Defines the radius of the camera from it s target point.
  34490. */
  34491. radius: number;
  34492. protected _target: Vector3;
  34493. protected _targetHost: Nullable<AbstractMesh>;
  34494. /**
  34495. * Defines the target point of the camera.
  34496. * The camera looks towards it form the radius distance.
  34497. */
  34498. target: Vector3;
  34499. /**
  34500. * Define the current local position of the camera in the scene
  34501. */
  34502. position: Vector3;
  34503. protected _upVector: Vector3;
  34504. protected _upToYMatrix: Matrix;
  34505. protected _YToUpMatrix: Matrix;
  34506. /**
  34507. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34508. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34509. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34510. */
  34511. upVector: Vector3;
  34512. /**
  34513. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34514. */
  34515. setMatUp(): void;
  34516. /**
  34517. * Current inertia value on the longitudinal axis.
  34518. * The bigger this number the longer it will take for the camera to stop.
  34519. */
  34520. inertialAlphaOffset: number;
  34521. /**
  34522. * Current inertia value on the latitudinal axis.
  34523. * The bigger this number the longer it will take for the camera to stop.
  34524. */
  34525. inertialBetaOffset: number;
  34526. /**
  34527. * Current inertia value on the radius axis.
  34528. * The bigger this number the longer it will take for the camera to stop.
  34529. */
  34530. inertialRadiusOffset: number;
  34531. /**
  34532. * Minimum allowed angle on the longitudinal axis.
  34533. * This can help limiting how the Camera is able to move in the scene.
  34534. */
  34535. lowerAlphaLimit: Nullable<number>;
  34536. /**
  34537. * Maximum allowed angle on the longitudinal axis.
  34538. * This can help limiting how the Camera is able to move in the scene.
  34539. */
  34540. upperAlphaLimit: Nullable<number>;
  34541. /**
  34542. * Minimum allowed angle on the latitudinal axis.
  34543. * This can help limiting how the Camera is able to move in the scene.
  34544. */
  34545. lowerBetaLimit: number;
  34546. /**
  34547. * Maximum allowed angle on the latitudinal axis.
  34548. * This can help limiting how the Camera is able to move in the scene.
  34549. */
  34550. upperBetaLimit: number;
  34551. /**
  34552. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34553. * This can help limiting how the Camera is able to move in the scene.
  34554. */
  34555. lowerRadiusLimit: Nullable<number>;
  34556. /**
  34557. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34558. * This can help limiting how the Camera is able to move in the scene.
  34559. */
  34560. upperRadiusLimit: Nullable<number>;
  34561. /**
  34562. * Defines the current inertia value used during panning of the camera along the X axis.
  34563. */
  34564. inertialPanningX: number;
  34565. /**
  34566. * Defines the current inertia value used during panning of the camera along the Y axis.
  34567. */
  34568. inertialPanningY: number;
  34569. /**
  34570. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34571. * Basically if your fingers moves away from more than this distance you will be considered
  34572. * in pinch mode.
  34573. */
  34574. pinchToPanMaxDistance: number;
  34575. /**
  34576. * Defines the maximum distance the camera can pan.
  34577. * This could help keeping the cammera always in your scene.
  34578. */
  34579. panningDistanceLimit: Nullable<number>;
  34580. /**
  34581. * Defines the target of the camera before paning.
  34582. */
  34583. panningOriginTarget: Vector3;
  34584. /**
  34585. * Defines the value of the inertia used during panning.
  34586. * 0 would mean stop inertia and one would mean no decelleration at all.
  34587. */
  34588. panningInertia: number;
  34589. /**
  34590. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34591. */
  34592. angularSensibilityX: number;
  34593. /**
  34594. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34595. */
  34596. angularSensibilityY: number;
  34597. /**
  34598. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34599. */
  34600. pinchPrecision: number;
  34601. /**
  34602. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34603. * It will be used instead of pinchDeltaPrecision if different from 0.
  34604. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34605. */
  34606. pinchDeltaPercentage: number;
  34607. /**
  34608. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34609. */
  34610. panningSensibility: number;
  34611. /**
  34612. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34613. */
  34614. keysUp: number[];
  34615. /**
  34616. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34617. */
  34618. keysDown: number[];
  34619. /**
  34620. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34621. */
  34622. keysLeft: number[];
  34623. /**
  34624. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34625. */
  34626. keysRight: number[];
  34627. /**
  34628. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34629. */
  34630. wheelPrecision: number;
  34631. /**
  34632. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34633. * It will be used instead of pinchDeltaPrecision if different from 0.
  34634. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34635. */
  34636. wheelDeltaPercentage: number;
  34637. /**
  34638. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34639. */
  34640. zoomOnFactor: number;
  34641. /**
  34642. * Defines a screen offset for the camera position.
  34643. */
  34644. targetScreenOffset: Vector2;
  34645. /**
  34646. * Allows the camera to be completely reversed.
  34647. * If false the camera can not arrive upside down.
  34648. */
  34649. allowUpsideDown: boolean;
  34650. /**
  34651. * Define if double tap/click is used to restore the previously saved state of the camera.
  34652. */
  34653. useInputToRestoreState: boolean;
  34654. /** @hidden */ viewMatrix: Matrix;
  34655. /** @hidden */ useCtrlForPanning: boolean;
  34656. /** @hidden */ panningMouseButton: number;
  34657. /**
  34658. * Defines the input associated to the camera.
  34659. */
  34660. inputs: ArcRotateCameraInputsManager;
  34661. /** @hidden */ reset: () => void;
  34662. /**
  34663. * Defines the allowed panning axis.
  34664. */
  34665. panningAxis: Vector3;
  34666. protected _localDirection: Vector3;
  34667. protected _transformedDirection: Vector3;
  34668. private _bouncingBehavior;
  34669. /**
  34670. * Gets the bouncing behavior of the camera if it has been enabled.
  34671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34672. */
  34673. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34674. /**
  34675. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34676. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34677. */
  34678. useBouncingBehavior: boolean;
  34679. private _framingBehavior;
  34680. /**
  34681. * Gets the framing behavior of the camera if it has been enabled.
  34682. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34683. */
  34684. readonly framingBehavior: Nullable<FramingBehavior>;
  34685. /**
  34686. * Defines if the framing behavior of the camera is enabled on the camera.
  34687. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34688. */
  34689. useFramingBehavior: boolean;
  34690. private _autoRotationBehavior;
  34691. /**
  34692. * Gets the auto rotation behavior of the camera if it has been enabled.
  34693. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34694. */
  34695. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34696. /**
  34697. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34698. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34699. */
  34700. useAutoRotationBehavior: boolean;
  34701. /**
  34702. * Observable triggered when the mesh target has been changed on the camera.
  34703. */
  34704. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34705. /**
  34706. * Event raised when the camera is colliding with a mesh.
  34707. */
  34708. onCollide: (collidedMesh: AbstractMesh) => void;
  34709. /**
  34710. * Defines whether the camera should check collision with the objects oh the scene.
  34711. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34712. */
  34713. checkCollisions: boolean;
  34714. /**
  34715. * Defines the collision radius of the camera.
  34716. * This simulates a sphere around the camera.
  34717. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34718. */
  34719. collisionRadius: Vector3;
  34720. protected _collider: Collider;
  34721. protected _previousPosition: Vector3;
  34722. protected _collisionVelocity: Vector3;
  34723. protected _newPosition: Vector3;
  34724. protected _previousAlpha: number;
  34725. protected _previousBeta: number;
  34726. protected _previousRadius: number;
  34727. protected _collisionTriggered: boolean;
  34728. protected _targetBoundingCenter: Nullable<Vector3>;
  34729. private _computationVector;
  34730. /**
  34731. * Instantiates a new ArcRotateCamera in a given scene
  34732. * @param name Defines the name of the camera
  34733. * @param alpha Defines the camera rotation along the logitudinal axis
  34734. * @param beta Defines the camera rotation along the latitudinal axis
  34735. * @param radius Defines the camera distance from its target
  34736. * @param target Defines the camera target
  34737. * @param scene Defines the scene the camera belongs to
  34738. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34739. */
  34740. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34741. /** @hidden */ initCache(): void;
  34742. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34743. protected _getTargetPosition(): Vector3;
  34744. private _storedAlpha;
  34745. private _storedBeta;
  34746. private _storedRadius;
  34747. private _storedTarget;
  34748. /**
  34749. * Stores the current state of the camera (alpha, beta, radius and target)
  34750. * @returns the camera itself
  34751. */
  34752. storeState(): Camera;
  34753. /**
  34754. * @hidden
  34755. * Restored camera state. You must call storeState() first
  34756. */ restoreStateValues(): boolean;
  34757. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34758. /**
  34759. * Attached controls to the current camera.
  34760. * @param element Defines the element the controls should be listened from
  34761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34762. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34763. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34764. */
  34765. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34766. /**
  34767. * Detach the current controls from the camera.
  34768. * The camera will stop reacting to inputs.
  34769. * @param element Defines the element to stop listening the inputs from
  34770. */
  34771. detachControl(element: HTMLElement): void;
  34772. /** @hidden */ checkInputs(): void;
  34773. protected _checkLimits(): void;
  34774. /**
  34775. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34776. */
  34777. rebuildAnglesAndRadius(): void;
  34778. /**
  34779. * Use a position to define the current camera related information like aplha, beta and radius
  34780. * @param position Defines the position to set the camera at
  34781. */
  34782. setPosition(position: Vector3): void;
  34783. /**
  34784. * Defines the target the camera should look at.
  34785. * This will automatically adapt alpha beta and radius to fit within the new target.
  34786. * @param target Defines the new target as a Vector or a mesh
  34787. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34788. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34789. */
  34790. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34791. /** @hidden */ getViewMatrix(): Matrix;
  34792. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34793. /**
  34794. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34795. * @param meshes Defines the mesh to zoom on
  34796. * @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)
  34797. */
  34798. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34799. /**
  34800. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34801. * The target will be changed but the radius
  34802. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34803. * @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)
  34804. */
  34805. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34806. min: Vector3;
  34807. max: Vector3;
  34808. distance: number;
  34809. }, doNotUpdateMaxZ?: boolean): void;
  34810. /**
  34811. * @override
  34812. * Override Camera.createRigCamera
  34813. */
  34814. createRigCamera(name: string, cameraIndex: number): Camera;
  34815. /**
  34816. * @hidden
  34817. * @override
  34818. * Override Camera._updateRigCameras
  34819. */ updateRigCameras(): void;
  34820. /**
  34821. * Destroy the camera and release the current resources hold by it.
  34822. */
  34823. dispose(): void;
  34824. /**
  34825. * Gets the current object class name.
  34826. * @return the class name
  34827. */
  34828. getClassName(): string;
  34829. }
  34830. }
  34831. declare module BABYLON {
  34832. /**
  34833. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34834. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34835. */
  34836. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34837. /**
  34838. * Gets the name of the behavior.
  34839. */
  34840. readonly name: string;
  34841. private _zoomStopsAnimation;
  34842. private _idleRotationSpeed;
  34843. private _idleRotationWaitTime;
  34844. private _idleRotationSpinupTime;
  34845. /**
  34846. * Sets the flag that indicates if user zooming should stop animation.
  34847. */
  34848. /**
  34849. * Gets the flag that indicates if user zooming should stop animation.
  34850. */
  34851. zoomStopsAnimation: boolean;
  34852. /**
  34853. * Sets the default speed at which the camera rotates around the model.
  34854. */
  34855. /**
  34856. * Gets the default speed at which the camera rotates around the model.
  34857. */
  34858. idleRotationSpeed: number;
  34859. /**
  34860. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34861. */
  34862. /**
  34863. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34864. */
  34865. idleRotationWaitTime: number;
  34866. /**
  34867. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34868. */
  34869. /**
  34870. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34871. */
  34872. idleRotationSpinupTime: number;
  34873. /**
  34874. * Gets a value indicating if the camera is currently rotating because of this behavior
  34875. */
  34876. readonly rotationInProgress: boolean;
  34877. private _onPrePointerObservableObserver;
  34878. private _onAfterCheckInputsObserver;
  34879. private _attachedCamera;
  34880. private _isPointerDown;
  34881. private _lastFrameTime;
  34882. private _lastInteractionTime;
  34883. private _cameraRotationSpeed;
  34884. /**
  34885. * Initializes the behavior.
  34886. */
  34887. init(): void;
  34888. /**
  34889. * Attaches the behavior to its arc rotate camera.
  34890. * @param camera Defines the camera to attach the behavior to
  34891. */
  34892. attach(camera: ArcRotateCamera): void;
  34893. /**
  34894. * Detaches the behavior from its current arc rotate camera.
  34895. */
  34896. detach(): void;
  34897. /**
  34898. * Returns true if user is scrolling.
  34899. * @return true if user is scrolling.
  34900. */
  34901. private _userIsZooming;
  34902. private _lastFrameRadius;
  34903. private _shouldAnimationStopForInteraction;
  34904. /**
  34905. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34906. */
  34907. private _applyUserInteraction;
  34908. private _userIsMoving;
  34909. }
  34910. }
  34911. declare module BABYLON {
  34912. /**
  34913. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34914. */
  34915. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34916. private ui;
  34917. /**
  34918. * The name of the behavior
  34919. */
  34920. name: string;
  34921. /**
  34922. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34923. */
  34924. distanceAwayFromFace: number;
  34925. /**
  34926. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34927. */
  34928. distanceAwayFromBottomOfFace: number;
  34929. private _faceVectors;
  34930. private _target;
  34931. private _scene;
  34932. private _onRenderObserver;
  34933. private _tmpMatrix;
  34934. private _tmpVector;
  34935. /**
  34936. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34937. * @param ui The transform node that should be attched to the mesh
  34938. */
  34939. constructor(ui: TransformNode);
  34940. /**
  34941. * Initializes the behavior
  34942. */
  34943. init(): void;
  34944. private _closestFace;
  34945. private _zeroVector;
  34946. private _lookAtTmpMatrix;
  34947. private _lookAtToRef;
  34948. /**
  34949. * Attaches the AttachToBoxBehavior to the passed in mesh
  34950. * @param target The mesh that the specified node will be attached to
  34951. */
  34952. attach(target: Mesh): void;
  34953. /**
  34954. * Detaches the behavior from the mesh
  34955. */
  34956. detach(): void;
  34957. }
  34958. }
  34959. declare module BABYLON {
  34960. /**
  34961. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34962. */
  34963. export class FadeInOutBehavior implements Behavior<Mesh> {
  34964. /**
  34965. * Time in milliseconds to delay before fading in (Default: 0)
  34966. */
  34967. delay: number;
  34968. /**
  34969. * Time in milliseconds for the mesh to fade in (Default: 300)
  34970. */
  34971. fadeInTime: number;
  34972. private _millisecondsPerFrame;
  34973. private _hovered;
  34974. private _hoverValue;
  34975. private _ownerNode;
  34976. /**
  34977. * Instatiates the FadeInOutBehavior
  34978. */
  34979. constructor();
  34980. /**
  34981. * The name of the behavior
  34982. */
  34983. readonly name: string;
  34984. /**
  34985. * Initializes the behavior
  34986. */
  34987. init(): void;
  34988. /**
  34989. * Attaches the fade behavior on the passed in mesh
  34990. * @param ownerNode The mesh that will be faded in/out once attached
  34991. */
  34992. attach(ownerNode: Mesh): void;
  34993. /**
  34994. * Detaches the behavior from the mesh
  34995. */
  34996. detach(): void;
  34997. /**
  34998. * Triggers the mesh to begin fading in or out
  34999. * @param value if the object should fade in or out (true to fade in)
  35000. */
  35001. fadeIn(value: boolean): void;
  35002. private _update;
  35003. private _setAllVisibility;
  35004. }
  35005. }
  35006. declare module BABYLON {
  35007. /**
  35008. * Class containing a set of static utilities functions for managing Pivots
  35009. * @hidden
  35010. */
  35011. export class PivotTools {
  35012. private static _PivotCached;
  35013. private static _OldPivotPoint;
  35014. private static _PivotTranslation;
  35015. private static _PivotTmpVector;
  35016. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35017. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35018. }
  35019. }
  35020. declare module BABYLON {
  35021. /**
  35022. * Class containing static functions to help procedurally build meshes
  35023. */
  35024. export class PlaneBuilder {
  35025. /**
  35026. * Creates a plane mesh
  35027. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35028. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35029. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35031. * * 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
  35032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35033. * @param name defines the name of the mesh
  35034. * @param options defines the options used to create the mesh
  35035. * @param scene defines the hosting scene
  35036. * @returns the plane mesh
  35037. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35038. */
  35039. static CreatePlane(name: string, options: {
  35040. size?: number;
  35041. width?: number;
  35042. height?: number;
  35043. sideOrientation?: number;
  35044. frontUVs?: Vector4;
  35045. backUVs?: Vector4;
  35046. updatable?: boolean;
  35047. sourcePlane?: Plane;
  35048. }, scene?: Nullable<Scene>): Mesh;
  35049. }
  35050. }
  35051. declare module BABYLON {
  35052. /**
  35053. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35054. */
  35055. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35056. private static _AnyMouseID;
  35057. private _attachedNode;
  35058. private _dragPlane;
  35059. private _scene;
  35060. private _pointerObserver;
  35061. private _beforeRenderObserver;
  35062. private static _planeScene;
  35063. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35064. /**
  35065. * 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)
  35066. */
  35067. maxDragAngle: number;
  35068. /**
  35069. * @hidden
  35070. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  35071. /**
  35072. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35073. */
  35074. currentDraggingPointerID: number;
  35075. /**
  35076. * The last position where the pointer hit the drag plane in world space
  35077. */
  35078. lastDragPosition: Vector3;
  35079. /**
  35080. * If the behavior is currently in a dragging state
  35081. */
  35082. dragging: boolean;
  35083. /**
  35084. * 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)
  35085. */
  35086. dragDeltaRatio: number;
  35087. /**
  35088. * If the drag plane orientation should be updated during the dragging (Default: true)
  35089. */
  35090. updateDragPlane: boolean;
  35091. private _debugMode;
  35092. private _moving;
  35093. /**
  35094. * Fires each time the attached mesh is dragged with the pointer
  35095. * * delta between last drag position and current drag position in world space
  35096. * * dragDistance along the drag axis
  35097. * * dragPlaneNormal normal of the current drag plane used during the drag
  35098. * * dragPlanePoint in world space where the drag intersects the drag plane
  35099. */
  35100. onDragObservable: Observable<{
  35101. delta: Vector3;
  35102. dragPlanePoint: Vector3;
  35103. dragPlaneNormal: Vector3;
  35104. dragDistance: number;
  35105. pointerId: number;
  35106. }>;
  35107. /**
  35108. * Fires each time a drag begins (eg. mouse down on mesh)
  35109. */
  35110. onDragStartObservable: Observable<{
  35111. dragPlanePoint: Vector3;
  35112. pointerId: number;
  35113. }>;
  35114. /**
  35115. * Fires each time a drag ends (eg. mouse release after drag)
  35116. */
  35117. onDragEndObservable: Observable<{
  35118. dragPlanePoint: Vector3;
  35119. pointerId: number;
  35120. }>;
  35121. /**
  35122. * If the attached mesh should be moved when dragged
  35123. */
  35124. moveAttached: boolean;
  35125. /**
  35126. * If the drag behavior will react to drag events (Default: true)
  35127. */
  35128. enabled: boolean;
  35129. /**
  35130. * If camera controls should be detached during the drag
  35131. */
  35132. detachCameraControls: boolean;
  35133. /**
  35134. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35135. */
  35136. useObjectOrienationForDragging: boolean;
  35137. private _options;
  35138. /**
  35139. * Creates a pointer drag behavior that can be attached to a mesh
  35140. * @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)
  35141. */
  35142. constructor(options?: {
  35143. dragAxis?: Vector3;
  35144. dragPlaneNormal?: Vector3;
  35145. });
  35146. /**
  35147. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35148. */
  35149. validateDrag: (targetPosition: Vector3) => boolean;
  35150. /**
  35151. * The name of the behavior
  35152. */
  35153. readonly name: string;
  35154. /**
  35155. * Initializes the behavior
  35156. */
  35157. init(): void;
  35158. private _tmpVector;
  35159. private _alternatePickedPoint;
  35160. private _worldDragAxis;
  35161. private _targetPosition;
  35162. private _attachedElement;
  35163. /**
  35164. * Attaches the drag behavior the passed in mesh
  35165. * @param ownerNode The mesh that will be dragged around once attached
  35166. */
  35167. attach(ownerNode: AbstractMesh): void;
  35168. /**
  35169. * Force relase the drag action by code.
  35170. */
  35171. releaseDrag(): void;
  35172. private _startDragRay;
  35173. private _lastPointerRay;
  35174. /**
  35175. * Simulates the start of a pointer drag event on the behavior
  35176. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35177. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35178. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35179. */
  35180. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35181. private _startDrag;
  35182. private _dragDelta;
  35183. private _moveDrag;
  35184. private _pickWithRayOnDragPlane;
  35185. private _pointA;
  35186. private _pointB;
  35187. private _pointC;
  35188. private _lineA;
  35189. private _lineB;
  35190. private _localAxis;
  35191. private _lookAt;
  35192. private _updateDragPlanePosition;
  35193. /**
  35194. * Detaches the behavior from the mesh
  35195. */
  35196. detach(): void;
  35197. }
  35198. }
  35199. declare module BABYLON {
  35200. /**
  35201. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35202. */
  35203. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35204. private _dragBehaviorA;
  35205. private _dragBehaviorB;
  35206. private _startDistance;
  35207. private _initialScale;
  35208. private _targetScale;
  35209. private _ownerNode;
  35210. private _sceneRenderObserver;
  35211. /**
  35212. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35213. */
  35214. constructor();
  35215. /**
  35216. * The name of the behavior
  35217. */
  35218. readonly name: string;
  35219. /**
  35220. * Initializes the behavior
  35221. */
  35222. init(): void;
  35223. private _getCurrentDistance;
  35224. /**
  35225. * Attaches the scale behavior the passed in mesh
  35226. * @param ownerNode The mesh that will be scaled around once attached
  35227. */
  35228. attach(ownerNode: Mesh): void;
  35229. /**
  35230. * Detaches the behavior from the mesh
  35231. */
  35232. detach(): void;
  35233. }
  35234. }
  35235. declare module BABYLON {
  35236. /**
  35237. * 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
  35238. */
  35239. export class SixDofDragBehavior implements Behavior<Mesh> {
  35240. private static _virtualScene;
  35241. private _ownerNode;
  35242. private _sceneRenderObserver;
  35243. private _scene;
  35244. private _targetPosition;
  35245. private _virtualOriginMesh;
  35246. private _virtualDragMesh;
  35247. private _pointerObserver;
  35248. private _moving;
  35249. private _startingOrientation;
  35250. /**
  35251. * 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)
  35252. */
  35253. private zDragFactor;
  35254. /**
  35255. * If the object should rotate to face the drag origin
  35256. */
  35257. rotateDraggedObject: boolean;
  35258. /**
  35259. * If the behavior is currently in a dragging state
  35260. */
  35261. dragging: boolean;
  35262. /**
  35263. * 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)
  35264. */
  35265. dragDeltaRatio: number;
  35266. /**
  35267. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35268. */
  35269. currentDraggingPointerID: number;
  35270. /**
  35271. * If camera controls should be detached during the drag
  35272. */
  35273. detachCameraControls: boolean;
  35274. /**
  35275. * Fires each time a drag starts
  35276. */
  35277. onDragStartObservable: Observable<{}>;
  35278. /**
  35279. * Fires each time a drag ends (eg. mouse release after drag)
  35280. */
  35281. onDragEndObservable: Observable<{}>;
  35282. /**
  35283. * 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
  35284. */
  35285. constructor();
  35286. /**
  35287. * The name of the behavior
  35288. */
  35289. readonly name: string;
  35290. /**
  35291. * Initializes the behavior
  35292. */
  35293. init(): void;
  35294. /**
  35295. * Attaches the scale behavior the passed in mesh
  35296. * @param ownerNode The mesh that will be scaled around once attached
  35297. */
  35298. attach(ownerNode: Mesh): void;
  35299. /**
  35300. * Detaches the behavior from the mesh
  35301. */
  35302. detach(): void;
  35303. }
  35304. }
  35305. declare module BABYLON {
  35306. /**
  35307. * Class used to apply inverse kinematics to bones
  35308. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35309. */
  35310. export class BoneIKController {
  35311. private static _tmpVecs;
  35312. private static _tmpQuat;
  35313. private static _tmpMats;
  35314. /**
  35315. * Gets or sets the target mesh
  35316. */
  35317. targetMesh: AbstractMesh;
  35318. /** Gets or sets the mesh used as pole */
  35319. poleTargetMesh: AbstractMesh;
  35320. /**
  35321. * Gets or sets the bone used as pole
  35322. */
  35323. poleTargetBone: Nullable<Bone>;
  35324. /**
  35325. * Gets or sets the target position
  35326. */
  35327. targetPosition: Vector3;
  35328. /**
  35329. * Gets or sets the pole target position
  35330. */
  35331. poleTargetPosition: Vector3;
  35332. /**
  35333. * Gets or sets the pole target local offset
  35334. */
  35335. poleTargetLocalOffset: Vector3;
  35336. /**
  35337. * Gets or sets the pole angle
  35338. */
  35339. poleAngle: number;
  35340. /**
  35341. * Gets or sets the mesh associated with the controller
  35342. */
  35343. mesh: AbstractMesh;
  35344. /**
  35345. * 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)
  35346. */
  35347. slerpAmount: number;
  35348. private _bone1Quat;
  35349. private _bone1Mat;
  35350. private _bone2Ang;
  35351. private _bone1;
  35352. private _bone2;
  35353. private _bone1Length;
  35354. private _bone2Length;
  35355. private _maxAngle;
  35356. private _maxReach;
  35357. private _rightHandedSystem;
  35358. private _bendAxis;
  35359. private _slerping;
  35360. private _adjustRoll;
  35361. /**
  35362. * Gets or sets maximum allowed angle
  35363. */
  35364. maxAngle: number;
  35365. /**
  35366. * Creates a new BoneIKController
  35367. * @param mesh defines the mesh to control
  35368. * @param bone defines the bone to control
  35369. * @param options defines options to set up the controller
  35370. */
  35371. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35372. targetMesh?: AbstractMesh;
  35373. poleTargetMesh?: AbstractMesh;
  35374. poleTargetBone?: Bone;
  35375. poleTargetLocalOffset?: Vector3;
  35376. poleAngle?: number;
  35377. bendAxis?: Vector3;
  35378. maxAngle?: number;
  35379. slerpAmount?: number;
  35380. });
  35381. private _setMaxAngle;
  35382. /**
  35383. * Force the controller to update the bones
  35384. */
  35385. update(): void;
  35386. }
  35387. }
  35388. declare module BABYLON {
  35389. /**
  35390. * Class used to make a bone look toward a point in space
  35391. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35392. */
  35393. export class BoneLookController {
  35394. private static _tmpVecs;
  35395. private static _tmpQuat;
  35396. private static _tmpMats;
  35397. /**
  35398. * The target Vector3 that the bone will look at
  35399. */
  35400. target: Vector3;
  35401. /**
  35402. * The mesh that the bone is attached to
  35403. */
  35404. mesh: AbstractMesh;
  35405. /**
  35406. * The bone that will be looking to the target
  35407. */
  35408. bone: Bone;
  35409. /**
  35410. * The up axis of the coordinate system that is used when the bone is rotated
  35411. */
  35412. upAxis: Vector3;
  35413. /**
  35414. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35415. */
  35416. upAxisSpace: Space;
  35417. /**
  35418. * Used to make an adjustment to the yaw of the bone
  35419. */
  35420. adjustYaw: number;
  35421. /**
  35422. * Used to make an adjustment to the pitch of the bone
  35423. */
  35424. adjustPitch: number;
  35425. /**
  35426. * Used to make an adjustment to the roll of the bone
  35427. */
  35428. adjustRoll: number;
  35429. /**
  35430. * 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)
  35431. */
  35432. slerpAmount: number;
  35433. private _minYaw;
  35434. private _maxYaw;
  35435. private _minPitch;
  35436. private _maxPitch;
  35437. private _minYawSin;
  35438. private _minYawCos;
  35439. private _maxYawSin;
  35440. private _maxYawCos;
  35441. private _midYawConstraint;
  35442. private _minPitchTan;
  35443. private _maxPitchTan;
  35444. private _boneQuat;
  35445. private _slerping;
  35446. private _transformYawPitch;
  35447. private _transformYawPitchInv;
  35448. private _firstFrameSkipped;
  35449. private _yawRange;
  35450. private _fowardAxis;
  35451. /**
  35452. * Gets or sets the minimum yaw angle that the bone can look to
  35453. */
  35454. minYaw: number;
  35455. /**
  35456. * Gets or sets the maximum yaw angle that the bone can look to
  35457. */
  35458. maxYaw: number;
  35459. /**
  35460. * Gets or sets the minimum pitch angle that the bone can look to
  35461. */
  35462. minPitch: number;
  35463. /**
  35464. * Gets or sets the maximum pitch angle that the bone can look to
  35465. */
  35466. maxPitch: number;
  35467. /**
  35468. * Create a BoneLookController
  35469. * @param mesh the mesh that the bone belongs to
  35470. * @param bone the bone that will be looking to the target
  35471. * @param target the target Vector3 to look at
  35472. * @param options optional settings:
  35473. * * maxYaw: the maximum angle the bone will yaw to
  35474. * * minYaw: the minimum angle the bone will yaw to
  35475. * * maxPitch: the maximum angle the bone will pitch to
  35476. * * minPitch: the minimum angle the bone will yaw to
  35477. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35478. * * upAxis: the up axis of the coordinate system
  35479. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35480. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35481. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35482. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35483. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35484. * * adjustRoll: used to make an adjustment to the roll of the bone
  35485. **/
  35486. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35487. maxYaw?: number;
  35488. minYaw?: number;
  35489. maxPitch?: number;
  35490. minPitch?: number;
  35491. slerpAmount?: number;
  35492. upAxis?: Vector3;
  35493. upAxisSpace?: Space;
  35494. yawAxis?: Vector3;
  35495. pitchAxis?: Vector3;
  35496. adjustYaw?: number;
  35497. adjustPitch?: number;
  35498. adjustRoll?: number;
  35499. });
  35500. /**
  35501. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35502. */
  35503. update(): void;
  35504. private _getAngleDiff;
  35505. private _getAngleBetween;
  35506. private _isAngleBetween;
  35507. }
  35508. }
  35509. declare module BABYLON {
  35510. /**
  35511. * Manage the gamepad inputs to control an arc rotate camera.
  35512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35513. */
  35514. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35515. /**
  35516. * Defines the camera the input is attached to.
  35517. */
  35518. camera: ArcRotateCamera;
  35519. /**
  35520. * Defines the gamepad the input is gathering event from.
  35521. */
  35522. gamepad: Nullable<Gamepad>;
  35523. /**
  35524. * Defines the gamepad rotation sensiblity.
  35525. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35526. */
  35527. gamepadRotationSensibility: number;
  35528. /**
  35529. * Defines the gamepad move sensiblity.
  35530. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35531. */
  35532. gamepadMoveSensibility: number;
  35533. private _onGamepadConnectedObserver;
  35534. private _onGamepadDisconnectedObserver;
  35535. /**
  35536. * Attach the input controls to a specific dom element to get the input from.
  35537. * @param element Defines the element the controls should be listened from
  35538. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35539. */
  35540. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35541. /**
  35542. * Detach the current controls from the specified dom element.
  35543. * @param element Defines the element to stop listening the inputs from
  35544. */
  35545. detachControl(element: Nullable<HTMLElement>): void;
  35546. /**
  35547. * Update the current camera state depending on the inputs that have been used this frame.
  35548. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35549. */
  35550. checkInputs(): void;
  35551. /**
  35552. * Gets the class name of the current intput.
  35553. * @returns the class name
  35554. */
  35555. getClassName(): string;
  35556. /**
  35557. * Get the friendly name associated with the input class.
  35558. * @returns the input friendly name
  35559. */
  35560. getSimpleName(): string;
  35561. }
  35562. }
  35563. declare module BABYLON {
  35564. interface ArcRotateCameraInputsManager {
  35565. /**
  35566. * Add orientation input support to the input manager.
  35567. * @returns the current input manager
  35568. */
  35569. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35570. }
  35571. /**
  35572. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35573. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35574. */
  35575. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35576. /**
  35577. * Defines the camera the input is attached to.
  35578. */
  35579. camera: ArcRotateCamera;
  35580. /**
  35581. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35582. */
  35583. alphaCorrection: number;
  35584. /**
  35585. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35586. */
  35587. gammaCorrection: number;
  35588. private _alpha;
  35589. private _gamma;
  35590. private _dirty;
  35591. private _deviceOrientationHandler;
  35592. /**
  35593. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35594. */
  35595. constructor();
  35596. /**
  35597. * Attach the input controls to a specific dom element to get the input from.
  35598. * @param element Defines the element the controls should be listened from
  35599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35600. */
  35601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35602. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35603. /**
  35604. * Update the current camera state depending on the inputs that have been used this frame.
  35605. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35606. */
  35607. checkInputs(): void;
  35608. /**
  35609. * Detach the current controls from the specified dom element.
  35610. * @param element Defines the element to stop listening the inputs from
  35611. */
  35612. detachControl(element: Nullable<HTMLElement>): void;
  35613. /**
  35614. * Gets the class name of the current intput.
  35615. * @returns the class name
  35616. */
  35617. getClassName(): string;
  35618. /**
  35619. * Get the friendly name associated with the input class.
  35620. * @returns the input friendly name
  35621. */
  35622. getSimpleName(): string;
  35623. }
  35624. }
  35625. declare module BABYLON {
  35626. /**
  35627. * Listen to mouse events to control the camera.
  35628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35629. */
  35630. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35631. /**
  35632. * Defines the camera the input is attached to.
  35633. */
  35634. camera: FlyCamera;
  35635. /**
  35636. * Defines if touch is enabled. (Default is true.)
  35637. */
  35638. touchEnabled: boolean;
  35639. /**
  35640. * Defines the buttons associated with the input to handle camera rotation.
  35641. */
  35642. buttons: number[];
  35643. /**
  35644. * Assign buttons for Yaw control.
  35645. */
  35646. buttonsYaw: number[];
  35647. /**
  35648. * Assign buttons for Pitch control.
  35649. */
  35650. buttonsPitch: number[];
  35651. /**
  35652. * Assign buttons for Roll control.
  35653. */
  35654. buttonsRoll: number[];
  35655. /**
  35656. * Detect if any button is being pressed while mouse is moved.
  35657. * -1 = Mouse locked.
  35658. * 0 = Left button.
  35659. * 1 = Middle Button.
  35660. * 2 = Right Button.
  35661. */
  35662. activeButton: number;
  35663. /**
  35664. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35665. * Higher values reduce its sensitivity.
  35666. */
  35667. angularSensibility: number;
  35668. private _mousemoveCallback;
  35669. private _observer;
  35670. private _rollObserver;
  35671. private previousPosition;
  35672. private noPreventDefault;
  35673. private element;
  35674. /**
  35675. * Listen to mouse events to control the camera.
  35676. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35678. */
  35679. constructor(touchEnabled?: boolean);
  35680. /**
  35681. * Attach the mouse control to the HTML DOM element.
  35682. * @param element Defines the element that listens to the input events.
  35683. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35684. */
  35685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35686. /**
  35687. * Detach the current controls from the specified dom element.
  35688. * @param element Defines the element to stop listening the inputs from
  35689. */
  35690. detachControl(element: Nullable<HTMLElement>): void;
  35691. /**
  35692. * Gets the class name of the current input.
  35693. * @returns the class name.
  35694. */
  35695. getClassName(): string;
  35696. /**
  35697. * Get the friendly name associated with the input class.
  35698. * @returns the input's friendly name.
  35699. */
  35700. getSimpleName(): string;
  35701. private _pointerInput;
  35702. private _onMouseMove;
  35703. /**
  35704. * Rotate camera by mouse offset.
  35705. */
  35706. private rotateCamera;
  35707. }
  35708. }
  35709. declare module BABYLON {
  35710. /**
  35711. * Default Inputs manager for the FlyCamera.
  35712. * It groups all the default supported inputs for ease of use.
  35713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35714. */
  35715. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35716. /**
  35717. * Instantiates a new FlyCameraInputsManager.
  35718. * @param camera Defines the camera the inputs belong to.
  35719. */
  35720. constructor(camera: FlyCamera);
  35721. /**
  35722. * Add keyboard input support to the input manager.
  35723. * @returns the new FlyCameraKeyboardMoveInput().
  35724. */
  35725. addKeyboard(): FlyCameraInputsManager;
  35726. /**
  35727. * Add mouse input support to the input manager.
  35728. * @param touchEnabled Enable touch screen support.
  35729. * @returns the new FlyCameraMouseInput().
  35730. */
  35731. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35732. }
  35733. }
  35734. declare module BABYLON {
  35735. /**
  35736. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35737. * such as in a 3D Space Shooter or a Flight Simulator.
  35738. */
  35739. export class FlyCamera extends TargetCamera {
  35740. /**
  35741. * Define the collision ellipsoid of the camera.
  35742. * This is helpful for simulating a camera body, like a player's body.
  35743. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35744. */
  35745. ellipsoid: Vector3;
  35746. /**
  35747. * Define an offset for the position of the ellipsoid around the camera.
  35748. * This can be helpful if the camera is attached away from the player's body center,
  35749. * such as at its head.
  35750. */
  35751. ellipsoidOffset: Vector3;
  35752. /**
  35753. * Enable or disable collisions of the camera with the rest of the scene objects.
  35754. */
  35755. checkCollisions: boolean;
  35756. /**
  35757. * Enable or disable gravity on the camera.
  35758. */
  35759. applyGravity: boolean;
  35760. /**
  35761. * Define the current direction the camera is moving to.
  35762. */
  35763. cameraDirection: Vector3;
  35764. /**
  35765. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35766. * This overrides and empties cameraRotation.
  35767. */
  35768. rotationQuaternion: Quaternion;
  35769. /**
  35770. * Track Roll to maintain the wanted Rolling when looking around.
  35771. */ trackRoll: number;
  35772. /**
  35773. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35774. */
  35775. rollCorrect: number;
  35776. /**
  35777. * Mimic a banked turn, Rolling the camera when Yawing.
  35778. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35779. */
  35780. bankedTurn: boolean;
  35781. /**
  35782. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35783. */
  35784. bankedTurnLimit: number;
  35785. /**
  35786. * Value of 0 disables the banked Roll.
  35787. * Value of 1 is equal to the Yaw angle in radians.
  35788. */
  35789. bankedTurnMultiplier: number;
  35790. /**
  35791. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35792. */
  35793. inputs: FlyCameraInputsManager;
  35794. /**
  35795. * Gets the input sensibility for mouse input.
  35796. * Higher values reduce sensitivity.
  35797. */
  35798. /**
  35799. * Sets the input sensibility for a mouse input.
  35800. * Higher values reduce sensitivity.
  35801. */
  35802. angularSensibility: number;
  35803. /**
  35804. * Get the keys for camera movement forward.
  35805. */
  35806. /**
  35807. * Set the keys for camera movement forward.
  35808. */
  35809. keysForward: number[];
  35810. /**
  35811. * Get the keys for camera movement backward.
  35812. */
  35813. keysBackward: number[];
  35814. /**
  35815. * Get the keys for camera movement up.
  35816. */
  35817. /**
  35818. * Set the keys for camera movement up.
  35819. */
  35820. keysUp: number[];
  35821. /**
  35822. * Get the keys for camera movement down.
  35823. */
  35824. /**
  35825. * Set the keys for camera movement down.
  35826. */
  35827. keysDown: number[];
  35828. /**
  35829. * Get the keys for camera movement left.
  35830. */
  35831. /**
  35832. * Set the keys for camera movement left.
  35833. */
  35834. keysLeft: number[];
  35835. /**
  35836. * Set the keys for camera movement right.
  35837. */
  35838. /**
  35839. * Set the keys for camera movement right.
  35840. */
  35841. keysRight: number[];
  35842. /**
  35843. * Event raised when the camera collides with a mesh in the scene.
  35844. */
  35845. onCollide: (collidedMesh: AbstractMesh) => void;
  35846. private _collider;
  35847. private _needMoveForGravity;
  35848. private _oldPosition;
  35849. private _diffPosition;
  35850. private _newPosition;
  35851. /** @hidden */ localDirection: Vector3;
  35852. /** @hidden */ transformedDirection: Vector3;
  35853. /**
  35854. * Instantiates a FlyCamera.
  35855. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35856. * such as in a 3D Space Shooter or a Flight Simulator.
  35857. * @param name Define the name of the camera in the scene.
  35858. * @param position Define the starting position of the camera in the scene.
  35859. * @param scene Define the scene the camera belongs to.
  35860. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35861. */
  35862. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35863. /**
  35864. * Attach a control to the HTML DOM element.
  35865. * @param element Defines the element that listens to the input events.
  35866. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35867. */
  35868. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35869. /**
  35870. * Detach a control from the HTML DOM element.
  35871. * The camera will stop reacting to that input.
  35872. * @param element Defines the element that listens to the input events.
  35873. */
  35874. detachControl(element: HTMLElement): void;
  35875. private _collisionMask;
  35876. /**
  35877. * Get the mask that the camera ignores in collision events.
  35878. */
  35879. /**
  35880. * Set the mask that the camera ignores in collision events.
  35881. */
  35882. collisionMask: number;
  35883. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35884. /** @hidden */
  35885. private _onCollisionPositionChange;
  35886. /** @hidden */ checkInputs(): void;
  35887. /** @hidden */ decideIfNeedsToMove(): boolean;
  35888. /** @hidden */ updatePosition(): void;
  35889. /**
  35890. * Restore the Roll to its target value at the rate specified.
  35891. * @param rate - Higher means slower restoring.
  35892. * @hidden
  35893. */
  35894. restoreRoll(rate: number): void;
  35895. /**
  35896. * Destroy the camera and release the current resources held by it.
  35897. */
  35898. dispose(): void;
  35899. /**
  35900. * Get the current object class name.
  35901. * @returns the class name.
  35902. */
  35903. getClassName(): string;
  35904. }
  35905. }
  35906. declare module BABYLON {
  35907. /**
  35908. * Listen to keyboard events to control the camera.
  35909. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35910. */
  35911. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35912. /**
  35913. * Defines the camera the input is attached to.
  35914. */
  35915. camera: FlyCamera;
  35916. /**
  35917. * The list of keyboard keys used to control the forward move of the camera.
  35918. */
  35919. keysForward: number[];
  35920. /**
  35921. * The list of keyboard keys used to control the backward move of the camera.
  35922. */
  35923. keysBackward: number[];
  35924. /**
  35925. * The list of keyboard keys used to control the forward move of the camera.
  35926. */
  35927. keysUp: number[];
  35928. /**
  35929. * The list of keyboard keys used to control the backward move of the camera.
  35930. */
  35931. keysDown: number[];
  35932. /**
  35933. * The list of keyboard keys used to control the right strafe move of the camera.
  35934. */
  35935. keysRight: number[];
  35936. /**
  35937. * The list of keyboard keys used to control the left strafe move of the camera.
  35938. */
  35939. keysLeft: number[];
  35940. private _keys;
  35941. private _onCanvasBlurObserver;
  35942. private _onKeyboardObserver;
  35943. private _engine;
  35944. private _scene;
  35945. /**
  35946. * Attach the input controls to a specific dom element to get the input from.
  35947. * @param element Defines the element the controls should be listened from
  35948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35949. */
  35950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35951. /**
  35952. * Detach the current controls from the specified dom element.
  35953. * @param element Defines the element to stop listening the inputs from
  35954. */
  35955. detachControl(element: Nullable<HTMLElement>): void;
  35956. /**
  35957. * Gets the class name of the current intput.
  35958. * @returns the class name
  35959. */
  35960. getClassName(): string;
  35961. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35962. /**
  35963. * Get the friendly name associated with the input class.
  35964. * @returns the input friendly name
  35965. */
  35966. getSimpleName(): string;
  35967. /**
  35968. * Update the current camera state depending on the inputs that have been used this frame.
  35969. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35970. */
  35971. checkInputs(): void;
  35972. }
  35973. }
  35974. declare module BABYLON {
  35975. /**
  35976. * Manage the mouse wheel inputs to control a follow camera.
  35977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35978. */
  35979. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35980. /**
  35981. * Defines the camera the input is attached to.
  35982. */
  35983. camera: FollowCamera;
  35984. /**
  35985. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35986. */
  35987. axisControlRadius: boolean;
  35988. /**
  35989. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35990. */
  35991. axisControlHeight: boolean;
  35992. /**
  35993. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35994. */
  35995. axisControlRotation: boolean;
  35996. /**
  35997. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35998. * relation to mouseWheel events.
  35999. */
  36000. wheelPrecision: number;
  36001. /**
  36002. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36003. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36004. */
  36005. wheelDeltaPercentage: number;
  36006. private _wheel;
  36007. private _observer;
  36008. /**
  36009. * Attach the input controls to a specific dom element to get the input from.
  36010. * @param element Defines the element the controls should be listened from
  36011. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36012. */
  36013. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36014. /**
  36015. * Detach the current controls from the specified dom element.
  36016. * @param element Defines the element to stop listening the inputs from
  36017. */
  36018. detachControl(element: Nullable<HTMLElement>): void;
  36019. /**
  36020. * Gets the class name of the current intput.
  36021. * @returns the class name
  36022. */
  36023. getClassName(): string;
  36024. /**
  36025. * Get the friendly name associated with the input class.
  36026. * @returns the input friendly name
  36027. */
  36028. getSimpleName(): string;
  36029. }
  36030. }
  36031. declare module BABYLON {
  36032. /**
  36033. * Manage the pointers inputs to control an follow camera.
  36034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36035. */
  36036. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36037. /**
  36038. * Defines the camera the input is attached to.
  36039. */
  36040. camera: FollowCamera;
  36041. /**
  36042. * Gets the class name of the current input.
  36043. * @returns the class name
  36044. */
  36045. getClassName(): string;
  36046. /**
  36047. * Defines the pointer angular sensibility along the X axis or how fast is
  36048. * the camera rotating.
  36049. * A negative number will reverse the axis direction.
  36050. */
  36051. angularSensibilityX: number;
  36052. /**
  36053. * Defines the pointer angular sensibility along the Y axis or how fast is
  36054. * the camera rotating.
  36055. * A negative number will reverse the axis direction.
  36056. */
  36057. angularSensibilityY: number;
  36058. /**
  36059. * Defines the pointer pinch precision or how fast is the camera zooming.
  36060. * A negative number will reverse the axis direction.
  36061. */
  36062. pinchPrecision: number;
  36063. /**
  36064. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36065. * from 0.
  36066. * It defines the percentage of current camera.radius to use as delta when
  36067. * pinch zoom is used.
  36068. */
  36069. pinchDeltaPercentage: number;
  36070. /**
  36071. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36072. */
  36073. axisXControlRadius: boolean;
  36074. /**
  36075. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36076. */
  36077. axisXControlHeight: boolean;
  36078. /**
  36079. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36080. */
  36081. axisXControlRotation: boolean;
  36082. /**
  36083. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36084. */
  36085. axisYControlRadius: boolean;
  36086. /**
  36087. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36088. */
  36089. axisYControlHeight: boolean;
  36090. /**
  36091. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36092. */
  36093. axisYControlRotation: boolean;
  36094. /**
  36095. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36096. */
  36097. axisPinchControlRadius: boolean;
  36098. /**
  36099. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36100. */
  36101. axisPinchControlHeight: boolean;
  36102. /**
  36103. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36104. */
  36105. axisPinchControlRotation: boolean;
  36106. /**
  36107. * Log error messages if basic misconfiguration has occurred.
  36108. */
  36109. warningEnable: boolean;
  36110. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36111. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36112. private _warningCounter;
  36113. private _warning;
  36114. }
  36115. }
  36116. declare module BABYLON {
  36117. /**
  36118. * Default Inputs manager for the FollowCamera.
  36119. * It groups all the default supported inputs for ease of use.
  36120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36121. */
  36122. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36123. /**
  36124. * Instantiates a new FollowCameraInputsManager.
  36125. * @param camera Defines the camera the inputs belong to
  36126. */
  36127. constructor(camera: FollowCamera);
  36128. /**
  36129. * Add keyboard input support to the input manager.
  36130. * @returns the current input manager
  36131. */
  36132. addKeyboard(): FollowCameraInputsManager;
  36133. /**
  36134. * Add mouse wheel input support to the input manager.
  36135. * @returns the current input manager
  36136. */
  36137. addMouseWheel(): FollowCameraInputsManager;
  36138. /**
  36139. * Add pointers input support to the input manager.
  36140. * @returns the current input manager
  36141. */
  36142. addPointers(): FollowCameraInputsManager;
  36143. /**
  36144. * Add orientation input support to the input manager.
  36145. * @returns the current input manager
  36146. */
  36147. addVRDeviceOrientation(): FollowCameraInputsManager;
  36148. }
  36149. }
  36150. declare module BABYLON {
  36151. /**
  36152. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36153. * an arc rotate version arcFollowCamera are available.
  36154. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36155. */
  36156. export class FollowCamera extends TargetCamera {
  36157. /**
  36158. * Distance the follow camera should follow an object at
  36159. */
  36160. radius: number;
  36161. /**
  36162. * Minimum allowed distance of the camera to the axis of rotation
  36163. * (The camera can not get closer).
  36164. * This can help limiting how the Camera is able to move in the scene.
  36165. */
  36166. lowerRadiusLimit: Nullable<number>;
  36167. /**
  36168. * Maximum allowed distance of the camera to the axis of rotation
  36169. * (The camera can not get further).
  36170. * This can help limiting how the Camera is able to move in the scene.
  36171. */
  36172. upperRadiusLimit: Nullable<number>;
  36173. /**
  36174. * Define a rotation offset between the camera and the object it follows
  36175. */
  36176. rotationOffset: number;
  36177. /**
  36178. * Minimum allowed angle to camera position relative to target object.
  36179. * This can help limiting how the Camera is able to move in the scene.
  36180. */
  36181. lowerRotationOffsetLimit: Nullable<number>;
  36182. /**
  36183. * Maximum allowed angle to camera position relative to target object.
  36184. * This can help limiting how the Camera is able to move in the scene.
  36185. */
  36186. upperRotationOffsetLimit: Nullable<number>;
  36187. /**
  36188. * Define a height offset between the camera and the object it follows.
  36189. * It can help following an object from the top (like a car chaing a plane)
  36190. */
  36191. heightOffset: number;
  36192. /**
  36193. * Minimum allowed height of camera position relative to target object.
  36194. * This can help limiting how the Camera is able to move in the scene.
  36195. */
  36196. lowerHeightOffsetLimit: Nullable<number>;
  36197. /**
  36198. * Maximum allowed height of camera position relative to target object.
  36199. * This can help limiting how the Camera is able to move in the scene.
  36200. */
  36201. upperHeightOffsetLimit: Nullable<number>;
  36202. /**
  36203. * Define how fast the camera can accelerate to follow it s target.
  36204. */
  36205. cameraAcceleration: number;
  36206. /**
  36207. * Define the speed limit of the camera following an object.
  36208. */
  36209. maxCameraSpeed: number;
  36210. /**
  36211. * Define the target of the camera.
  36212. */
  36213. lockedTarget: Nullable<AbstractMesh>;
  36214. /**
  36215. * Defines the input associated with the camera.
  36216. */
  36217. inputs: FollowCameraInputsManager;
  36218. /**
  36219. * Instantiates the follow camera.
  36220. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36221. * @param name Define the name of the camera in the scene
  36222. * @param position Define the position of the camera
  36223. * @param scene Define the scene the camera belong to
  36224. * @param lockedTarget Define the target of the camera
  36225. */
  36226. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36227. private _follow;
  36228. /**
  36229. * Attached controls to the current camera.
  36230. * @param element Defines the element the controls should be listened from
  36231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36232. */
  36233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36234. /**
  36235. * Detach the current controls from the camera.
  36236. * The camera will stop reacting to inputs.
  36237. * @param element Defines the element to stop listening the inputs from
  36238. */
  36239. detachControl(element: HTMLElement): void;
  36240. /** @hidden */ checkInputs(): void;
  36241. private _checkLimits;
  36242. /**
  36243. * Gets the camera class name.
  36244. * @returns the class name
  36245. */
  36246. getClassName(): string;
  36247. }
  36248. /**
  36249. * Arc Rotate version of the follow camera.
  36250. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36251. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36252. */
  36253. export class ArcFollowCamera extends TargetCamera {
  36254. /** The longitudinal angle of the camera */
  36255. alpha: number;
  36256. /** The latitudinal angle of the camera */
  36257. beta: number;
  36258. /** The radius of the camera from its target */
  36259. radius: number;
  36260. /** Define the camera target (the messh it should follow) */
  36261. target: Nullable<AbstractMesh>;
  36262. private _cartesianCoordinates;
  36263. /**
  36264. * Instantiates a new ArcFollowCamera
  36265. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36266. * @param name Define the name of the camera
  36267. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36268. * @param beta Define the rotation angle of the camera around the elevation axis
  36269. * @param radius Define the radius of the camera from its target point
  36270. * @param target Define the target of the camera
  36271. * @param scene Define the scene the camera belongs to
  36272. */
  36273. constructor(name: string,
  36274. /** The longitudinal angle of the camera */
  36275. alpha: number,
  36276. /** The latitudinal angle of the camera */
  36277. beta: number,
  36278. /** The radius of the camera from its target */
  36279. radius: number,
  36280. /** Define the camera target (the messh it should follow) */
  36281. target: Nullable<AbstractMesh>, scene: Scene);
  36282. private _follow;
  36283. /** @hidden */ checkInputs(): void;
  36284. /**
  36285. * Returns the class name of the object.
  36286. * It is mostly used internally for serialization purposes.
  36287. */
  36288. getClassName(): string;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. /**
  36293. * Manage the keyboard inputs to control the movement of a follow camera.
  36294. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36295. */
  36296. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36297. /**
  36298. * Defines the camera the input is attached to.
  36299. */
  36300. camera: FollowCamera;
  36301. /**
  36302. * Defines the list of key codes associated with the up action (increase heightOffset)
  36303. */
  36304. keysHeightOffsetIncr: number[];
  36305. /**
  36306. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36307. */
  36308. keysHeightOffsetDecr: number[];
  36309. /**
  36310. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36311. */
  36312. keysHeightOffsetModifierAlt: boolean;
  36313. /**
  36314. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36315. */
  36316. keysHeightOffsetModifierCtrl: boolean;
  36317. /**
  36318. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36319. */
  36320. keysHeightOffsetModifierShift: boolean;
  36321. /**
  36322. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36323. */
  36324. keysRotationOffsetIncr: number[];
  36325. /**
  36326. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36327. */
  36328. keysRotationOffsetDecr: number[];
  36329. /**
  36330. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36331. */
  36332. keysRotationOffsetModifierAlt: boolean;
  36333. /**
  36334. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36335. */
  36336. keysRotationOffsetModifierCtrl: boolean;
  36337. /**
  36338. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36339. */
  36340. keysRotationOffsetModifierShift: boolean;
  36341. /**
  36342. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36343. */
  36344. keysRadiusIncr: number[];
  36345. /**
  36346. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36347. */
  36348. keysRadiusDecr: number[];
  36349. /**
  36350. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36351. */
  36352. keysRadiusModifierAlt: boolean;
  36353. /**
  36354. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36355. */
  36356. keysRadiusModifierCtrl: boolean;
  36357. /**
  36358. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36359. */
  36360. keysRadiusModifierShift: boolean;
  36361. /**
  36362. * Defines the rate of change of heightOffset.
  36363. */
  36364. heightSensibility: number;
  36365. /**
  36366. * Defines the rate of change of rotationOffset.
  36367. */
  36368. rotationSensibility: number;
  36369. /**
  36370. * Defines the rate of change of radius.
  36371. */
  36372. radiusSensibility: number;
  36373. private _keys;
  36374. private _ctrlPressed;
  36375. private _altPressed;
  36376. private _shiftPressed;
  36377. private _onCanvasBlurObserver;
  36378. private _onKeyboardObserver;
  36379. private _engine;
  36380. private _scene;
  36381. /**
  36382. * Attach the input controls to a specific dom element to get the input from.
  36383. * @param element Defines the element the controls should be listened from
  36384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36385. */
  36386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36387. /**
  36388. * Detach the current controls from the specified dom element.
  36389. * @param element Defines the element to stop listening the inputs from
  36390. */
  36391. detachControl(element: Nullable<HTMLElement>): void;
  36392. /**
  36393. * Update the current camera state depending on the inputs that have been used this frame.
  36394. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36395. */
  36396. checkInputs(): void;
  36397. /**
  36398. * Gets the class name of the current input.
  36399. * @returns the class name
  36400. */
  36401. getClassName(): string;
  36402. /**
  36403. * Get the friendly name associated with the input class.
  36404. * @returns the input friendly name
  36405. */
  36406. getSimpleName(): string;
  36407. /**
  36408. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36409. * allow modification of the heightOffset value.
  36410. */
  36411. private _modifierHeightOffset;
  36412. /**
  36413. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36414. * allow modification of the rotationOffset value.
  36415. */
  36416. private _modifierRotationOffset;
  36417. /**
  36418. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36419. * allow modification of the radius value.
  36420. */
  36421. private _modifierRadius;
  36422. }
  36423. }
  36424. declare module BABYLON {
  36425. interface FreeCameraInputsManager {
  36426. /**
  36427. * @hidden
  36428. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36429. /**
  36430. * Add orientation input support to the input manager.
  36431. * @returns the current input manager
  36432. */
  36433. addDeviceOrientation(): FreeCameraInputsManager;
  36434. }
  36435. /**
  36436. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36437. * Screen rotation is taken into account.
  36438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36439. */
  36440. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36441. private _camera;
  36442. private _screenOrientationAngle;
  36443. private _constantTranform;
  36444. private _screenQuaternion;
  36445. private _alpha;
  36446. private _beta;
  36447. private _gamma;
  36448. /**
  36449. * @hidden
  36450. */ onDeviceOrientationChangedObservable: Observable<void>;
  36451. /**
  36452. * Instantiates a new input
  36453. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36454. */
  36455. constructor();
  36456. /**
  36457. * Define the camera controlled by the input.
  36458. */
  36459. camera: FreeCamera;
  36460. /**
  36461. * Attach the input controls to a specific dom element to get the input from.
  36462. * @param element Defines the element the controls should be listened from
  36463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36464. */
  36465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36466. private _orientationChanged;
  36467. private _deviceOrientation;
  36468. /**
  36469. * Detach the current controls from the specified dom element.
  36470. * @param element Defines the element to stop listening the inputs from
  36471. */
  36472. detachControl(element: Nullable<HTMLElement>): void;
  36473. /**
  36474. * Update the current camera state depending on the inputs that have been used this frame.
  36475. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36476. */
  36477. checkInputs(): void;
  36478. /**
  36479. * Gets the class name of the current intput.
  36480. * @returns the class name
  36481. */
  36482. getClassName(): string;
  36483. /**
  36484. * Get the friendly name associated with the input class.
  36485. * @returns the input friendly name
  36486. */
  36487. getSimpleName(): string;
  36488. }
  36489. }
  36490. declare module BABYLON {
  36491. /**
  36492. * Manage the gamepad inputs to control a free camera.
  36493. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36494. */
  36495. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36496. /**
  36497. * Define the camera the input is attached to.
  36498. */
  36499. camera: FreeCamera;
  36500. /**
  36501. * Define the Gamepad controlling the input
  36502. */
  36503. gamepad: Nullable<Gamepad>;
  36504. /**
  36505. * Defines the gamepad rotation sensiblity.
  36506. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36507. */
  36508. gamepadAngularSensibility: number;
  36509. /**
  36510. * Defines the gamepad move sensiblity.
  36511. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36512. */
  36513. gamepadMoveSensibility: number;
  36514. private _onGamepadConnectedObserver;
  36515. private _onGamepadDisconnectedObserver;
  36516. private _cameraTransform;
  36517. private _deltaTransform;
  36518. private _vector3;
  36519. private _vector2;
  36520. /**
  36521. * Attach the input controls to a specific dom element to get the input from.
  36522. * @param element Defines the element the controls should be listened from
  36523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36524. */
  36525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36526. /**
  36527. * Detach the current controls from the specified dom element.
  36528. * @param element Defines the element to stop listening the inputs from
  36529. */
  36530. detachControl(element: Nullable<HTMLElement>): void;
  36531. /**
  36532. * Update the current camera state depending on the inputs that have been used this frame.
  36533. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36534. */
  36535. checkInputs(): void;
  36536. /**
  36537. * Gets the class name of the current intput.
  36538. * @returns the class name
  36539. */
  36540. getClassName(): string;
  36541. /**
  36542. * Get the friendly name associated with the input class.
  36543. * @returns the input friendly name
  36544. */
  36545. getSimpleName(): string;
  36546. }
  36547. }
  36548. declare module BABYLON {
  36549. /**
  36550. * Defines the potential axis of a Joystick
  36551. */
  36552. export enum JoystickAxis {
  36553. /** X axis */
  36554. X = 0,
  36555. /** Y axis */
  36556. Y = 1,
  36557. /** Z axis */
  36558. Z = 2
  36559. }
  36560. /**
  36561. * Class used to define virtual joystick (used in touch mode)
  36562. */
  36563. export class VirtualJoystick {
  36564. /**
  36565. * Gets or sets a boolean indicating that left and right values must be inverted
  36566. */
  36567. reverseLeftRight: boolean;
  36568. /**
  36569. * Gets or sets a boolean indicating that up and down values must be inverted
  36570. */
  36571. reverseUpDown: boolean;
  36572. /**
  36573. * Gets the offset value for the position (ie. the change of the position value)
  36574. */
  36575. deltaPosition: Vector3;
  36576. /**
  36577. * Gets a boolean indicating if the virtual joystick was pressed
  36578. */
  36579. pressed: boolean;
  36580. /**
  36581. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36582. */
  36583. static Canvas: Nullable<HTMLCanvasElement>;
  36584. private static _globalJoystickIndex;
  36585. private static vjCanvasContext;
  36586. private static vjCanvasWidth;
  36587. private static vjCanvasHeight;
  36588. private static halfWidth;
  36589. private _action;
  36590. private _axisTargetedByLeftAndRight;
  36591. private _axisTargetedByUpAndDown;
  36592. private _joystickSensibility;
  36593. private _inversedSensibility;
  36594. private _joystickPointerID;
  36595. private _joystickColor;
  36596. private _joystickPointerPos;
  36597. private _joystickPreviousPointerPos;
  36598. private _joystickPointerStartPos;
  36599. private _deltaJoystickVector;
  36600. private _leftJoystick;
  36601. private _touches;
  36602. private _onPointerDownHandlerRef;
  36603. private _onPointerMoveHandlerRef;
  36604. private _onPointerUpHandlerRef;
  36605. private _onResize;
  36606. /**
  36607. * Creates a new virtual joystick
  36608. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36609. */
  36610. constructor(leftJoystick?: boolean);
  36611. /**
  36612. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36613. * @param newJoystickSensibility defines the new sensibility
  36614. */
  36615. setJoystickSensibility(newJoystickSensibility: number): void;
  36616. private _onPointerDown;
  36617. private _onPointerMove;
  36618. private _onPointerUp;
  36619. /**
  36620. * Change the color of the virtual joystick
  36621. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36622. */
  36623. setJoystickColor(newColor: string): void;
  36624. /**
  36625. * Defines a callback to call when the joystick is touched
  36626. * @param action defines the callback
  36627. */
  36628. setActionOnTouch(action: () => any): void;
  36629. /**
  36630. * Defines which axis you'd like to control for left & right
  36631. * @param axis defines the axis to use
  36632. */
  36633. setAxisForLeftRight(axis: JoystickAxis): void;
  36634. /**
  36635. * Defines which axis you'd like to control for up & down
  36636. * @param axis defines the axis to use
  36637. */
  36638. setAxisForUpDown(axis: JoystickAxis): void;
  36639. private _drawVirtualJoystick;
  36640. /**
  36641. * Release internal HTML canvas
  36642. */
  36643. releaseCanvas(): void;
  36644. }
  36645. }
  36646. declare module BABYLON {
  36647. interface FreeCameraInputsManager {
  36648. /**
  36649. * Add virtual joystick input support to the input manager.
  36650. * @returns the current input manager
  36651. */
  36652. addVirtualJoystick(): FreeCameraInputsManager;
  36653. }
  36654. /**
  36655. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36656. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36657. */
  36658. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36659. /**
  36660. * Defines the camera the input is attached to.
  36661. */
  36662. camera: FreeCamera;
  36663. private _leftjoystick;
  36664. private _rightjoystick;
  36665. /**
  36666. * Gets the left stick of the virtual joystick.
  36667. * @returns The virtual Joystick
  36668. */
  36669. getLeftJoystick(): VirtualJoystick;
  36670. /**
  36671. * Gets the right stick of the virtual joystick.
  36672. * @returns The virtual Joystick
  36673. */
  36674. getRightJoystick(): VirtualJoystick;
  36675. /**
  36676. * Update the current camera state depending on the inputs that have been used this frame.
  36677. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36678. */
  36679. checkInputs(): void;
  36680. /**
  36681. * Attach the input controls to a specific dom element to get the input from.
  36682. * @param element Defines the element the controls should be listened from
  36683. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36684. */
  36685. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36686. /**
  36687. * Detach the current controls from the specified dom element.
  36688. * @param element Defines the element to stop listening the inputs from
  36689. */
  36690. detachControl(element: Nullable<HTMLElement>): void;
  36691. /**
  36692. * Gets the class name of the current intput.
  36693. * @returns the class name
  36694. */
  36695. getClassName(): string;
  36696. /**
  36697. * Get the friendly name associated with the input class.
  36698. * @returns the input friendly name
  36699. */
  36700. getSimpleName(): string;
  36701. }
  36702. }
  36703. declare module BABYLON {
  36704. /**
  36705. * This represents a FPS type of camera controlled by touch.
  36706. * This is like a universal camera minus the Gamepad controls.
  36707. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36708. */
  36709. export class TouchCamera extends FreeCamera {
  36710. /**
  36711. * Defines the touch sensibility for rotation.
  36712. * The higher the faster.
  36713. */
  36714. touchAngularSensibility: number;
  36715. /**
  36716. * Defines the touch sensibility for move.
  36717. * The higher the faster.
  36718. */
  36719. touchMoveSensibility: number;
  36720. /**
  36721. * Instantiates a new touch camera.
  36722. * This represents a FPS type of camera controlled by touch.
  36723. * This is like a universal camera minus the Gamepad controls.
  36724. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36725. * @param name Define the name of the camera in the scene
  36726. * @param position Define the start position of the camera in the scene
  36727. * @param scene Define the scene the camera belongs to
  36728. */
  36729. constructor(name: string, position: Vector3, scene: Scene);
  36730. /**
  36731. * Gets the current object class name.
  36732. * @return the class name
  36733. */
  36734. getClassName(): string;
  36735. /** @hidden */ setupInputs(): void;
  36736. }
  36737. }
  36738. declare module BABYLON {
  36739. /**
  36740. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36741. * being tilted forward or back and left or right.
  36742. */
  36743. export class DeviceOrientationCamera extends FreeCamera {
  36744. private _initialQuaternion;
  36745. private _quaternionCache;
  36746. private _tmpDragQuaternion;
  36747. /**
  36748. * Creates a new device orientation camera
  36749. * @param name The name of the camera
  36750. * @param position The start position camera
  36751. * @param scene The scene the camera belongs to
  36752. */
  36753. constructor(name: string, position: Vector3, scene: Scene);
  36754. /**
  36755. * @hidden
  36756. * Disabled pointer input on first orientation sensor update (Default: true)
  36757. */ disablePointerInputWhenUsingDeviceOrientation: boolean;
  36758. private _dragFactor;
  36759. /**
  36760. * Enabled turning on the y axis when the orientation sensor is active
  36761. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36762. */
  36763. enableHorizontalDragging(dragFactor?: number): void;
  36764. /**
  36765. * Gets the current instance class name ("DeviceOrientationCamera").
  36766. * This helps avoiding instanceof at run time.
  36767. * @returns the class name
  36768. */
  36769. getClassName(): string;
  36770. /**
  36771. * @hidden
  36772. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36773. */ checkInputs(): void;
  36774. /**
  36775. * Reset the camera to its default orientation on the specified axis only.
  36776. * @param axis The axis to reset
  36777. */
  36778. resetToCurrentRotation(axis?: Axis): void;
  36779. }
  36780. }
  36781. declare module BABYLON {
  36782. /**
  36783. * 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,
  36784. * which still works and will still be found in many Playgrounds.
  36785. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36786. */
  36787. export class UniversalCamera extends TouchCamera {
  36788. /**
  36789. * Defines the gamepad rotation sensiblity.
  36790. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36791. */
  36792. gamepadAngularSensibility: number;
  36793. /**
  36794. * Defines the gamepad move sensiblity.
  36795. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36796. */
  36797. gamepadMoveSensibility: number;
  36798. /**
  36799. * 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,
  36800. * which still works and will still be found in many Playgrounds.
  36801. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36802. * @param name Define the name of the camera in the scene
  36803. * @param position Define the start position of the camera in the scene
  36804. * @param scene Define the scene the camera belongs to
  36805. */
  36806. constructor(name: string, position: Vector3, scene: Scene);
  36807. /**
  36808. * Gets the current object class name.
  36809. * @return the class name
  36810. */
  36811. getClassName(): string;
  36812. }
  36813. }
  36814. declare module BABYLON {
  36815. /**
  36816. * This represents a FPS type of camera. This is only here for back compat purpose.
  36817. * Please use the UniversalCamera instead as both are identical.
  36818. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36819. */
  36820. export class GamepadCamera extends UniversalCamera {
  36821. /**
  36822. * Instantiates a new Gamepad Camera
  36823. * This represents a FPS type of camera. This is only here for back compat purpose.
  36824. * Please use the UniversalCamera instead as both are identical.
  36825. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36826. * @param name Define the name of the camera in the scene
  36827. * @param position Define the start position of the camera in the scene
  36828. * @param scene Define the scene the camera belongs to
  36829. */
  36830. constructor(name: string, position: Vector3, scene: Scene);
  36831. /**
  36832. * Gets the current object class name.
  36833. * @return the class name
  36834. */
  36835. getClassName(): string;
  36836. }
  36837. }
  36838. declare module BABYLON {
  36839. /** @hidden */
  36840. export var passPixelShader: {
  36841. name: string;
  36842. shader: string;
  36843. };
  36844. }
  36845. declare module BABYLON {
  36846. /** @hidden */
  36847. export var passCubePixelShader: {
  36848. name: string;
  36849. shader: string;
  36850. };
  36851. }
  36852. declare module BABYLON {
  36853. /**
  36854. * PassPostProcess which produces an output the same as it's input
  36855. */
  36856. export class PassPostProcess extends PostProcess {
  36857. /**
  36858. * Creates the PassPostProcess
  36859. * @param name The name of the effect.
  36860. * @param options The required width/height ratio to downsize to before computing the render pass.
  36861. * @param camera The camera to apply the render pass to.
  36862. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36863. * @param engine The engine which the post process will be applied. (default: current engine)
  36864. * @param reusable If the post process can be reused on the same frame. (default: false)
  36865. * @param textureType The type of texture to be used when performing the post processing.
  36866. * @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)
  36867. */
  36868. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36869. }
  36870. /**
  36871. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36872. */
  36873. export class PassCubePostProcess extends PostProcess {
  36874. private _face;
  36875. /**
  36876. * Gets or sets the cube face to display.
  36877. * * 0 is +X
  36878. * * 1 is -X
  36879. * * 2 is +Y
  36880. * * 3 is -Y
  36881. * * 4 is +Z
  36882. * * 5 is -Z
  36883. */
  36884. face: number;
  36885. /**
  36886. * Creates the PassCubePostProcess
  36887. * @param name The name of the effect.
  36888. * @param options The required width/height ratio to downsize to before computing the render pass.
  36889. * @param camera The camera to apply the render pass to.
  36890. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36891. * @param engine The engine which the post process will be applied. (default: current engine)
  36892. * @param reusable If the post process can be reused on the same frame. (default: false)
  36893. * @param textureType The type of texture to be used when performing the post processing.
  36894. * @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)
  36895. */
  36896. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36897. }
  36898. }
  36899. declare module BABYLON {
  36900. /** @hidden */
  36901. export var anaglyphPixelShader: {
  36902. name: string;
  36903. shader: string;
  36904. };
  36905. }
  36906. declare module BABYLON {
  36907. /**
  36908. * Postprocess used to generate anaglyphic rendering
  36909. */
  36910. export class AnaglyphPostProcess extends PostProcess {
  36911. private _passedProcess;
  36912. /**
  36913. * Creates a new AnaglyphPostProcess
  36914. * @param name defines postprocess name
  36915. * @param options defines creation options or target ratio scale
  36916. * @param rigCameras defines cameras using this postprocess
  36917. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36918. * @param engine defines hosting engine
  36919. * @param reusable defines if the postprocess will be reused multiple times per frame
  36920. */
  36921. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36922. }
  36923. }
  36924. declare module BABYLON {
  36925. /**
  36926. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36927. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36928. */
  36929. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36930. /**
  36931. * Creates a new AnaglyphArcRotateCamera
  36932. * @param name defines camera name
  36933. * @param alpha defines alpha angle (in radians)
  36934. * @param beta defines beta angle (in radians)
  36935. * @param radius defines radius
  36936. * @param target defines camera target
  36937. * @param interaxialDistance defines distance between each color axis
  36938. * @param scene defines the hosting scene
  36939. */
  36940. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36941. /**
  36942. * Gets camera class name
  36943. * @returns AnaglyphArcRotateCamera
  36944. */
  36945. getClassName(): string;
  36946. }
  36947. }
  36948. declare module BABYLON {
  36949. /**
  36950. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36951. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36952. */
  36953. export class AnaglyphFreeCamera extends FreeCamera {
  36954. /**
  36955. * Creates a new AnaglyphFreeCamera
  36956. * @param name defines camera name
  36957. * @param position defines initial position
  36958. * @param interaxialDistance defines distance between each color axis
  36959. * @param scene defines the hosting scene
  36960. */
  36961. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36962. /**
  36963. * Gets camera class name
  36964. * @returns AnaglyphFreeCamera
  36965. */
  36966. getClassName(): string;
  36967. }
  36968. }
  36969. declare module BABYLON {
  36970. /**
  36971. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36972. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36973. */
  36974. export class AnaglyphGamepadCamera extends GamepadCamera {
  36975. /**
  36976. * Creates a new AnaglyphGamepadCamera
  36977. * @param name defines camera name
  36978. * @param position defines initial position
  36979. * @param interaxialDistance defines distance between each color axis
  36980. * @param scene defines the hosting scene
  36981. */
  36982. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36983. /**
  36984. * Gets camera class name
  36985. * @returns AnaglyphGamepadCamera
  36986. */
  36987. getClassName(): string;
  36988. }
  36989. }
  36990. declare module BABYLON {
  36991. /**
  36992. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36993. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36994. */
  36995. export class AnaglyphUniversalCamera extends UniversalCamera {
  36996. /**
  36997. * Creates a new AnaglyphUniversalCamera
  36998. * @param name defines camera name
  36999. * @param position defines initial position
  37000. * @param interaxialDistance defines distance between each color axis
  37001. * @param scene defines the hosting scene
  37002. */
  37003. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37004. /**
  37005. * Gets camera class name
  37006. * @returns AnaglyphUniversalCamera
  37007. */
  37008. getClassName(): string;
  37009. }
  37010. }
  37011. declare module BABYLON {
  37012. /** @hidden */
  37013. export var stereoscopicInterlacePixelShader: {
  37014. name: string;
  37015. shader: string;
  37016. };
  37017. }
  37018. declare module BABYLON {
  37019. /**
  37020. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37021. */
  37022. export class StereoscopicInterlacePostProcess extends PostProcess {
  37023. private _stepSize;
  37024. private _passedProcess;
  37025. /**
  37026. * Initializes a StereoscopicInterlacePostProcess
  37027. * @param name The name of the effect.
  37028. * @param rigCameras The rig cameras to be appled to the post process
  37029. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37031. * @param engine The engine which the post process will be applied. (default: current engine)
  37032. * @param reusable If the post process can be reused on the same frame. (default: false)
  37033. */
  37034. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37035. }
  37036. }
  37037. declare module BABYLON {
  37038. /**
  37039. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37040. * @see http://doc.babylonjs.com/features/cameras
  37041. */
  37042. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37043. /**
  37044. * Creates a new StereoscopicArcRotateCamera
  37045. * @param name defines camera name
  37046. * @param alpha defines alpha angle (in radians)
  37047. * @param beta defines beta angle (in radians)
  37048. * @param radius defines radius
  37049. * @param target defines camera target
  37050. * @param interaxialDistance defines distance between each color axis
  37051. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37052. * @param scene defines the hosting scene
  37053. */
  37054. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37055. /**
  37056. * Gets camera class name
  37057. * @returns StereoscopicArcRotateCamera
  37058. */
  37059. getClassName(): string;
  37060. }
  37061. }
  37062. declare module BABYLON {
  37063. /**
  37064. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37065. * @see http://doc.babylonjs.com/features/cameras
  37066. */
  37067. export class StereoscopicFreeCamera extends FreeCamera {
  37068. /**
  37069. * Creates a new StereoscopicFreeCamera
  37070. * @param name defines camera name
  37071. * @param position defines initial position
  37072. * @param interaxialDistance defines distance between each color axis
  37073. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37074. * @param scene defines the hosting scene
  37075. */
  37076. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37077. /**
  37078. * Gets camera class name
  37079. * @returns StereoscopicFreeCamera
  37080. */
  37081. getClassName(): string;
  37082. }
  37083. }
  37084. declare module BABYLON {
  37085. /**
  37086. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37087. * @see http://doc.babylonjs.com/features/cameras
  37088. */
  37089. export class StereoscopicGamepadCamera extends GamepadCamera {
  37090. /**
  37091. * Creates a new StereoscopicGamepadCamera
  37092. * @param name defines camera name
  37093. * @param position defines initial position
  37094. * @param interaxialDistance defines distance between each color axis
  37095. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37096. * @param scene defines the hosting scene
  37097. */
  37098. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37099. /**
  37100. * Gets camera class name
  37101. * @returns StereoscopicGamepadCamera
  37102. */
  37103. getClassName(): string;
  37104. }
  37105. }
  37106. declare module BABYLON {
  37107. /**
  37108. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37109. * @see http://doc.babylonjs.com/features/cameras
  37110. */
  37111. export class StereoscopicUniversalCamera extends UniversalCamera {
  37112. /**
  37113. * Creates a new StereoscopicUniversalCamera
  37114. * @param name defines camera name
  37115. * @param position defines initial position
  37116. * @param interaxialDistance defines distance between each color axis
  37117. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37118. * @param scene defines the hosting scene
  37119. */
  37120. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37121. /**
  37122. * Gets camera class name
  37123. * @returns StereoscopicUniversalCamera
  37124. */
  37125. getClassName(): string;
  37126. }
  37127. }
  37128. declare module BABYLON {
  37129. /**
  37130. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37131. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37132. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37133. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37134. */
  37135. export class VirtualJoysticksCamera extends FreeCamera {
  37136. /**
  37137. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37138. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37139. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37140. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37141. * @param name Define the name of the camera in the scene
  37142. * @param position Define the start position of the camera in the scene
  37143. * @param scene Define the scene the camera belongs to
  37144. */
  37145. constructor(name: string, position: Vector3, scene: Scene);
  37146. /**
  37147. * Gets the current object class name.
  37148. * @return the class name
  37149. */
  37150. getClassName(): string;
  37151. }
  37152. }
  37153. declare module BABYLON {
  37154. /**
  37155. * This represents all the required metrics to create a VR camera.
  37156. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37157. */
  37158. export class VRCameraMetrics {
  37159. /**
  37160. * Define the horizontal resolution off the screen.
  37161. */
  37162. hResolution: number;
  37163. /**
  37164. * Define the vertical resolution off the screen.
  37165. */
  37166. vResolution: number;
  37167. /**
  37168. * Define the horizontal screen size.
  37169. */
  37170. hScreenSize: number;
  37171. /**
  37172. * Define the vertical screen size.
  37173. */
  37174. vScreenSize: number;
  37175. /**
  37176. * Define the vertical screen center position.
  37177. */
  37178. vScreenCenter: number;
  37179. /**
  37180. * Define the distance of the eyes to the screen.
  37181. */
  37182. eyeToScreenDistance: number;
  37183. /**
  37184. * Define the distance between both lenses
  37185. */
  37186. lensSeparationDistance: number;
  37187. /**
  37188. * Define the distance between both viewer's eyes.
  37189. */
  37190. interpupillaryDistance: number;
  37191. /**
  37192. * Define the distortion factor of the VR postprocess.
  37193. * Please, touch with care.
  37194. */
  37195. distortionK: number[];
  37196. /**
  37197. * Define the chromatic aberration correction factors for the VR post process.
  37198. */
  37199. chromaAbCorrection: number[];
  37200. /**
  37201. * Define the scale factor of the post process.
  37202. * The smaller the better but the slower.
  37203. */
  37204. postProcessScaleFactor: number;
  37205. /**
  37206. * Define an offset for the lens center.
  37207. */
  37208. lensCenterOffset: number;
  37209. /**
  37210. * Define if the current vr camera should compensate the distortion of the lense or not.
  37211. */
  37212. compensateDistortion: boolean;
  37213. /**
  37214. * Defines if multiview should be enabled when rendering (Default: false)
  37215. */
  37216. multiviewEnabled: boolean;
  37217. /**
  37218. * Gets the rendering aspect ratio based on the provided resolutions.
  37219. */
  37220. readonly aspectRatio: number;
  37221. /**
  37222. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37223. */
  37224. readonly aspectRatioFov: number;
  37225. /**
  37226. * @hidden
  37227. */
  37228. readonly leftHMatrix: Matrix;
  37229. /**
  37230. * @hidden
  37231. */
  37232. readonly rightHMatrix: Matrix;
  37233. /**
  37234. * @hidden
  37235. */
  37236. readonly leftPreViewMatrix: Matrix;
  37237. /**
  37238. * @hidden
  37239. */
  37240. readonly rightPreViewMatrix: Matrix;
  37241. /**
  37242. * Get the default VRMetrics based on the most generic setup.
  37243. * @returns the default vr metrics
  37244. */
  37245. static GetDefault(): VRCameraMetrics;
  37246. }
  37247. }
  37248. declare module BABYLON {
  37249. /** @hidden */
  37250. export var vrDistortionCorrectionPixelShader: {
  37251. name: string;
  37252. shader: string;
  37253. };
  37254. }
  37255. declare module BABYLON {
  37256. /**
  37257. * VRDistortionCorrectionPostProcess used for mobile VR
  37258. */
  37259. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37260. private _isRightEye;
  37261. private _distortionFactors;
  37262. private _postProcessScaleFactor;
  37263. private _lensCenterOffset;
  37264. private _scaleIn;
  37265. private _scaleFactor;
  37266. private _lensCenter;
  37267. /**
  37268. * Initializes the VRDistortionCorrectionPostProcess
  37269. * @param name The name of the effect.
  37270. * @param camera The camera to apply the render pass to.
  37271. * @param isRightEye If this is for the right eye distortion
  37272. * @param vrMetrics All the required metrics for the VR camera
  37273. */
  37274. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37275. }
  37276. }
  37277. declare module BABYLON {
  37278. /**
  37279. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37280. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37281. */
  37282. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37283. /**
  37284. * Creates a new VRDeviceOrientationArcRotateCamera
  37285. * @param name defines camera name
  37286. * @param alpha defines the camera rotation along the logitudinal axis
  37287. * @param beta defines the camera rotation along the latitudinal axis
  37288. * @param radius defines the camera distance from its target
  37289. * @param target defines the camera target
  37290. * @param scene defines the scene the camera belongs to
  37291. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37292. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37293. */
  37294. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37295. /**
  37296. * Gets camera class name
  37297. * @returns VRDeviceOrientationArcRotateCamera
  37298. */
  37299. getClassName(): string;
  37300. }
  37301. }
  37302. declare module BABYLON {
  37303. /**
  37304. * Camera used to simulate VR rendering (based on FreeCamera)
  37305. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37306. */
  37307. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37308. /**
  37309. * Creates a new VRDeviceOrientationFreeCamera
  37310. * @param name defines camera name
  37311. * @param position defines the start position of the camera
  37312. * @param scene defines the scene the camera belongs to
  37313. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37314. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37315. */
  37316. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37317. /**
  37318. * Gets camera class name
  37319. * @returns VRDeviceOrientationFreeCamera
  37320. */
  37321. getClassName(): string;
  37322. }
  37323. }
  37324. declare module BABYLON {
  37325. /**
  37326. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37327. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37328. */
  37329. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37330. /**
  37331. * Creates a new VRDeviceOrientationGamepadCamera
  37332. * @param name defines camera name
  37333. * @param position defines the start position of the camera
  37334. * @param scene defines the scene the camera belongs to
  37335. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37336. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37337. */
  37338. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37339. /**
  37340. * Gets camera class name
  37341. * @returns VRDeviceOrientationGamepadCamera
  37342. */
  37343. getClassName(): string;
  37344. }
  37345. }
  37346. declare module BABYLON {
  37347. /**
  37348. * Defines supported buttons for XBox360 compatible gamepads
  37349. */
  37350. export enum Xbox360Button {
  37351. /** A */
  37352. A = 0,
  37353. /** B */
  37354. B = 1,
  37355. /** X */
  37356. X = 2,
  37357. /** Y */
  37358. Y = 3,
  37359. /** Start */
  37360. Start = 4,
  37361. /** Back */
  37362. Back = 5,
  37363. /** Left button */
  37364. LB = 6,
  37365. /** Right button */
  37366. RB = 7,
  37367. /** Left stick */
  37368. LeftStick = 8,
  37369. /** Right stick */
  37370. RightStick = 9
  37371. }
  37372. /** Defines values for XBox360 DPad */
  37373. export enum Xbox360Dpad {
  37374. /** Up */
  37375. Up = 0,
  37376. /** Down */
  37377. Down = 1,
  37378. /** Left */
  37379. Left = 2,
  37380. /** Right */
  37381. Right = 3
  37382. }
  37383. /**
  37384. * Defines a XBox360 gamepad
  37385. */
  37386. export class Xbox360Pad extends Gamepad {
  37387. private _leftTrigger;
  37388. private _rightTrigger;
  37389. private _onlefttriggerchanged;
  37390. private _onrighttriggerchanged;
  37391. private _onbuttondown;
  37392. private _onbuttonup;
  37393. private _ondpaddown;
  37394. private _ondpadup;
  37395. /** Observable raised when a button is pressed */
  37396. onButtonDownObservable: Observable<Xbox360Button>;
  37397. /** Observable raised when a button is released */
  37398. onButtonUpObservable: Observable<Xbox360Button>;
  37399. /** Observable raised when a pad is pressed */
  37400. onPadDownObservable: Observable<Xbox360Dpad>;
  37401. /** Observable raised when a pad is released */
  37402. onPadUpObservable: Observable<Xbox360Dpad>;
  37403. private _buttonA;
  37404. private _buttonB;
  37405. private _buttonX;
  37406. private _buttonY;
  37407. private _buttonBack;
  37408. private _buttonStart;
  37409. private _buttonLB;
  37410. private _buttonRB;
  37411. private _buttonLeftStick;
  37412. private _buttonRightStick;
  37413. private _dPadUp;
  37414. private _dPadDown;
  37415. private _dPadLeft;
  37416. private _dPadRight;
  37417. private _isXboxOnePad;
  37418. /**
  37419. * Creates a new XBox360 gamepad object
  37420. * @param id defines the id of this gamepad
  37421. * @param index defines its index
  37422. * @param gamepad defines the internal HTML gamepad object
  37423. * @param xboxOne defines if it is a XBox One gamepad
  37424. */
  37425. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37426. /**
  37427. * Defines the callback to call when left trigger is pressed
  37428. * @param callback defines the callback to use
  37429. */
  37430. onlefttriggerchanged(callback: (value: number) => void): void;
  37431. /**
  37432. * Defines the callback to call when right trigger is pressed
  37433. * @param callback defines the callback to use
  37434. */
  37435. onrighttriggerchanged(callback: (value: number) => void): void;
  37436. /**
  37437. * Gets the left trigger value
  37438. */
  37439. /**
  37440. * Sets the left trigger value
  37441. */
  37442. leftTrigger: number;
  37443. /**
  37444. * Gets the right trigger value
  37445. */
  37446. /**
  37447. * Sets the right trigger value
  37448. */
  37449. rightTrigger: number;
  37450. /**
  37451. * Defines the callback to call when a button is pressed
  37452. * @param callback defines the callback to use
  37453. */
  37454. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37455. /**
  37456. * Defines the callback to call when a button is released
  37457. * @param callback defines the callback to use
  37458. */
  37459. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37460. /**
  37461. * Defines the callback to call when a pad is pressed
  37462. * @param callback defines the callback to use
  37463. */
  37464. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37465. /**
  37466. * Defines the callback to call when a pad is released
  37467. * @param callback defines the callback to use
  37468. */
  37469. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37470. private _setButtonValue;
  37471. private _setDPadValue;
  37472. /**
  37473. * Gets the value of the `A` button
  37474. */
  37475. /**
  37476. * Sets the value of the `A` button
  37477. */
  37478. buttonA: number;
  37479. /**
  37480. * Gets the value of the `B` button
  37481. */
  37482. /**
  37483. * Sets the value of the `B` button
  37484. */
  37485. buttonB: number;
  37486. /**
  37487. * Gets the value of the `X` button
  37488. */
  37489. /**
  37490. * Sets the value of the `X` button
  37491. */
  37492. buttonX: number;
  37493. /**
  37494. * Gets the value of the `Y` button
  37495. */
  37496. /**
  37497. * Sets the value of the `Y` button
  37498. */
  37499. buttonY: number;
  37500. /**
  37501. * Gets the value of the `Start` button
  37502. */
  37503. /**
  37504. * Sets the value of the `Start` button
  37505. */
  37506. buttonStart: number;
  37507. /**
  37508. * Gets the value of the `Back` button
  37509. */
  37510. /**
  37511. * Sets the value of the `Back` button
  37512. */
  37513. buttonBack: number;
  37514. /**
  37515. * Gets the value of the `Left` button
  37516. */
  37517. /**
  37518. * Sets the value of the `Left` button
  37519. */
  37520. buttonLB: number;
  37521. /**
  37522. * Gets the value of the `Right` button
  37523. */
  37524. /**
  37525. * Sets the value of the `Right` button
  37526. */
  37527. buttonRB: number;
  37528. /**
  37529. * Gets the value of the Left joystick
  37530. */
  37531. /**
  37532. * Sets the value of the Left joystick
  37533. */
  37534. buttonLeftStick: number;
  37535. /**
  37536. * Gets the value of the Right joystick
  37537. */
  37538. /**
  37539. * Sets the value of the Right joystick
  37540. */
  37541. buttonRightStick: number;
  37542. /**
  37543. * Gets the value of D-pad up
  37544. */
  37545. /**
  37546. * Sets the value of D-pad up
  37547. */
  37548. dPadUp: number;
  37549. /**
  37550. * Gets the value of D-pad down
  37551. */
  37552. /**
  37553. * Sets the value of D-pad down
  37554. */
  37555. dPadDown: number;
  37556. /**
  37557. * Gets the value of D-pad left
  37558. */
  37559. /**
  37560. * Sets the value of D-pad left
  37561. */
  37562. dPadLeft: number;
  37563. /**
  37564. * Gets the value of D-pad right
  37565. */
  37566. /**
  37567. * Sets the value of D-pad right
  37568. */
  37569. dPadRight: number;
  37570. /**
  37571. * Force the gamepad to synchronize with device values
  37572. */
  37573. update(): void;
  37574. /**
  37575. * Disposes the gamepad
  37576. */
  37577. dispose(): void;
  37578. }
  37579. }
  37580. declare module BABYLON {
  37581. /**
  37582. * Base class of materials working in push mode in babylon JS
  37583. * @hidden
  37584. */
  37585. export class PushMaterial extends Material {
  37586. protected _activeEffect: Effect;
  37587. protected _normalMatrix: Matrix;
  37588. /**
  37589. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37590. * This means that the material can keep using a previous shader while a new one is being compiled.
  37591. * This is mostly used when shader parallel compilation is supported (true by default)
  37592. */
  37593. allowShaderHotSwapping: boolean;
  37594. constructor(name: string, scene: Scene);
  37595. getEffect(): Effect;
  37596. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37597. /**
  37598. * Binds the given world matrix to the active effect
  37599. *
  37600. * @param world the matrix to bind
  37601. */
  37602. bindOnlyWorldMatrix(world: Matrix): void;
  37603. /**
  37604. * Binds the given normal matrix to the active effect
  37605. *
  37606. * @param normalMatrix the matrix to bind
  37607. */
  37608. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37609. bind(world: Matrix, mesh?: Mesh): void;
  37610. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37611. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37612. }
  37613. }
  37614. declare module BABYLON {
  37615. /**
  37616. * This groups all the flags used to control the materials channel.
  37617. */
  37618. export class MaterialFlags {
  37619. private static _DiffuseTextureEnabled;
  37620. /**
  37621. * Are diffuse textures enabled in the application.
  37622. */
  37623. static DiffuseTextureEnabled: boolean;
  37624. private static _AmbientTextureEnabled;
  37625. /**
  37626. * Are ambient textures enabled in the application.
  37627. */
  37628. static AmbientTextureEnabled: boolean;
  37629. private static _OpacityTextureEnabled;
  37630. /**
  37631. * Are opacity textures enabled in the application.
  37632. */
  37633. static OpacityTextureEnabled: boolean;
  37634. private static _ReflectionTextureEnabled;
  37635. /**
  37636. * Are reflection textures enabled in the application.
  37637. */
  37638. static ReflectionTextureEnabled: boolean;
  37639. private static _EmissiveTextureEnabled;
  37640. /**
  37641. * Are emissive textures enabled in the application.
  37642. */
  37643. static EmissiveTextureEnabled: boolean;
  37644. private static _SpecularTextureEnabled;
  37645. /**
  37646. * Are specular textures enabled in the application.
  37647. */
  37648. static SpecularTextureEnabled: boolean;
  37649. private static _BumpTextureEnabled;
  37650. /**
  37651. * Are bump textures enabled in the application.
  37652. */
  37653. static BumpTextureEnabled: boolean;
  37654. private static _LightmapTextureEnabled;
  37655. /**
  37656. * Are lightmap textures enabled in the application.
  37657. */
  37658. static LightmapTextureEnabled: boolean;
  37659. private static _RefractionTextureEnabled;
  37660. /**
  37661. * Are refraction textures enabled in the application.
  37662. */
  37663. static RefractionTextureEnabled: boolean;
  37664. private static _ColorGradingTextureEnabled;
  37665. /**
  37666. * Are color grading textures enabled in the application.
  37667. */
  37668. static ColorGradingTextureEnabled: boolean;
  37669. private static _FresnelEnabled;
  37670. /**
  37671. * Are fresnels enabled in the application.
  37672. */
  37673. static FresnelEnabled: boolean;
  37674. private static _ClearCoatTextureEnabled;
  37675. /**
  37676. * Are clear coat textures enabled in the application.
  37677. */
  37678. static ClearCoatTextureEnabled: boolean;
  37679. private static _ClearCoatBumpTextureEnabled;
  37680. /**
  37681. * Are clear coat bump textures enabled in the application.
  37682. */
  37683. static ClearCoatBumpTextureEnabled: boolean;
  37684. private static _ClearCoatTintTextureEnabled;
  37685. /**
  37686. * Are clear coat tint textures enabled in the application.
  37687. */
  37688. static ClearCoatTintTextureEnabled: boolean;
  37689. private static _SheenTextureEnabled;
  37690. /**
  37691. * Are sheen textures enabled in the application.
  37692. */
  37693. static SheenTextureEnabled: boolean;
  37694. private static _AnisotropicTextureEnabled;
  37695. /**
  37696. * Are anisotropic textures enabled in the application.
  37697. */
  37698. static AnisotropicTextureEnabled: boolean;
  37699. private static _ThicknessTextureEnabled;
  37700. /**
  37701. * Are thickness textures enabled in the application.
  37702. */
  37703. static ThicknessTextureEnabled: boolean;
  37704. }
  37705. }
  37706. declare module BABYLON {
  37707. /** @hidden */
  37708. export var defaultFragmentDeclaration: {
  37709. name: string;
  37710. shader: string;
  37711. };
  37712. }
  37713. declare module BABYLON {
  37714. /** @hidden */
  37715. export var defaultUboDeclaration: {
  37716. name: string;
  37717. shader: string;
  37718. };
  37719. }
  37720. declare module BABYLON {
  37721. /** @hidden */
  37722. export var lightFragmentDeclaration: {
  37723. name: string;
  37724. shader: string;
  37725. };
  37726. }
  37727. declare module BABYLON {
  37728. /** @hidden */
  37729. export var lightUboDeclaration: {
  37730. name: string;
  37731. shader: string;
  37732. };
  37733. }
  37734. declare module BABYLON {
  37735. /** @hidden */
  37736. export var lightsFragmentFunctions: {
  37737. name: string;
  37738. shader: string;
  37739. };
  37740. }
  37741. declare module BABYLON {
  37742. /** @hidden */
  37743. export var shadowsFragmentFunctions: {
  37744. name: string;
  37745. shader: string;
  37746. };
  37747. }
  37748. declare module BABYLON {
  37749. /** @hidden */
  37750. export var fresnelFunction: {
  37751. name: string;
  37752. shader: string;
  37753. };
  37754. }
  37755. declare module BABYLON {
  37756. /** @hidden */
  37757. export var reflectionFunction: {
  37758. name: string;
  37759. shader: string;
  37760. };
  37761. }
  37762. declare module BABYLON {
  37763. /** @hidden */
  37764. export var bumpFragmentFunctions: {
  37765. name: string;
  37766. shader: string;
  37767. };
  37768. }
  37769. declare module BABYLON {
  37770. /** @hidden */
  37771. export var logDepthDeclaration: {
  37772. name: string;
  37773. shader: string;
  37774. };
  37775. }
  37776. declare module BABYLON {
  37777. /** @hidden */
  37778. export var bumpFragment: {
  37779. name: string;
  37780. shader: string;
  37781. };
  37782. }
  37783. declare module BABYLON {
  37784. /** @hidden */
  37785. export var depthPrePass: {
  37786. name: string;
  37787. shader: string;
  37788. };
  37789. }
  37790. declare module BABYLON {
  37791. /** @hidden */
  37792. export var lightFragment: {
  37793. name: string;
  37794. shader: string;
  37795. };
  37796. }
  37797. declare module BABYLON {
  37798. /** @hidden */
  37799. export var logDepthFragment: {
  37800. name: string;
  37801. shader: string;
  37802. };
  37803. }
  37804. declare module BABYLON {
  37805. /** @hidden */
  37806. export var defaultPixelShader: {
  37807. name: string;
  37808. shader: string;
  37809. };
  37810. }
  37811. declare module BABYLON {
  37812. /** @hidden */
  37813. export var defaultVertexDeclaration: {
  37814. name: string;
  37815. shader: string;
  37816. };
  37817. }
  37818. declare module BABYLON {
  37819. /** @hidden */
  37820. export var bumpVertexDeclaration: {
  37821. name: string;
  37822. shader: string;
  37823. };
  37824. }
  37825. declare module BABYLON {
  37826. /** @hidden */
  37827. export var bumpVertex: {
  37828. name: string;
  37829. shader: string;
  37830. };
  37831. }
  37832. declare module BABYLON {
  37833. /** @hidden */
  37834. export var fogVertex: {
  37835. name: string;
  37836. shader: string;
  37837. };
  37838. }
  37839. declare module BABYLON {
  37840. /** @hidden */
  37841. export var shadowsVertex: {
  37842. name: string;
  37843. shader: string;
  37844. };
  37845. }
  37846. declare module BABYLON {
  37847. /** @hidden */
  37848. export var pointCloudVertex: {
  37849. name: string;
  37850. shader: string;
  37851. };
  37852. }
  37853. declare module BABYLON {
  37854. /** @hidden */
  37855. export var logDepthVertex: {
  37856. name: string;
  37857. shader: string;
  37858. };
  37859. }
  37860. declare module BABYLON {
  37861. /** @hidden */
  37862. export var defaultVertexShader: {
  37863. name: string;
  37864. shader: string;
  37865. };
  37866. }
  37867. declare module BABYLON {
  37868. /** @hidden */
  37869. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37870. MAINUV1: boolean;
  37871. MAINUV2: boolean;
  37872. DIFFUSE: boolean;
  37873. DIFFUSEDIRECTUV: number;
  37874. AMBIENT: boolean;
  37875. AMBIENTDIRECTUV: number;
  37876. OPACITY: boolean;
  37877. OPACITYDIRECTUV: number;
  37878. OPACITYRGB: boolean;
  37879. REFLECTION: boolean;
  37880. EMISSIVE: boolean;
  37881. EMISSIVEDIRECTUV: number;
  37882. SPECULAR: boolean;
  37883. SPECULARDIRECTUV: number;
  37884. BUMP: boolean;
  37885. BUMPDIRECTUV: number;
  37886. PARALLAX: boolean;
  37887. PARALLAXOCCLUSION: boolean;
  37888. SPECULAROVERALPHA: boolean;
  37889. CLIPPLANE: boolean;
  37890. CLIPPLANE2: boolean;
  37891. CLIPPLANE3: boolean;
  37892. CLIPPLANE4: boolean;
  37893. ALPHATEST: boolean;
  37894. DEPTHPREPASS: boolean;
  37895. ALPHAFROMDIFFUSE: boolean;
  37896. POINTSIZE: boolean;
  37897. FOG: boolean;
  37898. SPECULARTERM: boolean;
  37899. DIFFUSEFRESNEL: boolean;
  37900. OPACITYFRESNEL: boolean;
  37901. REFLECTIONFRESNEL: boolean;
  37902. REFRACTIONFRESNEL: boolean;
  37903. EMISSIVEFRESNEL: boolean;
  37904. FRESNEL: boolean;
  37905. NORMAL: boolean;
  37906. UV1: boolean;
  37907. UV2: boolean;
  37908. VERTEXCOLOR: boolean;
  37909. VERTEXALPHA: boolean;
  37910. NUM_BONE_INFLUENCERS: number;
  37911. BonesPerMesh: number;
  37912. BONETEXTURE: boolean;
  37913. INSTANCES: boolean;
  37914. GLOSSINESS: boolean;
  37915. ROUGHNESS: boolean;
  37916. EMISSIVEASILLUMINATION: boolean;
  37917. LINKEMISSIVEWITHDIFFUSE: boolean;
  37918. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37919. LIGHTMAP: boolean;
  37920. LIGHTMAPDIRECTUV: number;
  37921. OBJECTSPACE_NORMALMAP: boolean;
  37922. USELIGHTMAPASSHADOWMAP: boolean;
  37923. REFLECTIONMAP_3D: boolean;
  37924. REFLECTIONMAP_SPHERICAL: boolean;
  37925. REFLECTIONMAP_PLANAR: boolean;
  37926. REFLECTIONMAP_CUBIC: boolean;
  37927. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37928. REFLECTIONMAP_PROJECTION: boolean;
  37929. REFLECTIONMAP_SKYBOX: boolean;
  37930. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37931. REFLECTIONMAP_EXPLICIT: boolean;
  37932. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37933. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37934. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37935. INVERTCUBICMAP: boolean;
  37936. LOGARITHMICDEPTH: boolean;
  37937. REFRACTION: boolean;
  37938. REFRACTIONMAP_3D: boolean;
  37939. REFLECTIONOVERALPHA: boolean;
  37940. TWOSIDEDLIGHTING: boolean;
  37941. SHADOWFLOAT: boolean;
  37942. MORPHTARGETS: boolean;
  37943. MORPHTARGETS_NORMAL: boolean;
  37944. MORPHTARGETS_TANGENT: boolean;
  37945. NUM_MORPH_INFLUENCERS: number;
  37946. NONUNIFORMSCALING: boolean;
  37947. PREMULTIPLYALPHA: boolean;
  37948. IMAGEPROCESSING: boolean;
  37949. VIGNETTE: boolean;
  37950. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37951. VIGNETTEBLENDMODEOPAQUE: boolean;
  37952. TONEMAPPING: boolean;
  37953. TONEMAPPING_ACES: boolean;
  37954. CONTRAST: boolean;
  37955. COLORCURVES: boolean;
  37956. COLORGRADING: boolean;
  37957. COLORGRADING3D: boolean;
  37958. SAMPLER3DGREENDEPTH: boolean;
  37959. SAMPLER3DBGRMAP: boolean;
  37960. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37961. MULTIVIEW: boolean;
  37962. /**
  37963. * If the reflection texture on this material is in linear color space
  37964. * @hidden
  37965. */
  37966. IS_REFLECTION_LINEAR: boolean;
  37967. /**
  37968. * If the refraction texture on this material is in linear color space
  37969. * @hidden
  37970. */
  37971. IS_REFRACTION_LINEAR: boolean;
  37972. EXPOSURE: boolean;
  37973. constructor();
  37974. setReflectionMode(modeToEnable: string): void;
  37975. }
  37976. /**
  37977. * This is the default material used in Babylon. It is the best trade off between quality
  37978. * and performances.
  37979. * @see http://doc.babylonjs.com/babylon101/materials
  37980. */
  37981. export class StandardMaterial extends PushMaterial {
  37982. private _diffuseTexture;
  37983. /**
  37984. * The basic texture of the material as viewed under a light.
  37985. */
  37986. diffuseTexture: Nullable<BaseTexture>;
  37987. private _ambientTexture;
  37988. /**
  37989. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37990. */
  37991. ambientTexture: Nullable<BaseTexture>;
  37992. private _opacityTexture;
  37993. /**
  37994. * Define the transparency of the material from a texture.
  37995. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37996. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37997. */
  37998. opacityTexture: Nullable<BaseTexture>;
  37999. private _reflectionTexture;
  38000. /**
  38001. * Define the texture used to display the reflection.
  38002. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38003. */
  38004. reflectionTexture: Nullable<BaseTexture>;
  38005. private _emissiveTexture;
  38006. /**
  38007. * Define texture of the material as if self lit.
  38008. * This will be mixed in the final result even in the absence of light.
  38009. */
  38010. emissiveTexture: Nullable<BaseTexture>;
  38011. private _specularTexture;
  38012. /**
  38013. * Define how the color and intensity of the highlight given by the light in the material.
  38014. */
  38015. specularTexture: Nullable<BaseTexture>;
  38016. private _bumpTexture;
  38017. /**
  38018. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38019. * 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.
  38020. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38021. */
  38022. bumpTexture: Nullable<BaseTexture>;
  38023. private _lightmapTexture;
  38024. /**
  38025. * Complex lighting can be computationally expensive to compute at runtime.
  38026. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38027. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38028. */
  38029. lightmapTexture: Nullable<BaseTexture>;
  38030. private _refractionTexture;
  38031. /**
  38032. * Define the texture used to display the refraction.
  38033. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38034. */
  38035. refractionTexture: Nullable<BaseTexture>;
  38036. /**
  38037. * The color of the material lit by the environmental background lighting.
  38038. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38039. */
  38040. ambientColor: Color3;
  38041. /**
  38042. * The basic color of the material as viewed under a light.
  38043. */
  38044. diffuseColor: Color3;
  38045. /**
  38046. * Define how the color and intensity of the highlight given by the light in the material.
  38047. */
  38048. specularColor: Color3;
  38049. /**
  38050. * Define the color of the material as if self lit.
  38051. * This will be mixed in the final result even in the absence of light.
  38052. */
  38053. emissiveColor: Color3;
  38054. /**
  38055. * Defines how sharp are the highlights in the material.
  38056. * The bigger the value the sharper giving a more glossy feeling to the result.
  38057. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38058. */
  38059. specularPower: number;
  38060. private _useAlphaFromDiffuseTexture;
  38061. /**
  38062. * Does the transparency come from the diffuse texture alpha channel.
  38063. */
  38064. useAlphaFromDiffuseTexture: boolean;
  38065. private _useEmissiveAsIllumination;
  38066. /**
  38067. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38068. */
  38069. useEmissiveAsIllumination: boolean;
  38070. private _linkEmissiveWithDiffuse;
  38071. /**
  38072. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38073. * the emissive level when the final color is close to one.
  38074. */
  38075. linkEmissiveWithDiffuse: boolean;
  38076. private _useSpecularOverAlpha;
  38077. /**
  38078. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38079. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38080. */
  38081. useSpecularOverAlpha: boolean;
  38082. private _useReflectionOverAlpha;
  38083. /**
  38084. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38085. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38086. */
  38087. useReflectionOverAlpha: boolean;
  38088. private _disableLighting;
  38089. /**
  38090. * Does lights from the scene impacts this material.
  38091. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38092. */
  38093. disableLighting: boolean;
  38094. private _useObjectSpaceNormalMap;
  38095. /**
  38096. * Allows using an object space normal map (instead of tangent space).
  38097. */
  38098. useObjectSpaceNormalMap: boolean;
  38099. private _useParallax;
  38100. /**
  38101. * Is parallax enabled or not.
  38102. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38103. */
  38104. useParallax: boolean;
  38105. private _useParallaxOcclusion;
  38106. /**
  38107. * Is parallax occlusion enabled or not.
  38108. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38109. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38110. */
  38111. useParallaxOcclusion: boolean;
  38112. /**
  38113. * 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.
  38114. */
  38115. parallaxScaleBias: number;
  38116. private _roughness;
  38117. /**
  38118. * Helps to define how blurry the reflections should appears in the material.
  38119. */
  38120. roughness: number;
  38121. /**
  38122. * In case of refraction, define the value of the indice of refraction.
  38123. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38124. */
  38125. indexOfRefraction: number;
  38126. /**
  38127. * Invert the refraction texture alongside the y axis.
  38128. * It can be useful with procedural textures or probe for instance.
  38129. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38130. */
  38131. invertRefractionY: boolean;
  38132. /**
  38133. * Defines the alpha limits in alpha test mode.
  38134. */
  38135. alphaCutOff: number;
  38136. private _useLightmapAsShadowmap;
  38137. /**
  38138. * In case of light mapping, define whether the map contains light or shadow informations.
  38139. */
  38140. useLightmapAsShadowmap: boolean;
  38141. private _diffuseFresnelParameters;
  38142. /**
  38143. * Define the diffuse fresnel parameters of the material.
  38144. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38145. */
  38146. diffuseFresnelParameters: FresnelParameters;
  38147. private _opacityFresnelParameters;
  38148. /**
  38149. * Define the opacity fresnel parameters of the material.
  38150. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38151. */
  38152. opacityFresnelParameters: FresnelParameters;
  38153. private _reflectionFresnelParameters;
  38154. /**
  38155. * Define the reflection fresnel parameters of the material.
  38156. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38157. */
  38158. reflectionFresnelParameters: FresnelParameters;
  38159. private _refractionFresnelParameters;
  38160. /**
  38161. * Define the refraction fresnel parameters of the material.
  38162. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38163. */
  38164. refractionFresnelParameters: FresnelParameters;
  38165. private _emissiveFresnelParameters;
  38166. /**
  38167. * Define the emissive fresnel parameters of the material.
  38168. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38169. */
  38170. emissiveFresnelParameters: FresnelParameters;
  38171. private _useReflectionFresnelFromSpecular;
  38172. /**
  38173. * If true automatically deducts the fresnels values from the material specularity.
  38174. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38175. */
  38176. useReflectionFresnelFromSpecular: boolean;
  38177. private _useGlossinessFromSpecularMapAlpha;
  38178. /**
  38179. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38180. */
  38181. useGlossinessFromSpecularMapAlpha: boolean;
  38182. private _maxSimultaneousLights;
  38183. /**
  38184. * Defines the maximum number of lights that can be used in the material
  38185. */
  38186. maxSimultaneousLights: number;
  38187. private _invertNormalMapX;
  38188. /**
  38189. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38190. */
  38191. invertNormalMapX: boolean;
  38192. private _invertNormalMapY;
  38193. /**
  38194. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38195. */
  38196. invertNormalMapY: boolean;
  38197. private _twoSidedLighting;
  38198. /**
  38199. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38200. */
  38201. twoSidedLighting: boolean;
  38202. /**
  38203. * Default configuration related to image processing available in the standard Material.
  38204. */
  38205. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38206. /**
  38207. * Gets the image processing configuration used either in this material.
  38208. */
  38209. /**
  38210. * Sets the Default image processing configuration used either in the this material.
  38211. *
  38212. * If sets to null, the scene one is in use.
  38213. */
  38214. imageProcessingConfiguration: ImageProcessingConfiguration;
  38215. /**
  38216. * Keep track of the image processing observer to allow dispose and replace.
  38217. */
  38218. private _imageProcessingObserver;
  38219. /**
  38220. * Attaches a new image processing configuration to the Standard Material.
  38221. * @param configuration
  38222. */
  38223. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38224. /**
  38225. * Gets wether the color curves effect is enabled.
  38226. */
  38227. /**
  38228. * Sets wether the color curves effect is enabled.
  38229. */
  38230. cameraColorCurvesEnabled: boolean;
  38231. /**
  38232. * Gets wether the color grading effect is enabled.
  38233. */
  38234. /**
  38235. * Gets wether the color grading effect is enabled.
  38236. */
  38237. cameraColorGradingEnabled: boolean;
  38238. /**
  38239. * Gets wether tonemapping is enabled or not.
  38240. */
  38241. /**
  38242. * Sets wether tonemapping is enabled or not
  38243. */
  38244. cameraToneMappingEnabled: boolean;
  38245. /**
  38246. * The camera exposure used on this material.
  38247. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38248. * This corresponds to a photographic exposure.
  38249. */
  38250. /**
  38251. * The camera exposure used on this material.
  38252. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38253. * This corresponds to a photographic exposure.
  38254. */
  38255. cameraExposure: number;
  38256. /**
  38257. * Gets The camera contrast used on this material.
  38258. */
  38259. /**
  38260. * Sets The camera contrast used on this material.
  38261. */
  38262. cameraContrast: number;
  38263. /**
  38264. * Gets the Color Grading 2D Lookup Texture.
  38265. */
  38266. /**
  38267. * Sets the Color Grading 2D Lookup Texture.
  38268. */
  38269. cameraColorGradingTexture: Nullable<BaseTexture>;
  38270. /**
  38271. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38272. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38273. * 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;
  38274. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38275. */
  38276. /**
  38277. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38278. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38279. * 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;
  38280. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38281. */
  38282. cameraColorCurves: Nullable<ColorCurves>;
  38283. /**
  38284. * Custom callback helping to override the default shader used in the material.
  38285. */
  38286. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38287. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38288. protected _worldViewProjectionMatrix: Matrix;
  38289. protected _globalAmbientColor: Color3;
  38290. protected _useLogarithmicDepth: boolean;
  38291. /**
  38292. * Instantiates a new standard material.
  38293. * This is the default material used in Babylon. It is the best trade off between quality
  38294. * and performances.
  38295. * @see http://doc.babylonjs.com/babylon101/materials
  38296. * @param name Define the name of the material in the scene
  38297. * @param scene Define the scene the material belong to
  38298. */
  38299. constructor(name: string, scene: Scene);
  38300. /**
  38301. * Gets a boolean indicating that current material needs to register RTT
  38302. */
  38303. readonly hasRenderTargetTextures: boolean;
  38304. /**
  38305. * Gets the current class name of the material e.g. "StandardMaterial"
  38306. * Mainly use in serialization.
  38307. * @returns the class name
  38308. */
  38309. getClassName(): string;
  38310. /**
  38311. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38312. * You can try switching to logarithmic depth.
  38313. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38314. */
  38315. useLogarithmicDepth: boolean;
  38316. /**
  38317. * Specifies if the material will require alpha blending
  38318. * @returns a boolean specifying if alpha blending is needed
  38319. */
  38320. needAlphaBlending(): boolean;
  38321. /**
  38322. * Specifies if this material should be rendered in alpha test mode
  38323. * @returns a boolean specifying if an alpha test is needed.
  38324. */
  38325. needAlphaTesting(): boolean;
  38326. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38327. /**
  38328. * Get the texture used for alpha test purpose.
  38329. * @returns the diffuse texture in case of the standard material.
  38330. */
  38331. getAlphaTestTexture(): Nullable<BaseTexture>;
  38332. /**
  38333. * Get if the submesh is ready to be used and all its information available.
  38334. * Child classes can use it to update shaders
  38335. * @param mesh defines the mesh to check
  38336. * @param subMesh defines which submesh to check
  38337. * @param useInstances specifies that instances should be used
  38338. * @returns a boolean indicating that the submesh is ready or not
  38339. */
  38340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38341. /**
  38342. * Builds the material UBO layouts.
  38343. * Used internally during the effect preparation.
  38344. */
  38345. buildUniformLayout(): void;
  38346. /**
  38347. * Unbinds the material from the mesh
  38348. */
  38349. unbind(): void;
  38350. /**
  38351. * Binds the submesh to this material by preparing the effect and shader to draw
  38352. * @param world defines the world transformation matrix
  38353. * @param mesh defines the mesh containing the submesh
  38354. * @param subMesh defines the submesh to bind the material to
  38355. */
  38356. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38357. /**
  38358. * Get the list of animatables in the material.
  38359. * @returns the list of animatables object used in the material
  38360. */
  38361. getAnimatables(): IAnimatable[];
  38362. /**
  38363. * Gets the active textures from the material
  38364. * @returns an array of textures
  38365. */
  38366. getActiveTextures(): BaseTexture[];
  38367. /**
  38368. * Specifies if the material uses a texture
  38369. * @param texture defines the texture to check against the material
  38370. * @returns a boolean specifying if the material uses the texture
  38371. */
  38372. hasTexture(texture: BaseTexture): boolean;
  38373. /**
  38374. * Disposes the material
  38375. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38376. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38377. */
  38378. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38379. /**
  38380. * Makes a duplicate of the material, and gives it a new name
  38381. * @param name defines the new name for the duplicated material
  38382. * @returns the cloned material
  38383. */
  38384. clone(name: string): StandardMaterial;
  38385. /**
  38386. * Serializes this material in a JSON representation
  38387. * @returns the serialized material object
  38388. */
  38389. serialize(): any;
  38390. /**
  38391. * Creates a standard material from parsed material data
  38392. * @param source defines the JSON representation of the material
  38393. * @param scene defines the hosting scene
  38394. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38395. * @returns a new standard material
  38396. */
  38397. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38398. /**
  38399. * Are diffuse textures enabled in the application.
  38400. */
  38401. static DiffuseTextureEnabled: boolean;
  38402. /**
  38403. * Are ambient textures enabled in the application.
  38404. */
  38405. static AmbientTextureEnabled: boolean;
  38406. /**
  38407. * Are opacity textures enabled in the application.
  38408. */
  38409. static OpacityTextureEnabled: boolean;
  38410. /**
  38411. * Are reflection textures enabled in the application.
  38412. */
  38413. static ReflectionTextureEnabled: boolean;
  38414. /**
  38415. * Are emissive textures enabled in the application.
  38416. */
  38417. static EmissiveTextureEnabled: boolean;
  38418. /**
  38419. * Are specular textures enabled in the application.
  38420. */
  38421. static SpecularTextureEnabled: boolean;
  38422. /**
  38423. * Are bump textures enabled in the application.
  38424. */
  38425. static BumpTextureEnabled: boolean;
  38426. /**
  38427. * Are lightmap textures enabled in the application.
  38428. */
  38429. static LightmapTextureEnabled: boolean;
  38430. /**
  38431. * Are refraction textures enabled in the application.
  38432. */
  38433. static RefractionTextureEnabled: boolean;
  38434. /**
  38435. * Are color grading textures enabled in the application.
  38436. */
  38437. static ColorGradingTextureEnabled: boolean;
  38438. /**
  38439. * Are fresnels enabled in the application.
  38440. */
  38441. static FresnelEnabled: boolean;
  38442. }
  38443. }
  38444. declare module BABYLON {
  38445. /**
  38446. * A class extending Texture allowing drawing on a texture
  38447. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38448. */
  38449. export class DynamicTexture extends Texture {
  38450. private _generateMipMaps;
  38451. private _canvas;
  38452. private _context;
  38453. private _engine;
  38454. /**
  38455. * Creates a DynamicTexture
  38456. * @param name defines the name of the texture
  38457. * @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
  38458. * @param scene defines the scene where you want the texture
  38459. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38460. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38461. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38462. */
  38463. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38464. /**
  38465. * Get the current class name of the texture useful for serialization or dynamic coding.
  38466. * @returns "DynamicTexture"
  38467. */
  38468. getClassName(): string;
  38469. /**
  38470. * Gets the current state of canRescale
  38471. */
  38472. readonly canRescale: boolean;
  38473. private _recreate;
  38474. /**
  38475. * Scales the texture
  38476. * @param ratio the scale factor to apply to both width and height
  38477. */
  38478. scale(ratio: number): void;
  38479. /**
  38480. * Resizes the texture
  38481. * @param width the new width
  38482. * @param height the new height
  38483. */
  38484. scaleTo(width: number, height: number): void;
  38485. /**
  38486. * Gets the context of the canvas used by the texture
  38487. * @returns the canvas context of the dynamic texture
  38488. */
  38489. getContext(): CanvasRenderingContext2D;
  38490. /**
  38491. * Clears the texture
  38492. */
  38493. clear(): void;
  38494. /**
  38495. * Updates the texture
  38496. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38497. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38498. */
  38499. update(invertY?: boolean, premulAlpha?: boolean): void;
  38500. /**
  38501. * Draws text onto the texture
  38502. * @param text defines the text to be drawn
  38503. * @param x defines the placement of the text from the left
  38504. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38505. * @param font defines the font to be used with font-style, font-size, font-name
  38506. * @param color defines the color used for the text
  38507. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38508. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38509. * @param update defines whether texture is immediately update (default is true)
  38510. */
  38511. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38512. /**
  38513. * Clones the texture
  38514. * @returns the clone of the texture.
  38515. */
  38516. clone(): DynamicTexture;
  38517. /**
  38518. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38519. * @returns a serialized dynamic texture object
  38520. */
  38521. serialize(): any;
  38522. /** @hidden */ rebuild(): void;
  38523. }
  38524. }
  38525. declare module BABYLON {
  38526. /** @hidden */
  38527. export var imageProcessingPixelShader: {
  38528. name: string;
  38529. shader: string;
  38530. };
  38531. }
  38532. declare module BABYLON {
  38533. /**
  38534. * ImageProcessingPostProcess
  38535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38536. */
  38537. export class ImageProcessingPostProcess extends PostProcess {
  38538. /**
  38539. * Default configuration related to image processing available in the PBR Material.
  38540. */
  38541. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38542. /**
  38543. * Gets the image processing configuration used either in this material.
  38544. */
  38545. /**
  38546. * Sets the Default image processing configuration used either in the this material.
  38547. *
  38548. * If sets to null, the scene one is in use.
  38549. */
  38550. imageProcessingConfiguration: ImageProcessingConfiguration;
  38551. /**
  38552. * Keep track of the image processing observer to allow dispose and replace.
  38553. */
  38554. private _imageProcessingObserver;
  38555. /**
  38556. * Attaches a new image processing configuration to the PBR Material.
  38557. * @param configuration
  38558. */
  38559. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38560. /**
  38561. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38562. */
  38563. /**
  38564. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38565. */
  38566. colorCurves: Nullable<ColorCurves>;
  38567. /**
  38568. * Gets wether the color curves effect is enabled.
  38569. */
  38570. /**
  38571. * Sets wether the color curves effect is enabled.
  38572. */
  38573. colorCurvesEnabled: boolean;
  38574. /**
  38575. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38576. */
  38577. /**
  38578. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38579. */
  38580. colorGradingTexture: Nullable<BaseTexture>;
  38581. /**
  38582. * Gets wether the color grading effect is enabled.
  38583. */
  38584. /**
  38585. * Gets wether the color grading effect is enabled.
  38586. */
  38587. colorGradingEnabled: boolean;
  38588. /**
  38589. * Gets exposure used in the effect.
  38590. */
  38591. /**
  38592. * Sets exposure used in the effect.
  38593. */
  38594. exposure: number;
  38595. /**
  38596. * Gets wether tonemapping is enabled or not.
  38597. */
  38598. /**
  38599. * Sets wether tonemapping is enabled or not
  38600. */
  38601. toneMappingEnabled: boolean;
  38602. /**
  38603. * Gets the type of tone mapping effect.
  38604. */
  38605. /**
  38606. * Sets the type of tone mapping effect.
  38607. */
  38608. toneMappingType: number;
  38609. /**
  38610. * Gets contrast used in the effect.
  38611. */
  38612. /**
  38613. * Sets contrast used in the effect.
  38614. */
  38615. contrast: number;
  38616. /**
  38617. * Gets Vignette stretch size.
  38618. */
  38619. /**
  38620. * Sets Vignette stretch size.
  38621. */
  38622. vignetteStretch: number;
  38623. /**
  38624. * Gets Vignette centre X Offset.
  38625. */
  38626. /**
  38627. * Sets Vignette centre X Offset.
  38628. */
  38629. vignetteCentreX: number;
  38630. /**
  38631. * Gets Vignette centre Y Offset.
  38632. */
  38633. /**
  38634. * Sets Vignette centre Y Offset.
  38635. */
  38636. vignetteCentreY: number;
  38637. /**
  38638. * Gets Vignette weight or intensity of the vignette effect.
  38639. */
  38640. /**
  38641. * Sets Vignette weight or intensity of the vignette effect.
  38642. */
  38643. vignetteWeight: number;
  38644. /**
  38645. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38646. * if vignetteEnabled is set to true.
  38647. */
  38648. /**
  38649. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38650. * if vignetteEnabled is set to true.
  38651. */
  38652. vignetteColor: Color4;
  38653. /**
  38654. * Gets Camera field of view used by the Vignette effect.
  38655. */
  38656. /**
  38657. * Sets Camera field of view used by the Vignette effect.
  38658. */
  38659. vignetteCameraFov: number;
  38660. /**
  38661. * Gets the vignette blend mode allowing different kind of effect.
  38662. */
  38663. /**
  38664. * Sets the vignette blend mode allowing different kind of effect.
  38665. */
  38666. vignetteBlendMode: number;
  38667. /**
  38668. * Gets wether the vignette effect is enabled.
  38669. */
  38670. /**
  38671. * Sets wether the vignette effect is enabled.
  38672. */
  38673. vignetteEnabled: boolean;
  38674. private _fromLinearSpace;
  38675. /**
  38676. * Gets wether the input of the processing is in Gamma or Linear Space.
  38677. */
  38678. /**
  38679. * Sets wether the input of the processing is in Gamma or Linear Space.
  38680. */
  38681. fromLinearSpace: boolean;
  38682. /**
  38683. * Defines cache preventing GC.
  38684. */
  38685. private _defines;
  38686. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38687. /**
  38688. * "ImageProcessingPostProcess"
  38689. * @returns "ImageProcessingPostProcess"
  38690. */
  38691. getClassName(): string;
  38692. protected _updateParameters(): void;
  38693. dispose(camera?: Camera): void;
  38694. }
  38695. }
  38696. declare module BABYLON {
  38697. /**
  38698. * Class containing static functions to help procedurally build meshes
  38699. */
  38700. export class GroundBuilder {
  38701. /**
  38702. * Creates a ground mesh
  38703. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38704. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38706. * @param name defines the name of the mesh
  38707. * @param options defines the options used to create the mesh
  38708. * @param scene defines the hosting scene
  38709. * @returns the ground mesh
  38710. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38711. */
  38712. static CreateGround(name: string, options: {
  38713. width?: number;
  38714. height?: number;
  38715. subdivisions?: number;
  38716. subdivisionsX?: number;
  38717. subdivisionsY?: number;
  38718. updatable?: boolean;
  38719. }, scene: any): Mesh;
  38720. /**
  38721. * Creates a tiled ground mesh
  38722. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38723. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38724. * * 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
  38725. * * 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
  38726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38727. * @param name defines the name of the mesh
  38728. * @param options defines the options used to create the mesh
  38729. * @param scene defines the hosting scene
  38730. * @returns the tiled ground mesh
  38731. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38732. */
  38733. static CreateTiledGround(name: string, options: {
  38734. xmin: number;
  38735. zmin: number;
  38736. xmax: number;
  38737. zmax: number;
  38738. subdivisions?: {
  38739. w: number;
  38740. h: number;
  38741. };
  38742. precision?: {
  38743. w: number;
  38744. h: number;
  38745. };
  38746. updatable?: boolean;
  38747. }, scene?: Nullable<Scene>): Mesh;
  38748. /**
  38749. * Creates a ground mesh from a height map
  38750. * * The parameter `url` sets the URL of the height map image resource.
  38751. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38752. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38753. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38754. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38755. * * 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.
  38756. * * 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).
  38757. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38759. * @param name defines the name of the mesh
  38760. * @param url defines the url to the height map
  38761. * @param options defines the options used to create the mesh
  38762. * @param scene defines the hosting scene
  38763. * @returns the ground mesh
  38764. * @see https://doc.babylonjs.com/babylon101/height_map
  38765. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38766. */
  38767. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38768. width?: number;
  38769. height?: number;
  38770. subdivisions?: number;
  38771. minHeight?: number;
  38772. maxHeight?: number;
  38773. colorFilter?: Color3;
  38774. alphaFilter?: number;
  38775. updatable?: boolean;
  38776. onReady?: (mesh: GroundMesh) => void;
  38777. }, scene?: Nullable<Scene>): GroundMesh;
  38778. }
  38779. }
  38780. declare module BABYLON {
  38781. /**
  38782. * Class containing static functions to help procedurally build meshes
  38783. */
  38784. export class TorusBuilder {
  38785. /**
  38786. * Creates a torus mesh
  38787. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38788. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38789. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38791. * * 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
  38792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38793. * @param name defines the name of the mesh
  38794. * @param options defines the options used to create the mesh
  38795. * @param scene defines the hosting scene
  38796. * @returns the torus mesh
  38797. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38798. */
  38799. static CreateTorus(name: string, options: {
  38800. diameter?: number;
  38801. thickness?: number;
  38802. tessellation?: number;
  38803. updatable?: boolean;
  38804. sideOrientation?: number;
  38805. frontUVs?: Vector4;
  38806. backUVs?: Vector4;
  38807. }, scene: any): Mesh;
  38808. }
  38809. }
  38810. declare module BABYLON {
  38811. /**
  38812. * Class containing static functions to help procedurally build meshes
  38813. */
  38814. export class CylinderBuilder {
  38815. /**
  38816. * Creates a cylinder or a cone mesh
  38817. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38818. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38819. * * 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.
  38820. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38821. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38822. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38823. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38824. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38825. * * 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).
  38826. * * 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
  38827. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38828. * * 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
  38829. * * 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.
  38830. * * If `enclose` is false, a ring surface is one element.
  38831. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38832. * * 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
  38833. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38834. * * 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
  38835. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38836. * @param name defines the name of the mesh
  38837. * @param options defines the options used to create the mesh
  38838. * @param scene defines the hosting scene
  38839. * @returns the cylinder mesh
  38840. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38841. */
  38842. static CreateCylinder(name: string, options: {
  38843. height?: number;
  38844. diameterTop?: number;
  38845. diameterBottom?: number;
  38846. diameter?: number;
  38847. tessellation?: number;
  38848. subdivisions?: number;
  38849. arc?: number;
  38850. faceColors?: Color4[];
  38851. faceUV?: Vector4[];
  38852. updatable?: boolean;
  38853. hasRings?: boolean;
  38854. enclose?: boolean;
  38855. sideOrientation?: number;
  38856. frontUVs?: Vector4;
  38857. backUVs?: Vector4;
  38858. }, scene: any): Mesh;
  38859. }
  38860. }
  38861. declare module BABYLON {
  38862. /**
  38863. * Manager for handling gamepads
  38864. */
  38865. export class GamepadManager {
  38866. private _scene?;
  38867. private _babylonGamepads;
  38868. private _oneGamepadConnected;
  38869. /** @hidden */ isMonitoring: boolean;
  38870. private _gamepadEventSupported;
  38871. private _gamepadSupport;
  38872. /**
  38873. * observable to be triggered when the gamepad controller has been connected
  38874. */
  38875. onGamepadConnectedObservable: Observable<Gamepad>;
  38876. /**
  38877. * observable to be triggered when the gamepad controller has been disconnected
  38878. */
  38879. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38880. private _onGamepadConnectedEvent;
  38881. private _onGamepadDisconnectedEvent;
  38882. /**
  38883. * Initializes the gamepad manager
  38884. * @param _scene BabylonJS scene
  38885. */
  38886. constructor(_scene?: Scene | undefined);
  38887. /**
  38888. * The gamepads in the game pad manager
  38889. */
  38890. readonly gamepads: Gamepad[];
  38891. /**
  38892. * Get the gamepad controllers based on type
  38893. * @param type The type of gamepad controller
  38894. * @returns Nullable gamepad
  38895. */
  38896. getGamepadByType(type?: number): Nullable<Gamepad>;
  38897. /**
  38898. * Disposes the gamepad manager
  38899. */
  38900. dispose(): void;
  38901. private _addNewGamepad;
  38902. private _startMonitoringGamepads;
  38903. private _stopMonitoringGamepads;
  38904. /** @hidden */ checkGamepadsStatus(): void;
  38905. private _updateGamepadObjects;
  38906. }
  38907. }
  38908. declare module BABYLON {
  38909. interface Scene {
  38910. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38911. /**
  38912. * Gets the gamepad manager associated with the scene
  38913. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38914. */
  38915. gamepadManager: GamepadManager;
  38916. }
  38917. /**
  38918. * Interface representing a free camera inputs manager
  38919. */
  38920. interface FreeCameraInputsManager {
  38921. /**
  38922. * Adds gamepad input support to the FreeCameraInputsManager.
  38923. * @returns the FreeCameraInputsManager
  38924. */
  38925. addGamepad(): FreeCameraInputsManager;
  38926. }
  38927. /**
  38928. * Interface representing an arc rotate camera inputs manager
  38929. */
  38930. interface ArcRotateCameraInputsManager {
  38931. /**
  38932. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38933. * @returns the camera inputs manager
  38934. */
  38935. addGamepad(): ArcRotateCameraInputsManager;
  38936. }
  38937. /**
  38938. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38939. */
  38940. export class GamepadSystemSceneComponent implements ISceneComponent {
  38941. /**
  38942. * The component name helpfull to identify the component in the list of scene components.
  38943. */
  38944. readonly name: string;
  38945. /**
  38946. * The scene the component belongs to.
  38947. */
  38948. scene: Scene;
  38949. /**
  38950. * Creates a new instance of the component for the given scene
  38951. * @param scene Defines the scene to register the component in
  38952. */
  38953. constructor(scene: Scene);
  38954. /**
  38955. * Registers the component in a given scene
  38956. */
  38957. register(): void;
  38958. /**
  38959. * Rebuilds the elements related to this component in case of
  38960. * context lost for instance.
  38961. */
  38962. rebuild(): void;
  38963. /**
  38964. * Disposes the component and the associated ressources
  38965. */
  38966. dispose(): void;
  38967. private _beforeCameraUpdate;
  38968. }
  38969. }
  38970. declare module BABYLON {
  38971. /**
  38972. * Options to modify the vr teleportation behavior.
  38973. */
  38974. export interface VRTeleportationOptions {
  38975. /**
  38976. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38977. */
  38978. floorMeshName?: string;
  38979. /**
  38980. * A list of meshes to be used as the teleportation floor. (default: empty)
  38981. */
  38982. floorMeshes?: Mesh[];
  38983. }
  38984. /**
  38985. * Options to modify the vr experience helper's behavior.
  38986. */
  38987. export interface VRExperienceHelperOptions extends WebVROptions {
  38988. /**
  38989. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38990. */
  38991. createDeviceOrientationCamera?: boolean;
  38992. /**
  38993. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38994. */
  38995. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38996. /**
  38997. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38998. */
  38999. laserToggle?: boolean;
  39000. /**
  39001. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39002. */
  39003. floorMeshes?: Mesh[];
  39004. /**
  39005. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39006. */
  39007. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39008. }
  39009. /**
  39010. * Event containing information after VR has been entered
  39011. */
  39012. export class OnAfterEnteringVRObservableEvent {
  39013. /**
  39014. * If entering vr was successful
  39015. */
  39016. success: boolean;
  39017. }
  39018. /**
  39019. * Helps to quickly add VR support to an existing scene.
  39020. * See http://doc.babylonjs.com/how_to/webvr_helper
  39021. */
  39022. export class VRExperienceHelper {
  39023. /** Options to modify the vr experience helper's behavior. */
  39024. webVROptions: VRExperienceHelperOptions;
  39025. private _scene;
  39026. private _position;
  39027. private _btnVR;
  39028. private _btnVRDisplayed;
  39029. private _webVRsupported;
  39030. private _webVRready;
  39031. private _webVRrequesting;
  39032. private _webVRpresenting;
  39033. private _hasEnteredVR;
  39034. private _fullscreenVRpresenting;
  39035. private _canvas;
  39036. private _webVRCamera;
  39037. private _vrDeviceOrientationCamera;
  39038. private _deviceOrientationCamera;
  39039. private _existingCamera;
  39040. private _onKeyDown;
  39041. private _onVrDisplayPresentChange;
  39042. private _onVRDisplayChanged;
  39043. private _onVRRequestPresentStart;
  39044. private _onVRRequestPresentComplete;
  39045. /**
  39046. * Observable raised right before entering VR.
  39047. */
  39048. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39049. /**
  39050. * Observable raised when entering VR has completed.
  39051. */
  39052. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39053. /**
  39054. * Observable raised when exiting VR.
  39055. */
  39056. onExitingVRObservable: Observable<VRExperienceHelper>;
  39057. /**
  39058. * Observable raised when controller mesh is loaded.
  39059. */
  39060. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39061. /** Return this.onEnteringVRObservable
  39062. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39063. */
  39064. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39065. /** Return this.onExitingVRObservable
  39066. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39067. */
  39068. readonly onExitingVR: Observable<VRExperienceHelper>;
  39069. /** Return this.onControllerMeshLoadedObservable
  39070. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39071. */
  39072. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39073. private _rayLength;
  39074. private _useCustomVRButton;
  39075. private _teleportationRequested;
  39076. private _teleportActive;
  39077. private _floorMeshName;
  39078. private _floorMeshesCollection;
  39079. private _rotationAllowed;
  39080. private _teleportBackwardsVector;
  39081. private _teleportationTarget;
  39082. private _isDefaultTeleportationTarget;
  39083. private _postProcessMove;
  39084. private _teleportationFillColor;
  39085. private _teleportationBorderColor;
  39086. private _rotationAngle;
  39087. private _haloCenter;
  39088. private _cameraGazer;
  39089. private _padSensibilityUp;
  39090. private _padSensibilityDown;
  39091. private _leftController;
  39092. private _rightController;
  39093. /**
  39094. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39095. */
  39096. onNewMeshSelected: Observable<AbstractMesh>;
  39097. /**
  39098. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39099. */
  39100. onNewMeshPicked: Observable<PickingInfo>;
  39101. private _circleEase;
  39102. /**
  39103. * Observable raised before camera teleportation
  39104. */
  39105. onBeforeCameraTeleport: Observable<Vector3>;
  39106. /**
  39107. * Observable raised after camera teleportation
  39108. */
  39109. onAfterCameraTeleport: Observable<Vector3>;
  39110. /**
  39111. * Observable raised when current selected mesh gets unselected
  39112. */
  39113. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39114. private _raySelectionPredicate;
  39115. /**
  39116. * To be optionaly changed by user to define custom ray selection
  39117. */
  39118. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39119. /**
  39120. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39121. */
  39122. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39123. /**
  39124. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39125. */
  39126. teleportationEnabled: boolean;
  39127. private _defaultHeight;
  39128. private _teleportationInitialized;
  39129. private _interactionsEnabled;
  39130. private _interactionsRequested;
  39131. private _displayGaze;
  39132. private _displayLaserPointer;
  39133. /**
  39134. * The mesh used to display where the user is going to teleport.
  39135. */
  39136. /**
  39137. * Sets the mesh to be used to display where the user is going to teleport.
  39138. */
  39139. teleportationTarget: Mesh;
  39140. /**
  39141. * 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
  39142. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39143. * See http://doc.babylonjs.com/resources/baking_transformations
  39144. */
  39145. gazeTrackerMesh: Mesh;
  39146. /**
  39147. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39148. */
  39149. updateGazeTrackerScale: boolean;
  39150. /**
  39151. * If the gaze trackers color should be updated when selecting meshes
  39152. */
  39153. updateGazeTrackerColor: boolean;
  39154. /**
  39155. * The gaze tracking mesh corresponding to the left controller
  39156. */
  39157. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39158. /**
  39159. * The gaze tracking mesh corresponding to the right controller
  39160. */
  39161. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39162. /**
  39163. * If the ray of the gaze should be displayed.
  39164. */
  39165. /**
  39166. * Sets if the ray of the gaze should be displayed.
  39167. */
  39168. displayGaze: boolean;
  39169. /**
  39170. * If the ray of the LaserPointer should be displayed.
  39171. */
  39172. /**
  39173. * Sets if the ray of the LaserPointer should be displayed.
  39174. */
  39175. displayLaserPointer: boolean;
  39176. /**
  39177. * The deviceOrientationCamera used as the camera when not in VR.
  39178. */
  39179. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39180. /**
  39181. * Based on the current WebVR support, returns the current VR camera used.
  39182. */
  39183. readonly currentVRCamera: Nullable<Camera>;
  39184. /**
  39185. * The webVRCamera which is used when in VR.
  39186. */
  39187. readonly webVRCamera: WebVRFreeCamera;
  39188. /**
  39189. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39190. */
  39191. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39192. private readonly _teleportationRequestInitiated;
  39193. /**
  39194. * Defines wether or not Pointer lock should be requested when switching to
  39195. * full screen.
  39196. */
  39197. requestPointerLockOnFullScreen: boolean;
  39198. /**
  39199. * Instantiates a VRExperienceHelper.
  39200. * Helps to quickly add VR support to an existing scene.
  39201. * @param scene The scene the VRExperienceHelper belongs to.
  39202. * @param webVROptions Options to modify the vr experience helper's behavior.
  39203. */
  39204. constructor(scene: Scene,
  39205. /** Options to modify the vr experience helper's behavior. */
  39206. webVROptions?: VRExperienceHelperOptions);
  39207. private _onDefaultMeshLoaded;
  39208. private _onResize;
  39209. private _onFullscreenChange;
  39210. /**
  39211. * Gets a value indicating if we are currently in VR mode.
  39212. */
  39213. readonly isInVRMode: boolean;
  39214. private onVrDisplayPresentChange;
  39215. private onVRDisplayChanged;
  39216. private moveButtonToBottomRight;
  39217. private displayVRButton;
  39218. private updateButtonVisibility;
  39219. private _cachedAngularSensibility;
  39220. /**
  39221. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39222. * Otherwise, will use the fullscreen API.
  39223. */
  39224. enterVR(): void;
  39225. /**
  39226. * Attempt to exit VR, or fullscreen.
  39227. */
  39228. exitVR(): void;
  39229. /**
  39230. * The position of the vr experience helper.
  39231. */
  39232. /**
  39233. * Sets the position of the vr experience helper.
  39234. */
  39235. position: Vector3;
  39236. /**
  39237. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39238. */
  39239. enableInteractions(): void;
  39240. private readonly _noControllerIsActive;
  39241. private beforeRender;
  39242. private _isTeleportationFloor;
  39243. /**
  39244. * Adds a floor mesh to be used for teleportation.
  39245. * @param floorMesh the mesh to be used for teleportation.
  39246. */
  39247. addFloorMesh(floorMesh: Mesh): void;
  39248. /**
  39249. * Removes a floor mesh from being used for teleportation.
  39250. * @param floorMesh the mesh to be removed.
  39251. */
  39252. removeFloorMesh(floorMesh: Mesh): void;
  39253. /**
  39254. * Enables interactions and teleportation using the VR controllers and gaze.
  39255. * @param vrTeleportationOptions options to modify teleportation behavior.
  39256. */
  39257. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39258. private _onNewGamepadConnected;
  39259. private _tryEnableInteractionOnController;
  39260. private _onNewGamepadDisconnected;
  39261. private _enableInteractionOnController;
  39262. private _checkTeleportWithRay;
  39263. private _checkRotate;
  39264. private _checkTeleportBackwards;
  39265. private _enableTeleportationOnController;
  39266. private _createTeleportationCircles;
  39267. private _displayTeleportationTarget;
  39268. private _hideTeleportationTarget;
  39269. private _rotateCamera;
  39270. private _moveTeleportationSelectorTo;
  39271. private _workingVector;
  39272. private _workingQuaternion;
  39273. private _workingMatrix;
  39274. /**
  39275. * Teleports the users feet to the desired location
  39276. * @param location The location where the user's feet should be placed
  39277. */
  39278. teleportCamera(location: Vector3): void;
  39279. private _convertNormalToDirectionOfRay;
  39280. private _castRayAndSelectObject;
  39281. private _notifySelectedMeshUnselected;
  39282. /**
  39283. * Sets the color of the laser ray from the vr controllers.
  39284. * @param color new color for the ray.
  39285. */
  39286. changeLaserColor(color: Color3): void;
  39287. /**
  39288. * Sets the color of the ray from the vr headsets gaze.
  39289. * @param color new color for the ray.
  39290. */
  39291. changeGazeColor(color: Color3): void;
  39292. /**
  39293. * Exits VR and disposes of the vr experience helper
  39294. */
  39295. dispose(): void;
  39296. /**
  39297. * Gets the name of the VRExperienceHelper class
  39298. * @returns "VRExperienceHelper"
  39299. */
  39300. getClassName(): string;
  39301. }
  39302. }
  39303. declare module BABYLON {
  39304. /**
  39305. * Manages an XRSession
  39306. * @see https://doc.babylonjs.com/how_to/webxr
  39307. */
  39308. export class WebXRSessionManager implements IDisposable {
  39309. private scene;
  39310. /**
  39311. * Fires every time a new xrFrame arrives which can be used to update the camera
  39312. */
  39313. onXRFrameObservable: Observable<any>;
  39314. /**
  39315. * Fires when the xr session is ended either by the device or manually done
  39316. */
  39317. onXRSessionEnded: Observable<any>;
  39318. /** @hidden */ xrSession: XRSession;
  39319. /** @hidden */ frameOfReference: XRFrameOfReference;
  39320. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39321. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39322. private _xrNavigator;
  39323. private _xrDevice;
  39324. private _tmpMatrix;
  39325. /**
  39326. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39327. * @param scene The scene which the session should be created for
  39328. */
  39329. constructor(scene: Scene);
  39330. /**
  39331. * Initializes the manager
  39332. * After initialization enterXR can be called to start an XR session
  39333. * @returns Promise which resolves after it is initialized
  39334. */
  39335. initializeAsync(): Promise<void>;
  39336. /**
  39337. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39338. * @param sessionCreationOptions xr options to create the session with
  39339. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39340. * @returns Promise which resolves after it enters XR
  39341. */
  39342. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39343. /**
  39344. * Stops the xrSession and restores the renderloop
  39345. * @returns Promise which resolves after it exits XR
  39346. */
  39347. exitXRAsync(): Promise<void>;
  39348. /**
  39349. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39350. * @param ray ray to cast into the environment
  39351. * @returns Promise which resolves with a collision point in the environment if it exists
  39352. */
  39353. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39354. /**
  39355. * Checks if a session would be supported for the creation options specified
  39356. * @param options creation options to check if they are supported
  39357. * @returns true if supported
  39358. */
  39359. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39360. /**
  39361. * @hidden
  39362. * Converts the render layer of xrSession to a render target
  39363. * @param session session to create render target for
  39364. * @param scene scene the new render target should be created for
  39365. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39366. /**
  39367. * Disposes of the session manager
  39368. */
  39369. dispose(): void;
  39370. }
  39371. }
  39372. declare module BABYLON {
  39373. /**
  39374. * WebXR Camera which holds the views for the xrSession
  39375. * @see https://doc.babylonjs.com/how_to/webxr
  39376. */
  39377. export class WebXRCamera extends FreeCamera {
  39378. private static _TmpMatrix;
  39379. /**
  39380. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39381. * @param name the name of the camera
  39382. * @param scene the scene to add the camera to
  39383. */
  39384. constructor(name: string, scene: Scene);
  39385. private _updateNumberOfRigCameras;
  39386. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39387. /**
  39388. * Updates the cameras position from the current pose information of the XR session
  39389. * @param xrSessionManager the session containing pose information
  39390. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39391. */
  39392. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39393. }
  39394. }
  39395. declare module BABYLON {
  39396. /**
  39397. * States of the webXR experience
  39398. */
  39399. export enum WebXRState {
  39400. /**
  39401. * Transitioning to being in XR mode
  39402. */
  39403. ENTERING_XR = 0,
  39404. /**
  39405. * Transitioning to non XR mode
  39406. */
  39407. EXITING_XR = 1,
  39408. /**
  39409. * In XR mode and presenting
  39410. */
  39411. IN_XR = 2,
  39412. /**
  39413. * Not entered XR mode
  39414. */
  39415. NOT_IN_XR = 3
  39416. }
  39417. /**
  39418. * Helper class used to enable XR
  39419. * @see https://doc.babylonjs.com/how_to/webxr
  39420. */
  39421. export class WebXRExperienceHelper implements IDisposable {
  39422. private scene;
  39423. /**
  39424. * 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
  39425. */
  39426. container: AbstractMesh;
  39427. /**
  39428. * Camera used to render xr content
  39429. */
  39430. camera: WebXRCamera;
  39431. /**
  39432. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39433. */
  39434. state: WebXRState;
  39435. private _setState;
  39436. private static _TmpVector;
  39437. /**
  39438. * Fires when the state of the experience helper has changed
  39439. */
  39440. onStateChangedObservable: Observable<WebXRState>;
  39441. /** @hidden */ sessionManager: WebXRSessionManager;
  39442. private _nonVRCamera;
  39443. private _originalSceneAutoClear;
  39444. private _supported;
  39445. /**
  39446. * Creates the experience helper
  39447. * @param scene the scene to attach the experience helper to
  39448. * @returns a promise for the experience helper
  39449. */
  39450. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39451. /**
  39452. * Creates a WebXRExperienceHelper
  39453. * @param scene The scene the helper should be created in
  39454. */
  39455. private constructor();
  39456. /**
  39457. * Exits XR mode and returns the scene to its original state
  39458. * @returns promise that resolves after xr mode has exited
  39459. */
  39460. exitXRAsync(): Promise<void>;
  39461. /**
  39462. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39463. * @param sessionCreationOptions options for the XR session
  39464. * @param frameOfReference frame of reference of the XR session
  39465. * @returns promise that resolves after xr mode has entered
  39466. */
  39467. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39468. /**
  39469. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39470. * @param ray ray to cast into the environment
  39471. * @returns Promise which resolves with a collision point in the environment if it exists
  39472. */
  39473. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39474. /**
  39475. * Updates the global position of the camera by moving the camera's container
  39476. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39477. * @param position The desired global position of the camera
  39478. */
  39479. setPositionOfCameraUsingContainer(position: Vector3): void;
  39480. /**
  39481. * Rotates the xr camera by rotating the camera's container around the camera's position
  39482. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39483. * @param rotation the desired quaternion rotation to apply to the camera
  39484. */
  39485. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39486. /**
  39487. * Checks if the creation options are supported by the xr session
  39488. * @param options creation options
  39489. * @returns true if supported
  39490. */
  39491. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39492. /**
  39493. * Disposes of the experience helper
  39494. */
  39495. dispose(): void;
  39496. }
  39497. }
  39498. declare module BABYLON {
  39499. /**
  39500. * Button which can be used to enter a different mode of XR
  39501. */
  39502. export class WebXREnterExitUIButton {
  39503. /** button element */
  39504. element: HTMLElement;
  39505. /** XR initialization options for the button */
  39506. initializationOptions: XRSessionCreationOptions;
  39507. /**
  39508. * Creates a WebXREnterExitUIButton
  39509. * @param element button element
  39510. * @param initializationOptions XR initialization options for the button
  39511. */
  39512. constructor(
  39513. /** button element */
  39514. element: HTMLElement,
  39515. /** XR initialization options for the button */
  39516. initializationOptions: XRSessionCreationOptions);
  39517. /**
  39518. * Overwritable function which can be used to update the button's visuals when the state changes
  39519. * @param activeButton the current active button in the UI
  39520. */
  39521. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39522. }
  39523. /**
  39524. * Options to create the webXR UI
  39525. */
  39526. export class WebXREnterExitUIOptions {
  39527. /**
  39528. * Context to enter xr with
  39529. */
  39530. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39531. /**
  39532. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39533. */
  39534. customButtons?: Array<WebXREnterExitUIButton>;
  39535. }
  39536. /**
  39537. * UI to allow the user to enter/exit XR mode
  39538. */
  39539. export class WebXREnterExitUI implements IDisposable {
  39540. private scene;
  39541. private _overlay;
  39542. private _buttons;
  39543. private _activeButton;
  39544. /**
  39545. * Fired every time the active button is changed.
  39546. *
  39547. * When xr is entered via a button that launches xr that button will be the callback parameter
  39548. *
  39549. * When exiting xr the callback parameter will be null)
  39550. */
  39551. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39552. /**
  39553. * Creates UI to allow the user to enter/exit XR mode
  39554. * @param scene the scene to add the ui to
  39555. * @param helper the xr experience helper to enter/exit xr with
  39556. * @param options options to configure the UI
  39557. * @returns the created ui
  39558. */
  39559. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39560. private constructor();
  39561. private _updateButtons;
  39562. /**
  39563. * Disposes of the object
  39564. */
  39565. dispose(): void;
  39566. }
  39567. }
  39568. declare module BABYLON {
  39569. /**
  39570. * Represents an XR input
  39571. */
  39572. export class WebXRController {
  39573. /**
  39574. * 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
  39575. */
  39576. grip?: AbstractMesh;
  39577. /**
  39578. * Pointer which can be used to select objects or attach a visible laser to
  39579. */
  39580. pointer: AbstractMesh;
  39581. /**
  39582. * Creates the controller
  39583. * @see https://doc.babylonjs.com/how_to/webxr
  39584. * @param scene the scene which the controller should be associated to
  39585. */
  39586. constructor(scene: Scene);
  39587. /**
  39588. * Disposes of the object
  39589. */
  39590. dispose(): void;
  39591. }
  39592. /**
  39593. * XR input used to track XR inputs such as controllers/rays
  39594. */
  39595. export class WebXRInput implements IDisposable {
  39596. private helper;
  39597. /**
  39598. * XR controllers being tracked
  39599. */
  39600. controllers: Array<WebXRController>;
  39601. private _tmpMatrix;
  39602. private _frameObserver;
  39603. /**
  39604. * Initializes the WebXRInput
  39605. * @param helper experience helper which the input should be created for
  39606. */
  39607. constructor(helper: WebXRExperienceHelper);
  39608. /**
  39609. * Disposes of the object
  39610. */
  39611. dispose(): void;
  39612. }
  39613. }
  39614. declare module BABYLON {
  39615. /**
  39616. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39617. */
  39618. export class WebXRManagedOutputCanvas implements IDisposable {
  39619. private _canvas;
  39620. /**
  39621. * xrpresent context of the canvas which can be used to display/mirror xr content
  39622. */
  39623. canvasContext: Nullable<WebGLRenderingContext>;
  39624. /**
  39625. * Initializes the canvas to be added/removed upon entering/exiting xr
  39626. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39627. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39628. */
  39629. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39630. /**
  39631. * Disposes of the object
  39632. */
  39633. dispose(): void;
  39634. private _setManagedOutputCanvas;
  39635. private _addCanvas;
  39636. private _removeCanvas;
  39637. }
  39638. }
  39639. declare module BABYLON {
  39640. /**
  39641. * Contains an array of blocks representing the octree
  39642. */
  39643. export interface IOctreeContainer<T> {
  39644. /**
  39645. * Blocks within the octree
  39646. */
  39647. blocks: Array<OctreeBlock<T>>;
  39648. }
  39649. /**
  39650. * Class used to store a cell in an octree
  39651. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39652. */
  39653. export class OctreeBlock<T> {
  39654. /**
  39655. * Gets the content of the current block
  39656. */
  39657. entries: T[];
  39658. /**
  39659. * Gets the list of block children
  39660. */
  39661. blocks: Array<OctreeBlock<T>>;
  39662. private _depth;
  39663. private _maxDepth;
  39664. private _capacity;
  39665. private _minPoint;
  39666. private _maxPoint;
  39667. private _boundingVectors;
  39668. private _creationFunc;
  39669. /**
  39670. * Creates a new block
  39671. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39672. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39673. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39674. * @param depth defines the current depth of this block in the octree
  39675. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39676. * @param creationFunc defines a callback to call when an element is added to the block
  39677. */
  39678. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39679. /**
  39680. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39681. */
  39682. readonly capacity: number;
  39683. /**
  39684. * Gets the minimum vector (in world space) of the block's bounding box
  39685. */
  39686. readonly minPoint: Vector3;
  39687. /**
  39688. * Gets the maximum vector (in world space) of the block's bounding box
  39689. */
  39690. readonly maxPoint: Vector3;
  39691. /**
  39692. * Add a new element to this block
  39693. * @param entry defines the element to add
  39694. */
  39695. addEntry(entry: T): void;
  39696. /**
  39697. * Remove an element from this block
  39698. * @param entry defines the element to remove
  39699. */
  39700. removeEntry(entry: T): void;
  39701. /**
  39702. * Add an array of elements to this block
  39703. * @param entries defines the array of elements to add
  39704. */
  39705. addEntries(entries: T[]): void;
  39706. /**
  39707. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39708. * @param frustumPlanes defines the frustum planes to test
  39709. * @param selection defines the array to store current content if selection is positive
  39710. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39711. */
  39712. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39713. /**
  39714. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39715. * @param sphereCenter defines the bounding sphere center
  39716. * @param sphereRadius defines the bounding sphere radius
  39717. * @param selection defines the array to store current content if selection is positive
  39718. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39719. */
  39720. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39721. /**
  39722. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39723. * @param ray defines the ray to test with
  39724. * @param selection defines the array to store current content if selection is positive
  39725. */
  39726. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39727. /**
  39728. * Subdivide the content into child blocks (this block will then be empty)
  39729. */
  39730. createInnerBlocks(): void;
  39731. /**
  39732. * @hidden
  39733. */ 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;
  39734. }
  39735. }
  39736. declare module BABYLON {
  39737. /**
  39738. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39739. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39740. */
  39741. export class Octree<T> {
  39742. /** 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.) */
  39743. maxDepth: number;
  39744. /**
  39745. * Blocks within the octree containing objects
  39746. */
  39747. blocks: Array<OctreeBlock<T>>;
  39748. /**
  39749. * Content stored in the octree
  39750. */
  39751. dynamicContent: T[];
  39752. private _maxBlockCapacity;
  39753. private _selectionContent;
  39754. private _creationFunc;
  39755. /**
  39756. * Creates a octree
  39757. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39758. * @param creationFunc function to be used to instatiate the octree
  39759. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39760. * @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.)
  39761. */
  39762. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39763. /** 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.) */
  39764. maxDepth?: number);
  39765. /**
  39766. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39767. * @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);
  39768. * @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);
  39769. * @param entries meshes to be added to the octree blocks
  39770. */
  39771. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39772. /**
  39773. * Adds a mesh to the octree
  39774. * @param entry Mesh to add to the octree
  39775. */
  39776. addMesh(entry: T): void;
  39777. /**
  39778. * Remove an element from the octree
  39779. * @param entry defines the element to remove
  39780. */
  39781. removeMesh(entry: T): void;
  39782. /**
  39783. * Selects an array of meshes within the frustum
  39784. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39785. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39786. * @returns array of meshes within the frustum
  39787. */
  39788. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39789. /**
  39790. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39791. * @param sphereCenter defines the bounding sphere center
  39792. * @param sphereRadius defines the bounding sphere radius
  39793. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39794. * @returns an array of objects that intersect the sphere
  39795. */
  39796. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39797. /**
  39798. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39799. * @param ray defines the ray to test with
  39800. * @returns array of intersected objects
  39801. */
  39802. intersectsRay(ray: Ray): SmartArray<T>;
  39803. /**
  39804. * Adds a mesh into the octree block if it intersects the block
  39805. */
  39806. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39807. /**
  39808. * Adds a submesh into the octree block if it intersects the block
  39809. */
  39810. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39811. }
  39812. }
  39813. declare module BABYLON {
  39814. interface Scene {
  39815. /**
  39816. * @hidden
  39817. * Backing Filed
  39818. */ selectionOctree: Octree<AbstractMesh>;
  39819. /**
  39820. * Gets the octree used to boost mesh selection (picking)
  39821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39822. */
  39823. selectionOctree: Octree<AbstractMesh>;
  39824. /**
  39825. * Creates or updates the octree used to boost selection (picking)
  39826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39827. * @param maxCapacity defines the maximum capacity per leaf
  39828. * @param maxDepth defines the maximum depth of the octree
  39829. * @returns an octree of AbstractMesh
  39830. */
  39831. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39832. }
  39833. interface AbstractMesh {
  39834. /**
  39835. * @hidden
  39836. * Backing Field
  39837. */ submeshesOctree: Octree<SubMesh>;
  39838. /**
  39839. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39840. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39841. * @param maxCapacity defines the maximum size of each block (64 by default)
  39842. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39843. * @returns the new octree
  39844. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39845. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39846. */
  39847. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39848. }
  39849. /**
  39850. * Defines the octree scene component responsible to manage any octrees
  39851. * in a given scene.
  39852. */
  39853. export class OctreeSceneComponent {
  39854. /**
  39855. * The component name help to identify the component in the list of scene components.
  39856. */
  39857. readonly name: string;
  39858. /**
  39859. * The scene the component belongs to.
  39860. */
  39861. scene: Scene;
  39862. /**
  39863. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39864. */
  39865. readonly checksIsEnabled: boolean;
  39866. /**
  39867. * Creates a new instance of the component for the given scene
  39868. * @param scene Defines the scene to register the component in
  39869. */
  39870. constructor(scene: Scene);
  39871. /**
  39872. * Registers the component in a given scene
  39873. */
  39874. register(): void;
  39875. /**
  39876. * Return the list of active meshes
  39877. * @returns the list of active meshes
  39878. */
  39879. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39880. /**
  39881. * Return the list of active sub meshes
  39882. * @param mesh The mesh to get the candidates sub meshes from
  39883. * @returns the list of active sub meshes
  39884. */
  39885. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39886. private _tempRay;
  39887. /**
  39888. * Return the list of sub meshes intersecting with a given local ray
  39889. * @param mesh defines the mesh to find the submesh for
  39890. * @param localRay defines the ray in local space
  39891. * @returns the list of intersecting sub meshes
  39892. */
  39893. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39894. /**
  39895. * Return the list of sub meshes colliding with a collider
  39896. * @param mesh defines the mesh to find the submesh for
  39897. * @param collider defines the collider to evaluate the collision against
  39898. * @returns the list of colliding sub meshes
  39899. */
  39900. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39901. /**
  39902. * Rebuilds the elements related to this component in case of
  39903. * context lost for instance.
  39904. */
  39905. rebuild(): void;
  39906. /**
  39907. * Disposes the component and the associated ressources.
  39908. */
  39909. dispose(): void;
  39910. }
  39911. }
  39912. declare module BABYLON {
  39913. /**
  39914. * Renders a layer on top of an existing scene
  39915. */
  39916. export class UtilityLayerRenderer implements IDisposable {
  39917. /** the original scene that will be rendered on top of */
  39918. originalScene: Scene;
  39919. private _pointerCaptures;
  39920. private _lastPointerEvents;
  39921. private static _DefaultUtilityLayer;
  39922. private static _DefaultKeepDepthUtilityLayer;
  39923. private _sharedGizmoLight;
  39924. /**
  39925. * @hidden
  39926. * Light which used by gizmos to get light shading
  39927. */ getSharedGizmoLight(): HemisphericLight;
  39928. /**
  39929. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39930. */
  39931. pickUtilitySceneFirst: boolean;
  39932. /**
  39933. * 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)
  39934. */
  39935. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39936. /**
  39937. * 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)
  39938. */
  39939. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39940. /**
  39941. * The scene that is rendered on top of the original scene
  39942. */
  39943. utilityLayerScene: Scene;
  39944. /**
  39945. * If the utility layer should automatically be rendered on top of existing scene
  39946. */
  39947. shouldRender: boolean;
  39948. /**
  39949. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39950. */
  39951. onlyCheckPointerDownEvents: boolean;
  39952. /**
  39953. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39954. */
  39955. processAllEvents: boolean;
  39956. /**
  39957. * Observable raised when the pointer move from the utility layer scene to the main scene
  39958. */
  39959. onPointerOutObservable: Observable<number>;
  39960. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39961. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39962. private _afterRenderObserver;
  39963. private _sceneDisposeObserver;
  39964. private _originalPointerObserver;
  39965. /**
  39966. * Instantiates a UtilityLayerRenderer
  39967. * @param originalScene the original scene that will be rendered on top of
  39968. * @param handleEvents boolean indicating if the utility layer should handle events
  39969. */
  39970. constructor(
  39971. /** the original scene that will be rendered on top of */
  39972. originalScene: Scene, handleEvents?: boolean);
  39973. private _notifyObservers;
  39974. /**
  39975. * Renders the utility layers scene on top of the original scene
  39976. */
  39977. render(): void;
  39978. /**
  39979. * Disposes of the renderer
  39980. */
  39981. dispose(): void;
  39982. private _updateCamera;
  39983. }
  39984. }
  39985. declare module BABYLON {
  39986. /**
  39987. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39988. */
  39989. export class Gizmo implements IDisposable {
  39990. /** The utility layer the gizmo will be added to */
  39991. gizmoLayer: UtilityLayerRenderer;
  39992. /**
  39993. * The root mesh of the gizmo
  39994. */ rootMesh: Mesh;
  39995. private _attachedMesh;
  39996. /**
  39997. * Ratio for the scale of the gizmo (Default: 1)
  39998. */
  39999. scaleRatio: number;
  40000. /**
  40001. * If a custom mesh has been set (Default: false)
  40002. */
  40003. protected _customMeshSet: boolean;
  40004. /**
  40005. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40006. * * When set, interactions will be enabled
  40007. */
  40008. attachedMesh: Nullable<AbstractMesh>;
  40009. /**
  40010. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40011. * @param mesh The mesh to replace the default mesh of the gizmo
  40012. */
  40013. setCustomMesh(mesh: Mesh): void;
  40014. /**
  40015. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40016. */
  40017. updateGizmoRotationToMatchAttachedMesh: boolean;
  40018. /**
  40019. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40020. */
  40021. updateGizmoPositionToMatchAttachedMesh: boolean;
  40022. /**
  40023. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40024. */
  40025. protected _updateScale: boolean;
  40026. protected _interactionsEnabled: boolean;
  40027. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40028. private _beforeRenderObserver;
  40029. private _tempVector;
  40030. /**
  40031. * Creates a gizmo
  40032. * @param gizmoLayer The utility layer the gizmo will be added to
  40033. */
  40034. constructor(
  40035. /** The utility layer the gizmo will be added to */
  40036. gizmoLayer?: UtilityLayerRenderer);
  40037. /**
  40038. * Updates the gizmo to match the attached mesh's position/rotation
  40039. */
  40040. protected _update(): void;
  40041. /**
  40042. * Disposes of the gizmo
  40043. */
  40044. dispose(): void;
  40045. }
  40046. }
  40047. declare module BABYLON {
  40048. /**
  40049. * Single axis drag gizmo
  40050. */
  40051. export class AxisDragGizmo extends Gizmo {
  40052. /**
  40053. * Drag behavior responsible for the gizmos dragging interactions
  40054. */
  40055. dragBehavior: PointerDragBehavior;
  40056. private _pointerObserver;
  40057. /**
  40058. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40059. */
  40060. snapDistance: number;
  40061. /**
  40062. * Event that fires each time the gizmo snaps to a new location.
  40063. * * snapDistance is the the change in distance
  40064. */
  40065. onSnapObservable: Observable<{
  40066. snapDistance: number;
  40067. }>;
  40068. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40069. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40070. /**
  40071. * Creates an AxisDragGizmo
  40072. * @param gizmoLayer The utility layer the gizmo will be added to
  40073. * @param dragAxis The axis which the gizmo will be able to drag on
  40074. * @param color The color of the gizmo
  40075. */
  40076. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40077. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40078. /**
  40079. * Disposes of the gizmo
  40080. */
  40081. dispose(): void;
  40082. }
  40083. }
  40084. declare module BABYLON.Debug {
  40085. /**
  40086. * The Axes viewer will show 3 axes in a specific point in space
  40087. */
  40088. export class AxesViewer {
  40089. private _xAxis;
  40090. private _yAxis;
  40091. private _zAxis;
  40092. private _scaleLinesFactor;
  40093. private _instanced;
  40094. /**
  40095. * Gets the hosting scene
  40096. */
  40097. scene: Scene;
  40098. /**
  40099. * Gets or sets a number used to scale line length
  40100. */
  40101. scaleLines: number;
  40102. /** Gets the node hierarchy used to render x-axis */
  40103. readonly xAxis: TransformNode;
  40104. /** Gets the node hierarchy used to render y-axis */
  40105. readonly yAxis: TransformNode;
  40106. /** Gets the node hierarchy used to render z-axis */
  40107. readonly zAxis: TransformNode;
  40108. /**
  40109. * Creates a new AxesViewer
  40110. * @param scene defines the hosting scene
  40111. * @param scaleLines defines a number used to scale line length (1 by default)
  40112. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40113. * @param xAxis defines the node hierarchy used to render the x-axis
  40114. * @param yAxis defines the node hierarchy used to render the y-axis
  40115. * @param zAxis defines the node hierarchy used to render the z-axis
  40116. */
  40117. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40118. /**
  40119. * Force the viewer to update
  40120. * @param position defines the position of the viewer
  40121. * @param xaxis defines the x axis of the viewer
  40122. * @param yaxis defines the y axis of the viewer
  40123. * @param zaxis defines the z axis of the viewer
  40124. */
  40125. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40126. /**
  40127. * Creates an instance of this axes viewer.
  40128. * @returns a new axes viewer with instanced meshes
  40129. */
  40130. createInstance(): AxesViewer;
  40131. /** Releases resources */
  40132. dispose(): void;
  40133. private static _SetRenderingGroupId;
  40134. }
  40135. }
  40136. declare module BABYLON.Debug {
  40137. /**
  40138. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40139. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40140. */
  40141. export class BoneAxesViewer extends AxesViewer {
  40142. /**
  40143. * Gets or sets the target mesh where to display the axes viewer
  40144. */
  40145. mesh: Nullable<Mesh>;
  40146. /**
  40147. * Gets or sets the target bone where to display the axes viewer
  40148. */
  40149. bone: Nullable<Bone>;
  40150. /** Gets current position */
  40151. pos: Vector3;
  40152. /** Gets direction of X axis */
  40153. xaxis: Vector3;
  40154. /** Gets direction of Y axis */
  40155. yaxis: Vector3;
  40156. /** Gets direction of Z axis */
  40157. zaxis: Vector3;
  40158. /**
  40159. * Creates a new BoneAxesViewer
  40160. * @param scene defines the hosting scene
  40161. * @param bone defines the target bone
  40162. * @param mesh defines the target mesh
  40163. * @param scaleLines defines a scaling factor for line length (1 by default)
  40164. */
  40165. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40166. /**
  40167. * Force the viewer to update
  40168. */
  40169. update(): void;
  40170. /** Releases resources */
  40171. dispose(): void;
  40172. }
  40173. }
  40174. declare module BABYLON {
  40175. /**
  40176. * Interface used to define scene explorer extensibility option
  40177. */
  40178. export interface IExplorerExtensibilityOption {
  40179. /**
  40180. * Define the option label
  40181. */
  40182. label: string;
  40183. /**
  40184. * Defines the action to execute on click
  40185. */
  40186. action: (entity: any) => void;
  40187. }
  40188. /**
  40189. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40190. */
  40191. export interface IExplorerExtensibilityGroup {
  40192. /**
  40193. * Defines a predicate to test if a given type mut be extended
  40194. */
  40195. predicate: (entity: any) => boolean;
  40196. /**
  40197. * Gets the list of options added to a type
  40198. */
  40199. entries: IExplorerExtensibilityOption[];
  40200. }
  40201. /**
  40202. * Interface used to define the options to use to create the Inspector
  40203. */
  40204. export interface IInspectorOptions {
  40205. /**
  40206. * Display in overlay mode (default: false)
  40207. */
  40208. overlay?: boolean;
  40209. /**
  40210. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40211. */
  40212. globalRoot?: HTMLElement;
  40213. /**
  40214. * Display the Scene explorer
  40215. */
  40216. showExplorer?: boolean;
  40217. /**
  40218. * Display the property inspector
  40219. */
  40220. showInspector?: boolean;
  40221. /**
  40222. * Display in embed mode (both panes on the right)
  40223. */
  40224. embedMode?: boolean;
  40225. /**
  40226. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40227. */
  40228. handleResize?: boolean;
  40229. /**
  40230. * Allow the panes to popup (default: true)
  40231. */
  40232. enablePopup?: boolean;
  40233. /**
  40234. * Allow the panes to be closed by users (default: true)
  40235. */
  40236. enableClose?: boolean;
  40237. /**
  40238. * Optional list of extensibility entries
  40239. */
  40240. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40241. /**
  40242. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40243. */
  40244. inspectorURL?: string;
  40245. }
  40246. interface Scene {
  40247. /**
  40248. * @hidden
  40249. * Backing field
  40250. */ debugLayer: DebugLayer;
  40251. /**
  40252. * Gets the debug layer (aka Inspector) associated with the scene
  40253. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40254. */
  40255. debugLayer: DebugLayer;
  40256. }
  40257. /**
  40258. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40259. * what is happening in your scene
  40260. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40261. */
  40262. export class DebugLayer {
  40263. /**
  40264. * Define the url to get the inspector script from.
  40265. * By default it uses the babylonjs CDN.
  40266. * @ignoreNaming
  40267. */
  40268. static InspectorURL: string;
  40269. private _scene;
  40270. private BJSINSPECTOR;
  40271. /**
  40272. * Observable triggered when a property is changed through the inspector.
  40273. */
  40274. onPropertyChangedObservable: Observable<{
  40275. object: any;
  40276. property: string;
  40277. value: any;
  40278. initialValue: any;
  40279. }>;
  40280. /**
  40281. * Instantiates a new debug layer.
  40282. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40283. * what is happening in your scene
  40284. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40285. * @param scene Defines the scene to inspect
  40286. */
  40287. constructor(scene: Scene);
  40288. /** Creates the inspector window. */
  40289. private _createInspector;
  40290. /**
  40291. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40292. * @param entity defines the entity to select
  40293. * @param lineContainerTitle defines the specific block to highlight
  40294. */
  40295. select(entity: any, lineContainerTitle?: string): void;
  40296. /** Get the inspector from bundle or global */
  40297. private _getGlobalInspector;
  40298. /**
  40299. * Get if the inspector is visible or not.
  40300. * @returns true if visible otherwise, false
  40301. */
  40302. isVisible(): boolean;
  40303. /**
  40304. * Hide the inspector and close its window.
  40305. */
  40306. hide(): void;
  40307. /**
  40308. * Launch the debugLayer.
  40309. * @param config Define the configuration of the inspector
  40310. * @return a promise fulfilled when the debug layer is visible
  40311. */
  40312. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40313. }
  40314. }
  40315. declare module BABYLON {
  40316. /**
  40317. * Class containing static functions to help procedurally build meshes
  40318. */
  40319. export class BoxBuilder {
  40320. /**
  40321. * Creates a box mesh
  40322. * * The parameter `size` sets the size (float) of each box side (default 1)
  40323. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40324. * * 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)
  40325. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40327. * * 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
  40328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40329. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40330. * @param name defines the name of the mesh
  40331. * @param options defines the options used to create the mesh
  40332. * @param scene defines the hosting scene
  40333. * @returns the box mesh
  40334. */
  40335. static CreateBox(name: string, options: {
  40336. size?: number;
  40337. width?: number;
  40338. height?: number;
  40339. depth?: number;
  40340. faceUV?: Vector4[];
  40341. faceColors?: Color4[];
  40342. sideOrientation?: number;
  40343. frontUVs?: Vector4;
  40344. backUVs?: Vector4;
  40345. wrap?: boolean;
  40346. topBaseAt?: number;
  40347. bottomBaseAt?: number;
  40348. updatable?: boolean;
  40349. }, scene?: Nullable<Scene>): Mesh;
  40350. }
  40351. }
  40352. declare module BABYLON {
  40353. /**
  40354. * Class containing static functions to help procedurally build meshes
  40355. */
  40356. export class SphereBuilder {
  40357. /**
  40358. * Creates a sphere mesh
  40359. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40360. * * 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`)
  40361. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40362. * * 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
  40363. * * 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)
  40364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40365. * * 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
  40366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40367. * @param name defines the name of the mesh
  40368. * @param options defines the options used to create the mesh
  40369. * @param scene defines the hosting scene
  40370. * @returns the sphere mesh
  40371. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40372. */
  40373. static CreateSphere(name: string, options: {
  40374. segments?: number;
  40375. diameter?: number;
  40376. diameterX?: number;
  40377. diameterY?: number;
  40378. diameterZ?: number;
  40379. arc?: number;
  40380. slice?: number;
  40381. sideOrientation?: number;
  40382. frontUVs?: Vector4;
  40383. backUVs?: Vector4;
  40384. updatable?: boolean;
  40385. }, scene: any): Mesh;
  40386. }
  40387. }
  40388. declare module BABYLON.Debug {
  40389. /**
  40390. * Used to show the physics impostor around the specific mesh
  40391. */
  40392. export class PhysicsViewer {
  40393. /** @hidden */
  40394. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40395. /** @hidden */
  40396. protected _meshes: Array<Nullable<AbstractMesh>>;
  40397. /** @hidden */
  40398. protected _scene: Nullable<Scene>;
  40399. /** @hidden */
  40400. protected _numMeshes: number;
  40401. /** @hidden */
  40402. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40403. private _renderFunction;
  40404. private _utilityLayer;
  40405. private _debugBoxMesh;
  40406. private _debugSphereMesh;
  40407. private _debugCylinderMesh;
  40408. private _debugMaterial;
  40409. private _debugMeshMeshes;
  40410. /**
  40411. * Creates a new PhysicsViewer
  40412. * @param scene defines the hosting scene
  40413. */
  40414. constructor(scene: Scene);
  40415. /** @hidden */
  40416. protected _updateDebugMeshes(): void;
  40417. /**
  40418. * Renders a specified physic impostor
  40419. * @param impostor defines the impostor to render
  40420. * @param targetMesh defines the mesh represented by the impostor
  40421. * @returns the new debug mesh used to render the impostor
  40422. */
  40423. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40424. /**
  40425. * Hides a specified physic impostor
  40426. * @param impostor defines the impostor to hide
  40427. */
  40428. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40429. private _getDebugMaterial;
  40430. private _getDebugBoxMesh;
  40431. private _getDebugSphereMesh;
  40432. private _getDebugCylinderMesh;
  40433. private _getDebugMeshMesh;
  40434. private _getDebugMesh;
  40435. /** Releases all resources */
  40436. dispose(): void;
  40437. }
  40438. }
  40439. declare module BABYLON {
  40440. /**
  40441. * Class containing static functions to help procedurally build meshes
  40442. */
  40443. export class LinesBuilder {
  40444. /**
  40445. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40446. * * 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
  40447. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40448. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40449. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40450. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40451. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40452. * * 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
  40453. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40455. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40456. * @param name defines the name of the new line system
  40457. * @param options defines the options used to create the line system
  40458. * @param scene defines the hosting scene
  40459. * @returns a new line system mesh
  40460. */
  40461. static CreateLineSystem(name: string, options: {
  40462. lines: Vector3[][];
  40463. updatable?: boolean;
  40464. instance?: Nullable<LinesMesh>;
  40465. colors?: Nullable<Color4[][]>;
  40466. useVertexAlpha?: boolean;
  40467. }, scene: Nullable<Scene>): LinesMesh;
  40468. /**
  40469. * Creates a line mesh
  40470. * 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
  40471. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40472. * * The parameter `points` is an array successive Vector3
  40473. * * 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
  40474. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40475. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40476. * * When updating an instance, remember that only point positions can change, not the number of points
  40477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40478. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40479. * @param name defines the name of the new line system
  40480. * @param options defines the options used to create the line system
  40481. * @param scene defines the hosting scene
  40482. * @returns a new line mesh
  40483. */
  40484. static CreateLines(name: string, options: {
  40485. points: Vector3[];
  40486. updatable?: boolean;
  40487. instance?: Nullable<LinesMesh>;
  40488. colors?: Color4[];
  40489. useVertexAlpha?: boolean;
  40490. }, scene?: Nullable<Scene>): LinesMesh;
  40491. /**
  40492. * Creates a dashed line mesh
  40493. * * 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
  40494. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40495. * * The parameter `points` is an array successive Vector3
  40496. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40497. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40498. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40499. * * 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
  40500. * * When updating an instance, remember that only point positions can change, not the number of points
  40501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40502. * @param name defines the name of the mesh
  40503. * @param options defines the options used to create the mesh
  40504. * @param scene defines the hosting scene
  40505. * @returns the dashed line mesh
  40506. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40507. */
  40508. static CreateDashedLines(name: string, options: {
  40509. points: Vector3[];
  40510. dashSize?: number;
  40511. gapSize?: number;
  40512. dashNb?: number;
  40513. updatable?: boolean;
  40514. instance?: LinesMesh;
  40515. }, scene?: Nullable<Scene>): LinesMesh;
  40516. }
  40517. }
  40518. declare module BABYLON {
  40519. /**
  40520. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40521. * in order to better appreciate the issue one might have.
  40522. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40523. */
  40524. export class RayHelper {
  40525. /**
  40526. * Defines the ray we are currently tryin to visualize.
  40527. */
  40528. ray: Nullable<Ray>;
  40529. private _renderPoints;
  40530. private _renderLine;
  40531. private _renderFunction;
  40532. private _scene;
  40533. private _updateToMeshFunction;
  40534. private _attachedToMesh;
  40535. private _meshSpaceDirection;
  40536. private _meshSpaceOrigin;
  40537. /**
  40538. * Helper function to create a colored helper in a scene in one line.
  40539. * @param ray Defines the ray we are currently tryin to visualize
  40540. * @param scene Defines the scene the ray is used in
  40541. * @param color Defines the color we want to see the ray in
  40542. * @returns The newly created ray helper.
  40543. */
  40544. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40545. /**
  40546. * Instantiate a new ray helper.
  40547. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40548. * in order to better appreciate the issue one might have.
  40549. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40550. * @param ray Defines the ray we are currently tryin to visualize
  40551. */
  40552. constructor(ray: Ray);
  40553. /**
  40554. * Shows the ray we are willing to debug.
  40555. * @param scene Defines the scene the ray needs to be rendered in
  40556. * @param color Defines the color the ray needs to be rendered in
  40557. */
  40558. show(scene: Scene, color?: Color3): void;
  40559. /**
  40560. * Hides the ray we are debugging.
  40561. */
  40562. hide(): void;
  40563. private _render;
  40564. /**
  40565. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40566. * @param mesh Defines the mesh we want the helper attached to
  40567. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40568. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40569. * @param length Defines the length of the ray
  40570. */
  40571. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40572. /**
  40573. * Detach the ray helper from the mesh it has previously been attached to.
  40574. */
  40575. detachFromMesh(): void;
  40576. private _updateToMesh;
  40577. /**
  40578. * Dispose the helper and release its associated resources.
  40579. */
  40580. dispose(): void;
  40581. }
  40582. }
  40583. declare module BABYLON.Debug {
  40584. /**
  40585. * Class used to render a debug view of a given skeleton
  40586. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40587. */
  40588. export class SkeletonViewer {
  40589. /** defines the skeleton to render */
  40590. skeleton: Skeleton;
  40591. /** defines the mesh attached to the skeleton */
  40592. mesh: AbstractMesh;
  40593. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40594. autoUpdateBonesMatrices: boolean;
  40595. /** defines the rendering group id to use with the viewer */
  40596. renderingGroupId: number;
  40597. /** Gets or sets the color used to render the skeleton */
  40598. color: Color3;
  40599. private _scene;
  40600. private _debugLines;
  40601. private _debugMesh;
  40602. private _isEnabled;
  40603. private _renderFunction;
  40604. private _utilityLayer;
  40605. /**
  40606. * Returns the mesh used to render the bones
  40607. */
  40608. readonly debugMesh: Nullable<LinesMesh>;
  40609. /**
  40610. * Creates a new SkeletonViewer
  40611. * @param skeleton defines the skeleton to render
  40612. * @param mesh defines the mesh attached to the skeleton
  40613. * @param scene defines the hosting scene
  40614. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40615. * @param renderingGroupId defines the rendering group id to use with the viewer
  40616. */
  40617. constructor(
  40618. /** defines the skeleton to render */
  40619. skeleton: Skeleton,
  40620. /** defines the mesh attached to the skeleton */
  40621. mesh: AbstractMesh, scene: Scene,
  40622. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40623. autoUpdateBonesMatrices?: boolean,
  40624. /** defines the rendering group id to use with the viewer */
  40625. renderingGroupId?: number);
  40626. /** Gets or sets a boolean indicating if the viewer is enabled */
  40627. isEnabled: boolean;
  40628. private _getBonePosition;
  40629. private _getLinesForBonesWithLength;
  40630. private _getLinesForBonesNoLength;
  40631. /** Update the viewer to sync with current skeleton state */
  40632. update(): void;
  40633. /** Release associated resources */
  40634. dispose(): void;
  40635. }
  40636. }
  40637. declare module BABYLON {
  40638. /**
  40639. * Options to create the null engine
  40640. */
  40641. export class NullEngineOptions {
  40642. /**
  40643. * Render width (Default: 512)
  40644. */
  40645. renderWidth: number;
  40646. /**
  40647. * Render height (Default: 256)
  40648. */
  40649. renderHeight: number;
  40650. /**
  40651. * Texture size (Default: 512)
  40652. */
  40653. textureSize: number;
  40654. /**
  40655. * If delta time between frames should be constant
  40656. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40657. */
  40658. deterministicLockstep: boolean;
  40659. /**
  40660. * Maximum about of steps between frames (Default: 4)
  40661. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40662. */
  40663. lockstepMaxSteps: number;
  40664. }
  40665. /**
  40666. * The null engine class provides support for headless version of babylon.js.
  40667. * This can be used in server side scenario or for testing purposes
  40668. */
  40669. export class NullEngine extends Engine {
  40670. private _options;
  40671. /**
  40672. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40673. */
  40674. isDeterministicLockStep(): boolean;
  40675. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40676. getLockstepMaxSteps(): number;
  40677. /**
  40678. * Sets hardware scaling, used to save performance if needed
  40679. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40680. */
  40681. getHardwareScalingLevel(): number;
  40682. constructor(options?: NullEngineOptions);
  40683. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40684. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40685. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40686. getRenderWidth(useScreen?: boolean): number;
  40687. getRenderHeight(useScreen?: boolean): number;
  40688. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40689. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40690. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40691. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40692. bindSamplers(effect: Effect): void;
  40693. enableEffect(effect: Effect): void;
  40694. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40695. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40696. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40697. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40698. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40699. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40700. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40701. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40702. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40703. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40704. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40705. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40706. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40707. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40708. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40709. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40710. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40711. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40712. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40713. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40714. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40715. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40716. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40717. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40718. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40719. bindBuffers(vertexBuffers: {
  40720. [key: string]: VertexBuffer;
  40721. }, indexBuffer: DataBuffer, effect: Effect): void;
  40722. wipeCaches(bruteForce?: boolean): void;
  40723. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40724. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40725. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40726. /** @hidden */ createTexture(): WebGLTexture;
  40727. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40728. 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;
  40729. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40730. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40731. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40732. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40733. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40734. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40735. areAllEffectsReady(): boolean;
  40736. /**
  40737. * @hidden
  40738. * Get the current error code of the webGL context
  40739. * @returns the error code
  40740. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40741. */
  40742. getError(): number;
  40743. /** @hidden */ getUnpackAlignement(): number;
  40744. /** @hidden */ unpackFlipY(value: boolean): void;
  40745. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40746. /**
  40747. * Updates a dynamic vertex buffer.
  40748. * @param vertexBuffer the vertex buffer to update
  40749. * @param data the data used to update the vertex buffer
  40750. * @param byteOffset the byte offset of the data (optional)
  40751. * @param byteLength the byte length of the data (optional)
  40752. */
  40753. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40754. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40755. /** @hidden */ releaseBuffer(buffer: DataBuffer): boolean;
  40756. releaseEffects(): void;
  40757. displayLoadingUI(): void;
  40758. hideLoadingUI(): void;
  40759. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40760. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40761. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40762. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40763. }
  40764. }
  40765. declare module BABYLON {
  40766. /** @hidden */
  40767. export class _OcclusionDataStorage {
  40768. /** @hidden */
  40769. occlusionInternalRetryCounter: number;
  40770. /** @hidden */
  40771. isOcclusionQueryInProgress: boolean;
  40772. /** @hidden */
  40773. isOccluded: boolean;
  40774. /** @hidden */
  40775. occlusionRetryCount: number;
  40776. /** @hidden */
  40777. occlusionType: number;
  40778. /** @hidden */
  40779. occlusionQueryAlgorithmType: number;
  40780. }
  40781. interface Engine {
  40782. /**
  40783. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40784. * @return the new query
  40785. */
  40786. createQuery(): WebGLQuery;
  40787. /**
  40788. * Delete and release a webGL query
  40789. * @param query defines the query to delete
  40790. * @return the current engine
  40791. */
  40792. deleteQuery(query: WebGLQuery): Engine;
  40793. /**
  40794. * Check if a given query has resolved and got its value
  40795. * @param query defines the query to check
  40796. * @returns true if the query got its value
  40797. */
  40798. isQueryResultAvailable(query: WebGLQuery): boolean;
  40799. /**
  40800. * Gets the value of a given query
  40801. * @param query defines the query to check
  40802. * @returns the value of the query
  40803. */
  40804. getQueryResult(query: WebGLQuery): number;
  40805. /**
  40806. * Initiates an occlusion query
  40807. * @param algorithmType defines the algorithm to use
  40808. * @param query defines the query to use
  40809. * @returns the current engine
  40810. * @see http://doc.babylonjs.com/features/occlusionquery
  40811. */
  40812. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40813. /**
  40814. * Ends an occlusion query
  40815. * @see http://doc.babylonjs.com/features/occlusionquery
  40816. * @param algorithmType defines the algorithm to use
  40817. * @returns the current engine
  40818. */
  40819. endOcclusionQuery(algorithmType: number): Engine;
  40820. /**
  40821. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40822. * Please note that only one query can be issued at a time
  40823. * @returns a time token used to track the time span
  40824. */
  40825. startTimeQuery(): Nullable<_TimeToken>;
  40826. /**
  40827. * Ends a time query
  40828. * @param token defines the token used to measure the time span
  40829. * @returns the time spent (in ns)
  40830. */
  40831. endTimeQuery(token: _TimeToken): int;
  40832. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40833. /** @hidden */ createTimeQuery(): WebGLQuery;
  40834. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40835. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40836. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40837. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40838. }
  40839. interface AbstractMesh {
  40840. /**
  40841. * Backing filed
  40842. * @hidden
  40843. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40844. /**
  40845. * Access property
  40846. * @hidden
  40847. */ occlusionDataStorage: _OcclusionDataStorage;
  40848. /**
  40849. * 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.
  40850. * The default value is -1 which means don't break the query and wait till the result
  40851. * @see http://doc.babylonjs.com/features/occlusionquery
  40852. */
  40853. occlusionRetryCount: number;
  40854. /**
  40855. * 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:
  40856. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40857. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40858. * * 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.
  40859. * @see http://doc.babylonjs.com/features/occlusionquery
  40860. */
  40861. occlusionType: number;
  40862. /**
  40863. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40864. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40865. * * 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.
  40866. * @see http://doc.babylonjs.com/features/occlusionquery
  40867. */
  40868. occlusionQueryAlgorithmType: number;
  40869. /**
  40870. * 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
  40871. * @see http://doc.babylonjs.com/features/occlusionquery
  40872. */
  40873. isOccluded: boolean;
  40874. /**
  40875. * Flag to check the progress status of the query
  40876. * @see http://doc.babylonjs.com/features/occlusionquery
  40877. */
  40878. isOcclusionQueryInProgress: boolean;
  40879. }
  40880. }
  40881. declare module BABYLON {
  40882. /** @hidden */
  40883. export var _forceTransformFeedbackToBundle: boolean;
  40884. interface Engine {
  40885. /**
  40886. * Creates a webGL transform feedback object
  40887. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40888. * @returns the webGL transform feedback object
  40889. */
  40890. createTransformFeedback(): WebGLTransformFeedback;
  40891. /**
  40892. * Delete a webGL transform feedback object
  40893. * @param value defines the webGL transform feedback object to delete
  40894. */
  40895. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40896. /**
  40897. * Bind a webGL transform feedback object to the webgl context
  40898. * @param value defines the webGL transform feedback object to bind
  40899. */
  40900. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40901. /**
  40902. * Begins a transform feedback operation
  40903. * @param usePoints defines if points or triangles must be used
  40904. */
  40905. beginTransformFeedback(usePoints: boolean): void;
  40906. /**
  40907. * Ends a transform feedback operation
  40908. */
  40909. endTransformFeedback(): void;
  40910. /**
  40911. * Specify the varyings to use with transform feedback
  40912. * @param program defines the associated webGL program
  40913. * @param value defines the list of strings representing the varying names
  40914. */
  40915. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40916. /**
  40917. * Bind a webGL buffer for a transform feedback operation
  40918. * @param value defines the webGL buffer to bind
  40919. */
  40920. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  40921. }
  40922. }
  40923. declare module BABYLON {
  40924. /**
  40925. * Creation options of the multi render target texture.
  40926. */
  40927. export interface IMultiRenderTargetOptions {
  40928. /**
  40929. * Define if the texture needs to create mip maps after render.
  40930. */
  40931. generateMipMaps?: boolean;
  40932. /**
  40933. * Define the types of all the draw buffers we want to create
  40934. */
  40935. types?: number[];
  40936. /**
  40937. * Define the sampling modes of all the draw buffers we want to create
  40938. */
  40939. samplingModes?: number[];
  40940. /**
  40941. * Define if a depth buffer is required
  40942. */
  40943. generateDepthBuffer?: boolean;
  40944. /**
  40945. * Define if a stencil buffer is required
  40946. */
  40947. generateStencilBuffer?: boolean;
  40948. /**
  40949. * Define if a depth texture is required instead of a depth buffer
  40950. */
  40951. generateDepthTexture?: boolean;
  40952. /**
  40953. * Define the number of desired draw buffers
  40954. */
  40955. textureCount?: number;
  40956. /**
  40957. * Define if aspect ratio should be adapted to the texture or stay the scene one
  40958. */
  40959. doNotChangeAspectRatio?: boolean;
  40960. /**
  40961. * Define the default type of the buffers we are creating
  40962. */
  40963. defaultType?: number;
  40964. }
  40965. /**
  40966. * A multi render target, like a render target provides the ability to render to a texture.
  40967. * Unlike the render target, it can render to several draw buffers in one draw.
  40968. * This is specially interesting in deferred rendering or for any effects requiring more than
  40969. * just one color from a single pass.
  40970. */
  40971. export class MultiRenderTarget extends RenderTargetTexture {
  40972. private _internalTextures;
  40973. private _textures;
  40974. private _multiRenderTargetOptions;
  40975. /**
  40976. * Get if draw buffers are currently supported by the used hardware and browser.
  40977. */
  40978. readonly isSupported: boolean;
  40979. /**
  40980. * Get the list of textures generated by the multi render target.
  40981. */
  40982. readonly textures: Texture[];
  40983. /**
  40984. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  40985. */
  40986. readonly depthTexture: Texture;
  40987. /**
  40988. * Set the wrapping mode on U of all the textures we are rendering to.
  40989. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40990. */
  40991. wrapU: number;
  40992. /**
  40993. * Set the wrapping mode on V of all the textures we are rendering to.
  40994. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  40995. */
  40996. wrapV: number;
  40997. /**
  40998. * Instantiate a new multi render target texture.
  40999. * A multi render target, like a render target provides the ability to render to a texture.
  41000. * Unlike the render target, it can render to several draw buffers in one draw.
  41001. * This is specially interesting in deferred rendering or for any effects requiring more than
  41002. * just one color from a single pass.
  41003. * @param name Define the name of the texture
  41004. * @param size Define the size of the buffers to render to
  41005. * @param count Define the number of target we are rendering into
  41006. * @param scene Define the scene the texture belongs to
  41007. * @param options Define the options used to create the multi render target
  41008. */
  41009. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41010. /** @hidden */ rebuild(): void;
  41011. private _createInternalTextures;
  41012. private _createTextures;
  41013. /**
  41014. * Define the number of samples used if MSAA is enabled.
  41015. */
  41016. samples: number;
  41017. /**
  41018. * Resize all the textures in the multi render target.
  41019. * Be carrefull as it will recreate all the data in the new texture.
  41020. * @param size Define the new size
  41021. */
  41022. resize(size: any): void;
  41023. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41024. /**
  41025. * Dispose the render targets and their associated resources
  41026. */
  41027. dispose(): void;
  41028. /**
  41029. * Release all the underlying texture used as draw buffers.
  41030. */
  41031. releaseInternalTextures(): void;
  41032. }
  41033. }
  41034. declare module BABYLON {
  41035. interface Engine {
  41036. /**
  41037. * Unbind a list of render target textures from the webGL context
  41038. * This is used only when drawBuffer extension or webGL2 are active
  41039. * @param textures defines the render target textures to unbind
  41040. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41041. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41042. */
  41043. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41044. /**
  41045. * Create a multi render target texture
  41046. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41047. * @param size defines the size of the texture
  41048. * @param options defines the creation options
  41049. * @returns the cube texture as an InternalTexture
  41050. */
  41051. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41052. /**
  41053. * Update the sample count for a given multiple render target texture
  41054. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41055. * @param textures defines the textures to update
  41056. * @param samples defines the sample count to set
  41057. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41058. */
  41059. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41060. }
  41061. }
  41062. declare module BABYLON {
  41063. /**
  41064. * Gather the list of clipboard event types as constants.
  41065. */
  41066. export class ClipboardEventTypes {
  41067. /**
  41068. * The clipboard event is fired when a copy command is active (pressed).
  41069. */
  41070. static readonly COPY: number;
  41071. /**
  41072. * The clipboard event is fired when a cut command is active (pressed).
  41073. */
  41074. static readonly CUT: number;
  41075. /**
  41076. * The clipboard event is fired when a paste command is active (pressed).
  41077. */
  41078. static readonly PASTE: number;
  41079. }
  41080. /**
  41081. * This class is used to store clipboard related info for the onClipboardObservable event.
  41082. */
  41083. export class ClipboardInfo {
  41084. /**
  41085. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41086. */
  41087. type: number;
  41088. /**
  41089. * Defines the related dom event
  41090. */
  41091. event: ClipboardEvent;
  41092. /**
  41093. *Creates an instance of ClipboardInfo.
  41094. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41095. * @param event Defines the related dom event
  41096. */
  41097. constructor(
  41098. /**
  41099. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41100. */
  41101. type: number,
  41102. /**
  41103. * Defines the related dom event
  41104. */
  41105. event: ClipboardEvent);
  41106. /**
  41107. * Get the clipboard event's type from the keycode.
  41108. * @param keyCode Defines the keyCode for the current keyboard event.
  41109. * @return {number}
  41110. */
  41111. static GetTypeFromCharacter(keyCode: number): number;
  41112. }
  41113. }
  41114. declare module BABYLON {
  41115. /**
  41116. * Class used to represent data loading progression
  41117. */
  41118. export class SceneLoaderProgressEvent {
  41119. /** defines if data length to load can be evaluated */
  41120. readonly lengthComputable: boolean;
  41121. /** defines the loaded data length */
  41122. readonly loaded: number;
  41123. /** defines the data length to load */
  41124. readonly total: number;
  41125. /**
  41126. * Create a new progress event
  41127. * @param lengthComputable defines if data length to load can be evaluated
  41128. * @param loaded defines the loaded data length
  41129. * @param total defines the data length to load
  41130. */
  41131. constructor(
  41132. /** defines if data length to load can be evaluated */
  41133. lengthComputable: boolean,
  41134. /** defines the loaded data length */
  41135. loaded: number,
  41136. /** defines the data length to load */
  41137. total: number);
  41138. /**
  41139. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41140. * @param event defines the source event
  41141. * @returns a new SceneLoaderProgressEvent
  41142. */
  41143. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41144. }
  41145. /**
  41146. * Interface used by SceneLoader plugins to define supported file extensions
  41147. */
  41148. export interface ISceneLoaderPluginExtensions {
  41149. /**
  41150. * Defines the list of supported extensions
  41151. */
  41152. [extension: string]: {
  41153. isBinary: boolean;
  41154. };
  41155. }
  41156. /**
  41157. * Interface used by SceneLoader plugin factory
  41158. */
  41159. export interface ISceneLoaderPluginFactory {
  41160. /**
  41161. * Defines the name of the factory
  41162. */
  41163. name: string;
  41164. /**
  41165. * Function called to create a new plugin
  41166. * @return the new plugin
  41167. */
  41168. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41169. /**
  41170. * Boolean indicating if the plugin can direct load specific data
  41171. */
  41172. canDirectLoad?: (data: string) => boolean;
  41173. }
  41174. /**
  41175. * Interface used to define a SceneLoader plugin
  41176. */
  41177. export interface ISceneLoaderPlugin {
  41178. /**
  41179. * The friendly name of this plugin.
  41180. */
  41181. name: string;
  41182. /**
  41183. * The file extensions supported by this plugin.
  41184. */
  41185. extensions: string | ISceneLoaderPluginExtensions;
  41186. /**
  41187. * Import meshes into a scene.
  41188. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41189. * @param scene The scene to import into
  41190. * @param data The data to import
  41191. * @param rootUrl The root url for scene and resources
  41192. * @param meshes The meshes array to import into
  41193. * @param particleSystems The particle systems array to import into
  41194. * @param skeletons The skeletons array to import into
  41195. * @param onError The callback when import fails
  41196. * @returns True if successful or false otherwise
  41197. */
  41198. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41199. /**
  41200. * Load into a scene.
  41201. * @param scene The scene to load into
  41202. * @param data The data to import
  41203. * @param rootUrl The root url for scene and resources
  41204. * @param onError The callback when import fails
  41205. * @returns true if successful or false otherwise
  41206. */
  41207. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41208. /**
  41209. * The callback that returns true if the data can be directly loaded.
  41210. */
  41211. canDirectLoad?: (data: string) => boolean;
  41212. /**
  41213. * The callback that allows custom handling of the root url based on the response url.
  41214. */
  41215. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41216. /**
  41217. * Load into an asset container.
  41218. * @param scene The scene to load into
  41219. * @param data The data to import
  41220. * @param rootUrl The root url for scene and resources
  41221. * @param onError The callback when import fails
  41222. * @returns The loaded asset container
  41223. */
  41224. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41225. }
  41226. /**
  41227. * Interface used to define an async SceneLoader plugin
  41228. */
  41229. export interface ISceneLoaderPluginAsync {
  41230. /**
  41231. * The friendly name of this plugin.
  41232. */
  41233. name: string;
  41234. /**
  41235. * The file extensions supported by this plugin.
  41236. */
  41237. extensions: string | ISceneLoaderPluginExtensions;
  41238. /**
  41239. * Import meshes into a scene.
  41240. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41241. * @param scene The scene to import into
  41242. * @param data The data to import
  41243. * @param rootUrl The root url for scene and resources
  41244. * @param onProgress The callback when the load progresses
  41245. * @param fileName Defines the name of the file to load
  41246. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41247. */
  41248. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41249. meshes: AbstractMesh[];
  41250. particleSystems: IParticleSystem[];
  41251. skeletons: Skeleton[];
  41252. animationGroups: AnimationGroup[];
  41253. }>;
  41254. /**
  41255. * Load into a scene.
  41256. * @param scene The scene to load into
  41257. * @param data The data to import
  41258. * @param rootUrl The root url for scene and resources
  41259. * @param onProgress The callback when the load progresses
  41260. * @param fileName Defines the name of the file to load
  41261. * @returns Nothing
  41262. */
  41263. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41264. /**
  41265. * The callback that returns true if the data can be directly loaded.
  41266. */
  41267. canDirectLoad?: (data: string) => boolean;
  41268. /**
  41269. * The callback that allows custom handling of the root url based on the response url.
  41270. */
  41271. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41272. /**
  41273. * Load into an asset container.
  41274. * @param scene The scene to load into
  41275. * @param data The data to import
  41276. * @param rootUrl The root url for scene and resources
  41277. * @param onProgress The callback when the load progresses
  41278. * @param fileName Defines the name of the file to load
  41279. * @returns The loaded asset container
  41280. */
  41281. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41282. }
  41283. /**
  41284. * Class used to load scene from various file formats using registered plugins
  41285. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41286. */
  41287. export class SceneLoader {
  41288. /**
  41289. * No logging while loading
  41290. */
  41291. static readonly NO_LOGGING: number;
  41292. /**
  41293. * Minimal logging while loading
  41294. */
  41295. static readonly MINIMAL_LOGGING: number;
  41296. /**
  41297. * Summary logging while loading
  41298. */
  41299. static readonly SUMMARY_LOGGING: number;
  41300. /**
  41301. * Detailled logging while loading
  41302. */
  41303. static readonly DETAILED_LOGGING: number;
  41304. /**
  41305. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41306. */
  41307. static ForceFullSceneLoadingForIncremental: boolean;
  41308. /**
  41309. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41310. */
  41311. static ShowLoadingScreen: boolean;
  41312. /**
  41313. * Defines the current logging level (while loading the scene)
  41314. * @ignorenaming
  41315. */
  41316. static loggingLevel: number;
  41317. /**
  41318. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41319. */
  41320. static CleanBoneMatrixWeights: boolean;
  41321. /**
  41322. * Event raised when a plugin is used to load a scene
  41323. */
  41324. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41325. private static _registeredPlugins;
  41326. private static _getDefaultPlugin;
  41327. private static _getPluginForExtension;
  41328. private static _getPluginForDirectLoad;
  41329. private static _getPluginForFilename;
  41330. private static _getDirectLoad;
  41331. private static _loadData;
  41332. private static _getFileInfo;
  41333. /**
  41334. * Gets a plugin that can load the given extension
  41335. * @param extension defines the extension to load
  41336. * @returns a plugin or null if none works
  41337. */
  41338. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41339. /**
  41340. * Gets a boolean indicating that the given extension can be loaded
  41341. * @param extension defines the extension to load
  41342. * @returns true if the extension is supported
  41343. */
  41344. static IsPluginForExtensionAvailable(extension: string): boolean;
  41345. /**
  41346. * Adds a new plugin to the list of registered plugins
  41347. * @param plugin defines the plugin to add
  41348. */
  41349. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41350. /**
  41351. * Import meshes into a scene
  41352. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41353. * @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)
  41354. * @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)
  41355. * @param scene the instance of BABYLON.Scene to append to
  41356. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41357. * @param onProgress a callback with a progress event for each file being loaded
  41358. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41359. * @param pluginExtension the extension used to determine the plugin
  41360. * @returns The loaded plugin
  41361. */
  41362. 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>;
  41363. /**
  41364. * Import meshes into a scene
  41365. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41366. * @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)
  41367. * @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)
  41368. * @param scene the instance of BABYLON.Scene to append to
  41369. * @param onProgress a callback with a progress event for each file being loaded
  41370. * @param pluginExtension the extension used to determine the plugin
  41371. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41372. */
  41373. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41374. meshes: AbstractMesh[];
  41375. particleSystems: IParticleSystem[];
  41376. skeletons: Skeleton[];
  41377. animationGroups: AnimationGroup[];
  41378. }>;
  41379. /**
  41380. * Load a scene
  41381. * @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)
  41382. * @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)
  41383. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41384. * @param onSuccess a callback with the scene when import succeeds
  41385. * @param onProgress a callback with a progress event for each file being loaded
  41386. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41387. * @param pluginExtension the extension used to determine the plugin
  41388. * @returns The loaded plugin
  41389. */
  41390. 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>;
  41391. /**
  41392. * Load a scene
  41393. * @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)
  41394. * @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)
  41395. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41396. * @param onProgress a callback with a progress event for each file being loaded
  41397. * @param pluginExtension the extension used to determine the plugin
  41398. * @returns The loaded scene
  41399. */
  41400. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41401. /**
  41402. * Append a scene
  41403. * @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)
  41404. * @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)
  41405. * @param scene is the instance of BABYLON.Scene to append to
  41406. * @param onSuccess a callback with the scene when import succeeds
  41407. * @param onProgress a callback with a progress event for each file being loaded
  41408. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41409. * @param pluginExtension the extension used to determine the plugin
  41410. * @returns The loaded plugin
  41411. */
  41412. 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>;
  41413. /**
  41414. * Append a scene
  41415. * @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)
  41416. * @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)
  41417. * @param scene is the instance of BABYLON.Scene to append to
  41418. * @param onProgress a callback with a progress event for each file being loaded
  41419. * @param pluginExtension the extension used to determine the plugin
  41420. * @returns The given scene
  41421. */
  41422. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41423. /**
  41424. * Load a scene into an asset container
  41425. * @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)
  41426. * @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)
  41427. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41428. * @param onSuccess a callback with the scene when import succeeds
  41429. * @param onProgress a callback with a progress event for each file being loaded
  41430. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41431. * @param pluginExtension the extension used to determine the plugin
  41432. * @returns The loaded plugin
  41433. */
  41434. 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>;
  41435. /**
  41436. * Load a scene into an asset container
  41437. * @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)
  41438. * @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)
  41439. * @param scene is the instance of Scene to append to
  41440. * @param onProgress a callback with a progress event for each file being loaded
  41441. * @param pluginExtension the extension used to determine the plugin
  41442. * @returns The loaded asset container
  41443. */
  41444. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41445. }
  41446. }
  41447. declare module BABYLON {
  41448. /**
  41449. * Google Daydream controller
  41450. */
  41451. export class DaydreamController extends WebVRController {
  41452. /**
  41453. * Base Url for the controller model.
  41454. */
  41455. static MODEL_BASE_URL: string;
  41456. /**
  41457. * File name for the controller model.
  41458. */
  41459. static MODEL_FILENAME: string;
  41460. /**
  41461. * Gamepad Id prefix used to identify Daydream Controller.
  41462. */
  41463. static readonly GAMEPAD_ID_PREFIX: string;
  41464. /**
  41465. * Creates a new DaydreamController from a gamepad
  41466. * @param vrGamepad the gamepad that the controller should be created from
  41467. */
  41468. constructor(vrGamepad: any);
  41469. /**
  41470. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41471. * @param scene scene in which to add meshes
  41472. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41473. */
  41474. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41475. /**
  41476. * Called once for each button that changed state since the last frame
  41477. * @param buttonIdx Which button index changed
  41478. * @param state New state of the button
  41479. * @param changes Which properties on the state changed since last frame
  41480. */
  41481. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41482. }
  41483. }
  41484. declare module BABYLON {
  41485. /**
  41486. * Gear VR Controller
  41487. */
  41488. export class GearVRController extends WebVRController {
  41489. /**
  41490. * Base Url for the controller model.
  41491. */
  41492. static MODEL_BASE_URL: string;
  41493. /**
  41494. * File name for the controller model.
  41495. */
  41496. static MODEL_FILENAME: string;
  41497. /**
  41498. * Gamepad Id prefix used to identify this controller.
  41499. */
  41500. static readonly GAMEPAD_ID_PREFIX: string;
  41501. private readonly _buttonIndexToObservableNameMap;
  41502. /**
  41503. * Creates a new GearVRController from a gamepad
  41504. * @param vrGamepad the gamepad that the controller should be created from
  41505. */
  41506. constructor(vrGamepad: any);
  41507. /**
  41508. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41509. * @param scene scene in which to add meshes
  41510. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41511. */
  41512. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41513. /**
  41514. * Called once for each button that changed state since the last frame
  41515. * @param buttonIdx Which button index changed
  41516. * @param state New state of the button
  41517. * @param changes Which properties on the state changed since last frame
  41518. */
  41519. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41520. }
  41521. }
  41522. declare module BABYLON {
  41523. /**
  41524. * Generic Controller
  41525. */
  41526. export class GenericController extends WebVRController {
  41527. /**
  41528. * Base Url for the controller model.
  41529. */
  41530. static readonly MODEL_BASE_URL: string;
  41531. /**
  41532. * File name for the controller model.
  41533. */
  41534. static readonly MODEL_FILENAME: string;
  41535. /**
  41536. * Creates a new GenericController from a gamepad
  41537. * @param vrGamepad the gamepad that the controller should be created from
  41538. */
  41539. constructor(vrGamepad: any);
  41540. /**
  41541. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41542. * @param scene scene in which to add meshes
  41543. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41544. */
  41545. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41546. /**
  41547. * Called once for each button that changed state since the last frame
  41548. * @param buttonIdx Which button index changed
  41549. * @param state New state of the button
  41550. * @param changes Which properties on the state changed since last frame
  41551. */
  41552. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41553. }
  41554. }
  41555. declare module BABYLON {
  41556. /**
  41557. * Oculus Touch Controller
  41558. */
  41559. export class OculusTouchController extends WebVRController {
  41560. /**
  41561. * Base Url for the controller model.
  41562. */
  41563. static MODEL_BASE_URL: string;
  41564. /**
  41565. * File name for the left controller model.
  41566. */
  41567. static MODEL_LEFT_FILENAME: string;
  41568. /**
  41569. * File name for the right controller model.
  41570. */
  41571. static MODEL_RIGHT_FILENAME: string;
  41572. /**
  41573. * Fired when the secondary trigger on this controller is modified
  41574. */
  41575. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41576. /**
  41577. * Fired when the thumb rest on this controller is modified
  41578. */
  41579. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41580. /**
  41581. * Creates a new OculusTouchController from a gamepad
  41582. * @param vrGamepad the gamepad that the controller should be created from
  41583. */
  41584. constructor(vrGamepad: any);
  41585. /**
  41586. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41587. * @param scene scene in which to add meshes
  41588. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41589. */
  41590. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41591. /**
  41592. * Fired when the A button on this controller is modified
  41593. */
  41594. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41595. /**
  41596. * Fired when the B button on this controller is modified
  41597. */
  41598. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41599. /**
  41600. * Fired when the X button on this controller is modified
  41601. */
  41602. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41603. /**
  41604. * Fired when the Y button on this controller is modified
  41605. */
  41606. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41607. /**
  41608. * Called once for each button that changed state since the last frame
  41609. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41610. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41611. * 2) secondary trigger (same)
  41612. * 3) A (right) X (left), touch, pressed = value
  41613. * 4) B / Y
  41614. * 5) thumb rest
  41615. * @param buttonIdx Which button index changed
  41616. * @param state New state of the button
  41617. * @param changes Which properties on the state changed since last frame
  41618. */
  41619. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41620. }
  41621. }
  41622. declare module BABYLON {
  41623. /**
  41624. * Vive Controller
  41625. */
  41626. export class ViveController extends WebVRController {
  41627. /**
  41628. * Base Url for the controller model.
  41629. */
  41630. static MODEL_BASE_URL: string;
  41631. /**
  41632. * File name for the controller model.
  41633. */
  41634. static MODEL_FILENAME: string;
  41635. /**
  41636. * Creates a new ViveController from a gamepad
  41637. * @param vrGamepad the gamepad that the controller should be created from
  41638. */
  41639. constructor(vrGamepad: any);
  41640. /**
  41641. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41642. * @param scene scene in which to add meshes
  41643. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41644. */
  41645. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41646. /**
  41647. * Fired when the left button on this controller is modified
  41648. */
  41649. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41650. /**
  41651. * Fired when the right button on this controller is modified
  41652. */
  41653. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41654. /**
  41655. * Fired when the menu button on this controller is modified
  41656. */
  41657. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41658. /**
  41659. * Called once for each button that changed state since the last frame
  41660. * Vive mapping:
  41661. * 0: touchpad
  41662. * 1: trigger
  41663. * 2: left AND right buttons
  41664. * 3: menu button
  41665. * @param buttonIdx Which button index changed
  41666. * @param state New state of the button
  41667. * @param changes Which properties on the state changed since last frame
  41668. */
  41669. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41670. }
  41671. }
  41672. declare module BABYLON {
  41673. /**
  41674. * Defines the WindowsMotionController object that the state of the windows motion controller
  41675. */
  41676. export class WindowsMotionController extends WebVRController {
  41677. /**
  41678. * The base url used to load the left and right controller models
  41679. */
  41680. static MODEL_BASE_URL: string;
  41681. /**
  41682. * The name of the left controller model file
  41683. */
  41684. static MODEL_LEFT_FILENAME: string;
  41685. /**
  41686. * The name of the right controller model file
  41687. */
  41688. static MODEL_RIGHT_FILENAME: string;
  41689. /**
  41690. * The controller name prefix for this controller type
  41691. */
  41692. static readonly GAMEPAD_ID_PREFIX: string;
  41693. /**
  41694. * The controller id pattern for this controller type
  41695. */
  41696. private static readonly GAMEPAD_ID_PATTERN;
  41697. private _loadedMeshInfo;
  41698. private readonly _mapping;
  41699. /**
  41700. * Fired when the trackpad on this controller is clicked
  41701. */
  41702. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41703. /**
  41704. * Fired when the trackpad on this controller is modified
  41705. */
  41706. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41707. /**
  41708. * The current x and y values of this controller's trackpad
  41709. */
  41710. trackpad: StickValues;
  41711. /**
  41712. * Creates a new WindowsMotionController from a gamepad
  41713. * @param vrGamepad the gamepad that the controller should be created from
  41714. */
  41715. constructor(vrGamepad: any);
  41716. /**
  41717. * Fired when the trigger on this controller is modified
  41718. */
  41719. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41720. /**
  41721. * Fired when the menu button on this controller is modified
  41722. */
  41723. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41724. /**
  41725. * Fired when the grip button on this controller is modified
  41726. */
  41727. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41728. /**
  41729. * Fired when the thumbstick button on this controller is modified
  41730. */
  41731. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41732. /**
  41733. * Fired when the touchpad button on this controller is modified
  41734. */
  41735. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41736. /**
  41737. * Fired when the touchpad values on this controller are modified
  41738. */
  41739. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41740. private _updateTrackpad;
  41741. /**
  41742. * Called once per frame by the engine.
  41743. */
  41744. update(): void;
  41745. /**
  41746. * Called once for each button that changed state since the last frame
  41747. * @param buttonIdx Which button index changed
  41748. * @param state New state of the button
  41749. * @param changes Which properties on the state changed since last frame
  41750. */
  41751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41752. /**
  41753. * Moves the buttons on the controller mesh based on their current state
  41754. * @param buttonName the name of the button to move
  41755. * @param buttonValue the value of the button which determines the buttons new position
  41756. */
  41757. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41758. /**
  41759. * Moves the axis on the controller mesh based on its current state
  41760. * @param axis the index of the axis
  41761. * @param axisValue the value of the axis which determines the meshes new position
  41762. * @hidden
  41763. */
  41764. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41765. /**
  41766. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41767. * @param scene scene in which to add meshes
  41768. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41769. */
  41770. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41771. /**
  41772. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41773. * can be transformed by button presses and axes values, based on this._mapping.
  41774. *
  41775. * @param scene scene in which the meshes exist
  41776. * @param meshes list of meshes that make up the controller model to process
  41777. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41778. */
  41779. private processModel;
  41780. private createMeshInfo;
  41781. /**
  41782. * Gets the ray of the controller in the direction the controller is pointing
  41783. * @param length the length the resulting ray should be
  41784. * @returns a ray in the direction the controller is pointing
  41785. */
  41786. getForwardRay(length?: number): Ray;
  41787. /**
  41788. * Disposes of the controller
  41789. */
  41790. dispose(): void;
  41791. }
  41792. }
  41793. declare module BABYLON {
  41794. /**
  41795. * Single axis scale gizmo
  41796. */
  41797. export class AxisScaleGizmo extends Gizmo {
  41798. private _coloredMaterial;
  41799. /**
  41800. * Drag behavior responsible for the gizmos dragging interactions
  41801. */
  41802. dragBehavior: PointerDragBehavior;
  41803. private _pointerObserver;
  41804. /**
  41805. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41806. */
  41807. snapDistance: number;
  41808. /**
  41809. * Event that fires each time the gizmo snaps to a new location.
  41810. * * snapDistance is the the change in distance
  41811. */
  41812. onSnapObservable: Observable<{
  41813. snapDistance: number;
  41814. }>;
  41815. /**
  41816. * If the scaling operation should be done on all axis (default: false)
  41817. */
  41818. uniformScaling: boolean;
  41819. /**
  41820. * Creates an AxisScaleGizmo
  41821. * @param gizmoLayer The utility layer the gizmo will be added to
  41822. * @param dragAxis The axis which the gizmo will be able to scale on
  41823. * @param color The color of the gizmo
  41824. */
  41825. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41826. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41827. /**
  41828. * Disposes of the gizmo
  41829. */
  41830. dispose(): void;
  41831. /**
  41832. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41833. * @param mesh The mesh to replace the default mesh of the gizmo
  41834. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41835. */
  41836. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41837. }
  41838. }
  41839. declare module BABYLON {
  41840. /**
  41841. * Bounding box gizmo
  41842. */
  41843. export class BoundingBoxGizmo extends Gizmo {
  41844. private _lineBoundingBox;
  41845. private _rotateSpheresParent;
  41846. private _scaleBoxesParent;
  41847. private _boundingDimensions;
  41848. private _renderObserver;
  41849. private _pointerObserver;
  41850. private _scaleDragSpeed;
  41851. private _tmpQuaternion;
  41852. private _tmpVector;
  41853. private _tmpRotationMatrix;
  41854. /**
  41855. * 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)
  41856. */
  41857. ignoreChildren: boolean;
  41858. /**
  41859. * 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)
  41860. */
  41861. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41862. /**
  41863. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41864. */
  41865. rotationSphereSize: number;
  41866. /**
  41867. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41868. */
  41869. scaleBoxSize: number;
  41870. /**
  41871. * 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)
  41872. */
  41873. fixedDragMeshScreenSize: boolean;
  41874. /**
  41875. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41876. */
  41877. fixedDragMeshScreenSizeDistanceFactor: number;
  41878. /**
  41879. * Fired when a rotation sphere or scale box is dragged
  41880. */
  41881. onDragStartObservable: Observable<{}>;
  41882. /**
  41883. * Fired when a scale box is dragged
  41884. */
  41885. onScaleBoxDragObservable: Observable<{}>;
  41886. /**
  41887. * Fired when a scale box drag is ended
  41888. */
  41889. onScaleBoxDragEndObservable: Observable<{}>;
  41890. /**
  41891. * Fired when a rotation sphere is dragged
  41892. */
  41893. onRotationSphereDragObservable: Observable<{}>;
  41894. /**
  41895. * Fired when a rotation sphere drag is ended
  41896. */
  41897. onRotationSphereDragEndObservable: Observable<{}>;
  41898. /**
  41899. * 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)
  41900. */
  41901. scalePivot: Nullable<Vector3>;
  41902. /**
  41903. * Mesh used as a pivot to rotate the attached mesh
  41904. */
  41905. private _anchorMesh;
  41906. private _existingMeshScale;
  41907. private _dragMesh;
  41908. private pointerDragBehavior;
  41909. private coloredMaterial;
  41910. private hoverColoredMaterial;
  41911. /**
  41912. * Sets the color of the bounding box gizmo
  41913. * @param color the color to set
  41914. */
  41915. setColor(color: Color3): void;
  41916. /**
  41917. * Creates an BoundingBoxGizmo
  41918. * @param gizmoLayer The utility layer the gizmo will be added to
  41919. * @param color The color of the gizmo
  41920. */
  41921. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41922. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41923. private _selectNode;
  41924. /**
  41925. * Updates the bounding box information for the Gizmo
  41926. */
  41927. updateBoundingBox(): void;
  41928. private _updateRotationSpheres;
  41929. private _updateScaleBoxes;
  41930. /**
  41931. * Enables rotation on the specified axis and disables rotation on the others
  41932. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41933. */
  41934. setEnabledRotationAxis(axis: string): void;
  41935. /**
  41936. * Enables/disables scaling
  41937. * @param enable if scaling should be enabled
  41938. */
  41939. setEnabledScaling(enable: boolean): void;
  41940. private _updateDummy;
  41941. /**
  41942. * Enables a pointer drag behavior on the bounding box of the gizmo
  41943. */
  41944. enableDragBehavior(): void;
  41945. /**
  41946. * Disposes of the gizmo
  41947. */
  41948. dispose(): void;
  41949. /**
  41950. * 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)
  41951. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41952. * @returns the bounding box mesh with the passed in mesh as a child
  41953. */
  41954. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41955. /**
  41956. * CustomMeshes are not supported by this gizmo
  41957. * @param mesh The mesh to replace the default mesh of the gizmo
  41958. */
  41959. setCustomMesh(mesh: Mesh): void;
  41960. }
  41961. }
  41962. declare module BABYLON {
  41963. /**
  41964. * Single plane rotation gizmo
  41965. */
  41966. export class PlaneRotationGizmo extends Gizmo {
  41967. /**
  41968. * Drag behavior responsible for the gizmos dragging interactions
  41969. */
  41970. dragBehavior: PointerDragBehavior;
  41971. private _pointerObserver;
  41972. /**
  41973. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41974. */
  41975. snapDistance: number;
  41976. /**
  41977. * Event that fires each time the gizmo snaps to a new location.
  41978. * * snapDistance is the the change in distance
  41979. */
  41980. onSnapObservable: Observable<{
  41981. snapDistance: number;
  41982. }>;
  41983. /**
  41984. * Creates a PlaneRotationGizmo
  41985. * @param gizmoLayer The utility layer the gizmo will be added to
  41986. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41987. * @param color The color of the gizmo
  41988. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41989. */
  41990. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41991. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41992. /**
  41993. * Disposes of the gizmo
  41994. */
  41995. dispose(): void;
  41996. }
  41997. }
  41998. declare module BABYLON {
  41999. /**
  42000. * Gizmo that enables rotating a mesh along 3 axis
  42001. */
  42002. export class RotationGizmo extends Gizmo {
  42003. /**
  42004. * Internal gizmo used for interactions on the x axis
  42005. */
  42006. xGizmo: PlaneRotationGizmo;
  42007. /**
  42008. * Internal gizmo used for interactions on the y axis
  42009. */
  42010. yGizmo: PlaneRotationGizmo;
  42011. /**
  42012. * Internal gizmo used for interactions on the z axis
  42013. */
  42014. zGizmo: PlaneRotationGizmo;
  42015. /** Fires an event when any of it's sub gizmos are dragged */
  42016. onDragStartObservable: Observable<{}>;
  42017. /** Fires an event when any of it's sub gizmos are released from dragging */
  42018. onDragEndObservable: Observable<{}>;
  42019. attachedMesh: Nullable<AbstractMesh>;
  42020. /**
  42021. * Creates a RotationGizmo
  42022. * @param gizmoLayer The utility layer the gizmo will be added to
  42023. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42024. */
  42025. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42026. updateGizmoRotationToMatchAttachedMesh: boolean;
  42027. /**
  42028. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42029. */
  42030. snapDistance: number;
  42031. /**
  42032. * Ratio for the scale of the gizmo (Default: 1)
  42033. */
  42034. scaleRatio: number;
  42035. /**
  42036. * Disposes of the gizmo
  42037. */
  42038. dispose(): void;
  42039. /**
  42040. * CustomMeshes are not supported by this gizmo
  42041. * @param mesh The mesh to replace the default mesh of the gizmo
  42042. */
  42043. setCustomMesh(mesh: Mesh): void;
  42044. }
  42045. }
  42046. declare module BABYLON {
  42047. /**
  42048. * Gizmo that enables dragging a mesh along 3 axis
  42049. */
  42050. export class PositionGizmo extends Gizmo {
  42051. /**
  42052. * Internal gizmo used for interactions on the x axis
  42053. */
  42054. xGizmo: AxisDragGizmo;
  42055. /**
  42056. * Internal gizmo used for interactions on the y axis
  42057. */
  42058. yGizmo: AxisDragGizmo;
  42059. /**
  42060. * Internal gizmo used for interactions on the z axis
  42061. */
  42062. zGizmo: AxisDragGizmo;
  42063. /** Fires an event when any of it's sub gizmos are dragged */
  42064. onDragStartObservable: Observable<{}>;
  42065. /** Fires an event when any of it's sub gizmos are released from dragging */
  42066. onDragEndObservable: Observable<{}>;
  42067. attachedMesh: Nullable<AbstractMesh>;
  42068. /**
  42069. * Creates a PositionGizmo
  42070. * @param gizmoLayer The utility layer the gizmo will be added to
  42071. */
  42072. constructor(gizmoLayer?: UtilityLayerRenderer);
  42073. updateGizmoRotationToMatchAttachedMesh: boolean;
  42074. /**
  42075. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42076. */
  42077. snapDistance: number;
  42078. /**
  42079. * Ratio for the scale of the gizmo (Default: 1)
  42080. */
  42081. scaleRatio: number;
  42082. /**
  42083. * Disposes of the gizmo
  42084. */
  42085. dispose(): void;
  42086. /**
  42087. * CustomMeshes are not supported by this gizmo
  42088. * @param mesh The mesh to replace the default mesh of the gizmo
  42089. */
  42090. setCustomMesh(mesh: Mesh): void;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * Class containing static functions to help procedurally build meshes
  42096. */
  42097. export class PolyhedronBuilder {
  42098. /**
  42099. * Creates a polyhedron mesh
  42100. * * 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
  42101. * * The parameter `size` (positive float, default 1) sets the polygon size
  42102. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42103. * * 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`
  42104. * * 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
  42105. * * 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)`)
  42106. * * 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
  42107. * * 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
  42108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42109. * * 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
  42110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42111. * @param name defines the name of the mesh
  42112. * @param options defines the options used to create the mesh
  42113. * @param scene defines the hosting scene
  42114. * @returns the polyhedron mesh
  42115. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42116. */
  42117. static CreatePolyhedron(name: string, options: {
  42118. type?: number;
  42119. size?: number;
  42120. sizeX?: number;
  42121. sizeY?: number;
  42122. sizeZ?: number;
  42123. custom?: any;
  42124. faceUV?: Vector4[];
  42125. faceColors?: Color4[];
  42126. flat?: boolean;
  42127. updatable?: boolean;
  42128. sideOrientation?: number;
  42129. frontUVs?: Vector4;
  42130. backUVs?: Vector4;
  42131. }, scene?: Nullable<Scene>): Mesh;
  42132. }
  42133. }
  42134. declare module BABYLON {
  42135. /**
  42136. * Gizmo that enables scaling a mesh along 3 axis
  42137. */
  42138. export class ScaleGizmo extends Gizmo {
  42139. /**
  42140. * Internal gizmo used for interactions on the x axis
  42141. */
  42142. xGizmo: AxisScaleGizmo;
  42143. /**
  42144. * Internal gizmo used for interactions on the y axis
  42145. */
  42146. yGizmo: AxisScaleGizmo;
  42147. /**
  42148. * Internal gizmo used for interactions on the z axis
  42149. */
  42150. zGizmo: AxisScaleGizmo;
  42151. /**
  42152. * Internal gizmo used to scale all axis equally
  42153. */
  42154. uniformScaleGizmo: AxisScaleGizmo;
  42155. /** Fires an event when any of it's sub gizmos are dragged */
  42156. onDragStartObservable: Observable<{}>;
  42157. /** Fires an event when any of it's sub gizmos are released from dragging */
  42158. onDragEndObservable: Observable<{}>;
  42159. attachedMesh: Nullable<AbstractMesh>;
  42160. /**
  42161. * Creates a ScaleGizmo
  42162. * @param gizmoLayer The utility layer the gizmo will be added to
  42163. */
  42164. constructor(gizmoLayer?: UtilityLayerRenderer);
  42165. updateGizmoRotationToMatchAttachedMesh: boolean;
  42166. /**
  42167. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42168. */
  42169. snapDistance: number;
  42170. /**
  42171. * Ratio for the scale of the gizmo (Default: 1)
  42172. */
  42173. scaleRatio: number;
  42174. /**
  42175. * Disposes of the gizmo
  42176. */
  42177. dispose(): void;
  42178. }
  42179. }
  42180. declare module BABYLON {
  42181. /**
  42182. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42183. */
  42184. export class GizmoManager implements IDisposable {
  42185. private scene;
  42186. /**
  42187. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42188. */
  42189. gizmos: {
  42190. positionGizmo: Nullable<PositionGizmo>;
  42191. rotationGizmo: Nullable<RotationGizmo>;
  42192. scaleGizmo: Nullable<ScaleGizmo>;
  42193. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42194. };
  42195. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42196. clearGizmoOnEmptyPointerEvent: boolean;
  42197. /** Fires an event when the manager is attached to a mesh */
  42198. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42199. private _gizmosEnabled;
  42200. private _pointerObserver;
  42201. private _attachedMesh;
  42202. private _boundingBoxColor;
  42203. private _defaultUtilityLayer;
  42204. private _defaultKeepDepthUtilityLayer;
  42205. /**
  42206. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42207. */
  42208. boundingBoxDragBehavior: SixDofDragBehavior;
  42209. /**
  42210. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42211. */
  42212. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42213. /**
  42214. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42215. */
  42216. usePointerToAttachGizmos: boolean;
  42217. /**
  42218. * Instatiates a gizmo manager
  42219. * @param scene the scene to overlay the gizmos on top of
  42220. */
  42221. constructor(scene: Scene);
  42222. /**
  42223. * Attaches a set of gizmos to the specified mesh
  42224. * @param mesh The mesh the gizmo's should be attached to
  42225. */
  42226. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42227. /**
  42228. * If the position gizmo is enabled
  42229. */
  42230. positionGizmoEnabled: boolean;
  42231. /**
  42232. * If the rotation gizmo is enabled
  42233. */
  42234. rotationGizmoEnabled: boolean;
  42235. /**
  42236. * If the scale gizmo is enabled
  42237. */
  42238. scaleGizmoEnabled: boolean;
  42239. /**
  42240. * If the boundingBox gizmo is enabled
  42241. */
  42242. boundingBoxGizmoEnabled: boolean;
  42243. /**
  42244. * Disposes of the gizmo manager
  42245. */
  42246. dispose(): void;
  42247. }
  42248. }
  42249. declare module BABYLON {
  42250. /**
  42251. * A directional light is defined by a direction (what a surprise!).
  42252. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42253. * 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.
  42254. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42255. */
  42256. export class DirectionalLight extends ShadowLight {
  42257. private _shadowFrustumSize;
  42258. /**
  42259. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42260. */
  42261. /**
  42262. * Specifies a fix frustum size for the shadow generation.
  42263. */
  42264. shadowFrustumSize: number;
  42265. private _shadowOrthoScale;
  42266. /**
  42267. * Gets the shadow projection scale against the optimal computed one.
  42268. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42269. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42270. */
  42271. /**
  42272. * Sets the shadow projection scale against the optimal computed one.
  42273. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42274. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42275. */
  42276. shadowOrthoScale: number;
  42277. /**
  42278. * Automatically compute the projection matrix to best fit (including all the casters)
  42279. * on each frame.
  42280. */
  42281. autoUpdateExtends: boolean;
  42282. private _orthoLeft;
  42283. private _orthoRight;
  42284. private _orthoTop;
  42285. private _orthoBottom;
  42286. /**
  42287. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42288. * The directional light is emitted from everywhere in the given direction.
  42289. * It can cast shadows.
  42290. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42291. * @param name The friendly name of the light
  42292. * @param direction The direction of the light
  42293. * @param scene The scene the light belongs to
  42294. */
  42295. constructor(name: string, direction: Vector3, scene: Scene);
  42296. /**
  42297. * Returns the string "DirectionalLight".
  42298. * @return The class name
  42299. */
  42300. getClassName(): string;
  42301. /**
  42302. * Returns the integer 1.
  42303. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42304. */
  42305. getTypeID(): number;
  42306. /**
  42307. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42308. * Returns the DirectionalLight Shadow projection matrix.
  42309. */
  42310. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42311. /**
  42312. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42313. * Returns the DirectionalLight Shadow projection matrix.
  42314. */
  42315. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42316. /**
  42317. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42318. * Returns the DirectionalLight Shadow projection matrix.
  42319. */
  42320. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42321. protected _buildUniformLayout(): void;
  42322. /**
  42323. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42324. * @param effect The effect to update
  42325. * @param lightIndex The index of the light in the effect to update
  42326. * @returns The directional light
  42327. */
  42328. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42329. /**
  42330. * Gets the minZ used for shadow according to both the scene and the light.
  42331. *
  42332. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42333. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42334. * @param activeCamera The camera we are returning the min for
  42335. * @returns the depth min z
  42336. */
  42337. getDepthMinZ(activeCamera: Camera): number;
  42338. /**
  42339. * Gets the maxZ used for shadow according to both the scene and the light.
  42340. *
  42341. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42342. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42343. * @param activeCamera The camera we are returning the max for
  42344. * @returns the depth max z
  42345. */
  42346. getDepthMaxZ(activeCamera: Camera): number;
  42347. /**
  42348. * Prepares the list of defines specific to the light type.
  42349. * @param defines the list of defines
  42350. * @param lightIndex defines the index of the light for the effect
  42351. */
  42352. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42353. }
  42354. }
  42355. declare module BABYLON {
  42356. /**
  42357. * Class containing static functions to help procedurally build meshes
  42358. */
  42359. export class HemisphereBuilder {
  42360. /**
  42361. * Creates a hemisphere mesh
  42362. * @param name defines the name of the mesh
  42363. * @param options defines the options used to create the mesh
  42364. * @param scene defines the hosting scene
  42365. * @returns the hemisphere mesh
  42366. */
  42367. static CreateHemisphere(name: string, options: {
  42368. segments?: number;
  42369. diameter?: number;
  42370. sideOrientation?: number;
  42371. }, scene: any): Mesh;
  42372. }
  42373. }
  42374. declare module BABYLON {
  42375. /**
  42376. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42377. * These values define a cone of light starting from the position, emitting toward the direction.
  42378. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42379. * and the exponent defines the speed of the decay of the light with distance (reach).
  42380. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42381. */
  42382. export class SpotLight extends ShadowLight {
  42383. private _angle;
  42384. private _innerAngle;
  42385. private _cosHalfAngle;
  42386. private _lightAngleScale;
  42387. private _lightAngleOffset;
  42388. /**
  42389. * Gets the cone angle of the spot light in Radians.
  42390. */
  42391. /**
  42392. * Sets the cone angle of the spot light in Radians.
  42393. */
  42394. angle: number;
  42395. /**
  42396. * Only used in gltf falloff mode, this defines the angle where
  42397. * the directional falloff will start before cutting at angle which could be seen
  42398. * as outer angle.
  42399. */
  42400. /**
  42401. * Only used in gltf falloff mode, this defines the angle where
  42402. * the directional falloff will start before cutting at angle which could be seen
  42403. * as outer angle.
  42404. */
  42405. innerAngle: number;
  42406. private _shadowAngleScale;
  42407. /**
  42408. * Allows scaling the angle of the light for shadow generation only.
  42409. */
  42410. /**
  42411. * Allows scaling the angle of the light for shadow generation only.
  42412. */
  42413. shadowAngleScale: number;
  42414. /**
  42415. * The light decay speed with the distance from the emission spot.
  42416. */
  42417. exponent: number;
  42418. private _projectionTextureMatrix;
  42419. /**
  42420. * Allows reading the projecton texture
  42421. */
  42422. readonly projectionTextureMatrix: Matrix;
  42423. protected _projectionTextureLightNear: number;
  42424. /**
  42425. * Gets the near clip of the Spotlight for texture projection.
  42426. */
  42427. /**
  42428. * Sets the near clip of the Spotlight for texture projection.
  42429. */
  42430. projectionTextureLightNear: number;
  42431. protected _projectionTextureLightFar: number;
  42432. /**
  42433. * Gets the far clip of the Spotlight for texture projection.
  42434. */
  42435. /**
  42436. * Sets the far clip of the Spotlight for texture projection.
  42437. */
  42438. projectionTextureLightFar: number;
  42439. protected _projectionTextureUpDirection: Vector3;
  42440. /**
  42441. * Gets the Up vector of the Spotlight for texture projection.
  42442. */
  42443. /**
  42444. * Sets the Up vector of the Spotlight for texture projection.
  42445. */
  42446. projectionTextureUpDirection: Vector3;
  42447. private _projectionTexture;
  42448. /**
  42449. * Gets the projection texture of the light.
  42450. */
  42451. /**
  42452. * Sets the projection texture of the light.
  42453. */
  42454. projectionTexture: Nullable<BaseTexture>;
  42455. private _projectionTextureViewLightDirty;
  42456. private _projectionTextureProjectionLightDirty;
  42457. private _projectionTextureDirty;
  42458. private _projectionTextureViewTargetVector;
  42459. private _projectionTextureViewLightMatrix;
  42460. private _projectionTextureProjectionLightMatrix;
  42461. private _projectionTextureScalingMatrix;
  42462. /**
  42463. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42464. * It can cast shadows.
  42465. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42466. * @param name The light friendly name
  42467. * @param position The position of the spot light in the scene
  42468. * @param direction The direction of the light in the scene
  42469. * @param angle The cone angle of the light in Radians
  42470. * @param exponent The light decay speed with the distance from the emission spot
  42471. * @param scene The scene the lights belongs to
  42472. */
  42473. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42474. /**
  42475. * Returns the string "SpotLight".
  42476. * @returns the class name
  42477. */
  42478. getClassName(): string;
  42479. /**
  42480. * Returns the integer 2.
  42481. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42482. */
  42483. getTypeID(): number;
  42484. /**
  42485. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42486. */
  42487. protected _setDirection(value: Vector3): void;
  42488. /**
  42489. * Overrides the position setter to recompute the projection texture view light Matrix.
  42490. */
  42491. protected _setPosition(value: Vector3): void;
  42492. /**
  42493. * 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.
  42494. * Returns the SpotLight.
  42495. */
  42496. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42497. protected _computeProjectionTextureViewLightMatrix(): void;
  42498. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42499. /**
  42500. * Main function for light texture projection matrix computing.
  42501. */
  42502. protected _computeProjectionTextureMatrix(): void;
  42503. protected _buildUniformLayout(): void;
  42504. private _computeAngleValues;
  42505. /**
  42506. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42507. * @param effect The effect to update
  42508. * @param lightIndex The index of the light in the effect to update
  42509. * @returns The spot light
  42510. */
  42511. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42512. /**
  42513. * Disposes the light and the associated resources.
  42514. */
  42515. dispose(): void;
  42516. /**
  42517. * Prepares the list of defines specific to the light type.
  42518. * @param defines the list of defines
  42519. * @param lightIndex defines the index of the light for the effect
  42520. */
  42521. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42522. }
  42523. }
  42524. declare module BABYLON {
  42525. /**
  42526. * Gizmo that enables viewing a light
  42527. */
  42528. export class LightGizmo extends Gizmo {
  42529. private _lightMesh;
  42530. private _material;
  42531. /**
  42532. * Creates a LightGizmo
  42533. * @param gizmoLayer The utility layer the gizmo will be added to
  42534. */
  42535. constructor(gizmoLayer?: UtilityLayerRenderer);
  42536. private _light;
  42537. /**
  42538. * The light that the gizmo is attached to
  42539. */
  42540. light: Nullable<Light>;
  42541. /**
  42542. * @hidden
  42543. * Updates the gizmo to match the attached mesh's position/rotation
  42544. */
  42545. protected _update(): void;
  42546. private static _Scale;
  42547. /**
  42548. * Creates the lines for a light mesh
  42549. */
  42550. private static _createLightLines;
  42551. private static _CreateHemisphericLightMesh;
  42552. private static _CreatePointLightMesh;
  42553. private static _CreateSpotLightMesh;
  42554. private static _CreateDirectionalLightMesh;
  42555. }
  42556. }
  42557. declare module BABYLON {
  42558. /** @hidden */
  42559. export var backgroundFragmentDeclaration: {
  42560. name: string;
  42561. shader: string;
  42562. };
  42563. }
  42564. declare module BABYLON {
  42565. /** @hidden */
  42566. export var backgroundUboDeclaration: {
  42567. name: string;
  42568. shader: string;
  42569. };
  42570. }
  42571. declare module BABYLON {
  42572. /** @hidden */
  42573. export var backgroundPixelShader: {
  42574. name: string;
  42575. shader: string;
  42576. };
  42577. }
  42578. declare module BABYLON {
  42579. /** @hidden */
  42580. export var backgroundVertexDeclaration: {
  42581. name: string;
  42582. shader: string;
  42583. };
  42584. }
  42585. declare module BABYLON {
  42586. /** @hidden */
  42587. export var backgroundVertexShader: {
  42588. name: string;
  42589. shader: string;
  42590. };
  42591. }
  42592. declare module BABYLON {
  42593. /**
  42594. * Background material used to create an efficient environement around your scene.
  42595. */
  42596. export class BackgroundMaterial extends PushMaterial {
  42597. /**
  42598. * Standard reflectance value at parallel view angle.
  42599. */
  42600. static StandardReflectance0: number;
  42601. /**
  42602. * Standard reflectance value at grazing angle.
  42603. */
  42604. static StandardReflectance90: number;
  42605. protected _primaryColor: Color3;
  42606. /**
  42607. * Key light Color (multiply against the environement texture)
  42608. */
  42609. primaryColor: Color3;
  42610. protected __perceptualColor: Nullable<Color3>;
  42611. /**
  42612. * Experimental Internal Use Only.
  42613. *
  42614. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42615. * This acts as a helper to set the primary color to a more "human friendly" value.
  42616. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42617. * output color as close as possible from the chosen value.
  42618. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42619. * part of lighting setup.)
  42620. */ perceptualColor: Nullable<Color3>;
  42621. protected _primaryColorShadowLevel: float;
  42622. /**
  42623. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42624. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42625. */
  42626. primaryColorShadowLevel: float;
  42627. protected _primaryColorHighlightLevel: float;
  42628. /**
  42629. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42630. * The primary color is used at the level chosen to define what the white area would look.
  42631. */
  42632. primaryColorHighlightLevel: float;
  42633. protected _reflectionTexture: Nullable<BaseTexture>;
  42634. /**
  42635. * Reflection Texture used in the material.
  42636. * Should be author in a specific way for the best result (refer to the documentation).
  42637. */
  42638. reflectionTexture: Nullable<BaseTexture>;
  42639. protected _reflectionBlur: float;
  42640. /**
  42641. * Reflection Texture level of blur.
  42642. *
  42643. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42644. * texture twice.
  42645. */
  42646. reflectionBlur: float;
  42647. protected _diffuseTexture: Nullable<BaseTexture>;
  42648. /**
  42649. * Diffuse Texture used in the material.
  42650. * Should be author in a specific way for the best result (refer to the documentation).
  42651. */
  42652. diffuseTexture: Nullable<BaseTexture>;
  42653. protected _shadowLights: Nullable<IShadowLight[]>;
  42654. /**
  42655. * Specify the list of lights casting shadow on the material.
  42656. * All scene shadow lights will be included if null.
  42657. */
  42658. shadowLights: Nullable<IShadowLight[]>;
  42659. protected _shadowLevel: float;
  42660. /**
  42661. * Helps adjusting the shadow to a softer level if required.
  42662. * 0 means black shadows and 1 means no shadows.
  42663. */
  42664. shadowLevel: float;
  42665. protected _sceneCenter: Vector3;
  42666. /**
  42667. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42668. * It is usually zero but might be interesting to modify according to your setup.
  42669. */
  42670. sceneCenter: Vector3;
  42671. protected _opacityFresnel: boolean;
  42672. /**
  42673. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42674. * This helps ensuring a nice transition when the camera goes under the ground.
  42675. */
  42676. opacityFresnel: boolean;
  42677. protected _reflectionFresnel: boolean;
  42678. /**
  42679. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42680. * This helps adding a mirror texture on the ground.
  42681. */
  42682. reflectionFresnel: boolean;
  42683. protected _reflectionFalloffDistance: number;
  42684. /**
  42685. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42686. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42687. */
  42688. reflectionFalloffDistance: number;
  42689. protected _reflectionAmount: number;
  42690. /**
  42691. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42692. */
  42693. reflectionAmount: number;
  42694. protected _reflectionReflectance0: number;
  42695. /**
  42696. * This specifies the weight of the reflection at grazing angle.
  42697. */
  42698. reflectionReflectance0: number;
  42699. protected _reflectionReflectance90: number;
  42700. /**
  42701. * This specifies the weight of the reflection at a perpendicular point of view.
  42702. */
  42703. reflectionReflectance90: number;
  42704. /**
  42705. * Sets the reflection reflectance fresnel values according to the default standard
  42706. * empirically know to work well :-)
  42707. */
  42708. reflectionStandardFresnelWeight: number;
  42709. protected _useRGBColor: boolean;
  42710. /**
  42711. * Helps to directly use the maps channels instead of their level.
  42712. */
  42713. useRGBColor: boolean;
  42714. protected _enableNoise: boolean;
  42715. /**
  42716. * This helps reducing the banding effect that could occur on the background.
  42717. */
  42718. enableNoise: boolean;
  42719. /**
  42720. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42721. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42722. * Recommended to be keep at 1.0 except for special cases.
  42723. */
  42724. fovMultiplier: number;
  42725. private _fovMultiplier;
  42726. /**
  42727. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42728. */
  42729. useEquirectangularFOV: boolean;
  42730. private _maxSimultaneousLights;
  42731. /**
  42732. * Number of Simultaneous lights allowed on the material.
  42733. */
  42734. maxSimultaneousLights: int;
  42735. /**
  42736. * Default configuration related to image processing available in the Background Material.
  42737. */
  42738. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42739. /**
  42740. * Keep track of the image processing observer to allow dispose and replace.
  42741. */
  42742. private _imageProcessingObserver;
  42743. /**
  42744. * Attaches a new image processing configuration to the PBR Material.
  42745. * @param configuration (if null the scene configuration will be use)
  42746. */
  42747. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42748. /**
  42749. * Gets the image processing configuration used either in this material.
  42750. */
  42751. /**
  42752. * Sets the Default image processing configuration used either in the this material.
  42753. *
  42754. * If sets to null, the scene one is in use.
  42755. */
  42756. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42757. /**
  42758. * Gets wether the color curves effect is enabled.
  42759. */
  42760. /**
  42761. * Sets wether the color curves effect is enabled.
  42762. */
  42763. cameraColorCurvesEnabled: boolean;
  42764. /**
  42765. * Gets wether the color grading effect is enabled.
  42766. */
  42767. /**
  42768. * Gets wether the color grading effect is enabled.
  42769. */
  42770. cameraColorGradingEnabled: boolean;
  42771. /**
  42772. * Gets wether tonemapping is enabled or not.
  42773. */
  42774. /**
  42775. * Sets wether tonemapping is enabled or not
  42776. */
  42777. cameraToneMappingEnabled: boolean;
  42778. /**
  42779. * The camera exposure used on this material.
  42780. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42781. * This corresponds to a photographic exposure.
  42782. */
  42783. /**
  42784. * The camera exposure used on this material.
  42785. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42786. * This corresponds to a photographic exposure.
  42787. */
  42788. cameraExposure: float;
  42789. /**
  42790. * Gets The camera contrast used on this material.
  42791. */
  42792. /**
  42793. * Sets The camera contrast used on this material.
  42794. */
  42795. cameraContrast: float;
  42796. /**
  42797. * Gets the Color Grading 2D Lookup Texture.
  42798. */
  42799. /**
  42800. * Sets the Color Grading 2D Lookup Texture.
  42801. */
  42802. cameraColorGradingTexture: Nullable<BaseTexture>;
  42803. /**
  42804. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42805. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42806. * 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;
  42807. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42808. */
  42809. /**
  42810. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42811. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42812. * 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;
  42813. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42814. */
  42815. cameraColorCurves: Nullable<ColorCurves>;
  42816. /**
  42817. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42818. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42819. */
  42820. switchToBGR: boolean;
  42821. private _renderTargets;
  42822. private _reflectionControls;
  42823. private _white;
  42824. private _primaryShadowColor;
  42825. private _primaryHighlightColor;
  42826. /**
  42827. * Instantiates a Background Material in the given scene
  42828. * @param name The friendly name of the material
  42829. * @param scene The scene to add the material to
  42830. */
  42831. constructor(name: string, scene: Scene);
  42832. /**
  42833. * Gets a boolean indicating that current material needs to register RTT
  42834. */
  42835. readonly hasRenderTargetTextures: boolean;
  42836. /**
  42837. * The entire material has been created in order to prevent overdraw.
  42838. * @returns false
  42839. */
  42840. needAlphaTesting(): boolean;
  42841. /**
  42842. * The entire material has been created in order to prevent overdraw.
  42843. * @returns true if blending is enable
  42844. */
  42845. needAlphaBlending(): boolean;
  42846. /**
  42847. * Checks wether the material is ready to be rendered for a given mesh.
  42848. * @param mesh The mesh to render
  42849. * @param subMesh The submesh to check against
  42850. * @param useInstances Specify wether or not the material is used with instances
  42851. * @returns true if all the dependencies are ready (Textures, Effects...)
  42852. */
  42853. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42854. /**
  42855. * Compute the primary color according to the chosen perceptual color.
  42856. */
  42857. private _computePrimaryColorFromPerceptualColor;
  42858. /**
  42859. * Compute the highlights and shadow colors according to their chosen levels.
  42860. */
  42861. private _computePrimaryColors;
  42862. /**
  42863. * Build the uniform buffer used in the material.
  42864. */
  42865. buildUniformLayout(): void;
  42866. /**
  42867. * Unbind the material.
  42868. */
  42869. unbind(): void;
  42870. /**
  42871. * Bind only the world matrix to the material.
  42872. * @param world The world matrix to bind.
  42873. */
  42874. bindOnlyWorldMatrix(world: Matrix): void;
  42875. /**
  42876. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42877. * @param world The world matrix to bind.
  42878. * @param subMesh The submesh to bind for.
  42879. */
  42880. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42881. /**
  42882. * Dispose the material.
  42883. * @param forceDisposeEffect Force disposal of the associated effect.
  42884. * @param forceDisposeTextures Force disposal of the associated textures.
  42885. */
  42886. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42887. /**
  42888. * Clones the material.
  42889. * @param name The cloned name.
  42890. * @returns The cloned material.
  42891. */
  42892. clone(name: string): BackgroundMaterial;
  42893. /**
  42894. * Serializes the current material to its JSON representation.
  42895. * @returns The JSON representation.
  42896. */
  42897. serialize(): any;
  42898. /**
  42899. * Gets the class name of the material
  42900. * @returns "BackgroundMaterial"
  42901. */
  42902. getClassName(): string;
  42903. /**
  42904. * Parse a JSON input to create back a background material.
  42905. * @param source The JSON data to parse
  42906. * @param scene The scene to create the parsed material in
  42907. * @param rootUrl The root url of the assets the material depends upon
  42908. * @returns the instantiated BackgroundMaterial.
  42909. */
  42910. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42911. }
  42912. }
  42913. declare module BABYLON {
  42914. /**
  42915. * Represents the different options available during the creation of
  42916. * a Environment helper.
  42917. *
  42918. * This can control the default ground, skybox and image processing setup of your scene.
  42919. */
  42920. export interface IEnvironmentHelperOptions {
  42921. /**
  42922. * Specifies wether or not to create a ground.
  42923. * True by default.
  42924. */
  42925. createGround: boolean;
  42926. /**
  42927. * Specifies the ground size.
  42928. * 15 by default.
  42929. */
  42930. groundSize: number;
  42931. /**
  42932. * The texture used on the ground for the main color.
  42933. * Comes from the BabylonJS CDN by default.
  42934. *
  42935. * Remarks: Can be either a texture or a url.
  42936. */
  42937. groundTexture: string | BaseTexture;
  42938. /**
  42939. * The color mixed in the ground texture by default.
  42940. * BabylonJS clearColor by default.
  42941. */
  42942. groundColor: Color3;
  42943. /**
  42944. * Specifies the ground opacity.
  42945. * 1 by default.
  42946. */
  42947. groundOpacity: number;
  42948. /**
  42949. * Enables the ground to receive shadows.
  42950. * True by default.
  42951. */
  42952. enableGroundShadow: boolean;
  42953. /**
  42954. * Helps preventing the shadow to be fully black on the ground.
  42955. * 0.5 by default.
  42956. */
  42957. groundShadowLevel: number;
  42958. /**
  42959. * Creates a mirror texture attach to the ground.
  42960. * false by default.
  42961. */
  42962. enableGroundMirror: boolean;
  42963. /**
  42964. * Specifies the ground mirror size ratio.
  42965. * 0.3 by default as the default kernel is 64.
  42966. */
  42967. groundMirrorSizeRatio: number;
  42968. /**
  42969. * Specifies the ground mirror blur kernel size.
  42970. * 64 by default.
  42971. */
  42972. groundMirrorBlurKernel: number;
  42973. /**
  42974. * Specifies the ground mirror visibility amount.
  42975. * 1 by default
  42976. */
  42977. groundMirrorAmount: number;
  42978. /**
  42979. * Specifies the ground mirror reflectance weight.
  42980. * This uses the standard weight of the background material to setup the fresnel effect
  42981. * of the mirror.
  42982. * 1 by default.
  42983. */
  42984. groundMirrorFresnelWeight: number;
  42985. /**
  42986. * Specifies the ground mirror Falloff distance.
  42987. * This can helps reducing the size of the reflection.
  42988. * 0 by Default.
  42989. */
  42990. groundMirrorFallOffDistance: number;
  42991. /**
  42992. * Specifies the ground mirror texture type.
  42993. * Unsigned Int by Default.
  42994. */
  42995. groundMirrorTextureType: number;
  42996. /**
  42997. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42998. * the shown objects.
  42999. */
  43000. groundYBias: number;
  43001. /**
  43002. * Specifies wether or not to create a skybox.
  43003. * True by default.
  43004. */
  43005. createSkybox: boolean;
  43006. /**
  43007. * Specifies the skybox size.
  43008. * 20 by default.
  43009. */
  43010. skyboxSize: number;
  43011. /**
  43012. * The texture used on the skybox for the main color.
  43013. * Comes from the BabylonJS CDN by default.
  43014. *
  43015. * Remarks: Can be either a texture or a url.
  43016. */
  43017. skyboxTexture: string | BaseTexture;
  43018. /**
  43019. * The color mixed in the skybox texture by default.
  43020. * BabylonJS clearColor by default.
  43021. */
  43022. skyboxColor: Color3;
  43023. /**
  43024. * The background rotation around the Y axis of the scene.
  43025. * This helps aligning the key lights of your scene with the background.
  43026. * 0 by default.
  43027. */
  43028. backgroundYRotation: number;
  43029. /**
  43030. * Compute automatically the size of the elements to best fit with the scene.
  43031. */
  43032. sizeAuto: boolean;
  43033. /**
  43034. * Default position of the rootMesh if autoSize is not true.
  43035. */
  43036. rootPosition: Vector3;
  43037. /**
  43038. * Sets up the image processing in the scene.
  43039. * true by default.
  43040. */
  43041. setupImageProcessing: boolean;
  43042. /**
  43043. * The texture used as your environment texture in the scene.
  43044. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43045. *
  43046. * Remarks: Can be either a texture or a url.
  43047. */
  43048. environmentTexture: string | BaseTexture;
  43049. /**
  43050. * The value of the exposure to apply to the scene.
  43051. * 0.6 by default if setupImageProcessing is true.
  43052. */
  43053. cameraExposure: number;
  43054. /**
  43055. * The value of the contrast to apply to the scene.
  43056. * 1.6 by default if setupImageProcessing is true.
  43057. */
  43058. cameraContrast: number;
  43059. /**
  43060. * Specifies wether or not tonemapping should be enabled in the scene.
  43061. * true by default if setupImageProcessing is true.
  43062. */
  43063. toneMappingEnabled: boolean;
  43064. }
  43065. /**
  43066. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43067. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43068. * It also helps with the default setup of your imageProcessing configuration.
  43069. */
  43070. export class EnvironmentHelper {
  43071. /**
  43072. * Default ground texture URL.
  43073. */
  43074. private static _groundTextureCDNUrl;
  43075. /**
  43076. * Default skybox texture URL.
  43077. */
  43078. private static _skyboxTextureCDNUrl;
  43079. /**
  43080. * Default environment texture URL.
  43081. */
  43082. private static _environmentTextureCDNUrl;
  43083. /**
  43084. * Creates the default options for the helper.
  43085. */
  43086. private static _getDefaultOptions;
  43087. private _rootMesh;
  43088. /**
  43089. * Gets the root mesh created by the helper.
  43090. */
  43091. readonly rootMesh: Mesh;
  43092. private _skybox;
  43093. /**
  43094. * Gets the skybox created by the helper.
  43095. */
  43096. readonly skybox: Nullable<Mesh>;
  43097. private _skyboxTexture;
  43098. /**
  43099. * Gets the skybox texture created by the helper.
  43100. */
  43101. readonly skyboxTexture: Nullable<BaseTexture>;
  43102. private _skyboxMaterial;
  43103. /**
  43104. * Gets the skybox material created by the helper.
  43105. */
  43106. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43107. private _ground;
  43108. /**
  43109. * Gets the ground mesh created by the helper.
  43110. */
  43111. readonly ground: Nullable<Mesh>;
  43112. private _groundTexture;
  43113. /**
  43114. * Gets the ground texture created by the helper.
  43115. */
  43116. readonly groundTexture: Nullable<BaseTexture>;
  43117. private _groundMirror;
  43118. /**
  43119. * Gets the ground mirror created by the helper.
  43120. */
  43121. readonly groundMirror: Nullable<MirrorTexture>;
  43122. /**
  43123. * Gets the ground mirror render list to helps pushing the meshes
  43124. * you wish in the ground reflection.
  43125. */
  43126. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43127. private _groundMaterial;
  43128. /**
  43129. * Gets the ground material created by the helper.
  43130. */
  43131. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43132. /**
  43133. * Stores the creation options.
  43134. */
  43135. private readonly _scene;
  43136. private _options;
  43137. /**
  43138. * This observable will be notified with any error during the creation of the environment,
  43139. * mainly texture creation errors.
  43140. */
  43141. onErrorObservable: Observable<{
  43142. message?: string;
  43143. exception?: any;
  43144. }>;
  43145. /**
  43146. * constructor
  43147. * @param options Defines the options we want to customize the helper
  43148. * @param scene The scene to add the material to
  43149. */
  43150. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43151. /**
  43152. * Updates the background according to the new options
  43153. * @param options
  43154. */
  43155. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43156. /**
  43157. * Sets the primary color of all the available elements.
  43158. * @param color the main color to affect to the ground and the background
  43159. */
  43160. setMainColor(color: Color3): void;
  43161. /**
  43162. * Setup the image processing according to the specified options.
  43163. */
  43164. private _setupImageProcessing;
  43165. /**
  43166. * Setup the environment texture according to the specified options.
  43167. */
  43168. private _setupEnvironmentTexture;
  43169. /**
  43170. * Setup the background according to the specified options.
  43171. */
  43172. private _setupBackground;
  43173. /**
  43174. * Get the scene sizes according to the setup.
  43175. */
  43176. private _getSceneSize;
  43177. /**
  43178. * Setup the ground according to the specified options.
  43179. */
  43180. private _setupGround;
  43181. /**
  43182. * Setup the ground material according to the specified options.
  43183. */
  43184. private _setupGroundMaterial;
  43185. /**
  43186. * Setup the ground diffuse texture according to the specified options.
  43187. */
  43188. private _setupGroundDiffuseTexture;
  43189. /**
  43190. * Setup the ground mirror texture according to the specified options.
  43191. */
  43192. private _setupGroundMirrorTexture;
  43193. /**
  43194. * Setup the ground to receive the mirror texture.
  43195. */
  43196. private _setupMirrorInGroundMaterial;
  43197. /**
  43198. * Setup the skybox according to the specified options.
  43199. */
  43200. private _setupSkybox;
  43201. /**
  43202. * Setup the skybox material according to the specified options.
  43203. */
  43204. private _setupSkyboxMaterial;
  43205. /**
  43206. * Setup the skybox reflection texture according to the specified options.
  43207. */
  43208. private _setupSkyboxReflectionTexture;
  43209. private _errorHandler;
  43210. /**
  43211. * Dispose all the elements created by the Helper.
  43212. */
  43213. dispose(): void;
  43214. }
  43215. }
  43216. declare module BABYLON {
  43217. /**
  43218. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43219. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43220. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43221. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43222. */
  43223. export class PhotoDome extends TransformNode {
  43224. private _useDirectMapping;
  43225. /**
  43226. * The texture being displayed on the sphere
  43227. */
  43228. protected _photoTexture: Texture;
  43229. /**
  43230. * Gets or sets the texture being displayed on the sphere
  43231. */
  43232. photoTexture: Texture;
  43233. /**
  43234. * Observable raised when an error occured while loading the 360 image
  43235. */
  43236. onLoadErrorObservable: Observable<string>;
  43237. /**
  43238. * The skybox material
  43239. */
  43240. protected _material: BackgroundMaterial;
  43241. /**
  43242. * The surface used for the skybox
  43243. */
  43244. protected _mesh: Mesh;
  43245. /**
  43246. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43247. * Also see the options.resolution property.
  43248. */
  43249. fovMultiplier: number;
  43250. /**
  43251. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43252. * @param name Element's name, child elements will append suffixes for their own names.
  43253. * @param urlsOfPhoto defines the url of the photo to display
  43254. * @param options defines an object containing optional or exposed sub element properties
  43255. * @param onError defines a callback called when an error occured while loading the texture
  43256. */
  43257. constructor(name: string, urlOfPhoto: string, options: {
  43258. resolution?: number;
  43259. size?: number;
  43260. useDirectMapping?: boolean;
  43261. faceForward?: boolean;
  43262. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43263. /**
  43264. * Releases resources associated with this node.
  43265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43267. */
  43268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43269. }
  43270. }
  43271. declare module BABYLON {
  43272. /** @hidden */
  43273. export var rgbdDecodePixelShader: {
  43274. name: string;
  43275. shader: string;
  43276. };
  43277. }
  43278. declare module BABYLON {
  43279. /**
  43280. * Class used to host texture specific utilities
  43281. */
  43282. export class BRDFTextureTools {
  43283. /**
  43284. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43285. * @param texture the texture to expand.
  43286. */
  43287. private static _ExpandDefaultBRDFTexture;
  43288. /**
  43289. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43290. * @param scene defines the hosting scene
  43291. * @returns the environment BRDF texture
  43292. */
  43293. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43294. private static _environmentBRDFBase64Texture;
  43295. }
  43296. }
  43297. declare module BABYLON {
  43298. /**
  43299. * @hidden
  43300. */
  43301. export interface IMaterialClearCoatDefines {
  43302. CLEARCOAT: boolean;
  43303. CLEARCOAT_DEFAULTIOR: boolean;
  43304. CLEARCOAT_TEXTURE: boolean;
  43305. CLEARCOAT_TEXTUREDIRECTUV: number;
  43306. CLEARCOAT_BUMP: boolean;
  43307. CLEARCOAT_BUMPDIRECTUV: number;
  43308. CLEARCOAT_TINT: boolean;
  43309. CLEARCOAT_TINT_TEXTURE: boolean;
  43310. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43311. /** @hidden */ areTexturesDirty: boolean;
  43312. }
  43313. /**
  43314. * Define the code related to the clear coat parameters of the pbr material.
  43315. */
  43316. export class PBRClearCoatConfiguration {
  43317. /**
  43318. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43319. * The default fits with a polyurethane material.
  43320. */
  43321. private static readonly _DefaultIndiceOfRefraction;
  43322. private _isEnabled;
  43323. /**
  43324. * Defines if the clear coat is enabled in the material.
  43325. */
  43326. isEnabled: boolean;
  43327. /**
  43328. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43329. */
  43330. intensity: number;
  43331. /**
  43332. * Defines the clear coat layer roughness.
  43333. */
  43334. roughness: number;
  43335. private _indiceOfRefraction;
  43336. /**
  43337. * Defines the indice of refraction of the clear coat.
  43338. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43339. * The default fits with a polyurethane material.
  43340. * Changing the default value is more performance intensive.
  43341. */
  43342. indiceOfRefraction: number;
  43343. private _texture;
  43344. /**
  43345. * Stores the clear coat values in a texture.
  43346. */
  43347. texture: Nullable<BaseTexture>;
  43348. private _bumpTexture;
  43349. /**
  43350. * Define the clear coat specific bump texture.
  43351. */
  43352. bumpTexture: Nullable<BaseTexture>;
  43353. private _isTintEnabled;
  43354. /**
  43355. * Defines if the clear coat tint is enabled in the material.
  43356. */
  43357. isTintEnabled: boolean;
  43358. /**
  43359. * Defines the clear coat tint of the material.
  43360. * This is only use if tint is enabled
  43361. */
  43362. tintColor: Color3;
  43363. /**
  43364. * Defines the distance at which the tint color should be found in the
  43365. * clear coat media.
  43366. * This is only use if tint is enabled
  43367. */
  43368. tintColorAtDistance: number;
  43369. /**
  43370. * Defines the clear coat layer thickness.
  43371. * This is only use if tint is enabled
  43372. */
  43373. tintThickness: number;
  43374. private _tintTexture;
  43375. /**
  43376. * Stores the clear tint values in a texture.
  43377. * rgb is tint
  43378. * a is a thickness factor
  43379. */
  43380. tintTexture: Nullable<BaseTexture>;
  43381. /** @hidden */
  43382. private _internalMarkAllSubMeshesAsTexturesDirty;
  43383. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43384. /**
  43385. * Instantiate a new istance of clear coat configuration.
  43386. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43387. */
  43388. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43389. /**
  43390. * Gets wehter the submesh is ready to be used or not.
  43391. * @param defines the list of "defines" to update.
  43392. * @param scene defines the scene the material belongs to.
  43393. * @param engine defines the engine the material belongs to.
  43394. * @param disableBumpMap defines wether the material disables bump or not.
  43395. * @returns - boolean indicating that the submesh is ready or not.
  43396. */
  43397. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43398. /**
  43399. * Checks to see if a texture is used in the material.
  43400. * @param defines the list of "defines" to update.
  43401. * @param scene defines the scene to the material belongs to.
  43402. */
  43403. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43404. /**
  43405. * Binds the material data.
  43406. * @param uniformBuffer defines the Uniform buffer to fill in.
  43407. * @param scene defines the scene the material belongs to.
  43408. * @param engine defines the engine the material belongs to.
  43409. * @param disableBumpMap defines wether the material disables bump or not.
  43410. * @param isFrozen defines wether the material is frozen or not.
  43411. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43412. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43413. */
  43414. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43415. /**
  43416. * Checks to see if a texture is used in the material.
  43417. * @param texture - Base texture to use.
  43418. * @returns - Boolean specifying if a texture is used in the material.
  43419. */
  43420. hasTexture(texture: BaseTexture): boolean;
  43421. /**
  43422. * Returns an array of the actively used textures.
  43423. * @param activeTextures Array of BaseTextures
  43424. */
  43425. getActiveTextures(activeTextures: BaseTexture[]): void;
  43426. /**
  43427. * Returns the animatable textures.
  43428. * @param animatables Array of animatable textures.
  43429. */
  43430. getAnimatables(animatables: IAnimatable[]): void;
  43431. /**
  43432. * Disposes the resources of the material.
  43433. * @param forceDisposeTextures - Forces the disposal of all textures.
  43434. */
  43435. dispose(forceDisposeTextures?: boolean): void;
  43436. /**
  43437. * Get the current class name of the texture useful for serialization or dynamic coding.
  43438. * @returns "PBRClearCoatConfiguration"
  43439. */
  43440. getClassName(): string;
  43441. /**
  43442. * Add fallbacks to the effect fallbacks list.
  43443. * @param defines defines the Base texture to use.
  43444. * @param fallbacks defines the current fallback list.
  43445. * @param currentRank defines the current fallback rank.
  43446. * @returns the new fallback rank.
  43447. */
  43448. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43449. /**
  43450. * Add the required uniforms to the current list.
  43451. * @param uniforms defines the current uniform list.
  43452. */
  43453. static AddUniforms(uniforms: string[]): void;
  43454. /**
  43455. * Add the required samplers to the current list.
  43456. * @param samplers defines the current sampler list.
  43457. */
  43458. static AddSamplers(samplers: string[]): void;
  43459. /**
  43460. * Add the required uniforms to the current buffer.
  43461. * @param uniformBuffer defines the current uniform buffer.
  43462. */
  43463. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43464. /**
  43465. * Makes a duplicate of the current configuration into another one.
  43466. * @param clearCoatConfiguration define the config where to copy the info
  43467. */
  43468. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43469. /**
  43470. * Serializes this clear coat configuration.
  43471. * @returns - An object with the serialized config.
  43472. */
  43473. serialize(): any;
  43474. /**
  43475. * Parses a Clear Coat Configuration from a serialized object.
  43476. * @param source - Serialized object.
  43477. */
  43478. parse(source: any): void;
  43479. }
  43480. }
  43481. declare module BABYLON {
  43482. /**
  43483. * @hidden
  43484. */
  43485. export interface IMaterialAnisotropicDefines {
  43486. ANISOTROPIC: boolean;
  43487. ANISOTROPIC_TEXTURE: boolean;
  43488. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43489. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43490. }
  43491. /**
  43492. * Define the code related to the anisotropic parameters of the pbr material.
  43493. */
  43494. export class PBRAnisotropicConfiguration {
  43495. private _isEnabled;
  43496. /**
  43497. * Defines if the anisotropy is enabled in the material.
  43498. */
  43499. isEnabled: boolean;
  43500. /**
  43501. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43502. */
  43503. intensity: number;
  43504. /**
  43505. * Defines if the effect is along the tangents, bitangents or in between.
  43506. * By default, the effect is "strectching" the highlights along the tangents.
  43507. */
  43508. direction: Vector2;
  43509. private _texture;
  43510. /**
  43511. * Stores the anisotropy values in a texture.
  43512. * rg is direction (like normal from -1 to 1)
  43513. * b is a intensity
  43514. */
  43515. texture: Nullable<BaseTexture>;
  43516. /** @hidden */
  43517. private _internalMarkAllSubMeshesAsTexturesDirty;
  43518. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43519. /**
  43520. * Instantiate a new istance of anisotropy configuration.
  43521. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43522. */
  43523. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43524. /**
  43525. * Specifies that the submesh is ready to be used.
  43526. * @param defines the list of "defines" to update.
  43527. * @param scene defines the scene the material belongs to.
  43528. * @returns - boolean indicating that the submesh is ready or not.
  43529. */
  43530. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43531. /**
  43532. * Checks to see if a texture is used in the material.
  43533. * @param defines the list of "defines" to update.
  43534. * @param mesh the mesh we are preparing the defines for.
  43535. * @param scene defines the scene the material belongs to.
  43536. */
  43537. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43538. /**
  43539. * Binds the material data.
  43540. * @param uniformBuffer defines the Uniform buffer to fill in.
  43541. * @param scene defines the scene the material belongs to.
  43542. * @param isFrozen defines wether the material is frozen or not.
  43543. */
  43544. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43545. /**
  43546. * Checks to see if a texture is used in the material.
  43547. * @param texture - Base texture to use.
  43548. * @returns - Boolean specifying if a texture is used in the material.
  43549. */
  43550. hasTexture(texture: BaseTexture): boolean;
  43551. /**
  43552. * Returns an array of the actively used textures.
  43553. * @param activeTextures Array of BaseTextures
  43554. */
  43555. getActiveTextures(activeTextures: BaseTexture[]): void;
  43556. /**
  43557. * Returns the animatable textures.
  43558. * @param animatables Array of animatable textures.
  43559. */
  43560. getAnimatables(animatables: IAnimatable[]): void;
  43561. /**
  43562. * Disposes the resources of the material.
  43563. * @param forceDisposeTextures - Forces the disposal of all textures.
  43564. */
  43565. dispose(forceDisposeTextures?: boolean): void;
  43566. /**
  43567. * Get the current class name of the texture useful for serialization or dynamic coding.
  43568. * @returns "PBRAnisotropicConfiguration"
  43569. */
  43570. getClassName(): string;
  43571. /**
  43572. * Add fallbacks to the effect fallbacks list.
  43573. * @param defines defines the Base texture to use.
  43574. * @param fallbacks defines the current fallback list.
  43575. * @param currentRank defines the current fallback rank.
  43576. * @returns the new fallback rank.
  43577. */
  43578. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43579. /**
  43580. * Add the required uniforms to the current list.
  43581. * @param uniforms defines the current uniform list.
  43582. */
  43583. static AddUniforms(uniforms: string[]): void;
  43584. /**
  43585. * Add the required uniforms to the current buffer.
  43586. * @param uniformBuffer defines the current uniform buffer.
  43587. */
  43588. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43589. /**
  43590. * Add the required samplers to the current list.
  43591. * @param samplers defines the current sampler list.
  43592. */
  43593. static AddSamplers(samplers: string[]): void;
  43594. /**
  43595. * Makes a duplicate of the current configuration into another one.
  43596. * @param anisotropicConfiguration define the config where to copy the info
  43597. */
  43598. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43599. /**
  43600. * Serializes this anisotropy configuration.
  43601. * @returns - An object with the serialized config.
  43602. */
  43603. serialize(): any;
  43604. /**
  43605. * Parses a anisotropy Configuration from a serialized object.
  43606. * @param source - Serialized object.
  43607. */
  43608. parse(source: any): void;
  43609. }
  43610. }
  43611. declare module BABYLON {
  43612. /**
  43613. * @hidden
  43614. */
  43615. export interface IMaterialBRDFDefines {
  43616. BRDF_V_HEIGHT_CORRELATED: boolean;
  43617. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43618. SPHERICAL_HARMONICS: boolean;
  43619. /** @hidden */ areMiscDirty: boolean;
  43620. }
  43621. /**
  43622. * Define the code related to the BRDF parameters of the pbr material.
  43623. */
  43624. export class PBRBRDFConfiguration {
  43625. /**
  43626. * Default value used for the energy conservation.
  43627. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43628. */
  43629. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43630. /**
  43631. * Default value used for the Smith Visibility Height Correlated mode.
  43632. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43633. */
  43634. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43635. /**
  43636. * Default value used for the IBL diffuse part.
  43637. * This can help switching back to the polynomials mode globally which is a tiny bit
  43638. * less GPU intensive at the drawback of a lower quality.
  43639. */
  43640. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  43641. private _useEnergyConservation;
  43642. /**
  43643. * Defines if the material uses energy conservation.
  43644. */
  43645. useEnergyConservation: boolean;
  43646. private _useSmithVisibilityHeightCorrelated;
  43647. /**
  43648. * LEGACY Mode set to false
  43649. * Defines if the material uses height smith correlated visibility term.
  43650. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43651. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43652. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43653. * Not relying on height correlated will also disable energy conservation.
  43654. */
  43655. useSmithVisibilityHeightCorrelated: boolean;
  43656. private _useSphericalHarmonics;
  43657. /**
  43658. * LEGACY Mode set to false
  43659. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  43660. * diffuse part of the IBL.
  43661. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  43662. * to the ground truth.
  43663. */
  43664. useSphericalHarmonics: boolean;
  43665. /** @hidden */
  43666. private _internalMarkAllSubMeshesAsMiscDirty;
  43667. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43668. /**
  43669. * Instantiate a new istance of clear coat configuration.
  43670. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43671. */
  43672. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43673. /**
  43674. * Checks to see if a texture is used in the material.
  43675. * @param defines the list of "defines" to update.
  43676. */
  43677. prepareDefines(defines: IMaterialBRDFDefines): void;
  43678. /**
  43679. * Get the current class name of the texture useful for serialization or dynamic coding.
  43680. * @returns "PBRClearCoatConfiguration"
  43681. */
  43682. getClassName(): string;
  43683. /**
  43684. * Makes a duplicate of the current configuration into another one.
  43685. * @param brdfConfiguration define the config where to copy the info
  43686. */
  43687. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43688. /**
  43689. * Serializes this BRDF configuration.
  43690. * @returns - An object with the serialized config.
  43691. */
  43692. serialize(): any;
  43693. /**
  43694. * Parses a BRDF Configuration from a serialized object.
  43695. * @param source - Serialized object.
  43696. */
  43697. parse(source: any): void;
  43698. }
  43699. }
  43700. declare module BABYLON {
  43701. /**
  43702. * @hidden
  43703. */
  43704. export interface IMaterialSheenDefines {
  43705. SHEEN: boolean;
  43706. SHEEN_TEXTURE: boolean;
  43707. SHEEN_TEXTUREDIRECTUV: number;
  43708. SHEEN_LINKWITHALBEDO: boolean;
  43709. /** @hidden */ areTexturesDirty: boolean;
  43710. }
  43711. /**
  43712. * Define the code related to the Sheen parameters of the pbr material.
  43713. */
  43714. export class PBRSheenConfiguration {
  43715. private _isEnabled;
  43716. /**
  43717. * Defines if the material uses sheen.
  43718. */
  43719. isEnabled: boolean;
  43720. private _linkSheenWithAlbedo;
  43721. /**
  43722. * Defines if the sheen is linked to the sheen color.
  43723. */
  43724. linkSheenWithAlbedo: boolean;
  43725. /**
  43726. * Defines the sheen intensity.
  43727. */
  43728. intensity: number;
  43729. /**
  43730. * Defines the sheen color.
  43731. */
  43732. color: Color3;
  43733. private _texture;
  43734. /**
  43735. * Stores the sheen tint values in a texture.
  43736. * rgb is tint
  43737. * a is a intensity
  43738. */
  43739. texture: Nullable<BaseTexture>;
  43740. /** @hidden */
  43741. private _internalMarkAllSubMeshesAsTexturesDirty;
  43742. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43743. /**
  43744. * Instantiate a new istance of clear coat configuration.
  43745. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43746. */
  43747. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43748. /**
  43749. * Specifies that the submesh is ready to be used.
  43750. * @param defines the list of "defines" to update.
  43751. * @param scene defines the scene the material belongs to.
  43752. * @returns - boolean indicating that the submesh is ready or not.
  43753. */
  43754. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43755. /**
  43756. * Checks to see if a texture is used in the material.
  43757. * @param defines the list of "defines" to update.
  43758. * @param scene defines the scene the material belongs to.
  43759. */
  43760. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43761. /**
  43762. * Binds the material data.
  43763. * @param uniformBuffer defines the Uniform buffer to fill in.
  43764. * @param scene defines the scene the material belongs to.
  43765. * @param isFrozen defines wether the material is frozen or not.
  43766. */
  43767. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43768. /**
  43769. * Checks to see if a texture is used in the material.
  43770. * @param texture - Base texture to use.
  43771. * @returns - Boolean specifying if a texture is used in the material.
  43772. */
  43773. hasTexture(texture: BaseTexture): boolean;
  43774. /**
  43775. * Returns an array of the actively used textures.
  43776. * @param activeTextures Array of BaseTextures
  43777. */
  43778. getActiveTextures(activeTextures: BaseTexture[]): void;
  43779. /**
  43780. * Returns the animatable textures.
  43781. * @param animatables Array of animatable textures.
  43782. */
  43783. getAnimatables(animatables: IAnimatable[]): void;
  43784. /**
  43785. * Disposes the resources of the material.
  43786. * @param forceDisposeTextures - Forces the disposal of all textures.
  43787. */
  43788. dispose(forceDisposeTextures?: boolean): void;
  43789. /**
  43790. * Get the current class name of the texture useful for serialization or dynamic coding.
  43791. * @returns "PBRSheenConfiguration"
  43792. */
  43793. getClassName(): string;
  43794. /**
  43795. * Add fallbacks to the effect fallbacks list.
  43796. * @param defines defines the Base texture to use.
  43797. * @param fallbacks defines the current fallback list.
  43798. * @param currentRank defines the current fallback rank.
  43799. * @returns the new fallback rank.
  43800. */
  43801. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43802. /**
  43803. * Add the required uniforms to the current list.
  43804. * @param uniforms defines the current uniform list.
  43805. */
  43806. static AddUniforms(uniforms: string[]): void;
  43807. /**
  43808. * Add the required uniforms to the current buffer.
  43809. * @param uniformBuffer defines the current uniform buffer.
  43810. */
  43811. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43812. /**
  43813. * Add the required samplers to the current list.
  43814. * @param samplers defines the current sampler list.
  43815. */
  43816. static AddSamplers(samplers: string[]): void;
  43817. /**
  43818. * Makes a duplicate of the current configuration into another one.
  43819. * @param sheenConfiguration define the config where to copy the info
  43820. */
  43821. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43822. /**
  43823. * Serializes this BRDF configuration.
  43824. * @returns - An object with the serialized config.
  43825. */
  43826. serialize(): any;
  43827. /**
  43828. * Parses a Sheen Configuration from a serialized object.
  43829. * @param source - Serialized object.
  43830. */
  43831. parse(source: any): void;
  43832. }
  43833. }
  43834. declare module BABYLON {
  43835. /**
  43836. * @hidden
  43837. */
  43838. export interface IMaterialSubSurfaceDefines {
  43839. SUBSURFACE: boolean;
  43840. SS_REFRACTION: boolean;
  43841. SS_TRANSLUCENCY: boolean;
  43842. SS_SCATERRING: boolean;
  43843. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43844. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43845. SS_REFRACTIONMAP_3D: boolean;
  43846. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43847. SS_LODINREFRACTIONALPHA: boolean;
  43848. SS_GAMMAREFRACTION: boolean;
  43849. SS_RGBDREFRACTION: boolean;
  43850. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43851. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43852. /** @hidden */ areTexturesDirty: boolean;
  43853. }
  43854. /**
  43855. * Define the code related to the sub surface parameters of the pbr material.
  43856. */
  43857. export class PBRSubSurfaceConfiguration {
  43858. private _isRefractionEnabled;
  43859. /**
  43860. * Defines if the refraction is enabled in the material.
  43861. */
  43862. isRefractionEnabled: boolean;
  43863. private _isTranslucencyEnabled;
  43864. /**
  43865. * Defines if the translucency is enabled in the material.
  43866. */
  43867. isTranslucencyEnabled: boolean;
  43868. private _isScatteringEnabled;
  43869. /**
  43870. * Defines the refraction intensity of the material.
  43871. * The refraction when enabled replaces the Diffuse part of the material.
  43872. * The intensity helps transitionning between diffuse and refraction.
  43873. */
  43874. refractionIntensity: number;
  43875. /**
  43876. * Defines the translucency intensity of the material.
  43877. * When translucency has been enabled, this defines how much of the "translucency"
  43878. * is addded to the diffuse part of the material.
  43879. */
  43880. translucencyIntensity: number;
  43881. /**
  43882. * Defines the scattering intensity of the material.
  43883. * When scattering has been enabled, this defines how much of the "scattered light"
  43884. * is addded to the diffuse part of the material.
  43885. */
  43886. scatteringIntensity: number;
  43887. private _thicknessTexture;
  43888. /**
  43889. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43890. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43891. * 0 would mean minimumThickness
  43892. * 1 would mean maximumThickness
  43893. * The other channels might be use as a mask to vary the different effects intensity.
  43894. */
  43895. thicknessTexture: Nullable<BaseTexture>;
  43896. private _refractionTexture;
  43897. /**
  43898. * Defines the texture to use for refraction.
  43899. */
  43900. refractionTexture: Nullable<BaseTexture>;
  43901. private _indexOfRefraction;
  43902. /**
  43903. * Defines the indice of refraction used in the material.
  43904. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43905. */
  43906. indexOfRefraction: number;
  43907. private _invertRefractionY;
  43908. /**
  43909. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43910. */
  43911. invertRefractionY: boolean;
  43912. private _linkRefractionWithTransparency;
  43913. /**
  43914. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43915. * Materials half opaque for instance using refraction could benefit from this control.
  43916. */
  43917. linkRefractionWithTransparency: boolean;
  43918. /**
  43919. * Defines the minimum thickness stored in the thickness map.
  43920. * If no thickness map is defined, this value will be used to simulate thickness.
  43921. */
  43922. minimumThickness: number;
  43923. /**
  43924. * Defines the maximum thickness stored in the thickness map.
  43925. */
  43926. maximumThickness: number;
  43927. /**
  43928. * Defines the volume tint of the material.
  43929. * This is used for both translucency and scattering.
  43930. */
  43931. tintColor: Color3;
  43932. /**
  43933. * Defines the distance at which the tint color should be found in the media.
  43934. * This is used for refraction only.
  43935. */
  43936. tintColorAtDistance: number;
  43937. /**
  43938. * Defines how far each channel transmit through the media.
  43939. * It is defined as a color to simplify it selection.
  43940. */
  43941. diffusionDistance: Color3;
  43942. private _useMaskFromThicknessTexture;
  43943. /**
  43944. * Stores the intensity of the different subsurface effects in the thickness texture.
  43945. * * the green channel is the translucency intensity.
  43946. * * the blue channel is the scattering intensity.
  43947. * * the alpha channel is the refraction intensity.
  43948. */
  43949. useMaskFromThicknessTexture: boolean;
  43950. /** @hidden */
  43951. private _internalMarkAllSubMeshesAsTexturesDirty;
  43952. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43953. /**
  43954. * Instantiate a new istance of sub surface configuration.
  43955. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43956. */
  43957. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43958. /**
  43959. * Gets wehter the submesh is ready to be used or not.
  43960. * @param defines the list of "defines" to update.
  43961. * @param scene defines the scene the material belongs to.
  43962. * @returns - boolean indicating that the submesh is ready or not.
  43963. */
  43964. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  43965. /**
  43966. * Checks to see if a texture is used in the material.
  43967. * @param defines the list of "defines" to update.
  43968. * @param scene defines the scene to the material belongs to.
  43969. */
  43970. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  43971. /**
  43972. * Binds the material data.
  43973. * @param uniformBuffer defines the Uniform buffer to fill in.
  43974. * @param scene defines the scene the material belongs to.
  43975. * @param engine defines the engine the material belongs to.
  43976. * @param isFrozen defines wether the material is frozen or not.
  43977. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  43978. */
  43979. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  43980. /**
  43981. * Unbinds the material from the mesh.
  43982. * @param activeEffect defines the effect that should be unbound from.
  43983. * @returns true if unbound, otherwise false
  43984. */
  43985. unbind(activeEffect: Effect): boolean;
  43986. /**
  43987. * Returns the texture used for refraction or null if none is used.
  43988. * @param scene defines the scene the material belongs to.
  43989. * @returns - Refraction texture if present. If no refraction texture and refraction
  43990. * is linked with transparency, returns environment texture. Otherwise, returns null.
  43991. */
  43992. private _getRefractionTexture;
  43993. /**
  43994. * Returns true if alpha blending should be disabled.
  43995. */
  43996. readonly disableAlphaBlending: boolean;
  43997. /**
  43998. * Fills the list of render target textures.
  43999. * @param renderTargets the list of render targets to update
  44000. */
  44001. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44002. /**
  44003. * Checks to see if a texture is used in the material.
  44004. * @param texture - Base texture to use.
  44005. * @returns - Boolean specifying if a texture is used in the material.
  44006. */
  44007. hasTexture(texture: BaseTexture): boolean;
  44008. /**
  44009. * Gets a boolean indicating that current material needs to register RTT
  44010. * @returns true if this uses a render target otherwise false.
  44011. */
  44012. hasRenderTargetTextures(): boolean;
  44013. /**
  44014. * Returns an array of the actively used textures.
  44015. * @param activeTextures Array of BaseTextures
  44016. */
  44017. getActiveTextures(activeTextures: BaseTexture[]): void;
  44018. /**
  44019. * Returns the animatable textures.
  44020. * @param animatables Array of animatable textures.
  44021. */
  44022. getAnimatables(animatables: IAnimatable[]): void;
  44023. /**
  44024. * Disposes the resources of the material.
  44025. * @param forceDisposeTextures - Forces the disposal of all textures.
  44026. */
  44027. dispose(forceDisposeTextures?: boolean): void;
  44028. /**
  44029. * Get the current class name of the texture useful for serialization or dynamic coding.
  44030. * @returns "PBRSubSurfaceConfiguration"
  44031. */
  44032. getClassName(): string;
  44033. /**
  44034. * Add fallbacks to the effect fallbacks list.
  44035. * @param defines defines the Base texture to use.
  44036. * @param fallbacks defines the current fallback list.
  44037. * @param currentRank defines the current fallback rank.
  44038. * @returns the new fallback rank.
  44039. */
  44040. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44041. /**
  44042. * Add the required uniforms to the current list.
  44043. * @param uniforms defines the current uniform list.
  44044. */
  44045. static AddUniforms(uniforms: string[]): void;
  44046. /**
  44047. * Add the required samplers to the current list.
  44048. * @param samplers defines the current sampler list.
  44049. */
  44050. static AddSamplers(samplers: string[]): void;
  44051. /**
  44052. * Add the required uniforms to the current buffer.
  44053. * @param uniformBuffer defines the current uniform buffer.
  44054. */
  44055. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44056. /**
  44057. * Makes a duplicate of the current configuration into another one.
  44058. * @param configuration define the config where to copy the info
  44059. */
  44060. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44061. /**
  44062. * Serializes this Sub Surface configuration.
  44063. * @returns - An object with the serialized config.
  44064. */
  44065. serialize(): any;
  44066. /**
  44067. * Parses a Sub Surface Configuration from a serialized object.
  44068. * @param source - Serialized object.
  44069. */
  44070. parse(source: any): void;
  44071. }
  44072. }
  44073. declare module BABYLON {
  44074. /** @hidden */
  44075. export var pbrFragmentDeclaration: {
  44076. name: string;
  44077. shader: string;
  44078. };
  44079. }
  44080. declare module BABYLON {
  44081. /** @hidden */
  44082. export var pbrUboDeclaration: {
  44083. name: string;
  44084. shader: string;
  44085. };
  44086. }
  44087. declare module BABYLON {
  44088. /** @hidden */
  44089. export var pbrFragmentExtraDeclaration: {
  44090. name: string;
  44091. shader: string;
  44092. };
  44093. }
  44094. declare module BABYLON {
  44095. /** @hidden */
  44096. export var pbrFragmentSamplersDeclaration: {
  44097. name: string;
  44098. shader: string;
  44099. };
  44100. }
  44101. declare module BABYLON {
  44102. /** @hidden */
  44103. export var pbrHelperFunctions: {
  44104. name: string;
  44105. shader: string;
  44106. };
  44107. }
  44108. declare module BABYLON {
  44109. /** @hidden */
  44110. export var harmonicsFunctions: {
  44111. name: string;
  44112. shader: string;
  44113. };
  44114. }
  44115. declare module BABYLON {
  44116. /** @hidden */
  44117. export var pbrDirectLightingSetupFunctions: {
  44118. name: string;
  44119. shader: string;
  44120. };
  44121. }
  44122. declare module BABYLON {
  44123. /** @hidden */
  44124. export var pbrDirectLightingFalloffFunctions: {
  44125. name: string;
  44126. shader: string;
  44127. };
  44128. }
  44129. declare module BABYLON {
  44130. /** @hidden */
  44131. export var pbrBRDFFunctions: {
  44132. name: string;
  44133. shader: string;
  44134. };
  44135. }
  44136. declare module BABYLON {
  44137. /** @hidden */
  44138. export var pbrDirectLightingFunctions: {
  44139. name: string;
  44140. shader: string;
  44141. };
  44142. }
  44143. declare module BABYLON {
  44144. /** @hidden */
  44145. export var pbrIBLFunctions: {
  44146. name: string;
  44147. shader: string;
  44148. };
  44149. }
  44150. declare module BABYLON {
  44151. /** @hidden */
  44152. export var pbrDebug: {
  44153. name: string;
  44154. shader: string;
  44155. };
  44156. }
  44157. declare module BABYLON {
  44158. /** @hidden */
  44159. export var pbrPixelShader: {
  44160. name: string;
  44161. shader: string;
  44162. };
  44163. }
  44164. declare module BABYLON {
  44165. /** @hidden */
  44166. export var pbrVertexDeclaration: {
  44167. name: string;
  44168. shader: string;
  44169. };
  44170. }
  44171. declare module BABYLON {
  44172. /** @hidden */
  44173. export var pbrVertexShader: {
  44174. name: string;
  44175. shader: string;
  44176. };
  44177. }
  44178. declare module BABYLON {
  44179. /**
  44180. * Manages the defines for the PBR Material.
  44181. * @hidden
  44182. */
  44183. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44184. PBR: boolean;
  44185. MAINUV1: boolean;
  44186. MAINUV2: boolean;
  44187. UV1: boolean;
  44188. UV2: boolean;
  44189. ALBEDO: boolean;
  44190. ALBEDODIRECTUV: number;
  44191. VERTEXCOLOR: boolean;
  44192. AMBIENT: boolean;
  44193. AMBIENTDIRECTUV: number;
  44194. AMBIENTINGRAYSCALE: boolean;
  44195. OPACITY: boolean;
  44196. VERTEXALPHA: boolean;
  44197. OPACITYDIRECTUV: number;
  44198. OPACITYRGB: boolean;
  44199. ALPHATEST: boolean;
  44200. DEPTHPREPASS: boolean;
  44201. ALPHABLEND: boolean;
  44202. ALPHAFROMALBEDO: boolean;
  44203. ALPHATESTVALUE: string;
  44204. SPECULAROVERALPHA: boolean;
  44205. RADIANCEOVERALPHA: boolean;
  44206. ALPHAFRESNEL: boolean;
  44207. LINEARALPHAFRESNEL: boolean;
  44208. PREMULTIPLYALPHA: boolean;
  44209. EMISSIVE: boolean;
  44210. EMISSIVEDIRECTUV: number;
  44211. REFLECTIVITY: boolean;
  44212. REFLECTIVITYDIRECTUV: number;
  44213. SPECULARTERM: boolean;
  44214. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44215. MICROSURFACEAUTOMATIC: boolean;
  44216. LODBASEDMICROSFURACE: boolean;
  44217. MICROSURFACEMAP: boolean;
  44218. MICROSURFACEMAPDIRECTUV: number;
  44219. METALLICWORKFLOW: boolean;
  44220. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44221. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44222. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44223. AOSTOREINMETALMAPRED: boolean;
  44224. ENVIRONMENTBRDF: boolean;
  44225. ENVIRONMENTBRDF_RGBD: boolean;
  44226. NORMAL: boolean;
  44227. TANGENT: boolean;
  44228. BUMP: boolean;
  44229. BUMPDIRECTUV: number;
  44230. OBJECTSPACE_NORMALMAP: boolean;
  44231. PARALLAX: boolean;
  44232. PARALLAXOCCLUSION: boolean;
  44233. NORMALXYSCALE: boolean;
  44234. LIGHTMAP: boolean;
  44235. LIGHTMAPDIRECTUV: number;
  44236. USELIGHTMAPASSHADOWMAP: boolean;
  44237. GAMMALIGHTMAP: boolean;
  44238. REFLECTION: boolean;
  44239. REFLECTIONMAP_3D: boolean;
  44240. REFLECTIONMAP_SPHERICAL: boolean;
  44241. REFLECTIONMAP_PLANAR: boolean;
  44242. REFLECTIONMAP_CUBIC: boolean;
  44243. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44244. REFLECTIONMAP_PROJECTION: boolean;
  44245. REFLECTIONMAP_SKYBOX: boolean;
  44246. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44247. REFLECTIONMAP_EXPLICIT: boolean;
  44248. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44249. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44250. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44251. INVERTCUBICMAP: boolean;
  44252. USESPHERICALFROMREFLECTIONMAP: boolean;
  44253. SPHERICAL_HARMONICS: boolean;
  44254. USESPHERICALINVERTEX: boolean;
  44255. REFLECTIONMAP_OPPOSITEZ: boolean;
  44256. LODINREFLECTIONALPHA: boolean;
  44257. GAMMAREFLECTION: boolean;
  44258. RGBDREFLECTION: boolean;
  44259. RADIANCEOCCLUSION: boolean;
  44260. HORIZONOCCLUSION: boolean;
  44261. INSTANCES: boolean;
  44262. NUM_BONE_INFLUENCERS: number;
  44263. BonesPerMesh: number;
  44264. BONETEXTURE: boolean;
  44265. NONUNIFORMSCALING: boolean;
  44266. MORPHTARGETS: boolean;
  44267. MORPHTARGETS_NORMAL: boolean;
  44268. MORPHTARGETS_TANGENT: boolean;
  44269. NUM_MORPH_INFLUENCERS: number;
  44270. IMAGEPROCESSING: boolean;
  44271. VIGNETTE: boolean;
  44272. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44273. VIGNETTEBLENDMODEOPAQUE: boolean;
  44274. TONEMAPPING: boolean;
  44275. TONEMAPPING_ACES: boolean;
  44276. CONTRAST: boolean;
  44277. COLORCURVES: boolean;
  44278. COLORGRADING: boolean;
  44279. COLORGRADING3D: boolean;
  44280. SAMPLER3DGREENDEPTH: boolean;
  44281. SAMPLER3DBGRMAP: boolean;
  44282. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44283. EXPOSURE: boolean;
  44284. MULTIVIEW: boolean;
  44285. USEPHYSICALLIGHTFALLOFF: boolean;
  44286. USEGLTFLIGHTFALLOFF: boolean;
  44287. TWOSIDEDLIGHTING: boolean;
  44288. SHADOWFLOAT: boolean;
  44289. CLIPPLANE: boolean;
  44290. CLIPPLANE2: boolean;
  44291. CLIPPLANE3: boolean;
  44292. CLIPPLANE4: boolean;
  44293. POINTSIZE: boolean;
  44294. FOG: boolean;
  44295. LOGARITHMICDEPTH: boolean;
  44296. FORCENORMALFORWARD: boolean;
  44297. SPECULARAA: boolean;
  44298. CLEARCOAT: boolean;
  44299. CLEARCOAT_DEFAULTIOR: boolean;
  44300. CLEARCOAT_TEXTURE: boolean;
  44301. CLEARCOAT_TEXTUREDIRECTUV: number;
  44302. CLEARCOAT_BUMP: boolean;
  44303. CLEARCOAT_BUMPDIRECTUV: number;
  44304. CLEARCOAT_TINT: boolean;
  44305. CLEARCOAT_TINT_TEXTURE: boolean;
  44306. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44307. ANISOTROPIC: boolean;
  44308. ANISOTROPIC_TEXTURE: boolean;
  44309. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44310. BRDF_V_HEIGHT_CORRELATED: boolean;
  44311. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44312. SHEEN: boolean;
  44313. SHEEN_TEXTURE: boolean;
  44314. SHEEN_TEXTUREDIRECTUV: number;
  44315. SHEEN_LINKWITHALBEDO: boolean;
  44316. SUBSURFACE: boolean;
  44317. SS_REFRACTION: boolean;
  44318. SS_TRANSLUCENCY: boolean;
  44319. SS_SCATERRING: boolean;
  44320. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44321. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44322. SS_REFRACTIONMAP_3D: boolean;
  44323. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44324. SS_LODINREFRACTIONALPHA: boolean;
  44325. SS_GAMMAREFRACTION: boolean;
  44326. SS_RGBDREFRACTION: boolean;
  44327. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44328. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44329. UNLIT: boolean;
  44330. DEBUGMODE: number;
  44331. /**
  44332. * Initializes the PBR Material defines.
  44333. */
  44334. constructor();
  44335. /**
  44336. * Resets the PBR Material defines.
  44337. */
  44338. reset(): void;
  44339. }
  44340. /**
  44341. * The Physically based material base class of BJS.
  44342. *
  44343. * This offers the main features of a standard PBR material.
  44344. * For more information, please refer to the documentation :
  44345. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44346. */
  44347. export abstract class PBRBaseMaterial extends PushMaterial {
  44348. /**
  44349. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44350. */
  44351. static readonly PBRMATERIAL_OPAQUE: number;
  44352. /**
  44353. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44354. */
  44355. static readonly PBRMATERIAL_ALPHATEST: number;
  44356. /**
  44357. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44358. */
  44359. static readonly PBRMATERIAL_ALPHABLEND: number;
  44360. /**
  44361. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44362. * They are also discarded below the alpha cutoff threshold to improve performances.
  44363. */
  44364. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44365. /**
  44366. * Defines the default value of how much AO map is occluding the analytical lights
  44367. * (point spot...).
  44368. */
  44369. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44370. /**
  44371. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44372. */
  44373. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44374. /**
  44375. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44376. * to enhance interoperability with other engines.
  44377. */
  44378. static readonly LIGHTFALLOFF_GLTF: number;
  44379. /**
  44380. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44381. * to enhance interoperability with other materials.
  44382. */
  44383. static readonly LIGHTFALLOFF_STANDARD: number;
  44384. /**
  44385. * Intensity of the direct lights e.g. the four lights available in your scene.
  44386. * This impacts both the direct diffuse and specular highlights.
  44387. */
  44388. protected _directIntensity: number;
  44389. /**
  44390. * Intensity of the emissive part of the material.
  44391. * This helps controlling the emissive effect without modifying the emissive color.
  44392. */
  44393. protected _emissiveIntensity: number;
  44394. /**
  44395. * Intensity of the environment e.g. how much the environment will light the object
  44396. * either through harmonics for rough material or through the refelction for shiny ones.
  44397. */
  44398. protected _environmentIntensity: number;
  44399. /**
  44400. * This is a special control allowing the reduction of the specular highlights coming from the
  44401. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44402. */
  44403. protected _specularIntensity: number;
  44404. /**
  44405. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44406. */
  44407. private _lightingInfos;
  44408. /**
  44409. * Debug Control allowing disabling the bump map on this material.
  44410. */
  44411. protected _disableBumpMap: boolean;
  44412. /**
  44413. * AKA Diffuse Texture in standard nomenclature.
  44414. */
  44415. protected _albedoTexture: Nullable<BaseTexture>;
  44416. /**
  44417. * AKA Occlusion Texture in other nomenclature.
  44418. */
  44419. protected _ambientTexture: Nullable<BaseTexture>;
  44420. /**
  44421. * AKA Occlusion Texture Intensity in other nomenclature.
  44422. */
  44423. protected _ambientTextureStrength: number;
  44424. /**
  44425. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44426. * 1 means it completely occludes it
  44427. * 0 mean it has no impact
  44428. */
  44429. protected _ambientTextureImpactOnAnalyticalLights: number;
  44430. /**
  44431. * Stores the alpha values in a texture.
  44432. */
  44433. protected _opacityTexture: Nullable<BaseTexture>;
  44434. /**
  44435. * Stores the reflection values in a texture.
  44436. */
  44437. protected _reflectionTexture: Nullable<BaseTexture>;
  44438. /**
  44439. * Stores the emissive values in a texture.
  44440. */
  44441. protected _emissiveTexture: Nullable<BaseTexture>;
  44442. /**
  44443. * AKA Specular texture in other nomenclature.
  44444. */
  44445. protected _reflectivityTexture: Nullable<BaseTexture>;
  44446. /**
  44447. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44448. */
  44449. protected _metallicTexture: Nullable<BaseTexture>;
  44450. /**
  44451. * Specifies the metallic scalar of the metallic/roughness workflow.
  44452. * Can also be used to scale the metalness values of the metallic texture.
  44453. */
  44454. protected _metallic: Nullable<number>;
  44455. /**
  44456. * Specifies the roughness scalar of the metallic/roughness workflow.
  44457. * Can also be used to scale the roughness values of the metallic texture.
  44458. */
  44459. protected _roughness: Nullable<number>;
  44460. /**
  44461. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44462. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44463. */
  44464. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44465. /**
  44466. * Stores surface normal data used to displace a mesh in a texture.
  44467. */
  44468. protected _bumpTexture: Nullable<BaseTexture>;
  44469. /**
  44470. * Stores the pre-calculated light information of a mesh in a texture.
  44471. */
  44472. protected _lightmapTexture: Nullable<BaseTexture>;
  44473. /**
  44474. * The color of a material in ambient lighting.
  44475. */
  44476. protected _ambientColor: Color3;
  44477. /**
  44478. * AKA Diffuse Color in other nomenclature.
  44479. */
  44480. protected _albedoColor: Color3;
  44481. /**
  44482. * AKA Specular Color in other nomenclature.
  44483. */
  44484. protected _reflectivityColor: Color3;
  44485. /**
  44486. * The color applied when light is reflected from a material.
  44487. */
  44488. protected _reflectionColor: Color3;
  44489. /**
  44490. * The color applied when light is emitted from a material.
  44491. */
  44492. protected _emissiveColor: Color3;
  44493. /**
  44494. * AKA Glossiness in other nomenclature.
  44495. */
  44496. protected _microSurface: number;
  44497. /**
  44498. * Specifies that the material will use the light map as a show map.
  44499. */
  44500. protected _useLightmapAsShadowmap: boolean;
  44501. /**
  44502. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44503. * makes the reflect vector face the model (under horizon).
  44504. */
  44505. protected _useHorizonOcclusion: boolean;
  44506. /**
  44507. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44508. * too much the area relying on ambient texture to define their ambient occlusion.
  44509. */
  44510. protected _useRadianceOcclusion: boolean;
  44511. /**
  44512. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44513. */
  44514. protected _useAlphaFromAlbedoTexture: boolean;
  44515. /**
  44516. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44517. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44518. */
  44519. protected _useSpecularOverAlpha: boolean;
  44520. /**
  44521. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44522. */
  44523. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44524. /**
  44525. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44526. */
  44527. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44528. /**
  44529. * Specifies if the metallic texture contains the roughness information in its green channel.
  44530. */
  44531. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44532. /**
  44533. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44534. */
  44535. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44536. /**
  44537. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44538. */
  44539. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44540. /**
  44541. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44542. */
  44543. protected _useAmbientInGrayScale: boolean;
  44544. /**
  44545. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44546. * The material will try to infer what glossiness each pixel should be.
  44547. */
  44548. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44549. /**
  44550. * Defines the falloff type used in this material.
  44551. * It by default is Physical.
  44552. */
  44553. protected _lightFalloff: number;
  44554. /**
  44555. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44556. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44557. */
  44558. protected _useRadianceOverAlpha: boolean;
  44559. /**
  44560. * Allows using an object space normal map (instead of tangent space).
  44561. */
  44562. protected _useObjectSpaceNormalMap: boolean;
  44563. /**
  44564. * Allows using the bump map in parallax mode.
  44565. */
  44566. protected _useParallax: boolean;
  44567. /**
  44568. * Allows using the bump map in parallax occlusion mode.
  44569. */
  44570. protected _useParallaxOcclusion: boolean;
  44571. /**
  44572. * Controls the scale bias of the parallax mode.
  44573. */
  44574. protected _parallaxScaleBias: number;
  44575. /**
  44576. * If sets to true, disables all the lights affecting the material.
  44577. */
  44578. protected _disableLighting: boolean;
  44579. /**
  44580. * Number of Simultaneous lights allowed on the material.
  44581. */
  44582. protected _maxSimultaneousLights: number;
  44583. /**
  44584. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44585. */
  44586. protected _invertNormalMapX: boolean;
  44587. /**
  44588. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44589. */
  44590. protected _invertNormalMapY: boolean;
  44591. /**
  44592. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44593. */
  44594. protected _twoSidedLighting: boolean;
  44595. /**
  44596. * Defines the alpha limits in alpha test mode.
  44597. */
  44598. protected _alphaCutOff: number;
  44599. /**
  44600. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44601. */
  44602. protected _forceAlphaTest: boolean;
  44603. /**
  44604. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44605. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44606. */
  44607. protected _useAlphaFresnel: boolean;
  44608. /**
  44609. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44610. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44611. */
  44612. protected _useLinearAlphaFresnel: boolean;
  44613. /**
  44614. * The transparency mode of the material.
  44615. */
  44616. protected _transparencyMode: Nullable<number>;
  44617. /**
  44618. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44619. * from cos thetav and roughness:
  44620. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44621. */
  44622. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44623. /**
  44624. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44625. */
  44626. protected _forceIrradianceInFragment: boolean;
  44627. /**
  44628. * Force normal to face away from face.
  44629. */
  44630. protected _forceNormalForward: boolean;
  44631. /**
  44632. * Enables specular anti aliasing in the PBR shader.
  44633. * It will both interacts on the Geometry for analytical and IBL lighting.
  44634. * It also prefilter the roughness map based on the bump values.
  44635. */
  44636. protected _enableSpecularAntiAliasing: boolean;
  44637. /**
  44638. * Default configuration related to image processing available in the PBR Material.
  44639. */
  44640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44641. /**
  44642. * Keep track of the image processing observer to allow dispose and replace.
  44643. */
  44644. private _imageProcessingObserver;
  44645. /**
  44646. * Attaches a new image processing configuration to the PBR Material.
  44647. * @param configuration
  44648. */
  44649. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44650. /**
  44651. * Stores the available render targets.
  44652. */
  44653. private _renderTargets;
  44654. /**
  44655. * Sets the global ambient color for the material used in lighting calculations.
  44656. */
  44657. private _globalAmbientColor;
  44658. /**
  44659. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44660. */
  44661. private _useLogarithmicDepth;
  44662. /**
  44663. * If set to true, no lighting calculations will be applied.
  44664. */
  44665. private _unlit;
  44666. private _debugMode;
  44667. /**
  44668. * @hidden
  44669. * This is reserved for the inspector.
  44670. * Defines the material debug mode.
  44671. * It helps seeing only some components of the material while troubleshooting.
  44672. */
  44673. debugMode: number;
  44674. /**
  44675. * @hidden
  44676. * This is reserved for the inspector.
  44677. * Specify from where on screen the debug mode should start.
  44678. * The value goes from -1 (full screen) to 1 (not visible)
  44679. * It helps with side by side comparison against the final render
  44680. * This defaults to -1
  44681. */
  44682. private debugLimit;
  44683. /**
  44684. * @hidden
  44685. * This is reserved for the inspector.
  44686. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44687. * You can use the factor to better multiply the final value.
  44688. */
  44689. private debugFactor;
  44690. /**
  44691. * Defines the clear coat layer parameters for the material.
  44692. */
  44693. readonly clearCoat: PBRClearCoatConfiguration;
  44694. /**
  44695. * Defines the anisotropic parameters for the material.
  44696. */
  44697. readonly anisotropy: PBRAnisotropicConfiguration;
  44698. /**
  44699. * Defines the BRDF parameters for the material.
  44700. */
  44701. readonly brdf: PBRBRDFConfiguration;
  44702. /**
  44703. * Defines the Sheen parameters for the material.
  44704. */
  44705. readonly sheen: PBRSheenConfiguration;
  44706. /**
  44707. * Defines the SubSurface parameters for the material.
  44708. */
  44709. readonly subSurface: PBRSubSurfaceConfiguration;
  44710. /**
  44711. * Custom callback helping to override the default shader used in the material.
  44712. */
  44713. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44714. /**
  44715. * Instantiates a new PBRMaterial instance.
  44716. *
  44717. * @param name The material name
  44718. * @param scene The scene the material will be use in.
  44719. */
  44720. constructor(name: string, scene: Scene);
  44721. /**
  44722. * Gets a boolean indicating that current material needs to register RTT
  44723. */
  44724. readonly hasRenderTargetTextures: boolean;
  44725. /**
  44726. * Gets the name of the material class.
  44727. */
  44728. getClassName(): string;
  44729. /**
  44730. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44731. */
  44732. /**
  44733. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44734. */
  44735. useLogarithmicDepth: boolean;
  44736. /**
  44737. * Gets the current transparency mode.
  44738. */
  44739. /**
  44740. * Sets the transparency mode of the material.
  44741. *
  44742. * | Value | Type | Description |
  44743. * | ----- | ----------------------------------- | ----------- |
  44744. * | 0 | OPAQUE | |
  44745. * | 1 | ALPHATEST | |
  44746. * | 2 | ALPHABLEND | |
  44747. * | 3 | ALPHATESTANDBLEND | |
  44748. *
  44749. */
  44750. transparencyMode: Nullable<number>;
  44751. /**
  44752. * Returns true if alpha blending should be disabled.
  44753. */
  44754. private readonly _disableAlphaBlending;
  44755. /**
  44756. * Specifies whether or not this material should be rendered in alpha blend mode.
  44757. */
  44758. needAlphaBlending(): boolean;
  44759. /**
  44760. * Specifies if the mesh will require alpha blending.
  44761. * @param mesh - BJS mesh.
  44762. */
  44763. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44764. /**
  44765. * Specifies whether or not this material should be rendered in alpha test mode.
  44766. */
  44767. needAlphaTesting(): boolean;
  44768. /**
  44769. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44770. */
  44771. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44772. /**
  44773. * Gets the texture used for the alpha test.
  44774. */
  44775. getAlphaTestTexture(): Nullable<BaseTexture>;
  44776. /**
  44777. * Specifies that the submesh is ready to be used.
  44778. * @param mesh - BJS mesh.
  44779. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44780. * @param useInstances - Specifies that instances should be used.
  44781. * @returns - boolean indicating that the submesh is ready or not.
  44782. */
  44783. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44784. /**
  44785. * Specifies if the material uses metallic roughness workflow.
  44786. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44787. */
  44788. isMetallicWorkflow(): boolean;
  44789. private _prepareEffect;
  44790. private _prepareDefines;
  44791. /**
  44792. * Force shader compilation
  44793. */
  44794. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44795. clipPlane: boolean;
  44796. }>): void;
  44797. /**
  44798. * Initializes the uniform buffer layout for the shader.
  44799. */
  44800. buildUniformLayout(): void;
  44801. /**
  44802. * Unbinds the material from the mesh
  44803. */
  44804. unbind(): void;
  44805. /**
  44806. * Binds the submesh data.
  44807. * @param world - The world matrix.
  44808. * @param mesh - The BJS mesh.
  44809. * @param subMesh - A submesh of the BJS mesh.
  44810. */
  44811. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44812. /**
  44813. * Returns the animatable textures.
  44814. * @returns - Array of animatable textures.
  44815. */
  44816. getAnimatables(): IAnimatable[];
  44817. /**
  44818. * Returns the texture used for reflections.
  44819. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44820. */
  44821. private _getReflectionTexture;
  44822. /**
  44823. * Returns an array of the actively used textures.
  44824. * @returns - Array of BaseTextures
  44825. */
  44826. getActiveTextures(): BaseTexture[];
  44827. /**
  44828. * Checks to see if a texture is used in the material.
  44829. * @param texture - Base texture to use.
  44830. * @returns - Boolean specifying if a texture is used in the material.
  44831. */
  44832. hasTexture(texture: BaseTexture): boolean;
  44833. /**
  44834. * Disposes the resources of the material.
  44835. * @param forceDisposeEffect - Forces the disposal of effects.
  44836. * @param forceDisposeTextures - Forces the disposal of all textures.
  44837. */
  44838. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44839. }
  44840. }
  44841. declare module BABYLON {
  44842. /**
  44843. * The Physically based material of BJS.
  44844. *
  44845. * This offers the main features of a standard PBR material.
  44846. * For more information, please refer to the documentation :
  44847. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44848. */
  44849. export class PBRMaterial extends PBRBaseMaterial {
  44850. /**
  44851. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44852. */
  44853. static readonly PBRMATERIAL_OPAQUE: number;
  44854. /**
  44855. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44856. */
  44857. static readonly PBRMATERIAL_ALPHATEST: number;
  44858. /**
  44859. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44860. */
  44861. static readonly PBRMATERIAL_ALPHABLEND: number;
  44862. /**
  44863. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44864. * They are also discarded below the alpha cutoff threshold to improve performances.
  44865. */
  44866. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44867. /**
  44868. * Defines the default value of how much AO map is occluding the analytical lights
  44869. * (point spot...).
  44870. */
  44871. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44872. /**
  44873. * Intensity of the direct lights e.g. the four lights available in your scene.
  44874. * This impacts both the direct diffuse and specular highlights.
  44875. */
  44876. directIntensity: number;
  44877. /**
  44878. * Intensity of the emissive part of the material.
  44879. * This helps controlling the emissive effect without modifying the emissive color.
  44880. */
  44881. emissiveIntensity: number;
  44882. /**
  44883. * Intensity of the environment e.g. how much the environment will light the object
  44884. * either through harmonics for rough material or through the refelction for shiny ones.
  44885. */
  44886. environmentIntensity: number;
  44887. /**
  44888. * This is a special control allowing the reduction of the specular highlights coming from the
  44889. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44890. */
  44891. specularIntensity: number;
  44892. /**
  44893. * Debug Control allowing disabling the bump map on this material.
  44894. */
  44895. disableBumpMap: boolean;
  44896. /**
  44897. * AKA Diffuse Texture in standard nomenclature.
  44898. */
  44899. albedoTexture: BaseTexture;
  44900. /**
  44901. * AKA Occlusion Texture in other nomenclature.
  44902. */
  44903. ambientTexture: BaseTexture;
  44904. /**
  44905. * AKA Occlusion Texture Intensity in other nomenclature.
  44906. */
  44907. ambientTextureStrength: number;
  44908. /**
  44909. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44910. * 1 means it completely occludes it
  44911. * 0 mean it has no impact
  44912. */
  44913. ambientTextureImpactOnAnalyticalLights: number;
  44914. /**
  44915. * Stores the alpha values in a texture.
  44916. */
  44917. opacityTexture: BaseTexture;
  44918. /**
  44919. * Stores the reflection values in a texture.
  44920. */
  44921. reflectionTexture: Nullable<BaseTexture>;
  44922. /**
  44923. * Stores the emissive values in a texture.
  44924. */
  44925. emissiveTexture: BaseTexture;
  44926. /**
  44927. * AKA Specular texture in other nomenclature.
  44928. */
  44929. reflectivityTexture: BaseTexture;
  44930. /**
  44931. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44932. */
  44933. metallicTexture: BaseTexture;
  44934. /**
  44935. * Specifies the metallic scalar of the metallic/roughness workflow.
  44936. * Can also be used to scale the metalness values of the metallic texture.
  44937. */
  44938. metallic: Nullable<number>;
  44939. /**
  44940. * Specifies the roughness scalar of the metallic/roughness workflow.
  44941. * Can also be used to scale the roughness values of the metallic texture.
  44942. */
  44943. roughness: Nullable<number>;
  44944. /**
  44945. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44946. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44947. */
  44948. microSurfaceTexture: BaseTexture;
  44949. /**
  44950. * Stores surface normal data used to displace a mesh in a texture.
  44951. */
  44952. bumpTexture: BaseTexture;
  44953. /**
  44954. * Stores the pre-calculated light information of a mesh in a texture.
  44955. */
  44956. lightmapTexture: BaseTexture;
  44957. /**
  44958. * Stores the refracted light information in a texture.
  44959. */
  44960. refractionTexture: Nullable<BaseTexture>;
  44961. /**
  44962. * The color of a material in ambient lighting.
  44963. */
  44964. ambientColor: Color3;
  44965. /**
  44966. * AKA Diffuse Color in other nomenclature.
  44967. */
  44968. albedoColor: Color3;
  44969. /**
  44970. * AKA Specular Color in other nomenclature.
  44971. */
  44972. reflectivityColor: Color3;
  44973. /**
  44974. * The color reflected from the material.
  44975. */
  44976. reflectionColor: Color3;
  44977. /**
  44978. * The color emitted from the material.
  44979. */
  44980. emissiveColor: Color3;
  44981. /**
  44982. * AKA Glossiness in other nomenclature.
  44983. */
  44984. microSurface: number;
  44985. /**
  44986. * source material index of refraction (IOR)' / 'destination material IOR.
  44987. */
  44988. indexOfRefraction: number;
  44989. /**
  44990. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44991. */
  44992. invertRefractionY: boolean;
  44993. /**
  44994. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44995. * Materials half opaque for instance using refraction could benefit from this control.
  44996. */
  44997. linkRefractionWithTransparency: boolean;
  44998. /**
  44999. * If true, the light map contains occlusion information instead of lighting info.
  45000. */
  45001. useLightmapAsShadowmap: boolean;
  45002. /**
  45003. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45004. */
  45005. useAlphaFromAlbedoTexture: boolean;
  45006. /**
  45007. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45008. */
  45009. forceAlphaTest: boolean;
  45010. /**
  45011. * Defines the alpha limits in alpha test mode.
  45012. */
  45013. alphaCutOff: number;
  45014. /**
  45015. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45016. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45017. */
  45018. useSpecularOverAlpha: boolean;
  45019. /**
  45020. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45021. */
  45022. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45023. /**
  45024. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45025. */
  45026. useRoughnessFromMetallicTextureAlpha: boolean;
  45027. /**
  45028. * Specifies if the metallic texture contains the roughness information in its green channel.
  45029. */
  45030. useRoughnessFromMetallicTextureGreen: boolean;
  45031. /**
  45032. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45033. */
  45034. useMetallnessFromMetallicTextureBlue: boolean;
  45035. /**
  45036. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45037. */
  45038. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45039. /**
  45040. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45041. */
  45042. useAmbientInGrayScale: boolean;
  45043. /**
  45044. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45045. * The material will try to infer what glossiness each pixel should be.
  45046. */
  45047. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45048. /**
  45049. * BJS is using an harcoded light falloff based on a manually sets up range.
  45050. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45051. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45052. */
  45053. /**
  45054. * BJS is using an harcoded light falloff based on a manually sets up range.
  45055. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45056. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45057. */
  45058. usePhysicalLightFalloff: boolean;
  45059. /**
  45060. * In order to support the falloff compatibility with gltf, a special mode has been added
  45061. * to reproduce the gltf light falloff.
  45062. */
  45063. /**
  45064. * In order to support the falloff compatibility with gltf, a special mode has been added
  45065. * to reproduce the gltf light falloff.
  45066. */
  45067. useGLTFLightFalloff: boolean;
  45068. /**
  45069. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45070. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45071. */
  45072. useRadianceOverAlpha: boolean;
  45073. /**
  45074. * Allows using an object space normal map (instead of tangent space).
  45075. */
  45076. useObjectSpaceNormalMap: boolean;
  45077. /**
  45078. * Allows using the bump map in parallax mode.
  45079. */
  45080. useParallax: boolean;
  45081. /**
  45082. * Allows using the bump map in parallax occlusion mode.
  45083. */
  45084. useParallaxOcclusion: boolean;
  45085. /**
  45086. * Controls the scale bias of the parallax mode.
  45087. */
  45088. parallaxScaleBias: number;
  45089. /**
  45090. * If sets to true, disables all the lights affecting the material.
  45091. */
  45092. disableLighting: boolean;
  45093. /**
  45094. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45095. */
  45096. forceIrradianceInFragment: boolean;
  45097. /**
  45098. * Number of Simultaneous lights allowed on the material.
  45099. */
  45100. maxSimultaneousLights: number;
  45101. /**
  45102. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45103. */
  45104. invertNormalMapX: boolean;
  45105. /**
  45106. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45107. */
  45108. invertNormalMapY: boolean;
  45109. /**
  45110. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45111. */
  45112. twoSidedLighting: boolean;
  45113. /**
  45114. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45115. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45116. */
  45117. useAlphaFresnel: boolean;
  45118. /**
  45119. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45120. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45121. */
  45122. useLinearAlphaFresnel: boolean;
  45123. /**
  45124. * Let user defines the brdf lookup texture used for IBL.
  45125. * A default 8bit version is embedded but you could point at :
  45126. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45127. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45128. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45129. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45130. */
  45131. environmentBRDFTexture: Nullable<BaseTexture>;
  45132. /**
  45133. * Force normal to face away from face.
  45134. */
  45135. forceNormalForward: boolean;
  45136. /**
  45137. * Enables specular anti aliasing in the PBR shader.
  45138. * It will both interacts on the Geometry for analytical and IBL lighting.
  45139. * It also prefilter the roughness map based on the bump values.
  45140. */
  45141. enableSpecularAntiAliasing: boolean;
  45142. /**
  45143. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45144. * makes the reflect vector face the model (under horizon).
  45145. */
  45146. useHorizonOcclusion: boolean;
  45147. /**
  45148. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45149. * too much the area relying on ambient texture to define their ambient occlusion.
  45150. */
  45151. useRadianceOcclusion: boolean;
  45152. /**
  45153. * If set to true, no lighting calculations will be applied.
  45154. */
  45155. unlit: boolean;
  45156. /**
  45157. * Gets the image processing configuration used either in this material.
  45158. */
  45159. /**
  45160. * Sets the Default image processing configuration used either in the this material.
  45161. *
  45162. * If sets to null, the scene one is in use.
  45163. */
  45164. imageProcessingConfiguration: ImageProcessingConfiguration;
  45165. /**
  45166. * Gets wether the color curves effect is enabled.
  45167. */
  45168. /**
  45169. * Sets wether the color curves effect is enabled.
  45170. */
  45171. cameraColorCurvesEnabled: boolean;
  45172. /**
  45173. * Gets wether the color grading effect is enabled.
  45174. */
  45175. /**
  45176. * Gets wether the color grading effect is enabled.
  45177. */
  45178. cameraColorGradingEnabled: boolean;
  45179. /**
  45180. * Gets wether tonemapping is enabled or not.
  45181. */
  45182. /**
  45183. * Sets wether tonemapping is enabled or not
  45184. */
  45185. cameraToneMappingEnabled: boolean;
  45186. /**
  45187. * The camera exposure used on this material.
  45188. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45189. * This corresponds to a photographic exposure.
  45190. */
  45191. /**
  45192. * The camera exposure used on this material.
  45193. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45194. * This corresponds to a photographic exposure.
  45195. */
  45196. cameraExposure: number;
  45197. /**
  45198. * Gets The camera contrast used on this material.
  45199. */
  45200. /**
  45201. * Sets The camera contrast used on this material.
  45202. */
  45203. cameraContrast: number;
  45204. /**
  45205. * Gets the Color Grading 2D Lookup Texture.
  45206. */
  45207. /**
  45208. * Sets the Color Grading 2D Lookup Texture.
  45209. */
  45210. cameraColorGradingTexture: Nullable<BaseTexture>;
  45211. /**
  45212. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45213. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45214. * 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;
  45215. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45216. */
  45217. /**
  45218. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45219. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45220. * 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;
  45221. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45222. */
  45223. cameraColorCurves: Nullable<ColorCurves>;
  45224. /**
  45225. * Instantiates a new PBRMaterial instance.
  45226. *
  45227. * @param name The material name
  45228. * @param scene The scene the material will be use in.
  45229. */
  45230. constructor(name: string, scene: Scene);
  45231. /**
  45232. * Returns the name of this material class.
  45233. */
  45234. getClassName(): string;
  45235. /**
  45236. * Makes a duplicate of the current material.
  45237. * @param name - name to use for the new material.
  45238. */
  45239. clone(name: string): PBRMaterial;
  45240. /**
  45241. * Serializes this PBR Material.
  45242. * @returns - An object with the serialized material.
  45243. */
  45244. serialize(): any;
  45245. /**
  45246. * Parses a PBR Material from a serialized object.
  45247. * @param source - Serialized object.
  45248. * @param scene - BJS scene instance.
  45249. * @param rootUrl - url for the scene object
  45250. * @returns - PBRMaterial
  45251. */
  45252. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45253. }
  45254. }
  45255. declare module BABYLON {
  45256. /**
  45257. * Direct draw surface info
  45258. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45259. */
  45260. export interface DDSInfo {
  45261. /**
  45262. * Width of the texture
  45263. */
  45264. width: number;
  45265. /**
  45266. * Width of the texture
  45267. */
  45268. height: number;
  45269. /**
  45270. * Number of Mipmaps for the texture
  45271. * @see https://en.wikipedia.org/wiki/Mipmap
  45272. */
  45273. mipmapCount: number;
  45274. /**
  45275. * If the textures format is a known fourCC format
  45276. * @see https://www.fourcc.org/
  45277. */
  45278. isFourCC: boolean;
  45279. /**
  45280. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45281. */
  45282. isRGB: boolean;
  45283. /**
  45284. * If the texture is a lumincance format
  45285. */
  45286. isLuminance: boolean;
  45287. /**
  45288. * If this is a cube texture
  45289. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45290. */
  45291. isCube: boolean;
  45292. /**
  45293. * If the texture is a compressed format eg. FOURCC_DXT1
  45294. */
  45295. isCompressed: boolean;
  45296. /**
  45297. * The dxgiFormat of the texture
  45298. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45299. */
  45300. dxgiFormat: number;
  45301. /**
  45302. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45303. */
  45304. textureType: number;
  45305. /**
  45306. * Sphericle polynomial created for the dds texture
  45307. */
  45308. sphericalPolynomial?: SphericalPolynomial;
  45309. }
  45310. /**
  45311. * Class used to provide DDS decompression tools
  45312. */
  45313. export class DDSTools {
  45314. /**
  45315. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45316. */
  45317. static StoreLODInAlphaChannel: boolean;
  45318. /**
  45319. * Gets DDS information from an array buffer
  45320. * @param arrayBuffer defines the array buffer to read data from
  45321. * @returns the DDS information
  45322. */
  45323. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45324. private static _FloatView;
  45325. private static _Int32View;
  45326. private static _ToHalfFloat;
  45327. private static _FromHalfFloat;
  45328. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45329. private static _GetHalfFloatRGBAArrayBuffer;
  45330. private static _GetFloatRGBAArrayBuffer;
  45331. private static _GetFloatAsUIntRGBAArrayBuffer;
  45332. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45333. private static _GetRGBAArrayBuffer;
  45334. private static _ExtractLongWordOrder;
  45335. private static _GetRGBArrayBuffer;
  45336. private static _GetLuminanceArrayBuffer;
  45337. /**
  45338. * Uploads DDS Levels to a Babylon Texture
  45339. * @hidden
  45340. */
  45341. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45342. }
  45343. interface Engine {
  45344. /**
  45345. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45346. * @param rootUrl defines the url where the file to load is located
  45347. * @param scene defines the current scene
  45348. * @param lodScale defines scale to apply to the mip map selection
  45349. * @param lodOffset defines offset to apply to the mip map selection
  45350. * @param onLoad defines an optional callback raised when the texture is loaded
  45351. * @param onError defines an optional callback raised if there is an issue to load the texture
  45352. * @param format defines the format of the data
  45353. * @param forcedExtension defines the extension to use to pick the right loader
  45354. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45355. * @returns the cube texture as an InternalTexture
  45356. */
  45357. 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;
  45358. }
  45359. }
  45360. declare module BABYLON {
  45361. /**
  45362. * Implementation of the DDS Texture Loader.
  45363. * @hidden
  45364. */
  45365. export class _DDSTextureLoader implements IInternalTextureLoader {
  45366. /**
  45367. * Defines wether the loader supports cascade loading the different faces.
  45368. */
  45369. readonly supportCascades: boolean;
  45370. /**
  45371. * This returns if the loader support the current file information.
  45372. * @param extension defines the file extension of the file being loaded
  45373. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45374. * @param fallback defines the fallback internal texture if any
  45375. * @param isBase64 defines whether the texture is encoded as a base64
  45376. * @param isBuffer defines whether the texture data are stored as a buffer
  45377. * @returns true if the loader can load the specified file
  45378. */
  45379. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45380. /**
  45381. * Transform the url before loading if required.
  45382. * @param rootUrl the url of the texture
  45383. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45384. * @returns the transformed texture
  45385. */
  45386. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45387. /**
  45388. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45389. * @param rootUrl the url of the texture
  45390. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45391. * @returns the fallback texture
  45392. */
  45393. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45394. /**
  45395. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45396. * @param data contains the texture data
  45397. * @param texture defines the BabylonJS internal texture
  45398. * @param createPolynomials will be true if polynomials have been requested
  45399. * @param onLoad defines the callback to trigger once the texture is ready
  45400. * @param onError defines the callback to trigger in case of error
  45401. */
  45402. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45403. /**
  45404. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45405. * @param data contains the texture data
  45406. * @param texture defines the BabylonJS internal texture
  45407. * @param callback defines the method to call once ready to upload
  45408. */
  45409. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45410. }
  45411. }
  45412. declare module BABYLON {
  45413. /** @hidden */
  45414. export var rgbdEncodePixelShader: {
  45415. name: string;
  45416. shader: string;
  45417. };
  45418. }
  45419. declare module BABYLON {
  45420. /**
  45421. * Raw texture data and descriptor sufficient for WebGL texture upload
  45422. */
  45423. export interface EnvironmentTextureInfo {
  45424. /**
  45425. * Version of the environment map
  45426. */
  45427. version: number;
  45428. /**
  45429. * Width of image
  45430. */
  45431. width: number;
  45432. /**
  45433. * Irradiance information stored in the file.
  45434. */
  45435. irradiance: any;
  45436. /**
  45437. * Specular information stored in the file.
  45438. */
  45439. specular: any;
  45440. }
  45441. /**
  45442. * Sets of helpers addressing the serialization and deserialization of environment texture
  45443. * stored in a BabylonJS env file.
  45444. * Those files are usually stored as .env files.
  45445. */
  45446. export class EnvironmentTextureTools {
  45447. /**
  45448. * Magic number identifying the env file.
  45449. */
  45450. private static _MagicBytes;
  45451. /**
  45452. * Gets the environment info from an env file.
  45453. * @param data The array buffer containing the .env bytes.
  45454. * @returns the environment file info (the json header) if successfully parsed.
  45455. */
  45456. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45457. /**
  45458. * Creates an environment texture from a loaded cube texture.
  45459. * @param texture defines the cube texture to convert in env file
  45460. * @return a promise containing the environment data if succesfull.
  45461. */
  45462. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45463. /**
  45464. * Creates a JSON representation of the spherical data.
  45465. * @param texture defines the texture containing the polynomials
  45466. * @return the JSON representation of the spherical info
  45467. */
  45468. private static _CreateEnvTextureIrradiance;
  45469. /**
  45470. * Uploads the texture info contained in the env file to the GPU.
  45471. * @param texture defines the internal texture to upload to
  45472. * @param arrayBuffer defines the buffer cotaining the data to load
  45473. * @param info defines the texture info retrieved through the GetEnvInfo method
  45474. * @returns a promise
  45475. */
  45476. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45477. /**
  45478. * Uploads the levels of image data to the GPU.
  45479. * @param texture defines the internal texture to upload to
  45480. * @param imageData defines the array buffer views of image data [mipmap][face]
  45481. * @returns a promise
  45482. */
  45483. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45484. /**
  45485. * Uploads spherical polynomials information to the texture.
  45486. * @param texture defines the texture we are trying to upload the information to
  45487. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45488. */
  45489. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45490. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45491. }
  45492. }
  45493. declare module BABYLON {
  45494. /**
  45495. * Implementation of the ENV Texture Loader.
  45496. * @hidden
  45497. */
  45498. export class _ENVTextureLoader implements IInternalTextureLoader {
  45499. /**
  45500. * Defines wether the loader supports cascade loading the different faces.
  45501. */
  45502. readonly supportCascades: boolean;
  45503. /**
  45504. * This returns if the loader support the current file information.
  45505. * @param extension defines the file extension of the file being loaded
  45506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45507. * @param fallback defines the fallback internal texture if any
  45508. * @param isBase64 defines whether the texture is encoded as a base64
  45509. * @param isBuffer defines whether the texture data are stored as a buffer
  45510. * @returns true if the loader can load the specified file
  45511. */
  45512. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45513. /**
  45514. * Transform the url before loading if required.
  45515. * @param rootUrl the url of the texture
  45516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45517. * @returns the transformed texture
  45518. */
  45519. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45520. /**
  45521. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45522. * @param rootUrl the url of the texture
  45523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45524. * @returns the fallback texture
  45525. */
  45526. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45527. /**
  45528. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45529. * @param data contains the texture data
  45530. * @param texture defines the BabylonJS internal texture
  45531. * @param createPolynomials will be true if polynomials have been requested
  45532. * @param onLoad defines the callback to trigger once the texture is ready
  45533. * @param onError defines the callback to trigger in case of error
  45534. */
  45535. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45536. /**
  45537. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45538. * @param data contains the texture data
  45539. * @param texture defines the BabylonJS internal texture
  45540. * @param callback defines the method to call once ready to upload
  45541. */
  45542. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45543. }
  45544. }
  45545. declare module BABYLON {
  45546. /**
  45547. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45548. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45549. */
  45550. export class KhronosTextureContainer {
  45551. /** contents of the KTX container file */
  45552. arrayBuffer: any;
  45553. private static HEADER_LEN;
  45554. private static COMPRESSED_2D;
  45555. private static COMPRESSED_3D;
  45556. private static TEX_2D;
  45557. private static TEX_3D;
  45558. /**
  45559. * Gets the openGL type
  45560. */
  45561. glType: number;
  45562. /**
  45563. * Gets the openGL type size
  45564. */
  45565. glTypeSize: number;
  45566. /**
  45567. * Gets the openGL format
  45568. */
  45569. glFormat: number;
  45570. /**
  45571. * Gets the openGL internal format
  45572. */
  45573. glInternalFormat: number;
  45574. /**
  45575. * Gets the base internal format
  45576. */
  45577. glBaseInternalFormat: number;
  45578. /**
  45579. * Gets image width in pixel
  45580. */
  45581. pixelWidth: number;
  45582. /**
  45583. * Gets image height in pixel
  45584. */
  45585. pixelHeight: number;
  45586. /**
  45587. * Gets image depth in pixels
  45588. */
  45589. pixelDepth: number;
  45590. /**
  45591. * Gets the number of array elements
  45592. */
  45593. numberOfArrayElements: number;
  45594. /**
  45595. * Gets the number of faces
  45596. */
  45597. numberOfFaces: number;
  45598. /**
  45599. * Gets the number of mipmap levels
  45600. */
  45601. numberOfMipmapLevels: number;
  45602. /**
  45603. * Gets the bytes of key value data
  45604. */
  45605. bytesOfKeyValueData: number;
  45606. /**
  45607. * Gets the load type
  45608. */
  45609. loadType: number;
  45610. /**
  45611. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45612. */
  45613. isInvalid: boolean;
  45614. /**
  45615. * Creates a new KhronosTextureContainer
  45616. * @param arrayBuffer contents of the KTX container file
  45617. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45618. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45619. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45620. */
  45621. constructor(
  45622. /** contents of the KTX container file */
  45623. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45624. /**
  45625. * Uploads KTX content to a Babylon Texture.
  45626. * It is assumed that the texture has already been created & is currently bound
  45627. * @hidden
  45628. */
  45629. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45630. private _upload2DCompressedLevels;
  45631. }
  45632. }
  45633. declare module BABYLON {
  45634. /**
  45635. * Implementation of the KTX Texture Loader.
  45636. * @hidden
  45637. */
  45638. export class _KTXTextureLoader implements IInternalTextureLoader {
  45639. /**
  45640. * Defines wether the loader supports cascade loading the different faces.
  45641. */
  45642. readonly supportCascades: boolean;
  45643. /**
  45644. * This returns if the loader support the current file information.
  45645. * @param extension defines the file extension of the file being loaded
  45646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45647. * @param fallback defines the fallback internal texture if any
  45648. * @param isBase64 defines whether the texture is encoded as a base64
  45649. * @param isBuffer defines whether the texture data are stored as a buffer
  45650. * @returns true if the loader can load the specified file
  45651. */
  45652. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45653. /**
  45654. * Transform the url before loading if required.
  45655. * @param rootUrl the url of the texture
  45656. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45657. * @returns the transformed texture
  45658. */
  45659. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45660. /**
  45661. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45662. * @param rootUrl the url of the texture
  45663. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45664. * @returns the fallback texture
  45665. */
  45666. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45667. /**
  45668. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45669. * @param data contains the texture data
  45670. * @param texture defines the BabylonJS internal texture
  45671. * @param createPolynomials will be true if polynomials have been requested
  45672. * @param onLoad defines the callback to trigger once the texture is ready
  45673. * @param onError defines the callback to trigger in case of error
  45674. */
  45675. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45676. /**
  45677. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45678. * @param data contains the texture data
  45679. * @param texture defines the BabylonJS internal texture
  45680. * @param callback defines the method to call once ready to upload
  45681. */
  45682. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45683. }
  45684. }
  45685. declare module BABYLON {
  45686. /** @hidden */
  45687. export var _forceSceneHelpersToBundle: boolean;
  45688. interface Scene {
  45689. /**
  45690. * Creates a default light for the scene.
  45691. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45692. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45693. */
  45694. createDefaultLight(replace?: boolean): void;
  45695. /**
  45696. * Creates a default camera for the scene.
  45697. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45698. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45699. * @param replace has default false, when true replaces the active camera in the scene
  45700. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45701. */
  45702. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45703. /**
  45704. * Creates a default camera and a default light.
  45705. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45706. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45707. * @param replace has the default false, when true replaces the active camera/light in the scene
  45708. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45709. */
  45710. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45711. /**
  45712. * Creates a new sky box
  45713. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45714. * @param environmentTexture defines the texture to use as environment texture
  45715. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45716. * @param scale defines the overall scale of the skybox
  45717. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45718. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45719. * @returns a new mesh holding the sky box
  45720. */
  45721. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45722. /**
  45723. * Creates a new environment
  45724. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45725. * @param options defines the options you can use to configure the environment
  45726. * @returns the new EnvironmentHelper
  45727. */
  45728. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45729. /**
  45730. * Creates a new VREXperienceHelper
  45731. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45732. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45733. * @returns a new VREXperienceHelper
  45734. */
  45735. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45736. /**
  45737. * Creates a new XREXperienceHelper
  45738. * @see http://doc.babylonjs.com/how_to/webxr
  45739. * @returns a promise for a new XREXperienceHelper
  45740. */
  45741. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45742. }
  45743. }
  45744. declare module BABYLON {
  45745. /**
  45746. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45747. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45748. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45749. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45750. */
  45751. export class VideoDome extends TransformNode {
  45752. /**
  45753. * Define the video source as a Monoscopic panoramic 360 video.
  45754. */
  45755. static readonly MODE_MONOSCOPIC: number;
  45756. /**
  45757. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45758. */
  45759. static readonly MODE_TOPBOTTOM: number;
  45760. /**
  45761. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45762. */
  45763. static readonly MODE_SIDEBYSIDE: number;
  45764. private _useDirectMapping;
  45765. /**
  45766. * The video texture being displayed on the sphere
  45767. */
  45768. protected _videoTexture: VideoTexture;
  45769. /**
  45770. * Gets the video texture being displayed on the sphere
  45771. */
  45772. readonly videoTexture: VideoTexture;
  45773. /**
  45774. * The skybox material
  45775. */
  45776. protected _material: BackgroundMaterial;
  45777. /**
  45778. * The surface used for the skybox
  45779. */
  45780. protected _mesh: Mesh;
  45781. /**
  45782. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45783. * Also see the options.resolution property.
  45784. */
  45785. fovMultiplier: number;
  45786. private _videoMode;
  45787. /**
  45788. * Gets or set the current video mode for the video. It can be:
  45789. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45790. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45791. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45792. */
  45793. videoMode: number;
  45794. /**
  45795. * Oberserver used in Stereoscopic VR Mode.
  45796. */
  45797. private _onBeforeCameraRenderObserver;
  45798. /**
  45799. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45800. * @param name Element's name, child elements will append suffixes for their own names.
  45801. * @param urlsOrVideo defines the url(s) or the video element to use
  45802. * @param options An object containing optional or exposed sub element properties
  45803. */
  45804. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45805. resolution?: number;
  45806. clickToPlay?: boolean;
  45807. autoPlay?: boolean;
  45808. loop?: boolean;
  45809. size?: number;
  45810. poster?: string;
  45811. faceForward?: boolean;
  45812. useDirectMapping?: boolean;
  45813. }, scene: Scene);
  45814. private _changeVideoMode;
  45815. /**
  45816. * Releases resources associated with this node.
  45817. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45818. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45819. */
  45820. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45821. }
  45822. }
  45823. declare module BABYLON {
  45824. /**
  45825. * This class can be used to get instrumentation data from a Babylon engine
  45826. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45827. */
  45828. export class EngineInstrumentation implements IDisposable {
  45829. /**
  45830. * Define the instrumented engine.
  45831. */
  45832. engine: Engine;
  45833. private _captureGPUFrameTime;
  45834. private _gpuFrameTimeToken;
  45835. private _gpuFrameTime;
  45836. private _captureShaderCompilationTime;
  45837. private _shaderCompilationTime;
  45838. private _onBeginFrameObserver;
  45839. private _onEndFrameObserver;
  45840. private _onBeforeShaderCompilationObserver;
  45841. private _onAfterShaderCompilationObserver;
  45842. /**
  45843. * Gets the perf counter used for GPU frame time
  45844. */
  45845. readonly gpuFrameTimeCounter: PerfCounter;
  45846. /**
  45847. * Gets the GPU frame time capture status
  45848. */
  45849. /**
  45850. * Enable or disable the GPU frame time capture
  45851. */
  45852. captureGPUFrameTime: boolean;
  45853. /**
  45854. * Gets the perf counter used for shader compilation time
  45855. */
  45856. readonly shaderCompilationTimeCounter: PerfCounter;
  45857. /**
  45858. * Gets the shader compilation time capture status
  45859. */
  45860. /**
  45861. * Enable or disable the shader compilation time capture
  45862. */
  45863. captureShaderCompilationTime: boolean;
  45864. /**
  45865. * Instantiates a new engine instrumentation.
  45866. * This class can be used to get instrumentation data from a Babylon engine
  45867. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45868. * @param engine Defines the engine to instrument
  45869. */
  45870. constructor(
  45871. /**
  45872. * Define the instrumented engine.
  45873. */
  45874. engine: Engine);
  45875. /**
  45876. * Dispose and release associated resources.
  45877. */
  45878. dispose(): void;
  45879. }
  45880. }
  45881. declare module BABYLON {
  45882. /**
  45883. * This class can be used to get instrumentation data from a Babylon engine
  45884. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45885. */
  45886. export class SceneInstrumentation implements IDisposable {
  45887. /**
  45888. * Defines the scene to instrument
  45889. */
  45890. scene: Scene;
  45891. private _captureActiveMeshesEvaluationTime;
  45892. private _activeMeshesEvaluationTime;
  45893. private _captureRenderTargetsRenderTime;
  45894. private _renderTargetsRenderTime;
  45895. private _captureFrameTime;
  45896. private _frameTime;
  45897. private _captureRenderTime;
  45898. private _renderTime;
  45899. private _captureInterFrameTime;
  45900. private _interFrameTime;
  45901. private _captureParticlesRenderTime;
  45902. private _particlesRenderTime;
  45903. private _captureSpritesRenderTime;
  45904. private _spritesRenderTime;
  45905. private _capturePhysicsTime;
  45906. private _physicsTime;
  45907. private _captureAnimationsTime;
  45908. private _animationsTime;
  45909. private _captureCameraRenderTime;
  45910. private _cameraRenderTime;
  45911. private _onBeforeActiveMeshesEvaluationObserver;
  45912. private _onAfterActiveMeshesEvaluationObserver;
  45913. private _onBeforeRenderTargetsRenderObserver;
  45914. private _onAfterRenderTargetsRenderObserver;
  45915. private _onAfterRenderObserver;
  45916. private _onBeforeDrawPhaseObserver;
  45917. private _onAfterDrawPhaseObserver;
  45918. private _onBeforeAnimationsObserver;
  45919. private _onBeforeParticlesRenderingObserver;
  45920. private _onAfterParticlesRenderingObserver;
  45921. private _onBeforeSpritesRenderingObserver;
  45922. private _onAfterSpritesRenderingObserver;
  45923. private _onBeforePhysicsObserver;
  45924. private _onAfterPhysicsObserver;
  45925. private _onAfterAnimationsObserver;
  45926. private _onBeforeCameraRenderObserver;
  45927. private _onAfterCameraRenderObserver;
  45928. /**
  45929. * Gets the perf counter used for active meshes evaluation time
  45930. */
  45931. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45932. /**
  45933. * Gets the active meshes evaluation time capture status
  45934. */
  45935. /**
  45936. * Enable or disable the active meshes evaluation time capture
  45937. */
  45938. captureActiveMeshesEvaluationTime: boolean;
  45939. /**
  45940. * Gets the perf counter used for render targets render time
  45941. */
  45942. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45943. /**
  45944. * Gets the render targets render time capture status
  45945. */
  45946. /**
  45947. * Enable or disable the render targets render time capture
  45948. */
  45949. captureRenderTargetsRenderTime: boolean;
  45950. /**
  45951. * Gets the perf counter used for particles render time
  45952. */
  45953. readonly particlesRenderTimeCounter: PerfCounter;
  45954. /**
  45955. * Gets the particles render time capture status
  45956. */
  45957. /**
  45958. * Enable or disable the particles render time capture
  45959. */
  45960. captureParticlesRenderTime: boolean;
  45961. /**
  45962. * Gets the perf counter used for sprites render time
  45963. */
  45964. readonly spritesRenderTimeCounter: PerfCounter;
  45965. /**
  45966. * Gets the sprites render time capture status
  45967. */
  45968. /**
  45969. * Enable or disable the sprites render time capture
  45970. */
  45971. captureSpritesRenderTime: boolean;
  45972. /**
  45973. * Gets the perf counter used for physics time
  45974. */
  45975. readonly physicsTimeCounter: PerfCounter;
  45976. /**
  45977. * Gets the physics time capture status
  45978. */
  45979. /**
  45980. * Enable or disable the physics time capture
  45981. */
  45982. capturePhysicsTime: boolean;
  45983. /**
  45984. * Gets the perf counter used for animations time
  45985. */
  45986. readonly animationsTimeCounter: PerfCounter;
  45987. /**
  45988. * Gets the animations time capture status
  45989. */
  45990. /**
  45991. * Enable or disable the animations time capture
  45992. */
  45993. captureAnimationsTime: boolean;
  45994. /**
  45995. * Gets the perf counter used for frame time capture
  45996. */
  45997. readonly frameTimeCounter: PerfCounter;
  45998. /**
  45999. * Gets the frame time capture status
  46000. */
  46001. /**
  46002. * Enable or disable the frame time capture
  46003. */
  46004. captureFrameTime: boolean;
  46005. /**
  46006. * Gets the perf counter used for inter-frames time capture
  46007. */
  46008. readonly interFrameTimeCounter: PerfCounter;
  46009. /**
  46010. * Gets the inter-frames time capture status
  46011. */
  46012. /**
  46013. * Enable or disable the inter-frames time capture
  46014. */
  46015. captureInterFrameTime: boolean;
  46016. /**
  46017. * Gets the perf counter used for render time capture
  46018. */
  46019. readonly renderTimeCounter: PerfCounter;
  46020. /**
  46021. * Gets the render time capture status
  46022. */
  46023. /**
  46024. * Enable or disable the render time capture
  46025. */
  46026. captureRenderTime: boolean;
  46027. /**
  46028. * Gets the perf counter used for camera render time capture
  46029. */
  46030. readonly cameraRenderTimeCounter: PerfCounter;
  46031. /**
  46032. * Gets the camera render time capture status
  46033. */
  46034. /**
  46035. * Enable or disable the camera render time capture
  46036. */
  46037. captureCameraRenderTime: boolean;
  46038. /**
  46039. * Gets the perf counter used for draw calls
  46040. */
  46041. readonly drawCallsCounter: PerfCounter;
  46042. /**
  46043. * Instantiates a new scene instrumentation.
  46044. * This class can be used to get instrumentation data from a Babylon engine
  46045. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46046. * @param scene Defines the scene to instrument
  46047. */
  46048. constructor(
  46049. /**
  46050. * Defines the scene to instrument
  46051. */
  46052. scene: Scene);
  46053. /**
  46054. * Dispose and release associated resources.
  46055. */
  46056. dispose(): void;
  46057. }
  46058. }
  46059. declare module BABYLON {
  46060. /** @hidden */
  46061. export var glowMapGenerationPixelShader: {
  46062. name: string;
  46063. shader: string;
  46064. };
  46065. }
  46066. declare module BABYLON {
  46067. /** @hidden */
  46068. export var glowMapGenerationVertexShader: {
  46069. name: string;
  46070. shader: string;
  46071. };
  46072. }
  46073. declare module BABYLON {
  46074. /**
  46075. * Effect layer options. This helps customizing the behaviour
  46076. * of the effect layer.
  46077. */
  46078. export interface IEffectLayerOptions {
  46079. /**
  46080. * Multiplication factor apply to the canvas size to compute the render target size
  46081. * used to generated the objects (the smaller the faster).
  46082. */
  46083. mainTextureRatio: number;
  46084. /**
  46085. * Enforces a fixed size texture to ensure effect stability across devices.
  46086. */
  46087. mainTextureFixedSize?: number;
  46088. /**
  46089. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46090. */
  46091. alphaBlendingMode: number;
  46092. /**
  46093. * The camera attached to the layer.
  46094. */
  46095. camera: Nullable<Camera>;
  46096. /**
  46097. * The rendering group to draw the layer in.
  46098. */
  46099. renderingGroupId: number;
  46100. }
  46101. /**
  46102. * The effect layer Helps adding post process effect blended with the main pass.
  46103. *
  46104. * This can be for instance use to generate glow or higlight effects on the scene.
  46105. *
  46106. * The effect layer class can not be used directly and is intented to inherited from to be
  46107. * customized per effects.
  46108. */
  46109. export abstract class EffectLayer {
  46110. private _vertexBuffers;
  46111. private _indexBuffer;
  46112. private _cachedDefines;
  46113. private _effectLayerMapGenerationEffect;
  46114. private _effectLayerOptions;
  46115. private _mergeEffect;
  46116. protected _scene: Scene;
  46117. protected _engine: Engine;
  46118. protected _maxSize: number;
  46119. protected _mainTextureDesiredSize: ISize;
  46120. protected _mainTexture: RenderTargetTexture;
  46121. protected _shouldRender: boolean;
  46122. protected _postProcesses: PostProcess[];
  46123. protected _textures: BaseTexture[];
  46124. protected _emissiveTextureAndColor: {
  46125. texture: Nullable<BaseTexture>;
  46126. color: Color4;
  46127. };
  46128. /**
  46129. * The name of the layer
  46130. */
  46131. name: string;
  46132. /**
  46133. * The clear color of the texture used to generate the glow map.
  46134. */
  46135. neutralColor: Color4;
  46136. /**
  46137. * Specifies wether the highlight layer is enabled or not.
  46138. */
  46139. isEnabled: boolean;
  46140. /**
  46141. * Gets the camera attached to the layer.
  46142. */
  46143. readonly camera: Nullable<Camera>;
  46144. /**
  46145. * Gets the rendering group id the layer should render in.
  46146. */
  46147. readonly renderingGroupId: number;
  46148. /**
  46149. * An event triggered when the effect layer has been disposed.
  46150. */
  46151. onDisposeObservable: Observable<EffectLayer>;
  46152. /**
  46153. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46154. */
  46155. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46156. /**
  46157. * An event triggered when the generated texture is being merged in the scene.
  46158. */
  46159. onBeforeComposeObservable: Observable<EffectLayer>;
  46160. /**
  46161. * An event triggered when the generated texture has been merged in the scene.
  46162. */
  46163. onAfterComposeObservable: Observable<EffectLayer>;
  46164. /**
  46165. * An event triggered when the efffect layer changes its size.
  46166. */
  46167. onSizeChangedObservable: Observable<EffectLayer>;
  46168. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46169. /**
  46170. * Instantiates a new effect Layer and references it in the scene.
  46171. * @param name The name of the layer
  46172. * @param scene The scene to use the layer in
  46173. */
  46174. constructor(
  46175. /** The Friendly of the effect in the scene */
  46176. name: string, scene: Scene);
  46177. /**
  46178. * Get the effect name of the layer.
  46179. * @return The effect name
  46180. */
  46181. abstract getEffectName(): string;
  46182. /**
  46183. * Checks for the readiness of the element composing the layer.
  46184. * @param subMesh the mesh to check for
  46185. * @param useInstances specify wether or not to use instances to render the mesh
  46186. * @return true if ready otherwise, false
  46187. */
  46188. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46189. /**
  46190. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46191. * @returns true if the effect requires stencil during the main canvas render pass.
  46192. */
  46193. abstract needStencil(): boolean;
  46194. /**
  46195. * Create the merge effect. This is the shader use to blit the information back
  46196. * to the main canvas at the end of the scene rendering.
  46197. * @returns The effect containing the shader used to merge the effect on the main canvas
  46198. */
  46199. protected abstract _createMergeEffect(): Effect;
  46200. /**
  46201. * Creates the render target textures and post processes used in the effect layer.
  46202. */
  46203. protected abstract _createTextureAndPostProcesses(): void;
  46204. /**
  46205. * Implementation specific of rendering the generating effect on the main canvas.
  46206. * @param effect The effect used to render through
  46207. */
  46208. protected abstract _internalRender(effect: Effect): void;
  46209. /**
  46210. * Sets the required values for both the emissive texture and and the main color.
  46211. */
  46212. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46213. /**
  46214. * Free any resources and references associated to a mesh.
  46215. * Internal use
  46216. * @param mesh The mesh to free.
  46217. */
  46218. abstract _disposeMesh(mesh: Mesh): void;
  46219. /**
  46220. * Serializes this layer (Glow or Highlight for example)
  46221. * @returns a serialized layer object
  46222. */
  46223. abstract serialize?(): any;
  46224. /**
  46225. * Initializes the effect layer with the required options.
  46226. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46227. */
  46228. protected _init(options: Partial<IEffectLayerOptions>): void;
  46229. /**
  46230. * Generates the index buffer of the full screen quad blending to the main canvas.
  46231. */
  46232. private _generateIndexBuffer;
  46233. /**
  46234. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46235. */
  46236. private _generateVertexBuffer;
  46237. /**
  46238. * Sets the main texture desired size which is the closest power of two
  46239. * of the engine canvas size.
  46240. */
  46241. private _setMainTextureSize;
  46242. /**
  46243. * Creates the main texture for the effect layer.
  46244. */
  46245. protected _createMainTexture(): void;
  46246. /**
  46247. * Adds specific effects defines.
  46248. * @param defines The defines to add specifics to.
  46249. */
  46250. protected _addCustomEffectDefines(defines: string[]): void;
  46251. /**
  46252. * Checks for the readiness of the element composing the layer.
  46253. * @param subMesh the mesh to check for
  46254. * @param useInstances specify wether or not to use instances to render the mesh
  46255. * @param emissiveTexture the associated emissive texture used to generate the glow
  46256. * @return true if ready otherwise, false
  46257. */
  46258. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46259. /**
  46260. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46261. */
  46262. render(): void;
  46263. /**
  46264. * Determine if a given mesh will be used in the current effect.
  46265. * @param mesh mesh to test
  46266. * @returns true if the mesh will be used
  46267. */
  46268. hasMesh(mesh: AbstractMesh): boolean;
  46269. /**
  46270. * Returns true if the layer contains information to display, otherwise false.
  46271. * @returns true if the glow layer should be rendered
  46272. */
  46273. shouldRender(): boolean;
  46274. /**
  46275. * Returns true if the mesh should render, otherwise false.
  46276. * @param mesh The mesh to render
  46277. * @returns true if it should render otherwise false
  46278. */
  46279. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46280. /**
  46281. * Returns true if the mesh can be rendered, otherwise false.
  46282. * @param mesh The mesh to render
  46283. * @param material The material used on the mesh
  46284. * @returns true if it can be rendered otherwise false
  46285. */
  46286. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46287. /**
  46288. * Returns true if the mesh should render, otherwise false.
  46289. * @param mesh The mesh to render
  46290. * @returns true if it should render otherwise false
  46291. */
  46292. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46293. /**
  46294. * Renders the submesh passed in parameter to the generation map.
  46295. */
  46296. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46297. /**
  46298. * Rebuild the required buffers.
  46299. * @hidden Internal use only.
  46300. */ rebuild(): void;
  46301. /**
  46302. * Dispose only the render target textures and post process.
  46303. */
  46304. private _disposeTextureAndPostProcesses;
  46305. /**
  46306. * Dispose the highlight layer and free resources.
  46307. */
  46308. dispose(): void;
  46309. /**
  46310. * Gets the class name of the effect layer
  46311. * @returns the string with the class name of the effect layer
  46312. */
  46313. getClassName(): string;
  46314. /**
  46315. * Creates an effect layer from parsed effect layer data
  46316. * @param parsedEffectLayer defines effect layer data
  46317. * @param scene defines the current scene
  46318. * @param rootUrl defines the root URL containing the effect layer information
  46319. * @returns a parsed effect Layer
  46320. */
  46321. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46322. }
  46323. }
  46324. declare module BABYLON {
  46325. interface AbstractScene {
  46326. /**
  46327. * The list of effect layers (highlights/glow) added to the scene
  46328. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46329. * @see http://doc.babylonjs.com/how_to/glow_layer
  46330. */
  46331. effectLayers: Array<EffectLayer>;
  46332. /**
  46333. * Removes the given effect layer from this scene.
  46334. * @param toRemove defines the effect layer to remove
  46335. * @returns the index of the removed effect layer
  46336. */
  46337. removeEffectLayer(toRemove: EffectLayer): number;
  46338. /**
  46339. * Adds the given effect layer to this scene
  46340. * @param newEffectLayer defines the effect layer to add
  46341. */
  46342. addEffectLayer(newEffectLayer: EffectLayer): void;
  46343. }
  46344. /**
  46345. * Defines the layer scene component responsible to manage any effect layers
  46346. * in a given scene.
  46347. */
  46348. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46349. /**
  46350. * The component name helpfull to identify the component in the list of scene components.
  46351. */
  46352. readonly name: string;
  46353. /**
  46354. * The scene the component belongs to.
  46355. */
  46356. scene: Scene;
  46357. private _engine;
  46358. private _renderEffects;
  46359. private _needStencil;
  46360. private _previousStencilState;
  46361. /**
  46362. * Creates a new instance of the component for the given scene
  46363. * @param scene Defines the scene to register the component in
  46364. */
  46365. constructor(scene: Scene);
  46366. /**
  46367. * Registers the component in a given scene
  46368. */
  46369. register(): void;
  46370. /**
  46371. * Rebuilds the elements related to this component in case of
  46372. * context lost for instance.
  46373. */
  46374. rebuild(): void;
  46375. /**
  46376. * Serializes the component data to the specified json object
  46377. * @param serializationObject The object to serialize to
  46378. */
  46379. serialize(serializationObject: any): void;
  46380. /**
  46381. * Adds all the element from the container to the scene
  46382. * @param container the container holding the elements
  46383. */
  46384. addFromContainer(container: AbstractScene): void;
  46385. /**
  46386. * Removes all the elements in the container from the scene
  46387. * @param container contains the elements to remove
  46388. * @param dispose if the removed element should be disposed (default: false)
  46389. */
  46390. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46391. /**
  46392. * Disposes the component and the associated ressources.
  46393. */
  46394. dispose(): void;
  46395. private _isReadyForMesh;
  46396. private _renderMainTexture;
  46397. private _setStencil;
  46398. private _setStencilBack;
  46399. private _draw;
  46400. private _drawCamera;
  46401. private _drawRenderingGroup;
  46402. }
  46403. }
  46404. declare module BABYLON {
  46405. /** @hidden */
  46406. export var glowMapMergePixelShader: {
  46407. name: string;
  46408. shader: string;
  46409. };
  46410. }
  46411. declare module BABYLON {
  46412. /** @hidden */
  46413. export var glowMapMergeVertexShader: {
  46414. name: string;
  46415. shader: string;
  46416. };
  46417. }
  46418. declare module BABYLON {
  46419. interface AbstractScene {
  46420. /**
  46421. * Return a the first highlight layer of the scene with a given name.
  46422. * @param name The name of the highlight layer to look for.
  46423. * @return The highlight layer if found otherwise null.
  46424. */
  46425. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46426. }
  46427. /**
  46428. * Glow layer options. This helps customizing the behaviour
  46429. * of the glow layer.
  46430. */
  46431. export interface IGlowLayerOptions {
  46432. /**
  46433. * Multiplication factor apply to the canvas size to compute the render target size
  46434. * used to generated the glowing objects (the smaller the faster).
  46435. */
  46436. mainTextureRatio: number;
  46437. /**
  46438. * Enforces a fixed size texture to ensure resize independant blur.
  46439. */
  46440. mainTextureFixedSize?: number;
  46441. /**
  46442. * How big is the kernel of the blur texture.
  46443. */
  46444. blurKernelSize: number;
  46445. /**
  46446. * The camera attached to the layer.
  46447. */
  46448. camera: Nullable<Camera>;
  46449. /**
  46450. * Enable MSAA by chosing the number of samples.
  46451. */
  46452. mainTextureSamples?: number;
  46453. /**
  46454. * The rendering group to draw the layer in.
  46455. */
  46456. renderingGroupId: number;
  46457. }
  46458. /**
  46459. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46460. *
  46461. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46462. * glowy meshes to your scene.
  46463. *
  46464. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46465. */
  46466. export class GlowLayer extends EffectLayer {
  46467. /**
  46468. * Effect Name of the layer.
  46469. */
  46470. static readonly EffectName: string;
  46471. /**
  46472. * The default blur kernel size used for the glow.
  46473. */
  46474. static DefaultBlurKernelSize: number;
  46475. /**
  46476. * The default texture size ratio used for the glow.
  46477. */
  46478. static DefaultTextureRatio: number;
  46479. /**
  46480. * Sets the kernel size of the blur.
  46481. */
  46482. /**
  46483. * Gets the kernel size of the blur.
  46484. */
  46485. blurKernelSize: number;
  46486. /**
  46487. * Sets the glow intensity.
  46488. */
  46489. /**
  46490. * Gets the glow intensity.
  46491. */
  46492. intensity: number;
  46493. private _options;
  46494. private _intensity;
  46495. private _horizontalBlurPostprocess1;
  46496. private _verticalBlurPostprocess1;
  46497. private _horizontalBlurPostprocess2;
  46498. private _verticalBlurPostprocess2;
  46499. private _blurTexture1;
  46500. private _blurTexture2;
  46501. private _postProcesses1;
  46502. private _postProcesses2;
  46503. private _includedOnlyMeshes;
  46504. private _excludedMeshes;
  46505. /**
  46506. * Callback used to let the user override the color selection on a per mesh basis
  46507. */
  46508. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46509. /**
  46510. * Callback used to let the user override the texture selection on a per mesh basis
  46511. */
  46512. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46513. /**
  46514. * Instantiates a new glow Layer and references it to the scene.
  46515. * @param name The name of the layer
  46516. * @param scene The scene to use the layer in
  46517. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46518. */
  46519. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46520. /**
  46521. * Get the effect name of the layer.
  46522. * @return The effect name
  46523. */
  46524. getEffectName(): string;
  46525. /**
  46526. * Create the merge effect. This is the shader use to blit the information back
  46527. * to the main canvas at the end of the scene rendering.
  46528. */
  46529. protected _createMergeEffect(): Effect;
  46530. /**
  46531. * Creates the render target textures and post processes used in the glow layer.
  46532. */
  46533. protected _createTextureAndPostProcesses(): void;
  46534. /**
  46535. * Checks for the readiness of the element composing the layer.
  46536. * @param subMesh the mesh to check for
  46537. * @param useInstances specify wether or not to use instances to render the mesh
  46538. * @param emissiveTexture the associated emissive texture used to generate the glow
  46539. * @return true if ready otherwise, false
  46540. */
  46541. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46542. /**
  46543. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46544. */
  46545. needStencil(): boolean;
  46546. /**
  46547. * Returns true if the mesh can be rendered, otherwise false.
  46548. * @param mesh The mesh to render
  46549. * @param material The material used on the mesh
  46550. * @returns true if it can be rendered otherwise false
  46551. */
  46552. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46553. /**
  46554. * Implementation specific of rendering the generating effect on the main canvas.
  46555. * @param effect The effect used to render through
  46556. */
  46557. protected _internalRender(effect: Effect): void;
  46558. /**
  46559. * Sets the required values for both the emissive texture and and the main color.
  46560. */
  46561. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46562. /**
  46563. * Returns true if the mesh should render, otherwise false.
  46564. * @param mesh The mesh to render
  46565. * @returns true if it should render otherwise false
  46566. */
  46567. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46568. /**
  46569. * Adds specific effects defines.
  46570. * @param defines The defines to add specifics to.
  46571. */
  46572. protected _addCustomEffectDefines(defines: string[]): void;
  46573. /**
  46574. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46575. * @param mesh The mesh to exclude from the glow layer
  46576. */
  46577. addExcludedMesh(mesh: Mesh): void;
  46578. /**
  46579. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46580. * @param mesh The mesh to remove
  46581. */
  46582. removeExcludedMesh(mesh: Mesh): void;
  46583. /**
  46584. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46585. * @param mesh The mesh to include in the glow layer
  46586. */
  46587. addIncludedOnlyMesh(mesh: Mesh): void;
  46588. /**
  46589. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46590. * @param mesh The mesh to remove
  46591. */
  46592. removeIncludedOnlyMesh(mesh: Mesh): void;
  46593. /**
  46594. * Determine if a given mesh will be used in the glow layer
  46595. * @param mesh The mesh to test
  46596. * @returns true if the mesh will be highlighted by the current glow layer
  46597. */
  46598. hasMesh(mesh: AbstractMesh): boolean;
  46599. /**
  46600. * Free any resources and references associated to a mesh.
  46601. * Internal use
  46602. * @param mesh The mesh to free.
  46603. * @hidden
  46604. */ disposeMesh(mesh: Mesh): void;
  46605. /**
  46606. * Gets the class name of the effect layer
  46607. * @returns the string with the class name of the effect layer
  46608. */
  46609. getClassName(): string;
  46610. /**
  46611. * Serializes this glow layer
  46612. * @returns a serialized glow layer object
  46613. */
  46614. serialize(): any;
  46615. /**
  46616. * Creates a Glow Layer from parsed glow layer data
  46617. * @param parsedGlowLayer defines glow layer data
  46618. * @param scene defines the current scene
  46619. * @param rootUrl defines the root URL containing the glow layer information
  46620. * @returns a parsed Glow Layer
  46621. */
  46622. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46623. }
  46624. }
  46625. declare module BABYLON {
  46626. /** @hidden */
  46627. export var glowBlurPostProcessPixelShader: {
  46628. name: string;
  46629. shader: string;
  46630. };
  46631. }
  46632. declare module BABYLON {
  46633. interface AbstractScene {
  46634. /**
  46635. * Return a the first highlight layer of the scene with a given name.
  46636. * @param name The name of the highlight layer to look for.
  46637. * @return The highlight layer if found otherwise null.
  46638. */
  46639. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46640. }
  46641. /**
  46642. * Highlight layer options. This helps customizing the behaviour
  46643. * of the highlight layer.
  46644. */
  46645. export interface IHighlightLayerOptions {
  46646. /**
  46647. * Multiplication factor apply to the canvas size to compute the render target size
  46648. * used to generated the glowing objects (the smaller the faster).
  46649. */
  46650. mainTextureRatio: number;
  46651. /**
  46652. * Enforces a fixed size texture to ensure resize independant blur.
  46653. */
  46654. mainTextureFixedSize?: number;
  46655. /**
  46656. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46657. * of the picture to blur (the smaller the faster).
  46658. */
  46659. blurTextureSizeRatio: number;
  46660. /**
  46661. * How big in texel of the blur texture is the vertical blur.
  46662. */
  46663. blurVerticalSize: number;
  46664. /**
  46665. * How big in texel of the blur texture is the horizontal blur.
  46666. */
  46667. blurHorizontalSize: number;
  46668. /**
  46669. * Alpha blending mode used to apply the blur. Default is combine.
  46670. */
  46671. alphaBlendingMode: number;
  46672. /**
  46673. * The camera attached to the layer.
  46674. */
  46675. camera: Nullable<Camera>;
  46676. /**
  46677. * Should we display highlight as a solid stroke?
  46678. */
  46679. isStroke?: boolean;
  46680. /**
  46681. * The rendering group to draw the layer in.
  46682. */
  46683. renderingGroupId: number;
  46684. }
  46685. /**
  46686. * The highlight layer Helps adding a glow effect around a mesh.
  46687. *
  46688. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46689. * glowy meshes to your scene.
  46690. *
  46691. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46692. */
  46693. export class HighlightLayer extends EffectLayer {
  46694. name: string;
  46695. /**
  46696. * Effect Name of the highlight layer.
  46697. */
  46698. static readonly EffectName: string;
  46699. /**
  46700. * The neutral color used during the preparation of the glow effect.
  46701. * This is black by default as the blend operation is a blend operation.
  46702. */
  46703. static NeutralColor: Color4;
  46704. /**
  46705. * Stencil value used for glowing meshes.
  46706. */
  46707. static GlowingMeshStencilReference: number;
  46708. /**
  46709. * Stencil value used for the other meshes in the scene.
  46710. */
  46711. static NormalMeshStencilReference: number;
  46712. /**
  46713. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46714. */
  46715. innerGlow: boolean;
  46716. /**
  46717. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46718. */
  46719. outerGlow: boolean;
  46720. /**
  46721. * Specifies the horizontal size of the blur.
  46722. */
  46723. /**
  46724. * Gets the horizontal size of the blur.
  46725. */
  46726. blurHorizontalSize: number;
  46727. /**
  46728. * Specifies the vertical size of the blur.
  46729. */
  46730. /**
  46731. * Gets the vertical size of the blur.
  46732. */
  46733. blurVerticalSize: number;
  46734. /**
  46735. * An event triggered when the highlight layer is being blurred.
  46736. */
  46737. onBeforeBlurObservable: Observable<HighlightLayer>;
  46738. /**
  46739. * An event triggered when the highlight layer has been blurred.
  46740. */
  46741. onAfterBlurObservable: Observable<HighlightLayer>;
  46742. private _instanceGlowingMeshStencilReference;
  46743. private _options;
  46744. private _downSamplePostprocess;
  46745. private _horizontalBlurPostprocess;
  46746. private _verticalBlurPostprocess;
  46747. private _blurTexture;
  46748. private _meshes;
  46749. private _excludedMeshes;
  46750. /**
  46751. * Instantiates a new highlight Layer and references it to the scene..
  46752. * @param name The name of the layer
  46753. * @param scene The scene to use the layer in
  46754. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46755. */
  46756. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46757. /**
  46758. * Get the effect name of the layer.
  46759. * @return The effect name
  46760. */
  46761. getEffectName(): string;
  46762. /**
  46763. * Create the merge effect. This is the shader use to blit the information back
  46764. * to the main canvas at the end of the scene rendering.
  46765. */
  46766. protected _createMergeEffect(): Effect;
  46767. /**
  46768. * Creates the render target textures and post processes used in the highlight layer.
  46769. */
  46770. protected _createTextureAndPostProcesses(): void;
  46771. /**
  46772. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46773. */
  46774. needStencil(): boolean;
  46775. /**
  46776. * Checks for the readiness of the element composing the layer.
  46777. * @param subMesh the mesh to check for
  46778. * @param useInstances specify wether or not to use instances to render the mesh
  46779. * @param emissiveTexture the associated emissive texture used to generate the glow
  46780. * @return true if ready otherwise, false
  46781. */
  46782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46783. /**
  46784. * Implementation specific of rendering the generating effect on the main canvas.
  46785. * @param effect The effect used to render through
  46786. */
  46787. protected _internalRender(effect: Effect): void;
  46788. /**
  46789. * Returns true if the layer contains information to display, otherwise false.
  46790. */
  46791. shouldRender(): boolean;
  46792. /**
  46793. * Returns true if the mesh should render, otherwise false.
  46794. * @param mesh The mesh to render
  46795. * @returns true if it should render otherwise false
  46796. */
  46797. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46798. /**
  46799. * Sets the required values for both the emissive texture and and the main color.
  46800. */
  46801. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46802. /**
  46803. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46804. * @param mesh The mesh to exclude from the highlight layer
  46805. */
  46806. addExcludedMesh(mesh: Mesh): void;
  46807. /**
  46808. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46809. * @param mesh The mesh to highlight
  46810. */
  46811. removeExcludedMesh(mesh: Mesh): void;
  46812. /**
  46813. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46814. * @param mesh mesh to test
  46815. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46816. */
  46817. hasMesh(mesh: AbstractMesh): boolean;
  46818. /**
  46819. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46820. * @param mesh The mesh to highlight
  46821. * @param color The color of the highlight
  46822. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46823. */
  46824. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46825. /**
  46826. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46827. * @param mesh The mesh to highlight
  46828. */
  46829. removeMesh(mesh: Mesh): void;
  46830. /**
  46831. * Force the stencil to the normal expected value for none glowing parts
  46832. */
  46833. private _defaultStencilReference;
  46834. /**
  46835. * Free any resources and references associated to a mesh.
  46836. * Internal use
  46837. * @param mesh The mesh to free.
  46838. * @hidden
  46839. */ disposeMesh(mesh: Mesh): void;
  46840. /**
  46841. * Dispose the highlight layer and free resources.
  46842. */
  46843. dispose(): void;
  46844. /**
  46845. * Gets the class name of the effect layer
  46846. * @returns the string with the class name of the effect layer
  46847. */
  46848. getClassName(): string;
  46849. /**
  46850. * Serializes this Highlight layer
  46851. * @returns a serialized Highlight layer object
  46852. */
  46853. serialize(): any;
  46854. /**
  46855. * Creates a Highlight layer from parsed Highlight layer data
  46856. * @param parsedHightlightLayer defines the Highlight layer data
  46857. * @param scene defines the current scene
  46858. * @param rootUrl defines the root URL containing the Highlight layer information
  46859. * @returns a parsed Highlight layer
  46860. */
  46861. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46862. }
  46863. }
  46864. declare module BABYLON {
  46865. /** @hidden */
  46866. export var lensFlarePixelShader: {
  46867. name: string;
  46868. shader: string;
  46869. };
  46870. }
  46871. declare module BABYLON {
  46872. /** @hidden */
  46873. export var lensFlareVertexShader: {
  46874. name: string;
  46875. shader: string;
  46876. };
  46877. }
  46878. declare module BABYLON {
  46879. /**
  46880. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46881. * It is usually composed of several `lensFlare`.
  46882. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46883. */
  46884. export class LensFlareSystem {
  46885. /**
  46886. * Define the name of the lens flare system
  46887. */
  46888. name: string;
  46889. /**
  46890. * List of lens flares used in this system.
  46891. */
  46892. lensFlares: LensFlare[];
  46893. /**
  46894. * Define a limit from the border the lens flare can be visible.
  46895. */
  46896. borderLimit: number;
  46897. /**
  46898. * Define a viewport border we do not want to see the lens flare in.
  46899. */
  46900. viewportBorder: number;
  46901. /**
  46902. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46903. */
  46904. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46905. /**
  46906. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46907. */
  46908. layerMask: number;
  46909. /**
  46910. * Define the id of the lens flare system in the scene.
  46911. * (equal to name by default)
  46912. */
  46913. id: string;
  46914. private _scene;
  46915. private _emitter;
  46916. private _vertexBuffers;
  46917. private _indexBuffer;
  46918. private _effect;
  46919. private _positionX;
  46920. private _positionY;
  46921. private _isEnabled;
  46922. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46923. /**
  46924. * Instantiates a lens flare system.
  46925. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46926. * It is usually composed of several `lensFlare`.
  46927. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46928. * @param name Define the name of the lens flare system in the scene
  46929. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46930. * @param scene Define the scene the lens flare system belongs to
  46931. */
  46932. constructor(
  46933. /**
  46934. * Define the name of the lens flare system
  46935. */
  46936. name: string, emitter: any, scene: Scene);
  46937. /**
  46938. * Define if the lens flare system is enabled.
  46939. */
  46940. isEnabled: boolean;
  46941. /**
  46942. * Get the scene the effects belongs to.
  46943. * @returns the scene holding the lens flare system
  46944. */
  46945. getScene(): Scene;
  46946. /**
  46947. * Get the emitter of the lens flare system.
  46948. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46949. * @returns the emitter of the lens flare system
  46950. */
  46951. getEmitter(): any;
  46952. /**
  46953. * Set the emitter of the lens flare system.
  46954. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46955. * @param newEmitter Define the new emitter of the system
  46956. */
  46957. setEmitter(newEmitter: any): void;
  46958. /**
  46959. * Get the lens flare system emitter position.
  46960. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46961. * @returns the position
  46962. */
  46963. getEmitterPosition(): Vector3;
  46964. /**
  46965. * @hidden
  46966. */
  46967. computeEffectivePosition(globalViewport: Viewport): boolean;
  46968. /** @hidden */ isVisible(): boolean;
  46969. /**
  46970. * @hidden
  46971. */
  46972. render(): boolean;
  46973. /**
  46974. * Dispose and release the lens flare with its associated resources.
  46975. */
  46976. dispose(): void;
  46977. /**
  46978. * Parse a lens flare system from a JSON repressentation
  46979. * @param parsedLensFlareSystem Define the JSON to parse
  46980. * @param scene Define the scene the parsed system should be instantiated in
  46981. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46982. * @returns the parsed system
  46983. */
  46984. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46985. /**
  46986. * Serialize the current Lens Flare System into a JSON representation.
  46987. * @returns the serialized JSON
  46988. */
  46989. serialize(): any;
  46990. }
  46991. }
  46992. declare module BABYLON {
  46993. /**
  46994. * This represents one of the lens effect in a `lensFlareSystem`.
  46995. * It controls one of the indiviual texture used in the effect.
  46996. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46997. */
  46998. export class LensFlare {
  46999. /**
  47000. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47001. */
  47002. size: number;
  47003. /**
  47004. * 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.
  47005. */
  47006. position: number;
  47007. /**
  47008. * Define the lens color.
  47009. */
  47010. color: Color3;
  47011. /**
  47012. * Define the lens texture.
  47013. */
  47014. texture: Nullable<Texture>;
  47015. /**
  47016. * Define the alpha mode to render this particular lens.
  47017. */
  47018. alphaMode: number;
  47019. private _system;
  47020. /**
  47021. * Creates a new Lens Flare.
  47022. * This represents one of the lens effect in a `lensFlareSystem`.
  47023. * It controls one of the indiviual texture used in the effect.
  47024. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47025. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47026. * @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.
  47027. * @param color Define the lens color
  47028. * @param imgUrl Define the lens texture url
  47029. * @param system Define the `lensFlareSystem` this flare is part of
  47030. * @returns The newly created Lens Flare
  47031. */
  47032. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47033. /**
  47034. * Instantiates a new Lens Flare.
  47035. * This represents one of the lens effect in a `lensFlareSystem`.
  47036. * It controls one of the indiviual texture used in the effect.
  47037. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47038. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47039. * @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.
  47040. * @param color Define the lens color
  47041. * @param imgUrl Define the lens texture url
  47042. * @param system Define the `lensFlareSystem` this flare is part of
  47043. */
  47044. constructor(
  47045. /**
  47046. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47047. */
  47048. size: number,
  47049. /**
  47050. * 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.
  47051. */
  47052. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47053. /**
  47054. * Dispose and release the lens flare with its associated resources.
  47055. */
  47056. dispose(): void;
  47057. }
  47058. }
  47059. declare module BABYLON {
  47060. interface AbstractScene {
  47061. /**
  47062. * The list of lens flare system added to the scene
  47063. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47064. */
  47065. lensFlareSystems: Array<LensFlareSystem>;
  47066. /**
  47067. * Removes the given lens flare system from this scene.
  47068. * @param toRemove The lens flare system to remove
  47069. * @returns The index of the removed lens flare system
  47070. */
  47071. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47072. /**
  47073. * Adds the given lens flare system to this scene
  47074. * @param newLensFlareSystem The lens flare system to add
  47075. */
  47076. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47077. /**
  47078. * Gets a lens flare system using its name
  47079. * @param name defines the name to look for
  47080. * @returns the lens flare system or null if not found
  47081. */
  47082. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47083. /**
  47084. * Gets a lens flare system using its id
  47085. * @param id defines the id to look for
  47086. * @returns the lens flare system or null if not found
  47087. */
  47088. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47089. }
  47090. /**
  47091. * Defines the lens flare scene component responsible to manage any lens flares
  47092. * in a given scene.
  47093. */
  47094. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47095. /**
  47096. * The component name helpfull to identify the component in the list of scene components.
  47097. */
  47098. readonly name: string;
  47099. /**
  47100. * The scene the component belongs to.
  47101. */
  47102. scene: Scene;
  47103. /**
  47104. * Creates a new instance of the component for the given scene
  47105. * @param scene Defines the scene to register the component in
  47106. */
  47107. constructor(scene: Scene);
  47108. /**
  47109. * Registers the component in a given scene
  47110. */
  47111. register(): void;
  47112. /**
  47113. * Rebuilds the elements related to this component in case of
  47114. * context lost for instance.
  47115. */
  47116. rebuild(): void;
  47117. /**
  47118. * Adds all the element from the container to the scene
  47119. * @param container the container holding the elements
  47120. */
  47121. addFromContainer(container: AbstractScene): void;
  47122. /**
  47123. * Removes all the elements in the container from the scene
  47124. * @param container contains the elements to remove
  47125. * @param dispose if the removed element should be disposed (default: false)
  47126. */
  47127. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47128. /**
  47129. * Serializes the component data to the specified json object
  47130. * @param serializationObject The object to serialize to
  47131. */
  47132. serialize(serializationObject: any): void;
  47133. /**
  47134. * Disposes the component and the associated ressources.
  47135. */
  47136. dispose(): void;
  47137. private _draw;
  47138. }
  47139. }
  47140. declare module BABYLON {
  47141. /**
  47142. * Defines the shadow generator component responsible to manage any shadow generators
  47143. * in a given scene.
  47144. */
  47145. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47146. /**
  47147. * The component name helpfull to identify the component in the list of scene components.
  47148. */
  47149. readonly name: string;
  47150. /**
  47151. * The scene the component belongs to.
  47152. */
  47153. scene: Scene;
  47154. /**
  47155. * Creates a new instance of the component for the given scene
  47156. * @param scene Defines the scene to register the component in
  47157. */
  47158. constructor(scene: Scene);
  47159. /**
  47160. * Registers the component in a given scene
  47161. */
  47162. register(): void;
  47163. /**
  47164. * Rebuilds the elements related to this component in case of
  47165. * context lost for instance.
  47166. */
  47167. rebuild(): void;
  47168. /**
  47169. * Serializes the component data to the specified json object
  47170. * @param serializationObject The object to serialize to
  47171. */
  47172. serialize(serializationObject: any): void;
  47173. /**
  47174. * Adds all the element from the container to the scene
  47175. * @param container the container holding the elements
  47176. */
  47177. addFromContainer(container: AbstractScene): void;
  47178. /**
  47179. * Removes all the elements in the container from the scene
  47180. * @param container contains the elements to remove
  47181. * @param dispose if the removed element should be disposed (default: false)
  47182. */
  47183. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47184. /**
  47185. * Rebuilds the elements related to this component in case of
  47186. * context lost for instance.
  47187. */
  47188. dispose(): void;
  47189. private _gatherRenderTargets;
  47190. }
  47191. }
  47192. declare module BABYLON {
  47193. /**
  47194. * A point light is a light defined by an unique point in world space.
  47195. * The light is emitted in every direction from this point.
  47196. * A good example of a point light is a standard light bulb.
  47197. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47198. */
  47199. export class PointLight extends ShadowLight {
  47200. private _shadowAngle;
  47201. /**
  47202. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47203. * This specifies what angle the shadow will use to be created.
  47204. *
  47205. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47206. */
  47207. /**
  47208. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47209. * This specifies what angle the shadow will use to be created.
  47210. *
  47211. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47212. */
  47213. shadowAngle: number;
  47214. /**
  47215. * Gets the direction if it has been set.
  47216. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47217. */
  47218. /**
  47219. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47220. */
  47221. direction: Vector3;
  47222. /**
  47223. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47224. * A PointLight emits the light in every direction.
  47225. * It can cast shadows.
  47226. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47227. * ```javascript
  47228. * var pointLight = new PointLight("pl", camera.position, scene);
  47229. * ```
  47230. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47231. * @param name The light friendly name
  47232. * @param position The position of the point light in the scene
  47233. * @param scene The scene the lights belongs to
  47234. */
  47235. constructor(name: string, position: Vector3, scene: Scene);
  47236. /**
  47237. * Returns the string "PointLight"
  47238. * @returns the class name
  47239. */
  47240. getClassName(): string;
  47241. /**
  47242. * Returns the integer 0.
  47243. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47244. */
  47245. getTypeID(): number;
  47246. /**
  47247. * Specifies wether or not the shadowmap should be a cube texture.
  47248. * @returns true if the shadowmap needs to be a cube texture.
  47249. */
  47250. needCube(): boolean;
  47251. /**
  47252. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47253. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47254. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47255. */
  47256. getShadowDirection(faceIndex?: number): Vector3;
  47257. /**
  47258. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47259. * - fov = PI / 2
  47260. * - aspect ratio : 1.0
  47261. * - z-near and far equal to the active camera minZ and maxZ.
  47262. * Returns the PointLight.
  47263. */
  47264. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47265. protected _buildUniformLayout(): void;
  47266. /**
  47267. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47268. * @param effect The effect to update
  47269. * @param lightIndex The index of the light in the effect to update
  47270. * @returns The point light
  47271. */
  47272. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47273. /**
  47274. * Prepares the list of defines specific to the light type.
  47275. * @param defines the list of defines
  47276. * @param lightIndex defines the index of the light for the effect
  47277. */
  47278. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47279. }
  47280. }
  47281. declare module BABYLON {
  47282. /**
  47283. * Header information of HDR texture files.
  47284. */
  47285. export interface HDRInfo {
  47286. /**
  47287. * The height of the texture in pixels.
  47288. */
  47289. height: number;
  47290. /**
  47291. * The width of the texture in pixels.
  47292. */
  47293. width: number;
  47294. /**
  47295. * The index of the beginning of the data in the binary file.
  47296. */
  47297. dataPosition: number;
  47298. }
  47299. /**
  47300. * This groups tools to convert HDR texture to native colors array.
  47301. */
  47302. export class HDRTools {
  47303. private static Ldexp;
  47304. private static Rgbe2float;
  47305. private static readStringLine;
  47306. /**
  47307. * Reads header information from an RGBE texture stored in a native array.
  47308. * More information on this format are available here:
  47309. * https://en.wikipedia.org/wiki/RGBE_image_format
  47310. *
  47311. * @param uint8array The binary file stored in native array.
  47312. * @return The header information.
  47313. */
  47314. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47315. /**
  47316. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47317. * This RGBE texture needs to store the information as a panorama.
  47318. *
  47319. * More information on this format are available here:
  47320. * https://en.wikipedia.org/wiki/RGBE_image_format
  47321. *
  47322. * @param buffer The binary file stored in an array buffer.
  47323. * @param size The expected size of the extracted cubemap.
  47324. * @return The Cube Map information.
  47325. */
  47326. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47327. /**
  47328. * Returns the pixels data extracted from an RGBE texture.
  47329. * This pixels will be stored left to right up to down in the R G B order in one array.
  47330. *
  47331. * More information on this format are available here:
  47332. * https://en.wikipedia.org/wiki/RGBE_image_format
  47333. *
  47334. * @param uint8array The binary file stored in an array buffer.
  47335. * @param hdrInfo The header information of the file.
  47336. * @return The pixels data in RGB right to left up to down order.
  47337. */
  47338. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47339. private static RGBE_ReadPixels_RLE;
  47340. }
  47341. }
  47342. declare module BABYLON {
  47343. /**
  47344. * This represents a texture coming from an HDR input.
  47345. *
  47346. * The only supported format is currently panorama picture stored in RGBE format.
  47347. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47348. */
  47349. export class HDRCubeTexture extends BaseTexture {
  47350. private static _facesMapping;
  47351. private _generateHarmonics;
  47352. private _noMipmap;
  47353. private _textureMatrix;
  47354. private _size;
  47355. private _onLoad;
  47356. private _onError;
  47357. /**
  47358. * The texture URL.
  47359. */
  47360. url: string;
  47361. /**
  47362. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47363. */
  47364. coordinatesMode: number;
  47365. protected _isBlocking: boolean;
  47366. /**
  47367. * Sets wether or not the texture is blocking during loading.
  47368. */
  47369. /**
  47370. * Gets wether or not the texture is blocking during loading.
  47371. */
  47372. isBlocking: boolean;
  47373. protected _rotationY: number;
  47374. /**
  47375. * Sets texture matrix rotation angle around Y axis in radians.
  47376. */
  47377. /**
  47378. * Gets texture matrix rotation angle around Y axis radians.
  47379. */
  47380. rotationY: number;
  47381. /**
  47382. * Gets or sets the center of the bounding box associated with the cube texture
  47383. * It must define where the camera used to render the texture was set
  47384. */
  47385. boundingBoxPosition: Vector3;
  47386. private _boundingBoxSize;
  47387. /**
  47388. * Gets or sets the size of the bounding box associated with the cube texture
  47389. * When defined, the cubemap will switch to local mode
  47390. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47391. * @example https://www.babylonjs-playground.com/#RNASML
  47392. */
  47393. boundingBoxSize: Vector3;
  47394. /**
  47395. * Instantiates an HDRTexture from the following parameters.
  47396. *
  47397. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47398. * @param scene The scene the texture will be used in
  47399. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47400. * @param noMipmap Forces to not generate the mipmap if true
  47401. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47402. * @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)
  47403. * @param reserved Reserved flag for internal use.
  47404. */
  47405. 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>);
  47406. /**
  47407. * Get the current class name of the texture useful for serialization or dynamic coding.
  47408. * @returns "HDRCubeTexture"
  47409. */
  47410. getClassName(): string;
  47411. /**
  47412. * Occurs when the file is raw .hdr file.
  47413. */
  47414. private loadTexture;
  47415. clone(): HDRCubeTexture;
  47416. delayLoad(): void;
  47417. /**
  47418. * Get the texture reflection matrix used to rotate/transform the reflection.
  47419. * @returns the reflection matrix
  47420. */
  47421. getReflectionTextureMatrix(): Matrix;
  47422. /**
  47423. * Set the texture reflection matrix used to rotate/transform the reflection.
  47424. * @param value Define the reflection matrix to set
  47425. */
  47426. setReflectionTextureMatrix(value: Matrix): void;
  47427. /**
  47428. * Parses a JSON representation of an HDR Texture in order to create the texture
  47429. * @param parsedTexture Define the JSON representation
  47430. * @param scene Define the scene the texture should be created in
  47431. * @param rootUrl Define the root url in case we need to load relative dependencies
  47432. * @returns the newly created texture after parsing
  47433. */
  47434. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47435. serialize(): any;
  47436. }
  47437. }
  47438. declare module BABYLON {
  47439. /**
  47440. * Class used to control physics engine
  47441. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47442. */
  47443. export class PhysicsEngine implements IPhysicsEngine {
  47444. private _physicsPlugin;
  47445. /**
  47446. * Global value used to control the smallest number supported by the simulation
  47447. */
  47448. static Epsilon: number;
  47449. private _impostors;
  47450. private _joints;
  47451. /**
  47452. * Gets the gravity vector used by the simulation
  47453. */
  47454. gravity: Vector3;
  47455. /**
  47456. * Factory used to create the default physics plugin.
  47457. * @returns The default physics plugin
  47458. */
  47459. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47460. /**
  47461. * Creates a new Physics Engine
  47462. * @param gravity defines the gravity vector used by the simulation
  47463. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47464. */
  47465. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47466. /**
  47467. * Sets the gravity vector used by the simulation
  47468. * @param gravity defines the gravity vector to use
  47469. */
  47470. setGravity(gravity: Vector3): void;
  47471. /**
  47472. * Set the time step of the physics engine.
  47473. * Default is 1/60.
  47474. * To slow it down, enter 1/600 for example.
  47475. * To speed it up, 1/30
  47476. * @param newTimeStep defines the new timestep to apply to this world.
  47477. */
  47478. setTimeStep(newTimeStep?: number): void;
  47479. /**
  47480. * Get the time step of the physics engine.
  47481. * @returns the current time step
  47482. */
  47483. getTimeStep(): number;
  47484. /**
  47485. * Release all resources
  47486. */
  47487. dispose(): void;
  47488. /**
  47489. * Gets the name of the current physics plugin
  47490. * @returns the name of the plugin
  47491. */
  47492. getPhysicsPluginName(): string;
  47493. /**
  47494. * Adding a new impostor for the impostor tracking.
  47495. * This will be done by the impostor itself.
  47496. * @param impostor the impostor to add
  47497. */
  47498. addImpostor(impostor: PhysicsImpostor): void;
  47499. /**
  47500. * Remove an impostor from the engine.
  47501. * This impostor and its mesh will not longer be updated by the physics engine.
  47502. * @param impostor the impostor to remove
  47503. */
  47504. removeImpostor(impostor: PhysicsImpostor): void;
  47505. /**
  47506. * Add a joint to the physics engine
  47507. * @param mainImpostor defines the main impostor to which the joint is added.
  47508. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47509. * @param joint defines the joint that will connect both impostors.
  47510. */
  47511. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47512. /**
  47513. * Removes a joint from the simulation
  47514. * @param mainImpostor defines the impostor used with the joint
  47515. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47516. * @param joint defines the joint to remove
  47517. */
  47518. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47519. /**
  47520. * Called by the scene. No need to call it.
  47521. * @param delta defines the timespam between frames
  47522. */ step(delta: number): void;
  47523. /**
  47524. * Gets the current plugin used to run the simulation
  47525. * @returns current plugin
  47526. */
  47527. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47528. /**
  47529. * Gets the list of physic impostors
  47530. * @returns an array of PhysicsImpostor
  47531. */
  47532. getImpostors(): Array<PhysicsImpostor>;
  47533. /**
  47534. * Gets the impostor for a physics enabled object
  47535. * @param object defines the object impersonated by the impostor
  47536. * @returns the PhysicsImpostor or null if not found
  47537. */
  47538. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47539. /**
  47540. * Gets the impostor for a physics body object
  47541. * @param body defines physics body used by the impostor
  47542. * @returns the PhysicsImpostor or null if not found
  47543. */
  47544. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47545. /**
  47546. * Does a raycast in the physics world
  47547. * @param from when should the ray start?
  47548. * @param to when should the ray end?
  47549. * @returns PhysicsRaycastResult
  47550. */
  47551. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47552. }
  47553. }
  47554. declare module BABYLON {
  47555. /** @hidden */
  47556. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47557. private _useDeltaForWorldStep;
  47558. world: any;
  47559. name: string;
  47560. private _physicsMaterials;
  47561. private _fixedTimeStep;
  47562. private _cannonRaycastResult;
  47563. private _raycastResult;
  47564. private _removeAfterStep;
  47565. BJSCANNON: any;
  47566. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47567. setGravity(gravity: Vector3): void;
  47568. setTimeStep(timeStep: number): void;
  47569. getTimeStep(): number;
  47570. executeStep(delta: number): void;
  47571. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47572. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47573. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47574. private _processChildMeshes;
  47575. removePhysicsBody(impostor: PhysicsImpostor): void;
  47576. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47577. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47578. private _addMaterial;
  47579. private _checkWithEpsilon;
  47580. private _createShape;
  47581. private _createHeightmap;
  47582. private _minus90X;
  47583. private _plus90X;
  47584. private _tmpPosition;
  47585. private _tmpDeltaPosition;
  47586. private _tmpUnityRotation;
  47587. private _updatePhysicsBodyTransformation;
  47588. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47589. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47590. isSupported(): boolean;
  47591. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47592. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47593. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47594. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47595. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47596. getBodyMass(impostor: PhysicsImpostor): number;
  47597. getBodyFriction(impostor: PhysicsImpostor): number;
  47598. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47599. getBodyRestitution(impostor: PhysicsImpostor): number;
  47600. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47601. sleepBody(impostor: PhysicsImpostor): void;
  47602. wakeUpBody(impostor: PhysicsImpostor): void;
  47603. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47604. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47605. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47606. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47607. getRadius(impostor: PhysicsImpostor): number;
  47608. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47609. dispose(): void;
  47610. private _extendNamespace;
  47611. /**
  47612. * Does a raycast in the physics world
  47613. * @param from when should the ray start?
  47614. * @param to when should the ray end?
  47615. * @returns PhysicsRaycastResult
  47616. */
  47617. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47618. }
  47619. }
  47620. declare module BABYLON {
  47621. /** @hidden */
  47622. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47623. world: any;
  47624. name: string;
  47625. BJSOIMO: any;
  47626. private _raycastResult;
  47627. constructor(iterations?: number, oimoInjection?: any);
  47628. setGravity(gravity: Vector3): void;
  47629. setTimeStep(timeStep: number): void;
  47630. getTimeStep(): number;
  47631. private _tmpImpostorsArray;
  47632. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47633. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47634. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47635. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47636. private _tmpPositionVector;
  47637. removePhysicsBody(impostor: PhysicsImpostor): void;
  47638. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47639. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47640. isSupported(): boolean;
  47641. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47642. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47643. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47644. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47645. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47646. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47647. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47648. getBodyMass(impostor: PhysicsImpostor): number;
  47649. getBodyFriction(impostor: PhysicsImpostor): number;
  47650. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47651. getBodyRestitution(impostor: PhysicsImpostor): number;
  47652. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47653. sleepBody(impostor: PhysicsImpostor): void;
  47654. wakeUpBody(impostor: PhysicsImpostor): void;
  47655. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47656. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47657. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47658. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47659. getRadius(impostor: PhysicsImpostor): number;
  47660. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47661. dispose(): void;
  47662. /**
  47663. * Does a raycast in the physics world
  47664. * @param from when should the ray start?
  47665. * @param to when should the ray end?
  47666. * @returns PhysicsRaycastResult
  47667. */
  47668. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47669. }
  47670. }
  47671. declare module BABYLON {
  47672. /**
  47673. * Class containing static functions to help procedurally build meshes
  47674. */
  47675. export class RibbonBuilder {
  47676. /**
  47677. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47678. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47679. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47680. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47681. * * 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
  47682. * * 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
  47683. * * 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
  47684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47685. * * 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
  47686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47687. * * 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
  47688. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47689. * * 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
  47690. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47692. * @param name defines the name of the mesh
  47693. * @param options defines the options used to create the mesh
  47694. * @param scene defines the hosting scene
  47695. * @returns the ribbon mesh
  47696. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47698. */
  47699. static CreateRibbon(name: string, options: {
  47700. pathArray: Vector3[][];
  47701. closeArray?: boolean;
  47702. closePath?: boolean;
  47703. offset?: number;
  47704. updatable?: boolean;
  47705. sideOrientation?: number;
  47706. frontUVs?: Vector4;
  47707. backUVs?: Vector4;
  47708. instance?: Mesh;
  47709. invertUV?: boolean;
  47710. uvs?: Vector2[];
  47711. colors?: Color4[];
  47712. }, scene?: Nullable<Scene>): Mesh;
  47713. }
  47714. }
  47715. declare module BABYLON {
  47716. /**
  47717. * Class containing static functions to help procedurally build meshes
  47718. */
  47719. export class ShapeBuilder {
  47720. /**
  47721. * 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.
  47722. * * 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.
  47723. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47724. * * 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.
  47725. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47726. * * 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
  47727. * * 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
  47728. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47729. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47730. * * 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
  47731. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47733. * @param name defines the name of the mesh
  47734. * @param options defines the options used to create the mesh
  47735. * @param scene defines the hosting scene
  47736. * @returns the extruded shape mesh
  47737. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47739. */
  47740. static ExtrudeShape(name: string, options: {
  47741. shape: Vector3[];
  47742. path: Vector3[];
  47743. scale?: number;
  47744. rotation?: number;
  47745. cap?: number;
  47746. updatable?: boolean;
  47747. sideOrientation?: number;
  47748. frontUVs?: Vector4;
  47749. backUVs?: Vector4;
  47750. instance?: Mesh;
  47751. invertUV?: boolean;
  47752. }, scene?: Nullable<Scene>): Mesh;
  47753. /**
  47754. * Creates an custom extruded shape mesh.
  47755. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47756. * * 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.
  47757. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47758. * * 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
  47759. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47760. * * 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
  47761. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47762. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47763. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47764. * * 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
  47765. * * 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
  47766. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47768. * * 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
  47769. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47770. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47771. * @param name defines the name of the mesh
  47772. * @param options defines the options used to create the mesh
  47773. * @param scene defines the hosting scene
  47774. * @returns the custom extruded shape mesh
  47775. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47776. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47777. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47778. */
  47779. static ExtrudeShapeCustom(name: string, options: {
  47780. shape: Vector3[];
  47781. path: Vector3[];
  47782. scaleFunction?: any;
  47783. rotationFunction?: any;
  47784. ribbonCloseArray?: boolean;
  47785. ribbonClosePath?: boolean;
  47786. cap?: number;
  47787. updatable?: boolean;
  47788. sideOrientation?: number;
  47789. frontUVs?: Vector4;
  47790. backUVs?: Vector4;
  47791. instance?: Mesh;
  47792. invertUV?: boolean;
  47793. }, scene?: Nullable<Scene>): Mesh;
  47794. private static _ExtrudeShapeGeneric;
  47795. }
  47796. }
  47797. declare module BABYLON {
  47798. /**
  47799. * AmmoJS Physics plugin
  47800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47801. * @see https://github.com/kripken/ammo.js/
  47802. */
  47803. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47804. private _useDeltaForWorldStep;
  47805. /**
  47806. * Reference to the Ammo library
  47807. */
  47808. bjsAMMO: any;
  47809. /**
  47810. * Created ammoJS world which physics bodies are added to
  47811. */
  47812. world: any;
  47813. /**
  47814. * Name of the plugin
  47815. */
  47816. name: string;
  47817. private _timeStep;
  47818. private _fixedTimeStep;
  47819. private _maxSteps;
  47820. private _tmpQuaternion;
  47821. private _tmpAmmoTransform;
  47822. private _tmpAmmoQuaternion;
  47823. private _tmpAmmoConcreteContactResultCallback;
  47824. private _collisionConfiguration;
  47825. private _dispatcher;
  47826. private _overlappingPairCache;
  47827. private _solver;
  47828. private _softBodySolver;
  47829. private _tmpAmmoVectorA;
  47830. private _tmpAmmoVectorB;
  47831. private _tmpAmmoVectorC;
  47832. private _tmpAmmoVectorD;
  47833. private _tmpContactCallbackResult;
  47834. private _tmpAmmoVectorRCA;
  47835. private _tmpAmmoVectorRCB;
  47836. private _raycastResult;
  47837. private static readonly DISABLE_COLLISION_FLAG;
  47838. private static readonly KINEMATIC_FLAG;
  47839. private static readonly DISABLE_DEACTIVATION_FLAG;
  47840. /**
  47841. * Initializes the ammoJS plugin
  47842. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47843. * @param ammoInjection can be used to inject your own ammo reference
  47844. */
  47845. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47846. /**
  47847. * Sets the gravity of the physics world (m/(s^2))
  47848. * @param gravity Gravity to set
  47849. */
  47850. setGravity(gravity: Vector3): void;
  47851. /**
  47852. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47853. * @param timeStep timestep to use in seconds
  47854. */
  47855. setTimeStep(timeStep: number): void;
  47856. /**
  47857. * 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)
  47858. * @param fixedTimeStep fixedTimeStep to use in seconds
  47859. */
  47860. setFixedTimeStep(fixedTimeStep: number): void;
  47861. /**
  47862. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47863. * @param maxSteps the maximum number of steps by the physics engine per frame
  47864. */
  47865. setMaxSteps(maxSteps: number): void;
  47866. /**
  47867. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47868. * @returns the current timestep in seconds
  47869. */
  47870. getTimeStep(): number;
  47871. private _isImpostorInContact;
  47872. private _isImpostorPairInContact;
  47873. private _stepSimulation;
  47874. /**
  47875. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47876. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47877. * After the step the babylon meshes are set to the position of the physics imposters
  47878. * @param delta amount of time to step forward
  47879. * @param impostors array of imposters to update before/after the step
  47880. */
  47881. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47882. /**
  47883. * Update babylon mesh to match physics world object
  47884. * @param impostor imposter to match
  47885. */
  47886. private _afterSoftStep;
  47887. /**
  47888. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47889. * @param impostor imposter to match
  47890. */
  47891. private _ropeStep;
  47892. /**
  47893. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47894. * @param impostor imposter to match
  47895. */
  47896. private _softbodyOrClothStep;
  47897. private _tmpVector;
  47898. private _tmpMatrix;
  47899. /**
  47900. * Applies an impulse on the imposter
  47901. * @param impostor imposter to apply impulse to
  47902. * @param force amount of force to be applied to the imposter
  47903. * @param contactPoint the location to apply the impulse on the imposter
  47904. */
  47905. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47906. /**
  47907. * Applies a force on the imposter
  47908. * @param impostor imposter to apply force
  47909. * @param force amount of force to be applied to the imposter
  47910. * @param contactPoint the location to apply the force on the imposter
  47911. */
  47912. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47913. /**
  47914. * Creates a physics body using the plugin
  47915. * @param impostor the imposter to create the physics body on
  47916. */
  47917. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47918. /**
  47919. * Removes the physics body from the imposter and disposes of the body's memory
  47920. * @param impostor imposter to remove the physics body from
  47921. */
  47922. removePhysicsBody(impostor: PhysicsImpostor): void;
  47923. /**
  47924. * Generates a joint
  47925. * @param impostorJoint the imposter joint to create the joint with
  47926. */
  47927. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47928. /**
  47929. * Removes a joint
  47930. * @param impostorJoint the imposter joint to remove the joint from
  47931. */
  47932. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47933. private _addMeshVerts;
  47934. /**
  47935. * Initialise the soft body vertices to match its object's (mesh) vertices
  47936. * Softbody vertices (nodes) are in world space and to match this
  47937. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47938. * @param impostor to create the softbody for
  47939. */
  47940. private _softVertexData;
  47941. /**
  47942. * Create an impostor's soft body
  47943. * @param impostor to create the softbody for
  47944. */
  47945. private _createSoftbody;
  47946. /**
  47947. * Create cloth for an impostor
  47948. * @param impostor to create the softbody for
  47949. */
  47950. private _createCloth;
  47951. /**
  47952. * Create rope for an impostor
  47953. * @param impostor to create the softbody for
  47954. */
  47955. private _createRope;
  47956. private _addHullVerts;
  47957. private _createShape;
  47958. /**
  47959. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47960. * @param impostor imposter containing the physics body and babylon object
  47961. */
  47962. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47963. /**
  47964. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47965. * @param impostor imposter containing the physics body and babylon object
  47966. * @param newPosition new position
  47967. * @param newRotation new rotation
  47968. */
  47969. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47970. /**
  47971. * If this plugin is supported
  47972. * @returns true if its supported
  47973. */
  47974. isSupported(): boolean;
  47975. /**
  47976. * Sets the linear velocity of the physics body
  47977. * @param impostor imposter to set the velocity on
  47978. * @param velocity velocity to set
  47979. */
  47980. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47981. /**
  47982. * Sets the angular velocity of the physics body
  47983. * @param impostor imposter to set the velocity on
  47984. * @param velocity velocity to set
  47985. */
  47986. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47987. /**
  47988. * gets the linear velocity
  47989. * @param impostor imposter to get linear velocity from
  47990. * @returns linear velocity
  47991. */
  47992. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47993. /**
  47994. * gets the angular velocity
  47995. * @param impostor imposter to get angular velocity from
  47996. * @returns angular velocity
  47997. */
  47998. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47999. /**
  48000. * Sets the mass of physics body
  48001. * @param impostor imposter to set the mass on
  48002. * @param mass mass to set
  48003. */
  48004. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48005. /**
  48006. * Gets the mass of the physics body
  48007. * @param impostor imposter to get the mass from
  48008. * @returns mass
  48009. */
  48010. getBodyMass(impostor: PhysicsImpostor): number;
  48011. /**
  48012. * Gets friction of the impostor
  48013. * @param impostor impostor to get friction from
  48014. * @returns friction value
  48015. */
  48016. getBodyFriction(impostor: PhysicsImpostor): number;
  48017. /**
  48018. * Sets friction of the impostor
  48019. * @param impostor impostor to set friction on
  48020. * @param friction friction value
  48021. */
  48022. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48023. /**
  48024. * Gets restitution of the impostor
  48025. * @param impostor impostor to get restitution from
  48026. * @returns restitution value
  48027. */
  48028. getBodyRestitution(impostor: PhysicsImpostor): number;
  48029. /**
  48030. * Sets resitution of the impostor
  48031. * @param impostor impostor to set resitution on
  48032. * @param restitution resitution value
  48033. */
  48034. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48035. /**
  48036. * Gets pressure inside the impostor
  48037. * @param impostor impostor to get pressure from
  48038. * @returns pressure value
  48039. */
  48040. getBodyPressure(impostor: PhysicsImpostor): number;
  48041. /**
  48042. * Sets pressure inside a soft body impostor
  48043. * Cloth and rope must remain 0 pressure
  48044. * @param impostor impostor to set pressure on
  48045. * @param pressure pressure value
  48046. */
  48047. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48048. /**
  48049. * Gets stiffness of the impostor
  48050. * @param impostor impostor to get stiffness from
  48051. * @returns pressure value
  48052. */
  48053. getBodyStiffness(impostor: PhysicsImpostor): number;
  48054. /**
  48055. * Sets stiffness of the impostor
  48056. * @param impostor impostor to set stiffness on
  48057. * @param stiffness stiffness value from 0 to 1
  48058. */
  48059. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48060. /**
  48061. * Gets velocityIterations of the impostor
  48062. * @param impostor impostor to get velocity iterations from
  48063. * @returns velocityIterations value
  48064. */
  48065. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48066. /**
  48067. * Sets velocityIterations of the impostor
  48068. * @param impostor impostor to set velocity iterations on
  48069. * @param velocityIterations velocityIterations value
  48070. */
  48071. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48072. /**
  48073. * Gets positionIterations of the impostor
  48074. * @param impostor impostor to get position iterations from
  48075. * @returns positionIterations value
  48076. */
  48077. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48078. /**
  48079. * Sets positionIterations of the impostor
  48080. * @param impostor impostor to set position on
  48081. * @param positionIterations positionIterations value
  48082. */
  48083. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48084. /**
  48085. * Append an anchor to a cloth object
  48086. * @param impostor is the cloth impostor to add anchor to
  48087. * @param otherImpostor is the rigid impostor to anchor to
  48088. * @param width ratio across width from 0 to 1
  48089. * @param height ratio up height from 0 to 1
  48090. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48091. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48092. */
  48093. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48094. /**
  48095. * Append an hook to a rope object
  48096. * @param impostor is the rope impostor to add hook to
  48097. * @param otherImpostor is the rigid impostor to hook to
  48098. * @param length ratio along the rope from 0 to 1
  48099. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48100. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48101. */
  48102. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48103. /**
  48104. * Sleeps the physics body and stops it from being active
  48105. * @param impostor impostor to sleep
  48106. */
  48107. sleepBody(impostor: PhysicsImpostor): void;
  48108. /**
  48109. * Activates the physics body
  48110. * @param impostor impostor to activate
  48111. */
  48112. wakeUpBody(impostor: PhysicsImpostor): void;
  48113. /**
  48114. * Updates the distance parameters of the joint
  48115. * @param joint joint to update
  48116. * @param maxDistance maximum distance of the joint
  48117. * @param minDistance minimum distance of the joint
  48118. */
  48119. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48120. /**
  48121. * Sets a motor on the joint
  48122. * @param joint joint to set motor on
  48123. * @param speed speed of the motor
  48124. * @param maxForce maximum force of the motor
  48125. * @param motorIndex index of the motor
  48126. */
  48127. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48128. /**
  48129. * Sets the motors limit
  48130. * @param joint joint to set limit on
  48131. * @param upperLimit upper limit
  48132. * @param lowerLimit lower limit
  48133. */
  48134. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48135. /**
  48136. * Syncs the position and rotation of a mesh with the impostor
  48137. * @param mesh mesh to sync
  48138. * @param impostor impostor to update the mesh with
  48139. */
  48140. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48141. /**
  48142. * Gets the radius of the impostor
  48143. * @param impostor impostor to get radius from
  48144. * @returns the radius
  48145. */
  48146. getRadius(impostor: PhysicsImpostor): number;
  48147. /**
  48148. * Gets the box size of the impostor
  48149. * @param impostor impostor to get box size from
  48150. * @param result the resulting box size
  48151. */
  48152. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48153. /**
  48154. * Disposes of the impostor
  48155. */
  48156. dispose(): void;
  48157. /**
  48158. * Does a raycast in the physics world
  48159. * @param from when should the ray start?
  48160. * @param to when should the ray end?
  48161. * @returns PhysicsRaycastResult
  48162. */
  48163. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48164. }
  48165. }
  48166. declare module BABYLON {
  48167. interface AbstractScene {
  48168. /**
  48169. * The list of reflection probes added to the scene
  48170. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48171. */
  48172. reflectionProbes: Array<ReflectionProbe>;
  48173. /**
  48174. * Removes the given reflection probe from this scene.
  48175. * @param toRemove The reflection probe to remove
  48176. * @returns The index of the removed reflection probe
  48177. */
  48178. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48179. /**
  48180. * Adds the given reflection probe to this scene.
  48181. * @param newReflectionProbe The reflection probe to add
  48182. */
  48183. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48184. }
  48185. /**
  48186. * Class used to generate realtime reflection / refraction cube textures
  48187. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48188. */
  48189. export class ReflectionProbe {
  48190. /** defines the name of the probe */
  48191. name: string;
  48192. private _scene;
  48193. private _renderTargetTexture;
  48194. private _projectionMatrix;
  48195. private _viewMatrix;
  48196. private _target;
  48197. private _add;
  48198. private _attachedMesh;
  48199. private _invertYAxis;
  48200. /** Gets or sets probe position (center of the cube map) */
  48201. position: Vector3;
  48202. /**
  48203. * Creates a new reflection probe
  48204. * @param name defines the name of the probe
  48205. * @param size defines the texture resolution (for each face)
  48206. * @param scene defines the hosting scene
  48207. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48208. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48209. */
  48210. constructor(
  48211. /** defines the name of the probe */
  48212. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48213. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48214. samples: number;
  48215. /** Gets or sets the refresh rate to use (on every frame by default) */
  48216. refreshRate: number;
  48217. /**
  48218. * Gets the hosting scene
  48219. * @returns a Scene
  48220. */
  48221. getScene(): Scene;
  48222. /** Gets the internal CubeTexture used to render to */
  48223. readonly cubeTexture: RenderTargetTexture;
  48224. /** Gets the list of meshes to render */
  48225. readonly renderList: Nullable<AbstractMesh[]>;
  48226. /**
  48227. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48228. * @param mesh defines the mesh to attach to
  48229. */
  48230. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48231. /**
  48232. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48233. * @param renderingGroupId The rendering group id corresponding to its index
  48234. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48235. */
  48236. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48237. /**
  48238. * Clean all associated resources
  48239. */
  48240. dispose(): void;
  48241. /**
  48242. * Converts the reflection probe information to a readable string for debug purpose.
  48243. * @param fullDetails Supports for multiple levels of logging within scene loading
  48244. * @returns the human readable reflection probe info
  48245. */
  48246. toString(fullDetails?: boolean): string;
  48247. /**
  48248. * Get the class name of the relfection probe.
  48249. * @returns "ReflectionProbe"
  48250. */
  48251. getClassName(): string;
  48252. /**
  48253. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48254. * @returns The JSON representation of the texture
  48255. */
  48256. serialize(): any;
  48257. /**
  48258. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48259. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48260. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48261. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48262. * @returns The parsed reflection probe if successful
  48263. */
  48264. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48265. }
  48266. }
  48267. declare module BABYLON {
  48268. /** @hidden */
  48269. export var _BabylonLoaderRegistered: boolean;
  48270. }
  48271. declare module BABYLON {
  48272. /**
  48273. * The Physically based simple base material of BJS.
  48274. *
  48275. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48276. * It is used as the base class for both the specGloss and metalRough conventions.
  48277. */
  48278. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48279. /**
  48280. * Number of Simultaneous lights allowed on the material.
  48281. */
  48282. maxSimultaneousLights: number;
  48283. /**
  48284. * If sets to true, disables all the lights affecting the material.
  48285. */
  48286. disableLighting: boolean;
  48287. /**
  48288. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48289. */
  48290. environmentTexture: BaseTexture;
  48291. /**
  48292. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48293. */
  48294. invertNormalMapX: boolean;
  48295. /**
  48296. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48297. */
  48298. invertNormalMapY: boolean;
  48299. /**
  48300. * Normal map used in the model.
  48301. */
  48302. normalTexture: BaseTexture;
  48303. /**
  48304. * Emissivie color used to self-illuminate the model.
  48305. */
  48306. emissiveColor: Color3;
  48307. /**
  48308. * Emissivie texture used to self-illuminate the model.
  48309. */
  48310. emissiveTexture: BaseTexture;
  48311. /**
  48312. * Occlusion Channel Strenght.
  48313. */
  48314. occlusionStrength: number;
  48315. /**
  48316. * Occlusion Texture of the material (adding extra occlusion effects).
  48317. */
  48318. occlusionTexture: BaseTexture;
  48319. /**
  48320. * Defines the alpha limits in alpha test mode.
  48321. */
  48322. alphaCutOff: number;
  48323. /**
  48324. * Gets the current double sided mode.
  48325. */
  48326. /**
  48327. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48328. */
  48329. doubleSided: boolean;
  48330. /**
  48331. * Stores the pre-calculated light information of a mesh in a texture.
  48332. */
  48333. lightmapTexture: BaseTexture;
  48334. /**
  48335. * If true, the light map contains occlusion information instead of lighting info.
  48336. */
  48337. useLightmapAsShadowmap: boolean;
  48338. /**
  48339. * Instantiates a new PBRMaterial instance.
  48340. *
  48341. * @param name The material name
  48342. * @param scene The scene the material will be use in.
  48343. */
  48344. constructor(name: string, scene: Scene);
  48345. getClassName(): string;
  48346. }
  48347. }
  48348. declare module BABYLON {
  48349. /**
  48350. * The PBR material of BJS following the metal roughness convention.
  48351. *
  48352. * This fits to the PBR convention in the GLTF definition:
  48353. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48354. */
  48355. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48356. /**
  48357. * The base color has two different interpretations depending on the value of metalness.
  48358. * When the material is a metal, the base color is the specific measured reflectance value
  48359. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48360. * of the material.
  48361. */
  48362. baseColor: Color3;
  48363. /**
  48364. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48365. * well as opacity information in the alpha channel.
  48366. */
  48367. baseTexture: BaseTexture;
  48368. /**
  48369. * Specifies the metallic scalar value of the material.
  48370. * Can also be used to scale the metalness values of the metallic texture.
  48371. */
  48372. metallic: number;
  48373. /**
  48374. * Specifies the roughness scalar value of the material.
  48375. * Can also be used to scale the roughness values of the metallic texture.
  48376. */
  48377. roughness: number;
  48378. /**
  48379. * Texture containing both the metallic value in the B channel and the
  48380. * roughness value in the G channel to keep better precision.
  48381. */
  48382. metallicRoughnessTexture: BaseTexture;
  48383. /**
  48384. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48385. *
  48386. * @param name The material name
  48387. * @param scene The scene the material will be use in.
  48388. */
  48389. constructor(name: string, scene: Scene);
  48390. /**
  48391. * Return the currrent class name of the material.
  48392. */
  48393. getClassName(): string;
  48394. /**
  48395. * Makes a duplicate of the current material.
  48396. * @param name - name to use for the new material.
  48397. */
  48398. clone(name: string): PBRMetallicRoughnessMaterial;
  48399. /**
  48400. * Serialize the material to a parsable JSON object.
  48401. */
  48402. serialize(): any;
  48403. /**
  48404. * Parses a JSON object correponding to the serialize function.
  48405. */
  48406. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48407. }
  48408. }
  48409. declare module BABYLON {
  48410. /**
  48411. * The PBR material of BJS following the specular glossiness convention.
  48412. *
  48413. * This fits to the PBR convention in the GLTF definition:
  48414. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48415. */
  48416. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48417. /**
  48418. * Specifies the diffuse color of the material.
  48419. */
  48420. diffuseColor: Color3;
  48421. /**
  48422. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48423. * channel.
  48424. */
  48425. diffuseTexture: BaseTexture;
  48426. /**
  48427. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48428. */
  48429. specularColor: Color3;
  48430. /**
  48431. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48432. */
  48433. glossiness: number;
  48434. /**
  48435. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48436. */
  48437. specularGlossinessTexture: BaseTexture;
  48438. /**
  48439. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48440. *
  48441. * @param name The material name
  48442. * @param scene The scene the material will be use in.
  48443. */
  48444. constructor(name: string, scene: Scene);
  48445. /**
  48446. * Return the currrent class name of the material.
  48447. */
  48448. getClassName(): string;
  48449. /**
  48450. * Makes a duplicate of the current material.
  48451. * @param name - name to use for the new material.
  48452. */
  48453. clone(name: string): PBRSpecularGlossinessMaterial;
  48454. /**
  48455. * Serialize the material to a parsable JSON object.
  48456. */
  48457. serialize(): any;
  48458. /**
  48459. * Parses a JSON object correponding to the serialize function.
  48460. */
  48461. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48462. }
  48463. }
  48464. declare module BABYLON {
  48465. /**
  48466. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48467. * It can help converting any input color in a desired output one. This can then be used to create effects
  48468. * from sepia, black and white to sixties or futuristic rendering...
  48469. *
  48470. * The only supported format is currently 3dl.
  48471. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48472. */
  48473. export class ColorGradingTexture extends BaseTexture {
  48474. /**
  48475. * The current texture matrix. (will always be identity in color grading texture)
  48476. */
  48477. private _textureMatrix;
  48478. /**
  48479. * The texture URL.
  48480. */
  48481. url: string;
  48482. /**
  48483. * Empty line regex stored for GC.
  48484. */
  48485. private static _noneEmptyLineRegex;
  48486. private _engine;
  48487. /**
  48488. * Instantiates a ColorGradingTexture from the following parameters.
  48489. *
  48490. * @param url The location of the color gradind data (currently only supporting 3dl)
  48491. * @param scene The scene the texture will be used in
  48492. */
  48493. constructor(url: string, scene: Scene);
  48494. /**
  48495. * Returns the texture matrix used in most of the material.
  48496. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48497. */
  48498. getTextureMatrix(): Matrix;
  48499. /**
  48500. * Occurs when the file being loaded is a .3dl LUT file.
  48501. */
  48502. private load3dlTexture;
  48503. /**
  48504. * Starts the loading process of the texture.
  48505. */
  48506. private loadTexture;
  48507. /**
  48508. * Clones the color gradind texture.
  48509. */
  48510. clone(): ColorGradingTexture;
  48511. /**
  48512. * Called during delayed load for textures.
  48513. */
  48514. delayLoad(): void;
  48515. /**
  48516. * Parses a color grading texture serialized by Babylon.
  48517. * @param parsedTexture The texture information being parsedTexture
  48518. * @param scene The scene to load the texture in
  48519. * @param rootUrl The root url of the data assets to load
  48520. * @return A color gradind texture
  48521. */
  48522. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48523. /**
  48524. * Serializes the LUT texture to json format.
  48525. */
  48526. serialize(): any;
  48527. }
  48528. }
  48529. declare module BABYLON {
  48530. /**
  48531. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48532. */
  48533. export class EquiRectangularCubeTexture extends BaseTexture {
  48534. /** The six faces of the cube. */
  48535. private static _FacesMapping;
  48536. private _noMipmap;
  48537. private _onLoad;
  48538. private _onError;
  48539. /** The size of the cubemap. */
  48540. private _size;
  48541. /** The buffer of the image. */
  48542. private _buffer;
  48543. /** The width of the input image. */
  48544. private _width;
  48545. /** The height of the input image. */
  48546. private _height;
  48547. /** The URL to the image. */
  48548. url: string;
  48549. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48550. coordinatesMode: number;
  48551. /**
  48552. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48553. * @param url The location of the image
  48554. * @param scene The scene the texture will be used in
  48555. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48556. * @param noMipmap Forces to not generate the mipmap if true
  48557. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48558. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48559. * @param onLoad — defines a callback called when texture is loaded
  48560. * @param onError — defines a callback called if there is an error
  48561. */
  48562. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48563. /**
  48564. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48565. */
  48566. private loadImage;
  48567. /**
  48568. * Convert the image buffer into a cubemap and create a CubeTexture.
  48569. */
  48570. private loadTexture;
  48571. /**
  48572. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48573. * @param buffer The ArrayBuffer that should be converted.
  48574. * @returns The buffer as Float32Array.
  48575. */
  48576. private getFloat32ArrayFromArrayBuffer;
  48577. /**
  48578. * Get the current class name of the texture useful for serialization or dynamic coding.
  48579. * @returns "EquiRectangularCubeTexture"
  48580. */
  48581. getClassName(): string;
  48582. /**
  48583. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48584. * @returns A clone of the current EquiRectangularCubeTexture.
  48585. */
  48586. clone(): EquiRectangularCubeTexture;
  48587. }
  48588. }
  48589. declare module BABYLON {
  48590. /**
  48591. * Based on jsTGALoader - Javascript loader for TGA file
  48592. * By Vincent Thibault
  48593. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48594. */
  48595. export class TGATools {
  48596. private static _TYPE_INDEXED;
  48597. private static _TYPE_RGB;
  48598. private static _TYPE_GREY;
  48599. private static _TYPE_RLE_INDEXED;
  48600. private static _TYPE_RLE_RGB;
  48601. private static _TYPE_RLE_GREY;
  48602. private static _ORIGIN_MASK;
  48603. private static _ORIGIN_SHIFT;
  48604. private static _ORIGIN_BL;
  48605. private static _ORIGIN_BR;
  48606. private static _ORIGIN_UL;
  48607. private static _ORIGIN_UR;
  48608. /**
  48609. * Gets the header of a TGA file
  48610. * @param data defines the TGA data
  48611. * @returns the header
  48612. */
  48613. static GetTGAHeader(data: Uint8Array): any;
  48614. /**
  48615. * Uploads TGA content to a Babylon Texture
  48616. * @hidden
  48617. */
  48618. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48619. /** @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;
  48620. /** @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;
  48621. /** @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;
  48622. /** @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;
  48623. /** @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;
  48624. /** @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;
  48625. }
  48626. }
  48627. declare module BABYLON {
  48628. /**
  48629. * Implementation of the TGA Texture Loader.
  48630. * @hidden
  48631. */
  48632. export class _TGATextureLoader implements IInternalTextureLoader {
  48633. /**
  48634. * Defines wether the loader supports cascade loading the different faces.
  48635. */
  48636. readonly supportCascades: boolean;
  48637. /**
  48638. * This returns if the loader support the current file information.
  48639. * @param extension defines the file extension of the file being loaded
  48640. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48641. * @param fallback defines the fallback internal texture if any
  48642. * @param isBase64 defines whether the texture is encoded as a base64
  48643. * @param isBuffer defines whether the texture data are stored as a buffer
  48644. * @returns true if the loader can load the specified file
  48645. */
  48646. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48647. /**
  48648. * Transform the url before loading if required.
  48649. * @param rootUrl the url of the texture
  48650. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48651. * @returns the transformed texture
  48652. */
  48653. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48654. /**
  48655. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48656. * @param rootUrl the url of the texture
  48657. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48658. * @returns the fallback texture
  48659. */
  48660. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48661. /**
  48662. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48663. * @param data contains the texture data
  48664. * @param texture defines the BabylonJS internal texture
  48665. * @param createPolynomials will be true if polynomials have been requested
  48666. * @param onLoad defines the callback to trigger once the texture is ready
  48667. * @param onError defines the callback to trigger in case of error
  48668. */
  48669. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48670. /**
  48671. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48672. * @param data contains the texture data
  48673. * @param texture defines the BabylonJS internal texture
  48674. * @param callback defines the method to call once ready to upload
  48675. */
  48676. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48677. }
  48678. }
  48679. declare module BABYLON {
  48680. /**
  48681. * 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.
  48682. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48683. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48684. */
  48685. export class CustomProceduralTexture extends ProceduralTexture {
  48686. private _animate;
  48687. private _time;
  48688. private _config;
  48689. private _texturePath;
  48690. /**
  48691. * Instantiates a new Custom Procedural Texture.
  48692. * 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.
  48693. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48694. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48695. * @param name Define the name of the texture
  48696. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48697. * @param size Define the size of the texture to create
  48698. * @param scene Define the scene the texture belongs to
  48699. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48700. * @param generateMipMaps Define if the texture should creates mip maps or not
  48701. */
  48702. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48703. private _loadJson;
  48704. /**
  48705. * Is the texture ready to be used ? (rendered at least once)
  48706. * @returns true if ready, otherwise, false.
  48707. */
  48708. isReady(): boolean;
  48709. /**
  48710. * Render the texture to its associated render target.
  48711. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48712. */
  48713. render(useCameraPostProcess?: boolean): void;
  48714. /**
  48715. * Update the list of dependant textures samplers in the shader.
  48716. */
  48717. updateTextures(): void;
  48718. /**
  48719. * Update the uniform values of the procedural texture in the shader.
  48720. */
  48721. updateShaderUniforms(): void;
  48722. /**
  48723. * Define if the texture animates or not.
  48724. */
  48725. animate: boolean;
  48726. }
  48727. }
  48728. declare module BABYLON {
  48729. /** @hidden */
  48730. export var noisePixelShader: {
  48731. name: string;
  48732. shader: string;
  48733. };
  48734. }
  48735. declare module BABYLON {
  48736. /**
  48737. * Class used to generate noise procedural textures
  48738. */
  48739. export class NoiseProceduralTexture extends ProceduralTexture {
  48740. private _time;
  48741. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48742. brightness: number;
  48743. /** Defines the number of octaves to process */
  48744. octaves: number;
  48745. /** Defines the level of persistence (0.8 by default) */
  48746. persistence: number;
  48747. /** Gets or sets animation speed factor (default is 1) */
  48748. animationSpeedFactor: number;
  48749. /**
  48750. * Creates a new NoiseProceduralTexture
  48751. * @param name defines the name fo the texture
  48752. * @param size defines the size of the texture (default is 256)
  48753. * @param scene defines the hosting scene
  48754. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48755. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48756. */
  48757. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48758. private _updateShaderUniforms;
  48759. protected _getDefines(): string;
  48760. /** Generate the current state of the procedural texture */
  48761. render(useCameraPostProcess?: boolean): void;
  48762. /**
  48763. * Serializes this noise procedural texture
  48764. * @returns a serialized noise procedural texture object
  48765. */
  48766. serialize(): any;
  48767. /**
  48768. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48769. * @param parsedTexture defines parsed texture data
  48770. * @param scene defines the current scene
  48771. * @param rootUrl defines the root URL containing noise procedural texture information
  48772. * @returns a parsed NoiseProceduralTexture
  48773. */
  48774. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48775. }
  48776. }
  48777. declare module BABYLON {
  48778. /**
  48779. * Raw cube texture where the raw buffers are passed in
  48780. */
  48781. export class RawCubeTexture extends CubeTexture {
  48782. /**
  48783. * Creates a cube texture where the raw buffers are passed in.
  48784. * @param scene defines the scene the texture is attached to
  48785. * @param data defines the array of data to use to create each face
  48786. * @param size defines the size of the textures
  48787. * @param format defines the format of the data
  48788. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48789. * @param generateMipMaps defines if the engine should generate the mip levels
  48790. * @param invertY defines if data must be stored with Y axis inverted
  48791. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48792. * @param compression defines the compression used (null by default)
  48793. */
  48794. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48795. /**
  48796. * Updates the raw cube texture.
  48797. * @param data defines the data to store
  48798. * @param format defines the data format
  48799. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48800. * @param invertY defines if data must be stored with Y axis inverted
  48801. * @param compression defines the compression used (null by default)
  48802. * @param level defines which level of the texture to update
  48803. */
  48804. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48805. /**
  48806. * Updates a raw cube texture with RGBD encoded data.
  48807. * @param data defines the array of data [mipmap][face] to use to create each face
  48808. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48809. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48810. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48811. * @returns a promsie that resolves when the operation is complete
  48812. */
  48813. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48814. /**
  48815. * Clones the raw cube texture.
  48816. * @return a new cube texture
  48817. */
  48818. clone(): CubeTexture;
  48819. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48820. }
  48821. }
  48822. declare module BABYLON {
  48823. /**
  48824. * Class used to store 3D textures containing user data
  48825. */
  48826. export class RawTexture3D extends Texture {
  48827. /** Gets or sets the texture format to use */
  48828. format: number;
  48829. private _engine;
  48830. /**
  48831. * Create a new RawTexture3D
  48832. * @param data defines the data of the texture
  48833. * @param width defines the width of the texture
  48834. * @param height defines the height of the texture
  48835. * @param depth defines the depth of the texture
  48836. * @param format defines the texture format to use
  48837. * @param scene defines the hosting scene
  48838. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48839. * @param invertY defines if texture must be stored with Y axis inverted
  48840. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48841. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48842. */
  48843. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48844. /** Gets or sets the texture format to use */
  48845. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48846. /**
  48847. * Update the texture with new data
  48848. * @param data defines the data to store in the texture
  48849. */
  48850. update(data: ArrayBufferView): void;
  48851. }
  48852. }
  48853. declare module BABYLON {
  48854. /**
  48855. * Creates a refraction texture used by refraction channel of the standard material.
  48856. * It is like a mirror but to see through a material.
  48857. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48858. */
  48859. export class RefractionTexture extends RenderTargetTexture {
  48860. /**
  48861. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48862. * 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.
  48863. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48864. */
  48865. refractionPlane: Plane;
  48866. /**
  48867. * Define how deep under the surface we should see.
  48868. */
  48869. depth: number;
  48870. /**
  48871. * Creates a refraction texture used by refraction channel of the standard material.
  48872. * It is like a mirror but to see through a material.
  48873. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48874. * @param name Define the texture name
  48875. * @param size Define the size of the underlying texture
  48876. * @param scene Define the scene the refraction belongs to
  48877. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48878. */
  48879. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48880. /**
  48881. * Clone the refraction texture.
  48882. * @returns the cloned texture
  48883. */
  48884. clone(): RefractionTexture;
  48885. /**
  48886. * Serialize the texture to a JSON representation you could use in Parse later on
  48887. * @returns the serialized JSON representation
  48888. */
  48889. serialize(): any;
  48890. }
  48891. }
  48892. declare module BABYLON {
  48893. /**
  48894. * Defines the options related to the creation of an HtmlElementTexture
  48895. */
  48896. export interface IHtmlElementTextureOptions {
  48897. /**
  48898. * Defines wether mip maps should be created or not.
  48899. */
  48900. generateMipMaps?: boolean;
  48901. /**
  48902. * Defines the sampling mode of the texture.
  48903. */
  48904. samplingMode?: number;
  48905. /**
  48906. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  48907. */
  48908. engine: Nullable<Engine>;
  48909. /**
  48910. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  48911. */
  48912. scene: Nullable<Scene>;
  48913. }
  48914. /**
  48915. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  48916. * To be as efficient as possible depending on your constraints nothing aside the first upload
  48917. * is automatically managed.
  48918. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  48919. * in your application.
  48920. *
  48921. * As the update is not automatic, you need to call them manually.
  48922. */
  48923. export class HtmlElementTexture extends BaseTexture {
  48924. /**
  48925. * The texture URL.
  48926. */
  48927. element: HTMLVideoElement | HTMLCanvasElement;
  48928. private static readonly DefaultOptions;
  48929. private _textureMatrix;
  48930. private _engine;
  48931. private _isVideo;
  48932. private _generateMipMaps;
  48933. private _samplingMode;
  48934. /**
  48935. * Instantiates a HtmlElementTexture from the following parameters.
  48936. *
  48937. * @param name Defines the name of the texture
  48938. * @param element Defines the video or canvas the texture is filled with
  48939. * @param options Defines the other none mandatory texture creation options
  48940. */
  48941. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  48942. private _createInternalTexture;
  48943. /**
  48944. * Returns the texture matrix used in most of the material.
  48945. */
  48946. getTextureMatrix(): Matrix;
  48947. /**
  48948. * Updates the content of the texture.
  48949. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  48950. */
  48951. update(invertY?: Nullable<boolean>): void;
  48952. }
  48953. }
  48954. declare module BABYLON {
  48955. /**
  48956. * Helper class to push actions to a pool of workers.
  48957. */
  48958. export class WorkerPool implements IDisposable {
  48959. private _workerInfos;
  48960. private _pendingActions;
  48961. /**
  48962. * Constructor
  48963. * @param workers Array of workers to use for actions
  48964. */
  48965. constructor(workers: Array<Worker>);
  48966. /**
  48967. * Terminates all workers and clears any pending actions.
  48968. */
  48969. dispose(): void;
  48970. /**
  48971. * Pushes an action to the worker pool. If all the workers are active, the action will be
  48972. * pended until a worker has completed its action.
  48973. * @param action The action to perform. Call onComplete when the action is complete.
  48974. */
  48975. push(action: (worker: Worker, onComplete: () => void) => void): void;
  48976. private _execute;
  48977. }
  48978. }
  48979. declare module BABYLON {
  48980. /**
  48981. * Configuration for Draco compression
  48982. */
  48983. export interface IDracoCompressionConfiguration {
  48984. /**
  48985. * Configuration for the decoder.
  48986. */
  48987. decoder: {
  48988. /**
  48989. * The url to the WebAssembly module.
  48990. */
  48991. wasmUrl?: string;
  48992. /**
  48993. * The url to the WebAssembly binary.
  48994. */
  48995. wasmBinaryUrl?: string;
  48996. /**
  48997. * The url to the fallback JavaScript module.
  48998. */
  48999. fallbackUrl?: string;
  49000. };
  49001. }
  49002. /**
  49003. * Draco compression (https://google.github.io/draco/)
  49004. *
  49005. * This class wraps the Draco module.
  49006. *
  49007. * **Encoder**
  49008. *
  49009. * The encoder is not currently implemented.
  49010. *
  49011. * **Decoder**
  49012. *
  49013. * 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.
  49014. *
  49015. * To update the configuration, use the following code:
  49016. * ```javascript
  49017. * DracoCompression.Configuration = {
  49018. * decoder: {
  49019. * wasmUrl: "<url to the WebAssembly library>",
  49020. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  49021. * fallbackUrl: "<url to the fallback JavaScript library>",
  49022. * }
  49023. * };
  49024. * ```
  49025. *
  49026. * 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.
  49027. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  49028. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  49029. *
  49030. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  49031. * ```javascript
  49032. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  49033. * ```
  49034. *
  49035. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  49036. */
  49037. export class DracoCompression implements IDisposable {
  49038. private _workerPoolPromise?;
  49039. private _decoderModulePromise?;
  49040. /**
  49041. * The configuration. Defaults to the following urls:
  49042. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  49043. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  49044. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  49045. */
  49046. static Configuration: IDracoCompressionConfiguration;
  49047. /**
  49048. * Returns true if the decoder configuration is available.
  49049. */
  49050. static readonly DecoderAvailable: boolean;
  49051. /**
  49052. * Default number of workers to create when creating the draco compression object.
  49053. */
  49054. static DefaultNumWorkers: number;
  49055. private static GetDefaultNumWorkers;
  49056. private static _Default;
  49057. /**
  49058. * Default instance for the draco compression object.
  49059. */
  49060. static readonly Default: DracoCompression;
  49061. /**
  49062. * Constructor
  49063. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  49064. */
  49065. constructor(numWorkers?: number);
  49066. /**
  49067. * Stop all async operations and release resources.
  49068. */
  49069. dispose(): void;
  49070. /**
  49071. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  49072. * @returns a promise that resolves when ready
  49073. */
  49074. whenReadyAsync(): Promise<void>;
  49075. /**
  49076. * Decode Draco compressed mesh data to vertex data.
  49077. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  49078. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  49079. * @returns A promise that resolves with the decoded vertex data
  49080. */
  49081. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  49082. [kind: string]: number;
  49083. }): Promise<VertexData>;
  49084. }
  49085. }
  49086. declare module BABYLON {
  49087. /**
  49088. * Class for building Constructive Solid Geometry
  49089. */
  49090. export class CSG {
  49091. private polygons;
  49092. /**
  49093. * The world matrix
  49094. */
  49095. matrix: Matrix;
  49096. /**
  49097. * Stores the position
  49098. */
  49099. position: Vector3;
  49100. /**
  49101. * Stores the rotation
  49102. */
  49103. rotation: Vector3;
  49104. /**
  49105. * Stores the rotation quaternion
  49106. */
  49107. rotationQuaternion: Nullable<Quaternion>;
  49108. /**
  49109. * Stores the scaling vector
  49110. */
  49111. scaling: Vector3;
  49112. /**
  49113. * Convert the Mesh to CSG
  49114. * @param mesh The Mesh to convert to CSG
  49115. * @returns A new CSG from the Mesh
  49116. */
  49117. static FromMesh(mesh: Mesh): CSG;
  49118. /**
  49119. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  49120. * @param polygons Polygons used to construct a CSG solid
  49121. */
  49122. private static FromPolygons;
  49123. /**
  49124. * Clones, or makes a deep copy, of the CSG
  49125. * @returns A new CSG
  49126. */
  49127. clone(): CSG;
  49128. /**
  49129. * Unions this CSG with another CSG
  49130. * @param csg The CSG to union against this CSG
  49131. * @returns The unioned CSG
  49132. */
  49133. union(csg: CSG): CSG;
  49134. /**
  49135. * Unions this CSG with another CSG in place
  49136. * @param csg The CSG to union against this CSG
  49137. */
  49138. unionInPlace(csg: CSG): void;
  49139. /**
  49140. * Subtracts this CSG with another CSG
  49141. * @param csg The CSG to subtract against this CSG
  49142. * @returns A new CSG
  49143. */
  49144. subtract(csg: CSG): CSG;
  49145. /**
  49146. * Subtracts this CSG with another CSG in place
  49147. * @param csg The CSG to subtact against this CSG
  49148. */
  49149. subtractInPlace(csg: CSG): void;
  49150. /**
  49151. * Intersect this CSG with another CSG
  49152. * @param csg The CSG to intersect against this CSG
  49153. * @returns A new CSG
  49154. */
  49155. intersect(csg: CSG): CSG;
  49156. /**
  49157. * Intersects this CSG with another CSG in place
  49158. * @param csg The CSG to intersect against this CSG
  49159. */
  49160. intersectInPlace(csg: CSG): void;
  49161. /**
  49162. * Return a new CSG solid with solid and empty space switched. This solid is
  49163. * not modified.
  49164. * @returns A new CSG solid with solid and empty space switched
  49165. */
  49166. inverse(): CSG;
  49167. /**
  49168. * Inverses the CSG in place
  49169. */
  49170. inverseInPlace(): void;
  49171. /**
  49172. * This is used to keep meshes transformations so they can be restored
  49173. * when we build back a Babylon Mesh
  49174. * NB : All CSG operations are performed in world coordinates
  49175. * @param csg The CSG to copy the transform attributes from
  49176. * @returns This CSG
  49177. */
  49178. copyTransformAttributes(csg: CSG): CSG;
  49179. /**
  49180. * Build Raw mesh from CSG
  49181. * Coordinates here are in world space
  49182. * @param name The name of the mesh geometry
  49183. * @param scene The Scene
  49184. * @param keepSubMeshes Specifies if the submeshes should be kept
  49185. * @returns A new Mesh
  49186. */
  49187. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  49188. /**
  49189. * Build Mesh from CSG taking material and transforms into account
  49190. * @param name The name of the Mesh
  49191. * @param material The material of the Mesh
  49192. * @param scene The Scene
  49193. * @param keepSubMeshes Specifies if submeshes should be kept
  49194. * @returns The new Mesh
  49195. */
  49196. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  49197. }
  49198. }
  49199. declare module BABYLON {
  49200. /**
  49201. * Class used to create a trail following a mesh
  49202. */
  49203. export class TrailMesh extends Mesh {
  49204. private _generator;
  49205. private _autoStart;
  49206. private _running;
  49207. private _diameter;
  49208. private _length;
  49209. private _sectionPolygonPointsCount;
  49210. private _sectionVectors;
  49211. private _sectionNormalVectors;
  49212. private _beforeRenderObserver;
  49213. /**
  49214. * @constructor
  49215. * @param name The value used by scene.getMeshByName() to do a lookup.
  49216. * @param generator The mesh to generate a trail.
  49217. * @param scene The scene to add this mesh to.
  49218. * @param diameter Diameter of trailing mesh. Default is 1.
  49219. * @param length Length of trailing mesh. Default is 60.
  49220. * @param autoStart Automatically start trailing mesh. Default true.
  49221. */
  49222. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  49223. /**
  49224. * "TrailMesh"
  49225. * @returns "TrailMesh"
  49226. */
  49227. getClassName(): string;
  49228. private _createMesh;
  49229. /**
  49230. * Start trailing mesh.
  49231. */
  49232. start(): void;
  49233. /**
  49234. * Stop trailing mesh.
  49235. */
  49236. stop(): void;
  49237. /**
  49238. * Update trailing mesh geometry.
  49239. */
  49240. update(): void;
  49241. /**
  49242. * Returns a new TrailMesh object.
  49243. * @param name is a string, the name given to the new mesh
  49244. * @param newGenerator use new generator object for cloned trail mesh
  49245. * @returns a new mesh
  49246. */
  49247. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  49248. /**
  49249. * Serializes this trail mesh
  49250. * @param serializationObject object to write serialization to
  49251. */
  49252. serialize(serializationObject: any): void;
  49253. /**
  49254. * Parses a serialized trail mesh
  49255. * @param parsedMesh the serialized mesh
  49256. * @param scene the scene to create the trail mesh in
  49257. * @returns the created trail mesh
  49258. */
  49259. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  49260. }
  49261. }
  49262. declare module BABYLON {
  49263. /**
  49264. * Class containing static functions to help procedurally build meshes
  49265. */
  49266. export class TorusKnotBuilder {
  49267. /**
  49268. * Creates a torus knot mesh
  49269. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49270. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49271. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49272. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49274. * * 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
  49275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49276. * @param name defines the name of the mesh
  49277. * @param options defines the options used to create the mesh
  49278. * @param scene defines the hosting scene
  49279. * @returns the torus knot mesh
  49280. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49281. */
  49282. static CreateTorusKnot(name: string, options: {
  49283. radius?: number;
  49284. tube?: number;
  49285. radialSegments?: number;
  49286. tubularSegments?: number;
  49287. p?: number;
  49288. q?: number;
  49289. updatable?: boolean;
  49290. sideOrientation?: number;
  49291. frontUVs?: Vector4;
  49292. backUVs?: Vector4;
  49293. }, scene: any): Mesh;
  49294. }
  49295. }
  49296. declare module BABYLON {
  49297. /**
  49298. * Polygon
  49299. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  49300. */
  49301. export class Polygon {
  49302. /**
  49303. * Creates a rectangle
  49304. * @param xmin bottom X coord
  49305. * @param ymin bottom Y coord
  49306. * @param xmax top X coord
  49307. * @param ymax top Y coord
  49308. * @returns points that make the resulting rectation
  49309. */
  49310. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  49311. /**
  49312. * Creates a circle
  49313. * @param radius radius of circle
  49314. * @param cx scale in x
  49315. * @param cy scale in y
  49316. * @param numberOfSides number of sides that make up the circle
  49317. * @returns points that make the resulting circle
  49318. */
  49319. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  49320. /**
  49321. * Creates a polygon from input string
  49322. * @param input Input polygon data
  49323. * @returns the parsed points
  49324. */
  49325. static Parse(input: string): Vector2[];
  49326. /**
  49327. * Starts building a polygon from x and y coordinates
  49328. * @param x x coordinate
  49329. * @param y y coordinate
  49330. * @returns the started path2
  49331. */
  49332. static StartingAt(x: number, y: number): Path2;
  49333. }
  49334. /**
  49335. * Builds a polygon
  49336. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  49337. */
  49338. export class PolygonMeshBuilder {
  49339. private _points;
  49340. private _outlinepoints;
  49341. private _holes;
  49342. private _name;
  49343. private _scene;
  49344. private _epoints;
  49345. private _eholes;
  49346. private _addToepoint;
  49347. /**
  49348. * Babylon reference to the earcut plugin.
  49349. */
  49350. bjsEarcut: any;
  49351. /**
  49352. * Creates a PolygonMeshBuilder
  49353. * @param name name of the builder
  49354. * @param contours Path of the polygon
  49355. * @param scene scene to add to when creating the mesh
  49356. * @param earcutInjection can be used to inject your own earcut reference
  49357. */
  49358. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  49359. /**
  49360. * Adds a whole within the polygon
  49361. * @param hole Array of points defining the hole
  49362. * @returns this
  49363. */
  49364. addHole(hole: Vector2[]): PolygonMeshBuilder;
  49365. /**
  49366. * Creates the polygon
  49367. * @param updatable If the mesh should be updatable
  49368. * @param depth The depth of the mesh created
  49369. * @returns the created mesh
  49370. */
  49371. build(updatable?: boolean, depth?: number): Mesh;
  49372. /**
  49373. * Creates the polygon
  49374. * @param depth The depth of the mesh created
  49375. * @returns the created VertexData
  49376. */
  49377. buildVertexData(depth?: number): VertexData;
  49378. /**
  49379. * Adds a side to the polygon
  49380. * @param positions points that make the polygon
  49381. * @param normals normals of the polygon
  49382. * @param uvs uvs of the polygon
  49383. * @param indices indices of the polygon
  49384. * @param bounds bounds of the polygon
  49385. * @param points points of the polygon
  49386. * @param depth depth of the polygon
  49387. * @param flip flip of the polygon
  49388. */
  49389. private addSide;
  49390. }
  49391. }
  49392. declare module BABYLON {
  49393. /**
  49394. * Class containing static functions to help procedurally build meshes
  49395. */
  49396. export class PolygonBuilder {
  49397. /**
  49398. * Creates a polygon mesh
  49399. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49400. * * 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
  49401. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49402. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49403. * * 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)
  49404. * * Remember you can only change the shape positions, not their number when updating a polygon
  49405. * @param name defines the name of the mesh
  49406. * @param options defines the options used to create the mesh
  49407. * @param scene defines the hosting scene
  49408. * @param earcutInjection can be used to inject your own earcut reference
  49409. * @returns the polygon mesh
  49410. */
  49411. static CreatePolygon(name: string, options: {
  49412. shape: Vector3[];
  49413. holes?: Vector3[][];
  49414. depth?: number;
  49415. faceUV?: Vector4[];
  49416. faceColors?: Color4[];
  49417. updatable?: boolean;
  49418. sideOrientation?: number;
  49419. frontUVs?: Vector4;
  49420. backUVs?: Vector4;
  49421. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49422. /**
  49423. * Creates an extruded polygon mesh, with depth in the Y direction.
  49424. * * 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)
  49425. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49426. * @param name defines the name of the mesh
  49427. * @param options defines the options used to create the mesh
  49428. * @param scene defines the hosting scene
  49429. * @param earcutInjection can be used to inject your own earcut reference
  49430. * @returns the polygon mesh
  49431. */
  49432. static ExtrudePolygon(name: string, options: {
  49433. shape: Vector3[];
  49434. holes?: Vector3[][];
  49435. depth?: number;
  49436. faceUV?: Vector4[];
  49437. faceColors?: Color4[];
  49438. updatable?: boolean;
  49439. sideOrientation?: number;
  49440. frontUVs?: Vector4;
  49441. backUVs?: Vector4;
  49442. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  49443. }
  49444. }
  49445. declare module BABYLON {
  49446. /**
  49447. * Class containing static functions to help procedurally build meshes
  49448. */
  49449. export class LatheBuilder {
  49450. /**
  49451. * Creates lathe mesh.
  49452. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49453. * * 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
  49454. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49455. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49456. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49457. * * 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
  49458. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49459. * * 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
  49460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49461. * * 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
  49462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49464. * @param name defines the name of the mesh
  49465. * @param options defines the options used to create the mesh
  49466. * @param scene defines the hosting scene
  49467. * @returns the lathe mesh
  49468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49469. */
  49470. static CreateLathe(name: string, options: {
  49471. shape: Vector3[];
  49472. radius?: number;
  49473. tessellation?: number;
  49474. clip?: number;
  49475. arc?: number;
  49476. closed?: boolean;
  49477. updatable?: boolean;
  49478. sideOrientation?: number;
  49479. frontUVs?: Vector4;
  49480. backUVs?: Vector4;
  49481. cap?: number;
  49482. invertUV?: boolean;
  49483. }, scene?: Nullable<Scene>): Mesh;
  49484. }
  49485. }
  49486. declare module BABYLON {
  49487. /**
  49488. * Class containing static functions to help procedurally build meshes
  49489. */
  49490. export class TubeBuilder {
  49491. /**
  49492. * Creates a tube mesh.
  49493. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49494. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49495. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49496. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49497. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49498. * * 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)
  49499. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49500. * * 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
  49501. * * 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
  49502. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49503. * * 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
  49504. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49505. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49506. * @param name defines the name of the mesh
  49507. * @param options defines the options used to create the mesh
  49508. * @param scene defines the hosting scene
  49509. * @returns the tube mesh
  49510. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49511. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49512. */
  49513. static CreateTube(name: string, options: {
  49514. path: Vector3[];
  49515. radius?: number;
  49516. tessellation?: number;
  49517. radiusFunction?: {
  49518. (i: number, distance: number): number;
  49519. };
  49520. cap?: number;
  49521. arc?: number;
  49522. updatable?: boolean;
  49523. sideOrientation?: number;
  49524. frontUVs?: Vector4;
  49525. backUVs?: Vector4;
  49526. instance?: Mesh;
  49527. invertUV?: boolean;
  49528. }, scene?: Nullable<Scene>): Mesh;
  49529. }
  49530. }
  49531. declare module BABYLON {
  49532. /**
  49533. * Class containing static functions to help procedurally build meshes
  49534. */
  49535. export class IcoSphereBuilder {
  49536. /**
  49537. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49538. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49539. * * 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`)
  49540. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49541. * * 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
  49542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49543. * * 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
  49544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49545. * @param name defines the name of the mesh
  49546. * @param options defines the options used to create the mesh
  49547. * @param scene defines the hosting scene
  49548. * @returns the icosahedron mesh
  49549. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49550. */
  49551. static CreateIcoSphere(name: string, options: {
  49552. radius?: number;
  49553. radiusX?: number;
  49554. radiusY?: number;
  49555. radiusZ?: number;
  49556. flat?: boolean;
  49557. subdivisions?: number;
  49558. sideOrientation?: number;
  49559. frontUVs?: Vector4;
  49560. backUVs?: Vector4;
  49561. updatable?: boolean;
  49562. }, scene?: Nullable<Scene>): Mesh;
  49563. }
  49564. }
  49565. declare module BABYLON {
  49566. /**
  49567. * Class containing static functions to help procedurally build meshes
  49568. */
  49569. export class DecalBuilder {
  49570. /**
  49571. * Creates a decal mesh.
  49572. * 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
  49573. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49574. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49575. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49576. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49577. * @param name defines the name of the mesh
  49578. * @param sourceMesh defines the mesh where the decal must be applied
  49579. * @param options defines the options used to create the mesh
  49580. * @param scene defines the hosting scene
  49581. * @returns the decal mesh
  49582. * @see https://doc.babylonjs.com/how_to/decals
  49583. */
  49584. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49585. position?: Vector3;
  49586. normal?: Vector3;
  49587. size?: Vector3;
  49588. angle?: number;
  49589. }): Mesh;
  49590. }
  49591. }
  49592. declare module BABYLON {
  49593. /**
  49594. * Class containing static functions to help procedurally build meshes
  49595. */
  49596. export class MeshBuilder {
  49597. /**
  49598. * Creates a box mesh
  49599. * * The parameter `size` sets the size (float) of each box side (default 1)
  49600. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  49601. * * 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)
  49602. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49603. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49604. * * 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
  49605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49606. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  49607. * @param name defines the name of the mesh
  49608. * @param options defines the options used to create the mesh
  49609. * @param scene defines the hosting scene
  49610. * @returns the box mesh
  49611. */
  49612. static CreateBox(name: string, options: {
  49613. size?: number;
  49614. width?: number;
  49615. height?: number;
  49616. depth?: number;
  49617. faceUV?: Vector4[];
  49618. faceColors?: Color4[];
  49619. sideOrientation?: number;
  49620. frontUVs?: Vector4;
  49621. backUVs?: Vector4;
  49622. updatable?: boolean;
  49623. }, scene?: Nullable<Scene>): Mesh;
  49624. /**
  49625. * Creates a sphere mesh
  49626. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49627. * * 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`)
  49628. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49629. * * 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
  49630. * * 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)
  49631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49632. * * 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
  49633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49634. * @param name defines the name of the mesh
  49635. * @param options defines the options used to create the mesh
  49636. * @param scene defines the hosting scene
  49637. * @returns the sphere mesh
  49638. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49639. */
  49640. static CreateSphere(name: string, options: {
  49641. segments?: number;
  49642. diameter?: number;
  49643. diameterX?: number;
  49644. diameterY?: number;
  49645. diameterZ?: number;
  49646. arc?: number;
  49647. slice?: number;
  49648. sideOrientation?: number;
  49649. frontUVs?: Vector4;
  49650. backUVs?: Vector4;
  49651. updatable?: boolean;
  49652. }, scene?: Nullable<Scene>): Mesh;
  49653. /**
  49654. * Creates a plane polygonal mesh. By default, this is a disc
  49655. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  49656. * * 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
  49657. * * 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
  49658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49659. * * 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
  49660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49661. * @param name defines the name of the mesh
  49662. * @param options defines the options used to create the mesh
  49663. * @param scene defines the hosting scene
  49664. * @returns the plane polygonal mesh
  49665. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  49666. */
  49667. static CreateDisc(name: string, options: {
  49668. radius?: number;
  49669. tessellation?: number;
  49670. arc?: number;
  49671. updatable?: boolean;
  49672. sideOrientation?: number;
  49673. frontUVs?: Vector4;
  49674. backUVs?: Vector4;
  49675. }, scene?: Nullable<Scene>): Mesh;
  49676. /**
  49677. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  49678. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  49679. * * 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`)
  49680. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  49681. * * 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
  49682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49683. * * 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
  49684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49685. * @param name defines the name of the mesh
  49686. * @param options defines the options used to create the mesh
  49687. * @param scene defines the hosting scene
  49688. * @returns the icosahedron mesh
  49689. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  49690. */
  49691. static CreateIcoSphere(name: string, options: {
  49692. radius?: number;
  49693. radiusX?: number;
  49694. radiusY?: number;
  49695. radiusZ?: number;
  49696. flat?: boolean;
  49697. subdivisions?: number;
  49698. sideOrientation?: number;
  49699. frontUVs?: Vector4;
  49700. backUVs?: Vector4;
  49701. updatable?: boolean;
  49702. }, scene?: Nullable<Scene>): Mesh;
  49703. /**
  49704. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49705. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49706. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49707. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49708. * * 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
  49709. * * 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
  49710. * * 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
  49711. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49712. * * 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
  49713. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49714. * * 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
  49715. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49716. * * 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
  49717. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49719. * @param name defines the name of the mesh
  49720. * @param options defines the options used to create the mesh
  49721. * @param scene defines the hosting scene
  49722. * @returns the ribbon mesh
  49723. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49724. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49725. */
  49726. static CreateRibbon(name: string, options: {
  49727. pathArray: Vector3[][];
  49728. closeArray?: boolean;
  49729. closePath?: boolean;
  49730. offset?: number;
  49731. updatable?: boolean;
  49732. sideOrientation?: number;
  49733. frontUVs?: Vector4;
  49734. backUVs?: Vector4;
  49735. instance?: Mesh;
  49736. invertUV?: boolean;
  49737. uvs?: Vector2[];
  49738. colors?: Color4[];
  49739. }, scene?: Nullable<Scene>): Mesh;
  49740. /**
  49741. * Creates a cylinder or a cone mesh
  49742. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49743. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49744. * * 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.
  49745. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49746. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49747. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49748. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49749. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49750. * * 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).
  49751. * * 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
  49752. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49753. * * 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
  49754. * * 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.
  49755. * * If `enclose` is false, a ring surface is one element.
  49756. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49757. * * 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
  49758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49759. * * 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
  49760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49761. * @param name defines the name of the mesh
  49762. * @param options defines the options used to create the mesh
  49763. * @param scene defines the hosting scene
  49764. * @returns the cylinder mesh
  49765. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49766. */
  49767. static CreateCylinder(name: string, options: {
  49768. height?: number;
  49769. diameterTop?: number;
  49770. diameterBottom?: number;
  49771. diameter?: number;
  49772. tessellation?: number;
  49773. subdivisions?: number;
  49774. arc?: number;
  49775. faceColors?: Color4[];
  49776. faceUV?: Vector4[];
  49777. updatable?: boolean;
  49778. hasRings?: boolean;
  49779. enclose?: boolean;
  49780. sideOrientation?: number;
  49781. frontUVs?: Vector4;
  49782. backUVs?: Vector4;
  49783. }, scene?: Nullable<Scene>): Mesh;
  49784. /**
  49785. * Creates a torus mesh
  49786. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49787. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49788. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49790. * * 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
  49791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49792. * @param name defines the name of the mesh
  49793. * @param options defines the options used to create the mesh
  49794. * @param scene defines the hosting scene
  49795. * @returns the torus mesh
  49796. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49797. */
  49798. static CreateTorus(name: string, options: {
  49799. diameter?: number;
  49800. thickness?: number;
  49801. tessellation?: number;
  49802. updatable?: boolean;
  49803. sideOrientation?: number;
  49804. frontUVs?: Vector4;
  49805. backUVs?: Vector4;
  49806. }, scene?: Nullable<Scene>): Mesh;
  49807. /**
  49808. * Creates a torus knot mesh
  49809. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49810. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49811. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49812. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49813. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49814. * * 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
  49815. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49816. * @param name defines the name of the mesh
  49817. * @param options defines the options used to create the mesh
  49818. * @param scene defines the hosting scene
  49819. * @returns the torus knot mesh
  49820. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49821. */
  49822. static CreateTorusKnot(name: string, options: {
  49823. radius?: number;
  49824. tube?: number;
  49825. radialSegments?: number;
  49826. tubularSegments?: number;
  49827. p?: number;
  49828. q?: number;
  49829. updatable?: boolean;
  49830. sideOrientation?: number;
  49831. frontUVs?: Vector4;
  49832. backUVs?: Vector4;
  49833. }, scene?: Nullable<Scene>): Mesh;
  49834. /**
  49835. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49836. * * 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
  49837. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49838. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49839. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49840. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49841. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49842. * * 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
  49843. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49845. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49846. * @param name defines the name of the new line system
  49847. * @param options defines the options used to create the line system
  49848. * @param scene defines the hosting scene
  49849. * @returns a new line system mesh
  49850. */
  49851. static CreateLineSystem(name: string, options: {
  49852. lines: Vector3[][];
  49853. updatable?: boolean;
  49854. instance?: Nullable<LinesMesh>;
  49855. colors?: Nullable<Color4[][]>;
  49856. useVertexAlpha?: boolean;
  49857. }, scene: Nullable<Scene>): LinesMesh;
  49858. /**
  49859. * Creates a line mesh
  49860. * 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
  49861. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49862. * * The parameter `points` is an array successive Vector3
  49863. * * 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
  49864. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49865. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49866. * * When updating an instance, remember that only point positions can change, not the number of points
  49867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49868. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49869. * @param name defines the name of the new line system
  49870. * @param options defines the options used to create the line system
  49871. * @param scene defines the hosting scene
  49872. * @returns a new line mesh
  49873. */
  49874. static CreateLines(name: string, options: {
  49875. points: Vector3[];
  49876. updatable?: boolean;
  49877. instance?: Nullable<LinesMesh>;
  49878. colors?: Color4[];
  49879. useVertexAlpha?: boolean;
  49880. }, scene?: Nullable<Scene>): LinesMesh;
  49881. /**
  49882. * Creates a dashed line mesh
  49883. * * 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
  49884. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49885. * * The parameter `points` is an array successive Vector3
  49886. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49887. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49888. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49889. * * 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
  49890. * * When updating an instance, remember that only point positions can change, not the number of points
  49891. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49892. * @param name defines the name of the mesh
  49893. * @param options defines the options used to create the mesh
  49894. * @param scene defines the hosting scene
  49895. * @returns the dashed line mesh
  49896. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49897. */
  49898. static CreateDashedLines(name: string, options: {
  49899. points: Vector3[];
  49900. dashSize?: number;
  49901. gapSize?: number;
  49902. dashNb?: number;
  49903. updatable?: boolean;
  49904. instance?: LinesMesh;
  49905. }, scene?: Nullable<Scene>): LinesMesh;
  49906. /**
  49907. * 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.
  49908. * * 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.
  49909. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49910. * * 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.
  49911. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49912. * * 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
  49913. * * 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
  49914. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49916. * * 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
  49917. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49918. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49919. * @param name defines the name of the mesh
  49920. * @param options defines the options used to create the mesh
  49921. * @param scene defines the hosting scene
  49922. * @returns the extruded shape mesh
  49923. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49925. */
  49926. static ExtrudeShape(name: string, options: {
  49927. shape: Vector3[];
  49928. path: Vector3[];
  49929. scale?: number;
  49930. rotation?: number;
  49931. cap?: number;
  49932. updatable?: boolean;
  49933. sideOrientation?: number;
  49934. frontUVs?: Vector4;
  49935. backUVs?: Vector4;
  49936. instance?: Mesh;
  49937. invertUV?: boolean;
  49938. }, scene?: Nullable<Scene>): Mesh;
  49939. /**
  49940. * Creates an custom extruded shape mesh.
  49941. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49942. * * 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.
  49943. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49944. * * 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
  49945. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49946. * * 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
  49947. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49948. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49949. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49950. * * 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
  49951. * * 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
  49952. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49954. * * 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
  49955. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49957. * @param name defines the name of the mesh
  49958. * @param options defines the options used to create the mesh
  49959. * @param scene defines the hosting scene
  49960. * @returns the custom extruded shape mesh
  49961. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49962. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49963. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49964. */
  49965. static ExtrudeShapeCustom(name: string, options: {
  49966. shape: Vector3[];
  49967. path: Vector3[];
  49968. scaleFunction?: any;
  49969. rotationFunction?: any;
  49970. ribbonCloseArray?: boolean;
  49971. ribbonClosePath?: boolean;
  49972. cap?: number;
  49973. updatable?: boolean;
  49974. sideOrientation?: number;
  49975. frontUVs?: Vector4;
  49976. backUVs?: Vector4;
  49977. instance?: Mesh;
  49978. invertUV?: boolean;
  49979. }, scene?: Nullable<Scene>): Mesh;
  49980. /**
  49981. * Creates lathe mesh.
  49982. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49983. * * 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
  49984. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49985. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49986. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49987. * * 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
  49988. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49989. * * 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
  49990. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49991. * * 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
  49992. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49993. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49994. * @param name defines the name of the mesh
  49995. * @param options defines the options used to create the mesh
  49996. * @param scene defines the hosting scene
  49997. * @returns the lathe mesh
  49998. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49999. */
  50000. static CreateLathe(name: string, options: {
  50001. shape: Vector3[];
  50002. radius?: number;
  50003. tessellation?: number;
  50004. clip?: number;
  50005. arc?: number;
  50006. closed?: boolean;
  50007. updatable?: boolean;
  50008. sideOrientation?: number;
  50009. frontUVs?: Vector4;
  50010. backUVs?: Vector4;
  50011. cap?: number;
  50012. invertUV?: boolean;
  50013. }, scene?: Nullable<Scene>): Mesh;
  50014. /**
  50015. * Creates a plane mesh
  50016. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  50017. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  50018. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  50019. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50020. * * 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
  50021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50022. * @param name defines the name of the mesh
  50023. * @param options defines the options used to create the mesh
  50024. * @param scene defines the hosting scene
  50025. * @returns the plane mesh
  50026. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  50027. */
  50028. static CreatePlane(name: string, options: {
  50029. size?: number;
  50030. width?: number;
  50031. height?: number;
  50032. sideOrientation?: number;
  50033. frontUVs?: Vector4;
  50034. backUVs?: Vector4;
  50035. updatable?: boolean;
  50036. sourcePlane?: Plane;
  50037. }, scene?: Nullable<Scene>): Mesh;
  50038. /**
  50039. * Creates a ground mesh
  50040. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  50041. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  50042. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50043. * @param name defines the name of the mesh
  50044. * @param options defines the options used to create the mesh
  50045. * @param scene defines the hosting scene
  50046. * @returns the ground mesh
  50047. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  50048. */
  50049. static CreateGround(name: string, options: {
  50050. width?: number;
  50051. height?: number;
  50052. subdivisions?: number;
  50053. subdivisionsX?: number;
  50054. subdivisionsY?: number;
  50055. updatable?: boolean;
  50056. }, scene?: Nullable<Scene>): Mesh;
  50057. /**
  50058. * Creates a tiled ground mesh
  50059. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  50060. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  50061. * * 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
  50062. * * 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
  50063. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50064. * @param name defines the name of the mesh
  50065. * @param options defines the options used to create the mesh
  50066. * @param scene defines the hosting scene
  50067. * @returns the tiled ground mesh
  50068. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  50069. */
  50070. static CreateTiledGround(name: string, options: {
  50071. xmin: number;
  50072. zmin: number;
  50073. xmax: number;
  50074. zmax: number;
  50075. subdivisions?: {
  50076. w: number;
  50077. h: number;
  50078. };
  50079. precision?: {
  50080. w: number;
  50081. h: number;
  50082. };
  50083. updatable?: boolean;
  50084. }, scene?: Nullable<Scene>): Mesh;
  50085. /**
  50086. * Creates a ground mesh from a height map
  50087. * * The parameter `url` sets the URL of the height map image resource.
  50088. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  50089. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  50090. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  50091. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  50092. * * 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.
  50093. * * 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).
  50094. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  50095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50096. * @param name defines the name of the mesh
  50097. * @param url defines the url to the height map
  50098. * @param options defines the options used to create the mesh
  50099. * @param scene defines the hosting scene
  50100. * @returns the ground mesh
  50101. * @see https://doc.babylonjs.com/babylon101/height_map
  50102. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  50103. */
  50104. static CreateGroundFromHeightMap(name: string, url: string, options: {
  50105. width?: number;
  50106. height?: number;
  50107. subdivisions?: number;
  50108. minHeight?: number;
  50109. maxHeight?: number;
  50110. colorFilter?: Color3;
  50111. alphaFilter?: number;
  50112. updatable?: boolean;
  50113. onReady?: (mesh: GroundMesh) => void;
  50114. }, scene?: Nullable<Scene>): GroundMesh;
  50115. /**
  50116. * Creates a polygon mesh
  50117. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  50118. * * 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
  50119. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  50120. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50121. * * 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)
  50122. * * Remember you can only change the shape positions, not their number when updating a polygon
  50123. * @param name defines the name of the mesh
  50124. * @param options defines the options used to create the mesh
  50125. * @param scene defines the hosting scene
  50126. * @param earcutInjection can be used to inject your own earcut reference
  50127. * @returns the polygon mesh
  50128. */
  50129. static CreatePolygon(name: string, options: {
  50130. shape: Vector3[];
  50131. holes?: Vector3[][];
  50132. depth?: number;
  50133. faceUV?: Vector4[];
  50134. faceColors?: Color4[];
  50135. updatable?: boolean;
  50136. sideOrientation?: number;
  50137. frontUVs?: Vector4;
  50138. backUVs?: Vector4;
  50139. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50140. /**
  50141. * Creates an extruded polygon mesh, with depth in the Y direction.
  50142. * * 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)
  50143. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50144. * @param name defines the name of the mesh
  50145. * @param options defines the options used to create the mesh
  50146. * @param scene defines the hosting scene
  50147. * @param earcutInjection can be used to inject your own earcut reference
  50148. * @returns the polygon mesh
  50149. */
  50150. static ExtrudePolygon(name: string, options: {
  50151. shape: Vector3[];
  50152. holes?: Vector3[][];
  50153. depth?: number;
  50154. faceUV?: Vector4[];
  50155. faceColors?: Color4[];
  50156. updatable?: boolean;
  50157. sideOrientation?: number;
  50158. frontUVs?: Vector4;
  50159. backUVs?: Vector4;
  50160. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  50161. /**
  50162. * Creates a tube mesh.
  50163. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50164. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  50165. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  50166. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  50167. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  50168. * * 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)
  50169. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  50170. * * 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
  50171. * * 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
  50172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50173. * * 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
  50174. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50176. * @param name defines the name of the mesh
  50177. * @param options defines the options used to create the mesh
  50178. * @param scene defines the hosting scene
  50179. * @returns the tube mesh
  50180. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50181. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  50182. */
  50183. static CreateTube(name: string, options: {
  50184. path: Vector3[];
  50185. radius?: number;
  50186. tessellation?: number;
  50187. radiusFunction?: {
  50188. (i: number, distance: number): number;
  50189. };
  50190. cap?: number;
  50191. arc?: number;
  50192. updatable?: boolean;
  50193. sideOrientation?: number;
  50194. frontUVs?: Vector4;
  50195. backUVs?: Vector4;
  50196. instance?: Mesh;
  50197. invertUV?: boolean;
  50198. }, scene?: Nullable<Scene>): Mesh;
  50199. /**
  50200. * Creates a polyhedron mesh
  50201. * * 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
  50202. * * The parameter `size` (positive float, default 1) sets the polygon size
  50203. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50204. * * 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`
  50205. * * 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
  50206. * * 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)`)
  50207. * * 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
  50208. * * 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
  50209. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50210. * * 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
  50211. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50212. * @param name defines the name of the mesh
  50213. * @param options defines the options used to create the mesh
  50214. * @param scene defines the hosting scene
  50215. * @returns the polyhedron mesh
  50216. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50217. */
  50218. static CreatePolyhedron(name: string, options: {
  50219. type?: number;
  50220. size?: number;
  50221. sizeX?: number;
  50222. sizeY?: number;
  50223. sizeZ?: number;
  50224. custom?: any;
  50225. faceUV?: Vector4[];
  50226. faceColors?: Color4[];
  50227. flat?: boolean;
  50228. updatable?: boolean;
  50229. sideOrientation?: number;
  50230. frontUVs?: Vector4;
  50231. backUVs?: Vector4;
  50232. }, scene?: Nullable<Scene>): Mesh;
  50233. /**
  50234. * Creates a decal mesh.
  50235. * 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
  50236. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  50237. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  50238. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  50239. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  50240. * @param name defines the name of the mesh
  50241. * @param sourceMesh defines the mesh where the decal must be applied
  50242. * @param options defines the options used to create the mesh
  50243. * @param scene defines the hosting scene
  50244. * @returns the decal mesh
  50245. * @see https://doc.babylonjs.com/how_to/decals
  50246. */
  50247. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  50248. position?: Vector3;
  50249. normal?: Vector3;
  50250. size?: Vector3;
  50251. angle?: number;
  50252. }): Mesh;
  50253. }
  50254. }
  50255. declare module BABYLON {
  50256. /**
  50257. * A simplifier interface for future simplification implementations
  50258. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50259. */
  50260. export interface ISimplifier {
  50261. /**
  50262. * Simplification of a given mesh according to the given settings.
  50263. * Since this requires computation, it is assumed that the function runs async.
  50264. * @param settings The settings of the simplification, including quality and distance
  50265. * @param successCallback A callback that will be called after the mesh was simplified.
  50266. * @param errorCallback in case of an error, this callback will be called. optional.
  50267. */
  50268. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  50269. }
  50270. /**
  50271. * Expected simplification settings.
  50272. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  50273. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50274. */
  50275. export interface ISimplificationSettings {
  50276. /**
  50277. * Gets or sets the expected quality
  50278. */
  50279. quality: number;
  50280. /**
  50281. * Gets or sets the distance when this optimized version should be used
  50282. */
  50283. distance: number;
  50284. /**
  50285. * Gets an already optimized mesh
  50286. */
  50287. optimizeMesh?: boolean;
  50288. }
  50289. /**
  50290. * Class used to specify simplification options
  50291. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50292. */
  50293. export class SimplificationSettings implements ISimplificationSettings {
  50294. /** expected quality */
  50295. quality: number;
  50296. /** distance when this optimized version should be used */
  50297. distance: number;
  50298. /** already optimized mesh */
  50299. optimizeMesh?: boolean | undefined;
  50300. /**
  50301. * Creates a SimplificationSettings
  50302. * @param quality expected quality
  50303. * @param distance distance when this optimized version should be used
  50304. * @param optimizeMesh already optimized mesh
  50305. */
  50306. constructor(
  50307. /** expected quality */
  50308. quality: number,
  50309. /** distance when this optimized version should be used */
  50310. distance: number,
  50311. /** already optimized mesh */
  50312. optimizeMesh?: boolean | undefined);
  50313. }
  50314. /**
  50315. * Interface used to define a simplification task
  50316. */
  50317. export interface ISimplificationTask {
  50318. /**
  50319. * Array of settings
  50320. */
  50321. settings: Array<ISimplificationSettings>;
  50322. /**
  50323. * Simplification type
  50324. */
  50325. simplificationType: SimplificationType;
  50326. /**
  50327. * Mesh to simplify
  50328. */
  50329. mesh: Mesh;
  50330. /**
  50331. * Callback called on success
  50332. */
  50333. successCallback?: () => void;
  50334. /**
  50335. * Defines if parallel processing can be used
  50336. */
  50337. parallelProcessing: boolean;
  50338. }
  50339. /**
  50340. * Queue used to order the simplification tasks
  50341. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50342. */
  50343. export class SimplificationQueue {
  50344. private _simplificationArray;
  50345. /**
  50346. * Gets a boolean indicating that the process is still running
  50347. */
  50348. running: boolean;
  50349. /**
  50350. * Creates a new queue
  50351. */
  50352. constructor();
  50353. /**
  50354. * Adds a new simplification task
  50355. * @param task defines a task to add
  50356. */
  50357. addTask(task: ISimplificationTask): void;
  50358. /**
  50359. * Execute next task
  50360. */
  50361. executeNext(): void;
  50362. /**
  50363. * Execute a simplification task
  50364. * @param task defines the task to run
  50365. */
  50366. runSimplification(task: ISimplificationTask): void;
  50367. private getSimplifier;
  50368. }
  50369. /**
  50370. * The implemented types of simplification
  50371. * At the moment only Quadratic Error Decimation is implemented
  50372. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50373. */
  50374. export enum SimplificationType {
  50375. /** Quadratic error decimation */
  50376. QUADRATIC = 0
  50377. }
  50378. }
  50379. declare module BABYLON {
  50380. interface Scene {
  50381. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  50382. /**
  50383. * Gets or sets the simplification queue attached to the scene
  50384. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  50385. */
  50386. simplificationQueue: SimplificationQueue;
  50387. }
  50388. interface Mesh {
  50389. /**
  50390. * Simplify the mesh according to the given array of settings.
  50391. * Function will return immediately and will simplify async
  50392. * @param settings a collection of simplification settings
  50393. * @param parallelProcessing should all levels calculate parallel or one after the other
  50394. * @param simplificationType the type of simplification to run
  50395. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  50396. * @returns the current mesh
  50397. */
  50398. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  50399. }
  50400. /**
  50401. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  50402. * created in a scene
  50403. */
  50404. export class SimplicationQueueSceneComponent implements ISceneComponent {
  50405. /**
  50406. * The component name helpfull to identify the component in the list of scene components.
  50407. */
  50408. readonly name: string;
  50409. /**
  50410. * The scene the component belongs to.
  50411. */
  50412. scene: Scene;
  50413. /**
  50414. * Creates a new instance of the component for the given scene
  50415. * @param scene Defines the scene to register the component in
  50416. */
  50417. constructor(scene: Scene);
  50418. /**
  50419. * Registers the component in a given scene
  50420. */
  50421. register(): void;
  50422. /**
  50423. * Rebuilds the elements related to this component in case of
  50424. * context lost for instance.
  50425. */
  50426. rebuild(): void;
  50427. /**
  50428. * Disposes the component and the associated ressources
  50429. */
  50430. dispose(): void;
  50431. private _beforeCameraUpdate;
  50432. }
  50433. }
  50434. declare module BABYLON {
  50435. /**
  50436. * Class used to enable access to IndexedDB
  50437. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  50438. */
  50439. export class Database implements IOfflineProvider {
  50440. private _callbackManifestChecked;
  50441. private _currentSceneUrl;
  50442. private _db;
  50443. private _enableSceneOffline;
  50444. private _enableTexturesOffline;
  50445. private _manifestVersionFound;
  50446. private _mustUpdateRessources;
  50447. private _hasReachedQuota;
  50448. private _isSupported;
  50449. private _idbFactory;
  50450. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  50451. private static IsUASupportingBlobStorage;
  50452. /**
  50453. * Gets a boolean indicating if Database storate is enabled (off by default)
  50454. */
  50455. static IDBStorageEnabled: boolean;
  50456. /**
  50457. * Gets a boolean indicating if scene must be saved in the database
  50458. */
  50459. readonly enableSceneOffline: boolean;
  50460. /**
  50461. * Gets a boolean indicating if textures must be saved in the database
  50462. */
  50463. readonly enableTexturesOffline: boolean;
  50464. /**
  50465. * Creates a new Database
  50466. * @param urlToScene defines the url to load the scene
  50467. * @param callbackManifestChecked defines the callback to use when manifest is checked
  50468. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  50469. */
  50470. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  50471. private static _ParseURL;
  50472. private static _ReturnFullUrlLocation;
  50473. private _checkManifestFile;
  50474. /**
  50475. * Open the database and make it available
  50476. * @param successCallback defines the callback to call on success
  50477. * @param errorCallback defines the callback to call on error
  50478. */
  50479. open(successCallback: () => void, errorCallback: () => void): void;
  50480. /**
  50481. * Loads an image from the database
  50482. * @param url defines the url to load from
  50483. * @param image defines the target DOM image
  50484. */
  50485. loadImage(url: string, image: HTMLImageElement): void;
  50486. private _loadImageFromDBAsync;
  50487. private _saveImageIntoDBAsync;
  50488. private _checkVersionFromDB;
  50489. private _loadVersionFromDBAsync;
  50490. private _saveVersionIntoDBAsync;
  50491. /**
  50492. * Loads a file from database
  50493. * @param url defines the URL to load from
  50494. * @param sceneLoaded defines a callback to call on success
  50495. * @param progressCallBack defines a callback to call when progress changed
  50496. * @param errorCallback defines a callback to call on error
  50497. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  50498. */
  50499. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  50500. private _loadFileAsync;
  50501. private _saveFileAsync;
  50502. /**
  50503. * Validates if xhr data is correct
  50504. * @param xhr defines the request to validate
  50505. * @param dataType defines the expected data type
  50506. * @returns true if data is correct
  50507. */
  50508. private static _ValidateXHRData;
  50509. }
  50510. }
  50511. declare module BABYLON {
  50512. /** @hidden */
  50513. export var gpuUpdateParticlesPixelShader: {
  50514. name: string;
  50515. shader: string;
  50516. };
  50517. }
  50518. declare module BABYLON {
  50519. /** @hidden */
  50520. export var gpuUpdateParticlesVertexShader: {
  50521. name: string;
  50522. shader: string;
  50523. };
  50524. }
  50525. declare module BABYLON {
  50526. /** @hidden */
  50527. export var clipPlaneFragmentDeclaration2: {
  50528. name: string;
  50529. shader: string;
  50530. };
  50531. }
  50532. declare module BABYLON {
  50533. /** @hidden */
  50534. export var gpuRenderParticlesPixelShader: {
  50535. name: string;
  50536. shader: string;
  50537. };
  50538. }
  50539. declare module BABYLON {
  50540. /** @hidden */
  50541. export var clipPlaneVertexDeclaration2: {
  50542. name: string;
  50543. shader: string;
  50544. };
  50545. }
  50546. declare module BABYLON {
  50547. /** @hidden */
  50548. export var gpuRenderParticlesVertexShader: {
  50549. name: string;
  50550. shader: string;
  50551. };
  50552. }
  50553. declare module BABYLON {
  50554. /**
  50555. * This represents a GPU particle system in Babylon
  50556. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  50557. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  50558. */
  50559. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  50560. /**
  50561. * The layer mask we are rendering the particles through.
  50562. */
  50563. layerMask: number;
  50564. private _capacity;
  50565. private _activeCount;
  50566. private _currentActiveCount;
  50567. private _accumulatedCount;
  50568. private _renderEffect;
  50569. private _updateEffect;
  50570. private _buffer0;
  50571. private _buffer1;
  50572. private _spriteBuffer;
  50573. private _updateVAO;
  50574. private _renderVAO;
  50575. private _targetIndex;
  50576. private _sourceBuffer;
  50577. private _targetBuffer;
  50578. private _engine;
  50579. private _currentRenderId;
  50580. private _started;
  50581. private _stopped;
  50582. private _timeDelta;
  50583. private _randomTexture;
  50584. private _randomTexture2;
  50585. private _attributesStrideSize;
  50586. private _updateEffectOptions;
  50587. private _randomTextureSize;
  50588. private _actualFrame;
  50589. private readonly _rawTextureWidth;
  50590. /**
  50591. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  50592. */
  50593. static readonly IsSupported: boolean;
  50594. /**
  50595. * An event triggered when the system is disposed.
  50596. */
  50597. onDisposeObservable: Observable<GPUParticleSystem>;
  50598. /**
  50599. * Gets the maximum number of particles active at the same time.
  50600. * @returns The max number of active particles.
  50601. */
  50602. getCapacity(): number;
  50603. /**
  50604. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  50605. * to override the particles.
  50606. */
  50607. forceDepthWrite: boolean;
  50608. /**
  50609. * Gets or set the number of active particles
  50610. */
  50611. activeParticleCount: number;
  50612. private _preWarmDone;
  50613. /**
  50614. * Is this system ready to be used/rendered
  50615. * @return true if the system is ready
  50616. */
  50617. isReady(): boolean;
  50618. /**
  50619. * Gets if the system has been started. (Note: this will still be true after stop is called)
  50620. * @returns True if it has been started, otherwise false.
  50621. */
  50622. isStarted(): boolean;
  50623. /**
  50624. * Starts the particle system and begins to emit
  50625. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  50626. */
  50627. start(delay?: number): void;
  50628. /**
  50629. * Stops the particle system.
  50630. */
  50631. stop(): void;
  50632. /**
  50633. * Remove all active particles
  50634. */
  50635. reset(): void;
  50636. /**
  50637. * Returns the string "GPUParticleSystem"
  50638. * @returns a string containing the class name
  50639. */
  50640. getClassName(): string;
  50641. private _colorGradientsTexture;
  50642. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  50643. /**
  50644. * Adds a new color gradient
  50645. * @param gradient defines the gradient to use (between 0 and 1)
  50646. * @param color1 defines the color to affect to the specified gradient
  50647. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  50648. * @returns the current particle system
  50649. */
  50650. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  50651. /**
  50652. * Remove a specific color gradient
  50653. * @param gradient defines the gradient to remove
  50654. * @returns the current particle system
  50655. */
  50656. removeColorGradient(gradient: number): GPUParticleSystem;
  50657. private _angularSpeedGradientsTexture;
  50658. private _sizeGradientsTexture;
  50659. private _velocityGradientsTexture;
  50660. private _limitVelocityGradientsTexture;
  50661. private _dragGradientsTexture;
  50662. private _addFactorGradient;
  50663. /**
  50664. * Adds a new size gradient
  50665. * @param gradient defines the gradient to use (between 0 and 1)
  50666. * @param factor defines the size factor to affect to the specified gradient
  50667. * @returns the current particle system
  50668. */
  50669. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  50670. /**
  50671. * Remove a specific size gradient
  50672. * @param gradient defines the gradient to remove
  50673. * @returns the current particle system
  50674. */
  50675. removeSizeGradient(gradient: number): GPUParticleSystem;
  50676. /**
  50677. * Adds a new angular speed gradient
  50678. * @param gradient defines the gradient to use (between 0 and 1)
  50679. * @param factor defines the angular speed to affect to the specified gradient
  50680. * @returns the current particle system
  50681. */
  50682. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  50683. /**
  50684. * Remove a specific angular speed gradient
  50685. * @param gradient defines the gradient to remove
  50686. * @returns the current particle system
  50687. */
  50688. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  50689. /**
  50690. * Adds a new velocity gradient
  50691. * @param gradient defines the gradient to use (between 0 and 1)
  50692. * @param factor defines the velocity to affect to the specified gradient
  50693. * @returns the current particle system
  50694. */
  50695. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50696. /**
  50697. * Remove a specific velocity gradient
  50698. * @param gradient defines the gradient to remove
  50699. * @returns the current particle system
  50700. */
  50701. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50702. /**
  50703. * Adds a new limit velocity gradient
  50704. * @param gradient defines the gradient to use (between 0 and 1)
  50705. * @param factor defines the limit velocity value to affect to the specified gradient
  50706. * @returns the current particle system
  50707. */
  50708. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50709. /**
  50710. * Remove a specific limit velocity gradient
  50711. * @param gradient defines the gradient to remove
  50712. * @returns the current particle system
  50713. */
  50714. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50715. /**
  50716. * Adds a new drag gradient
  50717. * @param gradient defines the gradient to use (between 0 and 1)
  50718. * @param factor defines the drag value to affect to the specified gradient
  50719. * @returns the current particle system
  50720. */
  50721. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50722. /**
  50723. * Remove a specific drag gradient
  50724. * @param gradient defines the gradient to remove
  50725. * @returns the current particle system
  50726. */
  50727. removeDragGradient(gradient: number): GPUParticleSystem;
  50728. /**
  50729. * Not supported by GPUParticleSystem
  50730. * @param gradient defines the gradient to use (between 0 and 1)
  50731. * @param factor defines the emit rate value to affect to the specified gradient
  50732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50733. * @returns the current particle system
  50734. */
  50735. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50736. /**
  50737. * Not supported by GPUParticleSystem
  50738. * @param gradient defines the gradient to remove
  50739. * @returns the current particle system
  50740. */
  50741. removeEmitRateGradient(gradient: number): IParticleSystem;
  50742. /**
  50743. * Not supported by GPUParticleSystem
  50744. * @param gradient defines the gradient to use (between 0 and 1)
  50745. * @param factor defines the start size value to affect to the specified gradient
  50746. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50747. * @returns the current particle system
  50748. */
  50749. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50750. /**
  50751. * Not supported by GPUParticleSystem
  50752. * @param gradient defines the gradient to remove
  50753. * @returns the current particle system
  50754. */
  50755. removeStartSizeGradient(gradient: number): IParticleSystem;
  50756. /**
  50757. * Not supported by GPUParticleSystem
  50758. * @param gradient defines the gradient to use (between 0 and 1)
  50759. * @param min defines the color remap minimal range
  50760. * @param max defines the color remap maximal range
  50761. * @returns the current particle system
  50762. */
  50763. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50764. /**
  50765. * Not supported by GPUParticleSystem
  50766. * @param gradient defines the gradient to remove
  50767. * @returns the current particle system
  50768. */
  50769. removeColorRemapGradient(): IParticleSystem;
  50770. /**
  50771. * Not supported by GPUParticleSystem
  50772. * @param gradient defines the gradient to use (between 0 and 1)
  50773. * @param min defines the alpha remap minimal range
  50774. * @param max defines the alpha remap maximal range
  50775. * @returns the current particle system
  50776. */
  50777. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50778. /**
  50779. * Not supported by GPUParticleSystem
  50780. * @param gradient defines the gradient to remove
  50781. * @returns the current particle system
  50782. */
  50783. removeAlphaRemapGradient(): IParticleSystem;
  50784. /**
  50785. * Not supported by GPUParticleSystem
  50786. * @param gradient defines the gradient to use (between 0 and 1)
  50787. * @param color defines the color to affect to the specified gradient
  50788. * @returns the current particle system
  50789. */
  50790. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50791. /**
  50792. * Not supported by GPUParticleSystem
  50793. * @param gradient defines the gradient to remove
  50794. * @returns the current particle system
  50795. */
  50796. removeRampGradient(): IParticleSystem;
  50797. /**
  50798. * Not supported by GPUParticleSystem
  50799. * @returns the list of ramp gradients
  50800. */
  50801. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50802. /**
  50803. * Not supported by GPUParticleSystem
  50804. * Gets or sets a boolean indicating that ramp gradients must be used
  50805. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50806. */
  50807. useRampGradients: boolean;
  50808. /**
  50809. * Not supported by GPUParticleSystem
  50810. * @param gradient defines the gradient to use (between 0 and 1)
  50811. * @param factor defines the life time factor to affect to the specified gradient
  50812. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50813. * @returns the current particle system
  50814. */
  50815. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50816. /**
  50817. * Not supported by GPUParticleSystem
  50818. * @param gradient defines the gradient to remove
  50819. * @returns the current particle system
  50820. */
  50821. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50822. /**
  50823. * Instantiates a GPU particle system.
  50824. * 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.
  50825. * @param name The name of the particle system
  50826. * @param options The options used to create the system
  50827. * @param scene The scene the particle system belongs to
  50828. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50829. */
  50830. constructor(name: string, options: Partial<{
  50831. capacity: number;
  50832. randomTextureSize: number;
  50833. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50834. protected _reset(): void;
  50835. private _createUpdateVAO;
  50836. private _createRenderVAO;
  50837. private _initialize;
  50838. /** @hidden */ recreateUpdateEffect(): void;
  50839. /** @hidden */ recreateRenderEffect(): void;
  50840. /**
  50841. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50842. * @param preWarm defines if we are in the pre-warmimg phase
  50843. */
  50844. animate(preWarm?: boolean): void;
  50845. private _createFactorGradientTexture;
  50846. private _createSizeGradientTexture;
  50847. private _createAngularSpeedGradientTexture;
  50848. private _createVelocityGradientTexture;
  50849. private _createLimitVelocityGradientTexture;
  50850. private _createDragGradientTexture;
  50851. private _createColorGradientTexture;
  50852. /**
  50853. * Renders the particle system in its current state
  50854. * @param preWarm defines if the system should only update the particles but not render them
  50855. * @returns the current number of particles
  50856. */
  50857. render(preWarm?: boolean): number;
  50858. /**
  50859. * Rebuilds the particle system
  50860. */
  50861. rebuild(): void;
  50862. private _releaseBuffers;
  50863. private _releaseVAOs;
  50864. /**
  50865. * Disposes the particle system and free the associated resources
  50866. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50867. */
  50868. dispose(disposeTexture?: boolean): void;
  50869. /**
  50870. * Clones the particle system.
  50871. * @param name The name of the cloned object
  50872. * @param newEmitter The new emitter to use
  50873. * @returns the cloned particle system
  50874. */
  50875. clone(name: string, newEmitter: any): GPUParticleSystem;
  50876. /**
  50877. * Serializes the particle system to a JSON object.
  50878. * @returns the JSON object
  50879. */
  50880. serialize(): any;
  50881. /**
  50882. * Parses a JSON object to create a GPU particle system.
  50883. * @param parsedParticleSystem The JSON object to parse
  50884. * @param scene The scene to create the particle system in
  50885. * @param rootUrl The root url to use to load external dependencies like texture
  50886. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50887. * @returns the parsed GPU particle system
  50888. */
  50889. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50890. }
  50891. }
  50892. declare module BABYLON {
  50893. /**
  50894. * Represents a set of particle systems working together to create a specific effect
  50895. */
  50896. export class ParticleSystemSet implements IDisposable {
  50897. private _emitterCreationOptions;
  50898. private _emitterNode;
  50899. /**
  50900. * Gets the particle system list
  50901. */
  50902. systems: IParticleSystem[];
  50903. /**
  50904. * Gets the emitter node used with this set
  50905. */
  50906. readonly emitterNode: Nullable<TransformNode>;
  50907. /**
  50908. * Creates a new emitter mesh as a sphere
  50909. * @param options defines the options used to create the sphere
  50910. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50911. * @param scene defines the hosting scene
  50912. */
  50913. setEmitterAsSphere(options: {
  50914. diameter: number;
  50915. segments: number;
  50916. color: Color3;
  50917. }, renderingGroupId: number, scene: Scene): void;
  50918. /**
  50919. * Starts all particle systems of the set
  50920. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50921. */
  50922. start(emitter?: AbstractMesh): void;
  50923. /**
  50924. * Release all associated resources
  50925. */
  50926. dispose(): void;
  50927. /**
  50928. * Serialize the set into a JSON compatible object
  50929. * @returns a JSON compatible representation of the set
  50930. */
  50931. serialize(): any;
  50932. /**
  50933. * Parse a new ParticleSystemSet from a serialized source
  50934. * @param data defines a JSON compatible representation of the set
  50935. * @param scene defines the hosting scene
  50936. * @param gpu defines if we want GPU particles or CPU particles
  50937. * @returns a new ParticleSystemSet
  50938. */
  50939. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50940. }
  50941. }
  50942. declare module BABYLON {
  50943. /**
  50944. * This class is made for on one-liner static method to help creating particle system set.
  50945. */
  50946. export class ParticleHelper {
  50947. /**
  50948. * Gets or sets base Assets URL
  50949. */
  50950. static BaseAssetsUrl: string;
  50951. /**
  50952. * Create a default particle system that you can tweak
  50953. * @param emitter defines the emitter to use
  50954. * @param capacity defines the system capacity (default is 500 particles)
  50955. * @param scene defines the hosting scene
  50956. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50957. * @returns the new Particle system
  50958. */
  50959. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50960. /**
  50961. * This is the main static method (one-liner) of this helper to create different particle systems
  50962. * @param type This string represents the type to the particle system to create
  50963. * @param scene The scene where the particle system should live
  50964. * @param gpu If the system will use gpu
  50965. * @returns the ParticleSystemSet created
  50966. */
  50967. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50968. /**
  50969. * Static function used to export a particle system to a ParticleSystemSet variable.
  50970. * Please note that the emitter shape is not exported
  50971. * @param systems defines the particle systems to export
  50972. * @returns the created particle system set
  50973. */
  50974. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50975. }
  50976. }
  50977. declare module BABYLON {
  50978. interface Engine {
  50979. /**
  50980. * Create an effect to use with particle systems.
  50981. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50982. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50983. * @param uniformsNames defines a list of attribute names
  50984. * @param samplers defines an array of string used to represent textures
  50985. * @param defines defines the string containing the defines to use to compile the shaders
  50986. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50987. * @param onCompiled defines a function to call when the effect creation is successful
  50988. * @param onError defines a function to call when the effect creation has failed
  50989. * @returns the new Effect
  50990. */
  50991. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50992. }
  50993. interface Mesh {
  50994. /**
  50995. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50996. * @returns an array of IParticleSystem
  50997. */
  50998. getEmittedParticleSystems(): IParticleSystem[];
  50999. /**
  51000. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  51001. * @returns an array of IParticleSystem
  51002. */
  51003. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  51004. }
  51005. /**
  51006. * @hidden
  51007. */
  51008. export var _IDoNeedToBeInTheBuild: number;
  51009. }
  51010. declare module BABYLON {
  51011. interface Scene {
  51012. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  51013. /**
  51014. * Gets the current physics engine
  51015. * @returns a IPhysicsEngine or null if none attached
  51016. */
  51017. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  51018. /**
  51019. * Enables physics to the current scene
  51020. * @param gravity defines the scene's gravity for the physics engine
  51021. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  51022. * @return a boolean indicating if the physics engine was initialized
  51023. */
  51024. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  51025. /**
  51026. * Disables and disposes the physics engine associated with the scene
  51027. */
  51028. disablePhysicsEngine(): void;
  51029. /**
  51030. * Gets a boolean indicating if there is an active physics engine
  51031. * @returns a boolean indicating if there is an active physics engine
  51032. */
  51033. isPhysicsEnabled(): boolean;
  51034. /**
  51035. * Deletes a physics compound impostor
  51036. * @param compound defines the compound to delete
  51037. */
  51038. deleteCompoundImpostor(compound: any): void;
  51039. /**
  51040. * An event triggered when physic simulation is about to be run
  51041. */
  51042. onBeforePhysicsObservable: Observable<Scene>;
  51043. /**
  51044. * An event triggered when physic simulation has been done
  51045. */
  51046. onAfterPhysicsObservable: Observable<Scene>;
  51047. }
  51048. interface AbstractMesh {
  51049. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  51050. /**
  51051. * Gets or sets impostor used for physic simulation
  51052. * @see http://doc.babylonjs.com/features/physics_engine
  51053. */
  51054. physicsImpostor: Nullable<PhysicsImpostor>;
  51055. /**
  51056. * Gets the current physics impostor
  51057. * @see http://doc.babylonjs.com/features/physics_engine
  51058. * @returns a physics impostor or null
  51059. */
  51060. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  51061. /** Apply a physic impulse to the mesh
  51062. * @param force defines the force to apply
  51063. * @param contactPoint defines where to apply the force
  51064. * @returns the current mesh
  51065. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  51066. */
  51067. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  51068. /**
  51069. * Creates a physic joint between two meshes
  51070. * @param otherMesh defines the other mesh to use
  51071. * @param pivot1 defines the pivot to use on this mesh
  51072. * @param pivot2 defines the pivot to use on the other mesh
  51073. * @param options defines additional options (can be plugin dependent)
  51074. * @returns the current mesh
  51075. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  51076. */
  51077. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  51078. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  51079. }
  51080. /**
  51081. * Defines the physics engine scene component responsible to manage a physics engine
  51082. */
  51083. export class PhysicsEngineSceneComponent implements ISceneComponent {
  51084. /**
  51085. * The component name helpful to identify the component in the list of scene components.
  51086. */
  51087. readonly name: string;
  51088. /**
  51089. * The scene the component belongs to.
  51090. */
  51091. scene: Scene;
  51092. /**
  51093. * Creates a new instance of the component for the given scene
  51094. * @param scene Defines the scene to register the component in
  51095. */
  51096. constructor(scene: Scene);
  51097. /**
  51098. * Registers the component in a given scene
  51099. */
  51100. register(): void;
  51101. /**
  51102. * Rebuilds the elements related to this component in case of
  51103. * context lost for instance.
  51104. */
  51105. rebuild(): void;
  51106. /**
  51107. * Disposes the component and the associated ressources
  51108. */
  51109. dispose(): void;
  51110. }
  51111. }
  51112. declare module BABYLON {
  51113. /**
  51114. * A helper for physics simulations
  51115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51116. */
  51117. export class PhysicsHelper {
  51118. private _scene;
  51119. private _physicsEngine;
  51120. /**
  51121. * Initializes the Physics helper
  51122. * @param scene Babylon.js scene
  51123. */
  51124. constructor(scene: Scene);
  51125. /**
  51126. * Applies a radial explosion impulse
  51127. * @param origin the origin of the explosion
  51128. * @param radiusOrEventOptions the radius or the options of radial explosion
  51129. * @param strength the explosion strength
  51130. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51131. * @returns A physics radial explosion event, or null
  51132. */
  51133. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51134. /**
  51135. * Applies a radial explosion force
  51136. * @param origin the origin of the explosion
  51137. * @param radiusOrEventOptions the radius or the options of radial explosion
  51138. * @param strength the explosion strength
  51139. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51140. * @returns A physics radial explosion event, or null
  51141. */
  51142. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  51143. /**
  51144. * Creates a gravitational field
  51145. * @param origin the origin of the explosion
  51146. * @param radiusOrEventOptions the radius or the options of radial explosion
  51147. * @param strength the explosion strength
  51148. * @param falloff possible options: Constant & Linear. Defaults to Constant
  51149. * @returns A physics gravitational field event, or null
  51150. */
  51151. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  51152. /**
  51153. * Creates a physics updraft event
  51154. * @param origin the origin of the updraft
  51155. * @param radiusOrEventOptions the radius or the options of the updraft
  51156. * @param strength the strength of the updraft
  51157. * @param height the height of the updraft
  51158. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  51159. * @returns A physics updraft event, or null
  51160. */
  51161. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  51162. /**
  51163. * Creates a physics vortex event
  51164. * @param origin the of the vortex
  51165. * @param radiusOrEventOptions the radius or the options of the vortex
  51166. * @param strength the strength of the vortex
  51167. * @param height the height of the vortex
  51168. * @returns a Physics vortex event, or null
  51169. * A physics vortex event or null
  51170. */
  51171. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  51172. }
  51173. /**
  51174. * Represents a physics radial explosion event
  51175. */
  51176. class PhysicsRadialExplosionEvent {
  51177. private _scene;
  51178. private _options;
  51179. private _sphere;
  51180. private _dataFetched;
  51181. /**
  51182. * Initializes a radial explosioin event
  51183. * @param _scene BabylonJS scene
  51184. * @param _options The options for the vortex event
  51185. */
  51186. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  51187. /**
  51188. * Returns the data related to the radial explosion event (sphere).
  51189. * @returns The radial explosion event data
  51190. */
  51191. getData(): PhysicsRadialExplosionEventData;
  51192. /**
  51193. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  51194. * @param impostor A physics imposter
  51195. * @param origin the origin of the explosion
  51196. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  51197. */
  51198. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  51199. /**
  51200. * Triggers affecterd impostors callbacks
  51201. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  51202. */
  51203. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  51204. /**
  51205. * Disposes the sphere.
  51206. * @param force Specifies if the sphere should be disposed by force
  51207. */
  51208. dispose(force?: boolean): void;
  51209. /*** Helpers ***/
  51210. private _prepareSphere;
  51211. private _intersectsWithSphere;
  51212. }
  51213. /**
  51214. * Represents a gravitational field event
  51215. */
  51216. class PhysicsGravitationalFieldEvent {
  51217. private _physicsHelper;
  51218. private _scene;
  51219. private _origin;
  51220. private _options;
  51221. private _tickCallback;
  51222. private _sphere;
  51223. private _dataFetched;
  51224. /**
  51225. * Initializes the physics gravitational field event
  51226. * @param _physicsHelper A physics helper
  51227. * @param _scene BabylonJS scene
  51228. * @param _origin The origin position of the gravitational field event
  51229. * @param _options The options for the vortex event
  51230. */
  51231. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  51232. /**
  51233. * Returns the data related to the gravitational field event (sphere).
  51234. * @returns A gravitational field event
  51235. */
  51236. getData(): PhysicsGravitationalFieldEventData;
  51237. /**
  51238. * Enables the gravitational field.
  51239. */
  51240. enable(): void;
  51241. /**
  51242. * Disables the gravitational field.
  51243. */
  51244. disable(): void;
  51245. /**
  51246. * Disposes the sphere.
  51247. * @param force The force to dispose from the gravitational field event
  51248. */
  51249. dispose(force?: boolean): void;
  51250. private _tick;
  51251. }
  51252. /**
  51253. * Represents a physics updraft event
  51254. */
  51255. class PhysicsUpdraftEvent {
  51256. private _scene;
  51257. private _origin;
  51258. private _options;
  51259. private _physicsEngine;
  51260. private _originTop;
  51261. private _originDirection;
  51262. private _tickCallback;
  51263. private _cylinder;
  51264. private _cylinderPosition;
  51265. private _dataFetched;
  51266. /**
  51267. * Initializes the physics updraft event
  51268. * @param _scene BabylonJS scene
  51269. * @param _origin The origin position of the updraft
  51270. * @param _options The options for the updraft event
  51271. */
  51272. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  51273. /**
  51274. * Returns the data related to the updraft event (cylinder).
  51275. * @returns A physics updraft event
  51276. */
  51277. getData(): PhysicsUpdraftEventData;
  51278. /**
  51279. * Enables the updraft.
  51280. */
  51281. enable(): void;
  51282. /**
  51283. * Disables the updraft.
  51284. */
  51285. disable(): void;
  51286. /**
  51287. * Disposes the cylinder.
  51288. * @param force Specifies if the updraft should be disposed by force
  51289. */
  51290. dispose(force?: boolean): void;
  51291. private getImpostorHitData;
  51292. private _tick;
  51293. /*** Helpers ***/
  51294. private _prepareCylinder;
  51295. private _intersectsWithCylinder;
  51296. }
  51297. /**
  51298. * Represents a physics vortex event
  51299. */
  51300. class PhysicsVortexEvent {
  51301. private _scene;
  51302. private _origin;
  51303. private _options;
  51304. private _physicsEngine;
  51305. private _originTop;
  51306. private _tickCallback;
  51307. private _cylinder;
  51308. private _cylinderPosition;
  51309. private _dataFetched;
  51310. /**
  51311. * Initializes the physics vortex event
  51312. * @param _scene The BabylonJS scene
  51313. * @param _origin The origin position of the vortex
  51314. * @param _options The options for the vortex event
  51315. */
  51316. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  51317. /**
  51318. * Returns the data related to the vortex event (cylinder).
  51319. * @returns The physics vortex event data
  51320. */
  51321. getData(): PhysicsVortexEventData;
  51322. /**
  51323. * Enables the vortex.
  51324. */
  51325. enable(): void;
  51326. /**
  51327. * Disables the cortex.
  51328. */
  51329. disable(): void;
  51330. /**
  51331. * Disposes the sphere.
  51332. * @param force
  51333. */
  51334. dispose(force?: boolean): void;
  51335. private getImpostorHitData;
  51336. private _tick;
  51337. /*** Helpers ***/
  51338. private _prepareCylinder;
  51339. private _intersectsWithCylinder;
  51340. }
  51341. /**
  51342. * Options fot the radial explosion event
  51343. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51344. */
  51345. export class PhysicsRadialExplosionEventOptions {
  51346. /**
  51347. * The radius of the sphere for the radial explosion.
  51348. */
  51349. radius: number;
  51350. /**
  51351. * The strenth of the explosion.
  51352. */
  51353. strength: number;
  51354. /**
  51355. * The strenght of the force in correspondence to the distance of the affected object
  51356. */
  51357. falloff: PhysicsRadialImpulseFalloff;
  51358. /**
  51359. * Sphere options for the radial explosion.
  51360. */
  51361. sphere: {
  51362. segments: number;
  51363. diameter: number;
  51364. };
  51365. /**
  51366. * Sphere options for the radial explosion.
  51367. */
  51368. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  51369. }
  51370. /**
  51371. * Options fot the updraft event
  51372. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51373. */
  51374. export class PhysicsUpdraftEventOptions {
  51375. /**
  51376. * The radius of the cylinder for the vortex
  51377. */
  51378. radius: number;
  51379. /**
  51380. * The strenth of the updraft.
  51381. */
  51382. strength: number;
  51383. /**
  51384. * The height of the cylinder for the updraft.
  51385. */
  51386. height: number;
  51387. /**
  51388. * The mode for the the updraft.
  51389. */
  51390. updraftMode: PhysicsUpdraftMode;
  51391. }
  51392. /**
  51393. * Options fot the vortex event
  51394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51395. */
  51396. export class PhysicsVortexEventOptions {
  51397. /**
  51398. * The radius of the cylinder for the vortex
  51399. */
  51400. radius: number;
  51401. /**
  51402. * The strenth of the vortex.
  51403. */
  51404. strength: number;
  51405. /**
  51406. * The height of the cylinder for the vortex.
  51407. */
  51408. height: number;
  51409. /**
  51410. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  51411. */
  51412. centripetalForceThreshold: number;
  51413. /**
  51414. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  51415. */
  51416. centripetalForceMultiplier: number;
  51417. /**
  51418. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  51419. */
  51420. centrifugalForceMultiplier: number;
  51421. /**
  51422. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  51423. */
  51424. updraftForceMultiplier: number;
  51425. }
  51426. /**
  51427. * The strenght of the force in correspondence to the distance of the affected object
  51428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51429. */
  51430. export enum PhysicsRadialImpulseFalloff {
  51431. /** Defines that impulse is constant in strength across it's whole radius */
  51432. Constant = 0,
  51433. /** Defines that impulse gets weaker if it's further from the origin */
  51434. Linear = 1
  51435. }
  51436. /**
  51437. * The strength of the force in correspondence to the distance of the affected object
  51438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51439. */
  51440. export enum PhysicsUpdraftMode {
  51441. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  51442. Center = 0,
  51443. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  51444. Perpendicular = 1
  51445. }
  51446. /**
  51447. * Interface for a physics hit data
  51448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51449. */
  51450. export interface PhysicsHitData {
  51451. /**
  51452. * The force applied at the contact point
  51453. */
  51454. force: Vector3;
  51455. /**
  51456. * The contact point
  51457. */
  51458. contactPoint: Vector3;
  51459. /**
  51460. * The distance from the origin to the contact point
  51461. */
  51462. distanceFromOrigin: number;
  51463. }
  51464. /**
  51465. * Interface for radial explosion event data
  51466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51467. */
  51468. export interface PhysicsRadialExplosionEventData {
  51469. /**
  51470. * A sphere used for the radial explosion event
  51471. */
  51472. sphere: Mesh;
  51473. }
  51474. /**
  51475. * Interface for gravitational field event data
  51476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51477. */
  51478. export interface PhysicsGravitationalFieldEventData {
  51479. /**
  51480. * A sphere mesh used for the gravitational field event
  51481. */
  51482. sphere: Mesh;
  51483. }
  51484. /**
  51485. * Interface for updraft event data
  51486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51487. */
  51488. export interface PhysicsUpdraftEventData {
  51489. /**
  51490. * A cylinder used for the updraft event
  51491. */
  51492. cylinder: Mesh;
  51493. }
  51494. /**
  51495. * Interface for vortex event data
  51496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51497. */
  51498. export interface PhysicsVortexEventData {
  51499. /**
  51500. * A cylinder used for the vortex event
  51501. */
  51502. cylinder: Mesh;
  51503. }
  51504. /**
  51505. * Interface for an affected physics impostor
  51506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  51507. */
  51508. export interface PhysicsAffectedImpostorWithData {
  51509. /**
  51510. * The impostor affected by the effect
  51511. */
  51512. impostor: PhysicsImpostor;
  51513. /**
  51514. * The data about the hit/horce from the explosion
  51515. */
  51516. hitData: PhysicsHitData;
  51517. }
  51518. }
  51519. declare module BABYLON {
  51520. /** @hidden */
  51521. export var blackAndWhitePixelShader: {
  51522. name: string;
  51523. shader: string;
  51524. };
  51525. }
  51526. declare module BABYLON {
  51527. /**
  51528. * Post process used to render in black and white
  51529. */
  51530. export class BlackAndWhitePostProcess extends PostProcess {
  51531. /**
  51532. * Linear about to convert he result to black and white (default: 1)
  51533. */
  51534. degree: number;
  51535. /**
  51536. * Creates a black and white post process
  51537. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  51538. * @param name The name of the effect.
  51539. * @param options The required width/height ratio to downsize to before computing the render pass.
  51540. * @param camera The camera to apply the render pass to.
  51541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51542. * @param engine The engine which the post process will be applied. (default: current engine)
  51543. * @param reusable If the post process can be reused on the same frame. (default: false)
  51544. */
  51545. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51546. }
  51547. }
  51548. declare module BABYLON {
  51549. /**
  51550. * This represents a set of one or more post processes in Babylon.
  51551. * A post process can be used to apply a shader to a texture after it is rendered.
  51552. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51553. */
  51554. export class PostProcessRenderEffect {
  51555. private _postProcesses;
  51556. private _getPostProcesses;
  51557. private _singleInstance;
  51558. private _cameras;
  51559. private _indicesForCamera;
  51560. /**
  51561. * Name of the effect
  51562. * @hidden
  51563. */ name: string;
  51564. /**
  51565. * Instantiates a post process render effect.
  51566. * A post process can be used to apply a shader to a texture after it is rendered.
  51567. * @param engine The engine the effect is tied to
  51568. * @param name The name of the effect
  51569. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  51570. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  51571. */
  51572. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  51573. /**
  51574. * Checks if all the post processes in the effect are supported.
  51575. */
  51576. readonly isSupported: boolean;
  51577. /**
  51578. * Updates the current state of the effect
  51579. * @hidden
  51580. */ update(): void;
  51581. /**
  51582. * Attaches the effect on cameras
  51583. * @param cameras The camera to attach to.
  51584. * @hidden
  51585. */ attachCameras(cameras: Camera): void;
  51586. /**
  51587. * Attaches the effect on cameras
  51588. * @param cameras The camera to attach to.
  51589. * @hidden
  51590. */ attachCameras(cameras: Camera[]): void;
  51591. /**
  51592. * Detaches the effect on cameras
  51593. * @param cameras The camera to detatch from.
  51594. * @hidden
  51595. */ detachCameras(cameras: Camera): void;
  51596. /**
  51597. * Detatches the effect on cameras
  51598. * @param cameras The camera to detatch from.
  51599. * @hidden
  51600. */ detachCameras(cameras: Camera[]): void;
  51601. /**
  51602. * Enables the effect on given cameras
  51603. * @param cameras The camera to enable.
  51604. * @hidden
  51605. */ enable(cameras: Camera): void;
  51606. /**
  51607. * Enables the effect on given cameras
  51608. * @param cameras The camera to enable.
  51609. * @hidden
  51610. */ enable(cameras: Nullable<Camera[]>): void;
  51611. /**
  51612. * Disables the effect on the given cameras
  51613. * @param cameras The camera to disable.
  51614. * @hidden
  51615. */ disable(cameras: Camera): void;
  51616. /**
  51617. * Disables the effect on the given cameras
  51618. * @param cameras The camera to disable.
  51619. * @hidden
  51620. */ disable(cameras: Nullable<Camera[]>): void;
  51621. /**
  51622. * Gets a list of the post processes contained in the effect.
  51623. * @param camera The camera to get the post processes on.
  51624. * @returns The list of the post processes in the effect.
  51625. */
  51626. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  51627. }
  51628. }
  51629. declare module BABYLON {
  51630. /** @hidden */
  51631. export var extractHighlightsPixelShader: {
  51632. name: string;
  51633. shader: string;
  51634. };
  51635. }
  51636. declare module BABYLON {
  51637. /**
  51638. * 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.
  51639. */
  51640. export class ExtractHighlightsPostProcess extends PostProcess {
  51641. /**
  51642. * The luminance threshold, pixels below this value will be set to black.
  51643. */
  51644. threshold: number;
  51645. /** @hidden */ exposure: number;
  51646. /**
  51647. * Post process which has the input texture to be used when performing highlight extraction
  51648. * @hidden
  51649. */ inputPostProcess: Nullable<PostProcess>;
  51650. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51651. }
  51652. }
  51653. declare module BABYLON {
  51654. /** @hidden */
  51655. export var bloomMergePixelShader: {
  51656. name: string;
  51657. shader: string;
  51658. };
  51659. }
  51660. declare module BABYLON {
  51661. /**
  51662. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51663. */
  51664. export class BloomMergePostProcess extends PostProcess {
  51665. /** Weight of the bloom to be added to the original input. */
  51666. weight: number;
  51667. /**
  51668. * Creates a new instance of @see BloomMergePostProcess
  51669. * @param name The name of the effect.
  51670. * @param originalFromInput Post process which's input will be used for the merge.
  51671. * @param blurred Blurred highlights post process which's output will be used.
  51672. * @param weight Weight of the bloom to be added to the original input.
  51673. * @param options The required width/height ratio to downsize to before computing the render pass.
  51674. * @param camera The camera to apply the render pass to.
  51675. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51676. * @param engine The engine which the post process will be applied. (default: current engine)
  51677. * @param reusable If the post process can be reused on the same frame. (default: false)
  51678. * @param textureType Type of textures used when performing the post process. (default: 0)
  51679. * @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)
  51680. */
  51681. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  51682. /** Weight of the bloom to be added to the original input. */
  51683. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51684. }
  51685. }
  51686. declare module BABYLON {
  51687. /**
  51688. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  51689. */
  51690. export class BloomEffect extends PostProcessRenderEffect {
  51691. private bloomScale;
  51692. /**
  51693. * @hidden Internal
  51694. */ effects: Array<PostProcess>;
  51695. /**
  51696. * @hidden Internal
  51697. */ downscale: ExtractHighlightsPostProcess;
  51698. private _blurX;
  51699. private _blurY;
  51700. private _merge;
  51701. /**
  51702. * The luminance threshold to find bright areas of the image to bloom.
  51703. */
  51704. threshold: number;
  51705. /**
  51706. * The strength of the bloom.
  51707. */
  51708. weight: number;
  51709. /**
  51710. * Specifies the size of the bloom blur kernel, relative to the final output size
  51711. */
  51712. kernel: number;
  51713. /**
  51714. * Creates a new instance of @see BloomEffect
  51715. * @param scene The scene the effect belongs to.
  51716. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51717. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51718. * @param bloomWeight The the strength of bloom.
  51719. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51720. * @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)
  51721. */
  51722. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51723. /**
  51724. * Disposes each of the internal effects for a given camera.
  51725. * @param camera The camera to dispose the effect on.
  51726. */
  51727. disposeEffects(camera: Camera): void;
  51728. /**
  51729. * @hidden Internal
  51730. */ updateEffects(): void;
  51731. /**
  51732. * Internal
  51733. * @returns if all the contained post processes are ready.
  51734. * @hidden
  51735. */ isReady(): boolean;
  51736. }
  51737. }
  51738. declare module BABYLON {
  51739. /** @hidden */
  51740. export var chromaticAberrationPixelShader: {
  51741. name: string;
  51742. shader: string;
  51743. };
  51744. }
  51745. declare module BABYLON {
  51746. /**
  51747. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51748. */
  51749. export class ChromaticAberrationPostProcess extends PostProcess {
  51750. /**
  51751. * The amount of seperation of rgb channels (default: 30)
  51752. */
  51753. aberrationAmount: number;
  51754. /**
  51755. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51756. */
  51757. radialIntensity: number;
  51758. /**
  51759. * 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))
  51760. */
  51761. direction: Vector2;
  51762. /**
  51763. * 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))
  51764. */
  51765. centerPosition: Vector2;
  51766. /**
  51767. * Creates a new instance ChromaticAberrationPostProcess
  51768. * @param name The name of the effect.
  51769. * @param screenWidth The width of the screen to apply the effect on.
  51770. * @param screenHeight The height of the screen to apply the effect on.
  51771. * @param options The required width/height ratio to downsize to before computing the render pass.
  51772. * @param camera The camera to apply the render pass to.
  51773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51774. * @param engine The engine which the post process will be applied. (default: current engine)
  51775. * @param reusable If the post process can be reused on the same frame. (default: false)
  51776. * @param textureType Type of textures used when performing the post process. (default: 0)
  51777. * @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)
  51778. */
  51779. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51780. }
  51781. }
  51782. declare module BABYLON {
  51783. /** @hidden */
  51784. export var circleOfConfusionPixelShader: {
  51785. name: string;
  51786. shader: string;
  51787. };
  51788. }
  51789. declare module BABYLON {
  51790. /**
  51791. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51792. */
  51793. export class CircleOfConfusionPostProcess extends PostProcess {
  51794. /**
  51795. * 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.
  51796. */
  51797. lensSize: number;
  51798. /**
  51799. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51800. */
  51801. fStop: number;
  51802. /**
  51803. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51804. */
  51805. focusDistance: number;
  51806. /**
  51807. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51808. */
  51809. focalLength: number;
  51810. private _depthTexture;
  51811. /**
  51812. * Creates a new instance CircleOfConfusionPostProcess
  51813. * @param name The name of the effect.
  51814. * @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.
  51815. * @param options The required width/height ratio to downsize to before computing the render pass.
  51816. * @param camera The camera to apply the render pass to.
  51817. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51818. * @param engine The engine which the post process will be applied. (default: current engine)
  51819. * @param reusable If the post process can be reused on the same frame. (default: false)
  51820. * @param textureType Type of textures used when performing the post process. (default: 0)
  51821. * @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)
  51822. */
  51823. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51824. /**
  51825. * 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.
  51826. */
  51827. depthTexture: RenderTargetTexture;
  51828. }
  51829. }
  51830. declare module BABYLON {
  51831. /** @hidden */
  51832. export var colorCorrectionPixelShader: {
  51833. name: string;
  51834. shader: string;
  51835. };
  51836. }
  51837. declare module BABYLON {
  51838. /**
  51839. *
  51840. * This post-process allows the modification of rendered colors by using
  51841. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51842. *
  51843. * The object needs to be provided an url to a texture containing the color
  51844. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51845. * Use an image editing software to tweak the LUT to match your needs.
  51846. *
  51847. * For an example of a color LUT, see here:
  51848. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51849. * For explanations on color grading, see here:
  51850. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51851. *
  51852. */
  51853. export class ColorCorrectionPostProcess extends PostProcess {
  51854. private _colorTableTexture;
  51855. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51856. }
  51857. }
  51858. declare module BABYLON {
  51859. /** @hidden */
  51860. export var convolutionPixelShader: {
  51861. name: string;
  51862. shader: string;
  51863. };
  51864. }
  51865. declare module BABYLON {
  51866. /**
  51867. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51868. * input texture to perform effects such as edge detection or sharpening
  51869. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51870. */
  51871. export class ConvolutionPostProcess extends PostProcess {
  51872. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51873. kernel: number[];
  51874. /**
  51875. * Creates a new instance ConvolutionPostProcess
  51876. * @param name The name of the effect.
  51877. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51878. * @param options The required width/height ratio to downsize to before computing the render pass.
  51879. * @param camera The camera to apply the render pass to.
  51880. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51881. * @param engine The engine which the post process will be applied. (default: current engine)
  51882. * @param reusable If the post process can be reused on the same frame. (default: false)
  51883. * @param textureType Type of textures used when performing the post process. (default: 0)
  51884. */
  51885. constructor(name: string,
  51886. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51887. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51888. /**
  51889. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51890. */
  51891. static EdgeDetect0Kernel: number[];
  51892. /**
  51893. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51894. */
  51895. static EdgeDetect1Kernel: number[];
  51896. /**
  51897. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51898. */
  51899. static EdgeDetect2Kernel: number[];
  51900. /**
  51901. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51902. */
  51903. static SharpenKernel: number[];
  51904. /**
  51905. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51906. */
  51907. static EmbossKernel: number[];
  51908. /**
  51909. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51910. */
  51911. static GaussianKernel: number[];
  51912. }
  51913. }
  51914. declare module BABYLON {
  51915. /**
  51916. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51917. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51918. * based on samples that have a large difference in distance than the center pixel.
  51919. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51920. */
  51921. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51922. direction: Vector2;
  51923. /**
  51924. * Creates a new instance CircleOfConfusionPostProcess
  51925. * @param name The name of the effect.
  51926. * @param scene The scene the effect belongs to.
  51927. * @param direction The direction the blur should be applied.
  51928. * @param kernel The size of the kernel used to blur.
  51929. * @param options The required width/height ratio to downsize to before computing the render pass.
  51930. * @param camera The camera to apply the render pass to.
  51931. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51932. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51933. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51934. * @param engine The engine which the post process will be applied. (default: current engine)
  51935. * @param reusable If the post process can be reused on the same frame. (default: false)
  51936. * @param textureType Type of textures used when performing the post process. (default: 0)
  51937. * @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)
  51938. */
  51939. 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);
  51940. }
  51941. }
  51942. declare module BABYLON {
  51943. /** @hidden */
  51944. export var depthOfFieldMergePixelShader: {
  51945. name: string;
  51946. shader: string;
  51947. };
  51948. }
  51949. declare module BABYLON {
  51950. /**
  51951. * Options to be set when merging outputs from the default pipeline.
  51952. */
  51953. export class DepthOfFieldMergePostProcessOptions {
  51954. /**
  51955. * The original image to merge on top of
  51956. */
  51957. originalFromInput: PostProcess;
  51958. /**
  51959. * Parameters to perform the merge of the depth of field effect
  51960. */
  51961. depthOfField?: {
  51962. circleOfConfusion: PostProcess;
  51963. blurSteps: Array<PostProcess>;
  51964. };
  51965. /**
  51966. * Parameters to perform the merge of bloom effect
  51967. */
  51968. bloom?: {
  51969. blurred: PostProcess;
  51970. weight: number;
  51971. };
  51972. }
  51973. /**
  51974. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51975. */
  51976. export class DepthOfFieldMergePostProcess extends PostProcess {
  51977. private blurSteps;
  51978. /**
  51979. * Creates a new instance of DepthOfFieldMergePostProcess
  51980. * @param name The name of the effect.
  51981. * @param originalFromInput Post process which's input will be used for the merge.
  51982. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51983. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51984. * @param options The required width/height ratio to downsize to before computing the render pass.
  51985. * @param camera The camera to apply the render pass to.
  51986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51987. * @param engine The engine which the post process will be applied. (default: current engine)
  51988. * @param reusable If the post process can be reused on the same frame. (default: false)
  51989. * @param textureType Type of textures used when performing the post process. (default: 0)
  51990. * @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)
  51991. */
  51992. 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);
  51993. /**
  51994. * Updates the effect with the current post process compile time values and recompiles the shader.
  51995. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51996. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51997. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51998. * @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
  51999. * @param onCompiled Called when the shader has been compiled.
  52000. * @param onError Called if there is an error when compiling a shader.
  52001. */
  52002. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  52003. }
  52004. }
  52005. declare module BABYLON {
  52006. /**
  52007. * Specifies the level of max blur that should be applied when using the depth of field effect
  52008. */
  52009. export enum DepthOfFieldEffectBlurLevel {
  52010. /**
  52011. * Subtle blur
  52012. */
  52013. Low = 0,
  52014. /**
  52015. * Medium blur
  52016. */
  52017. Medium = 1,
  52018. /**
  52019. * Large blur
  52020. */
  52021. High = 2
  52022. }
  52023. /**
  52024. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  52025. */
  52026. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  52027. private _circleOfConfusion;
  52028. /**
  52029. * @hidden Internal, blurs from high to low
  52030. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  52031. private _depthOfFieldBlurY;
  52032. private _dofMerge;
  52033. /**
  52034. * @hidden Internal post processes in depth of field effect
  52035. */ effects: Array<PostProcess>;
  52036. /**
  52037. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  52038. */
  52039. focalLength: number;
  52040. /**
  52041. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  52042. */
  52043. fStop: number;
  52044. /**
  52045. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  52046. */
  52047. focusDistance: number;
  52048. /**
  52049. * 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.
  52050. */
  52051. lensSize: number;
  52052. /**
  52053. * Creates a new instance DepthOfFieldEffect
  52054. * @param scene The scene the effect belongs to.
  52055. * @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.
  52056. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  52057. * @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)
  52058. */
  52059. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  52060. /**
  52061. * Get the current class name of the current effet
  52062. * @returns "DepthOfFieldEffect"
  52063. */
  52064. getClassName(): string;
  52065. /**
  52066. * 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.
  52067. */
  52068. depthTexture: RenderTargetTexture;
  52069. /**
  52070. * Disposes each of the internal effects for a given camera.
  52071. * @param camera The camera to dispose the effect on.
  52072. */
  52073. disposeEffects(camera: Camera): void;
  52074. /**
  52075. * @hidden Internal
  52076. */ updateEffects(): void;
  52077. /**
  52078. * Internal
  52079. * @returns if all the contained post processes are ready.
  52080. * @hidden
  52081. */ isReady(): boolean;
  52082. }
  52083. }
  52084. declare module BABYLON {
  52085. /** @hidden */
  52086. export var displayPassPixelShader: {
  52087. name: string;
  52088. shader: string;
  52089. };
  52090. }
  52091. declare module BABYLON {
  52092. /**
  52093. * DisplayPassPostProcess which produces an output the same as it's input
  52094. */
  52095. export class DisplayPassPostProcess extends PostProcess {
  52096. /**
  52097. * Creates the DisplayPassPostProcess
  52098. * @param name The name of the effect.
  52099. * @param options The required width/height ratio to downsize to before computing the render pass.
  52100. * @param camera The camera to apply the render pass to.
  52101. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52102. * @param engine The engine which the post process will be applied. (default: current engine)
  52103. * @param reusable If the post process can be reused on the same frame. (default: false)
  52104. */
  52105. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52106. }
  52107. }
  52108. declare module BABYLON {
  52109. /** @hidden */
  52110. export var filterPixelShader: {
  52111. name: string;
  52112. shader: string;
  52113. };
  52114. }
  52115. declare module BABYLON {
  52116. /**
  52117. * Applies a kernel filter to the image
  52118. */
  52119. export class FilterPostProcess extends PostProcess {
  52120. /** The matrix to be applied to the image */
  52121. kernelMatrix: Matrix;
  52122. /**
  52123. *
  52124. * @param name The name of the effect.
  52125. * @param kernelMatrix The matrix to be applied to the image
  52126. * @param options The required width/height ratio to downsize to before computing the render pass.
  52127. * @param camera The camera to apply the render pass to.
  52128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52129. * @param engine The engine which the post process will be applied. (default: current engine)
  52130. * @param reusable If the post process can be reused on the same frame. (default: false)
  52131. */
  52132. constructor(name: string,
  52133. /** The matrix to be applied to the image */
  52134. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52135. }
  52136. }
  52137. declare module BABYLON {
  52138. /** @hidden */
  52139. export var fxaaPixelShader: {
  52140. name: string;
  52141. shader: string;
  52142. };
  52143. }
  52144. declare module BABYLON {
  52145. /** @hidden */
  52146. export var fxaaVertexShader: {
  52147. name: string;
  52148. shader: string;
  52149. };
  52150. }
  52151. declare module BABYLON {
  52152. /**
  52153. * Fxaa post process
  52154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  52155. */
  52156. export class FxaaPostProcess extends PostProcess {
  52157. /** @hidden */
  52158. texelWidth: number;
  52159. /** @hidden */
  52160. texelHeight: number;
  52161. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52162. private _getDefines;
  52163. }
  52164. }
  52165. declare module BABYLON {
  52166. /** @hidden */
  52167. export var grainPixelShader: {
  52168. name: string;
  52169. shader: string;
  52170. };
  52171. }
  52172. declare module BABYLON {
  52173. /**
  52174. * The GrainPostProcess adds noise to the image at mid luminance levels
  52175. */
  52176. export class GrainPostProcess extends PostProcess {
  52177. /**
  52178. * The intensity of the grain added (default: 30)
  52179. */
  52180. intensity: number;
  52181. /**
  52182. * If the grain should be randomized on every frame
  52183. */
  52184. animated: boolean;
  52185. /**
  52186. * Creates a new instance of @see GrainPostProcess
  52187. * @param name The name of the effect.
  52188. * @param options The required width/height ratio to downsize to before computing the render pass.
  52189. * @param camera The camera to apply the render pass to.
  52190. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52191. * @param engine The engine which the post process will be applied. (default: current engine)
  52192. * @param reusable If the post process can be reused on the same frame. (default: false)
  52193. * @param textureType Type of textures used when performing the post process. (default: 0)
  52194. * @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)
  52195. */
  52196. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. /** @hidden */
  52201. export var highlightsPixelShader: {
  52202. name: string;
  52203. shader: string;
  52204. };
  52205. }
  52206. declare module BABYLON {
  52207. /**
  52208. * Extracts highlights from the image
  52209. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52210. */
  52211. export class HighlightsPostProcess extends PostProcess {
  52212. /**
  52213. * Extracts highlights from the image
  52214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  52215. * @param name The name of the effect.
  52216. * @param options The required width/height ratio to downsize to before computing the render pass.
  52217. * @param camera The camera to apply the render pass to.
  52218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52219. * @param engine The engine which the post process will be applied. (default: current engine)
  52220. * @param reusable If the post process can be reused on the same frame. (default: false)
  52221. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  52222. */
  52223. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  52224. }
  52225. }
  52226. declare module BABYLON {
  52227. /** @hidden */
  52228. export var mrtFragmentDeclaration: {
  52229. name: string;
  52230. shader: string;
  52231. };
  52232. }
  52233. declare module BABYLON {
  52234. /** @hidden */
  52235. export var geometryPixelShader: {
  52236. name: string;
  52237. shader: string;
  52238. };
  52239. }
  52240. declare module BABYLON {
  52241. /** @hidden */
  52242. export var geometryVertexShader: {
  52243. name: string;
  52244. shader: string;
  52245. };
  52246. }
  52247. declare module BABYLON {
  52248. /**
  52249. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  52250. */
  52251. export class GeometryBufferRenderer {
  52252. /**
  52253. * Constant used to retrieve the position texture index in the G-Buffer textures array
  52254. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  52255. */
  52256. static readonly POSITION_TEXTURE_TYPE: number;
  52257. /**
  52258. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  52259. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  52260. */
  52261. static readonly VELOCITY_TEXTURE_TYPE: number;
  52262. /**
  52263. * Dictionary used to store the previous transformation matrices of each rendered mesh
  52264. * in order to compute objects velocities when enableVelocity is set to "true"
  52265. * @hidden
  52266. */ previousTransformationMatrices: {
  52267. [index: number]: Matrix;
  52268. };
  52269. private _scene;
  52270. private _multiRenderTarget;
  52271. private _ratio;
  52272. private _enablePosition;
  52273. private _enableVelocity;
  52274. private _positionIndex;
  52275. private _velocityIndex;
  52276. protected _effect: Effect;
  52277. protected _cachedDefines: string;
  52278. /**
  52279. * Set the render list (meshes to be rendered) used in the G buffer.
  52280. */
  52281. renderList: Mesh[];
  52282. /**
  52283. * Gets wether or not G buffer are supported by the running hardware.
  52284. * This requires draw buffer supports
  52285. */
  52286. readonly isSupported: boolean;
  52287. /**
  52288. * Returns the index of the given texture type in the G-Buffer textures array
  52289. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  52290. * @returns the index of the given texture type in the G-Buffer textures array
  52291. */
  52292. getTextureIndex(textureType: number): number;
  52293. /**
  52294. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  52295. */
  52296. /**
  52297. * Sets whether or not objects positions are enabled for the G buffer.
  52298. */
  52299. enablePosition: boolean;
  52300. /**
  52301. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  52302. */
  52303. /**
  52304. * Sets wether or not objects velocities are enabled for the G buffer.
  52305. */
  52306. enableVelocity: boolean;
  52307. /**
  52308. * Gets the scene associated with the buffer.
  52309. */
  52310. readonly scene: Scene;
  52311. /**
  52312. * Gets the ratio used by the buffer during its creation.
  52313. * How big is the buffer related to the main canvas.
  52314. */
  52315. readonly ratio: number;
  52316. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  52317. /**
  52318. * Creates a new G Buffer for the scene
  52319. * @param scene The scene the buffer belongs to
  52320. * @param ratio How big is the buffer related to the main canvas.
  52321. */
  52322. constructor(scene: Scene, ratio?: number);
  52323. /**
  52324. * Checks wether everything is ready to render a submesh to the G buffer.
  52325. * @param subMesh the submesh to check readiness for
  52326. * @param useInstances is the mesh drawn using instance or not
  52327. * @returns true if ready otherwise false
  52328. */
  52329. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52330. /**
  52331. * Gets the current underlying G Buffer.
  52332. * @returns the buffer
  52333. */
  52334. getGBuffer(): MultiRenderTarget;
  52335. /**
  52336. * Gets the number of samples used to render the buffer (anti aliasing).
  52337. */
  52338. /**
  52339. * Sets the number of samples used to render the buffer (anti aliasing).
  52340. */
  52341. samples: number;
  52342. /**
  52343. * Disposes the renderer and frees up associated resources.
  52344. */
  52345. dispose(): void;
  52346. protected _createRenderTargets(): void;
  52347. }
  52348. }
  52349. declare module BABYLON {
  52350. interface Scene {
  52351. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52352. /**
  52353. * Gets or Sets the current geometry buffer associated to the scene.
  52354. */
  52355. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  52356. /**
  52357. * Enables a GeometryBufferRender and associates it with the scene
  52358. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  52359. * @returns the GeometryBufferRenderer
  52360. */
  52361. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  52362. /**
  52363. * Disables the GeometryBufferRender associated with the scene
  52364. */
  52365. disableGeometryBufferRenderer(): void;
  52366. }
  52367. /**
  52368. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  52369. * in several rendering techniques.
  52370. */
  52371. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  52372. /**
  52373. * The component name helpful to identify the component in the list of scene components.
  52374. */
  52375. readonly name: string;
  52376. /**
  52377. * The scene the component belongs to.
  52378. */
  52379. scene: Scene;
  52380. /**
  52381. * Creates a new instance of the component for the given scene
  52382. * @param scene Defines the scene to register the component in
  52383. */
  52384. constructor(scene: Scene);
  52385. /**
  52386. * Registers the component in a given scene
  52387. */
  52388. register(): void;
  52389. /**
  52390. * Rebuilds the elements related to this component in case of
  52391. * context lost for instance.
  52392. */
  52393. rebuild(): void;
  52394. /**
  52395. * Disposes the component and the associated ressources
  52396. */
  52397. dispose(): void;
  52398. private _gatherRenderTargets;
  52399. }
  52400. }
  52401. declare module BABYLON {
  52402. /** @hidden */
  52403. export var motionBlurPixelShader: {
  52404. name: string;
  52405. shader: string;
  52406. };
  52407. }
  52408. declare module BABYLON {
  52409. /**
  52410. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  52411. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  52412. * As an example, all you have to do is to create the post-process:
  52413. * var mb = new BABYLON.MotionBlurPostProcess(
  52414. * 'mb', // The name of the effect.
  52415. * scene, // The scene containing the objects to blur according to their velocity.
  52416. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  52417. * camera // The camera to apply the render pass to.
  52418. * );
  52419. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  52420. */
  52421. export class MotionBlurPostProcess extends PostProcess {
  52422. /**
  52423. * Defines how much the image is blurred by the movement. Default value is equal to 1
  52424. */
  52425. motionStrength: number;
  52426. /**
  52427. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  52428. */
  52429. /**
  52430. * Sets the number of iterations to be used for motion blur quality
  52431. */
  52432. motionBlurSamples: number;
  52433. private _motionBlurSamples;
  52434. private _geometryBufferRenderer;
  52435. /**
  52436. * Creates a new instance MotionBlurPostProcess
  52437. * @param name The name of the effect.
  52438. * @param scene The scene containing the objects to blur according to their velocity.
  52439. * @param options The required width/height ratio to downsize to before computing the render pass.
  52440. * @param camera The camera to apply the render pass to.
  52441. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52442. * @param engine The engine which the post process will be applied. (default: current engine)
  52443. * @param reusable If the post process can be reused on the same frame. (default: false)
  52444. * @param textureType Type of textures used when performing the post process. (default: 0)
  52445. * @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)
  52446. */
  52447. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52448. /**
  52449. * Disposes the post process.
  52450. * @param camera The camera to dispose the post process on.
  52451. */
  52452. dispose(camera?: Camera): void;
  52453. }
  52454. }
  52455. declare module BABYLON {
  52456. /** @hidden */
  52457. export var refractionPixelShader: {
  52458. name: string;
  52459. shader: string;
  52460. };
  52461. }
  52462. declare module BABYLON {
  52463. /**
  52464. * Post process which applies a refractin texture
  52465. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52466. */
  52467. export class RefractionPostProcess extends PostProcess {
  52468. /** the base color of the refraction (used to taint the rendering) */
  52469. color: Color3;
  52470. /** simulated refraction depth */
  52471. depth: number;
  52472. /** the coefficient of the base color (0 to remove base color tainting) */
  52473. colorLevel: number;
  52474. private _refTexture;
  52475. private _ownRefractionTexture;
  52476. /**
  52477. * Gets or sets the refraction texture
  52478. * Please note that you are responsible for disposing the texture if you set it manually
  52479. */
  52480. refractionTexture: Texture;
  52481. /**
  52482. * Initializes the RefractionPostProcess
  52483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  52484. * @param name The name of the effect.
  52485. * @param refractionTextureUrl Url of the refraction texture to use
  52486. * @param color the base color of the refraction (used to taint the rendering)
  52487. * @param depth simulated refraction depth
  52488. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  52489. * @param camera The camera to apply the render pass to.
  52490. * @param options The required width/height ratio to downsize to before computing the render pass.
  52491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52492. * @param engine The engine which the post process will be applied. (default: current engine)
  52493. * @param reusable If the post process can be reused on the same frame. (default: false)
  52494. */
  52495. constructor(name: string, refractionTextureUrl: string,
  52496. /** the base color of the refraction (used to taint the rendering) */
  52497. color: Color3,
  52498. /** simulated refraction depth */
  52499. depth: number,
  52500. /** the coefficient of the base color (0 to remove base color tainting) */
  52501. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52502. /**
  52503. * Disposes of the post process
  52504. * @param camera Camera to dispose post process on
  52505. */
  52506. dispose(camera: Camera): void;
  52507. }
  52508. }
  52509. declare module BABYLON {
  52510. /** @hidden */
  52511. export var sharpenPixelShader: {
  52512. name: string;
  52513. shader: string;
  52514. };
  52515. }
  52516. declare module BABYLON {
  52517. /**
  52518. * The SharpenPostProcess applies a sharpen kernel to every pixel
  52519. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  52520. */
  52521. export class SharpenPostProcess extends PostProcess {
  52522. /**
  52523. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  52524. */
  52525. colorAmount: number;
  52526. /**
  52527. * How much sharpness should be applied (default: 0.3)
  52528. */
  52529. edgeAmount: number;
  52530. /**
  52531. * Creates a new instance ConvolutionPostProcess
  52532. * @param name The name of the effect.
  52533. * @param options The required width/height ratio to downsize to before computing the render pass.
  52534. * @param camera The camera to apply the render pass to.
  52535. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52536. * @param engine The engine which the post process will be applied. (default: current engine)
  52537. * @param reusable If the post process can be reused on the same frame. (default: false)
  52538. * @param textureType Type of textures used when performing the post process. (default: 0)
  52539. * @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)
  52540. */
  52541. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  52542. }
  52543. }
  52544. declare module BABYLON {
  52545. /**
  52546. * PostProcessRenderPipeline
  52547. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52548. */
  52549. export class PostProcessRenderPipeline {
  52550. private engine;
  52551. private _renderEffects;
  52552. private _renderEffectsForIsolatedPass;
  52553. /**
  52554. * List of inspectable custom properties (used by the Inspector)
  52555. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  52556. */
  52557. inspectableCustomProperties: IInspectable[];
  52558. /**
  52559. * @hidden
  52560. */
  52561. protected _cameras: Camera[];
  52562. /** @hidden */ name: string;
  52563. /**
  52564. * Gets pipeline name
  52565. */
  52566. readonly name: string;
  52567. /**
  52568. * Initializes a PostProcessRenderPipeline
  52569. * @param engine engine to add the pipeline to
  52570. * @param name name of the pipeline
  52571. */
  52572. constructor(engine: Engine, name: string);
  52573. /**
  52574. * Gets the class name
  52575. * @returns "PostProcessRenderPipeline"
  52576. */
  52577. getClassName(): string;
  52578. /**
  52579. * If all the render effects in the pipeline are supported
  52580. */
  52581. readonly isSupported: boolean;
  52582. /**
  52583. * Adds an effect to the pipeline
  52584. * @param renderEffect the effect to add
  52585. */
  52586. addEffect(renderEffect: PostProcessRenderEffect): void;
  52587. /** @hidden */ rebuild(): void;
  52588. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  52589. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  52590. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52591. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  52592. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  52593. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  52594. /** @hidden */ detachCameras(cameras: Camera): void;
  52595. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  52596. /** @hidden */ update(): void;
  52597. /** @hidden */ reset(): void;
  52598. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  52599. /**
  52600. * Disposes of the pipeline
  52601. */
  52602. dispose(): void;
  52603. }
  52604. }
  52605. declare module BABYLON {
  52606. /**
  52607. * PostProcessRenderPipelineManager class
  52608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52609. */
  52610. export class PostProcessRenderPipelineManager {
  52611. private _renderPipelines;
  52612. /**
  52613. * Initializes a PostProcessRenderPipelineManager
  52614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52615. */
  52616. constructor();
  52617. /**
  52618. * Gets the list of supported render pipelines
  52619. */
  52620. readonly supportedPipelines: PostProcessRenderPipeline[];
  52621. /**
  52622. * Adds a pipeline to the manager
  52623. * @param renderPipeline The pipeline to add
  52624. */
  52625. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  52626. /**
  52627. * Attaches a camera to the pipeline
  52628. * @param renderPipelineName The name of the pipeline to attach to
  52629. * @param cameras the camera to attach
  52630. * @param unique if the camera can be attached multiple times to the pipeline
  52631. */
  52632. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  52633. /**
  52634. * Detaches a camera from the pipeline
  52635. * @param renderPipelineName The name of the pipeline to detach from
  52636. * @param cameras the camera to detach
  52637. */
  52638. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  52639. /**
  52640. * Enables an effect by name on a pipeline
  52641. * @param renderPipelineName the name of the pipeline to enable the effect in
  52642. * @param renderEffectName the name of the effect to enable
  52643. * @param cameras the cameras that the effect should be enabled on
  52644. */
  52645. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52646. /**
  52647. * Disables an effect by name on a pipeline
  52648. * @param renderPipelineName the name of the pipeline to disable the effect in
  52649. * @param renderEffectName the name of the effect to disable
  52650. * @param cameras the cameras that the effect should be disabled on
  52651. */
  52652. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  52653. /**
  52654. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  52655. */
  52656. update(): void;
  52657. /** @hidden */ rebuild(): void;
  52658. /**
  52659. * Disposes of the manager and pipelines
  52660. */
  52661. dispose(): void;
  52662. }
  52663. }
  52664. declare module BABYLON {
  52665. interface Scene {
  52666. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52667. /**
  52668. * Gets the postprocess render pipeline manager
  52669. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  52670. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52671. */
  52672. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  52673. }
  52674. /**
  52675. * Defines the Render Pipeline scene component responsible to rendering pipelines
  52676. */
  52677. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  52678. /**
  52679. * The component name helpfull to identify the component in the list of scene components.
  52680. */
  52681. readonly name: string;
  52682. /**
  52683. * The scene the component belongs to.
  52684. */
  52685. scene: Scene;
  52686. /**
  52687. * Creates a new instance of the component for the given scene
  52688. * @param scene Defines the scene to register the component in
  52689. */
  52690. constructor(scene: Scene);
  52691. /**
  52692. * Registers the component in a given scene
  52693. */
  52694. register(): void;
  52695. /**
  52696. * Rebuilds the elements related to this component in case of
  52697. * context lost for instance.
  52698. */
  52699. rebuild(): void;
  52700. /**
  52701. * Disposes the component and the associated ressources
  52702. */
  52703. dispose(): void;
  52704. private _gatherRenderTargets;
  52705. }
  52706. }
  52707. declare module BABYLON {
  52708. /**
  52709. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52710. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52711. */
  52712. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52713. private _scene;
  52714. private _camerasToBeAttached;
  52715. /**
  52716. * ID of the sharpen post process,
  52717. */
  52718. private readonly SharpenPostProcessId;
  52719. /**
  52720. * @ignore
  52721. * ID of the image processing post process;
  52722. */
  52723. readonly ImageProcessingPostProcessId: string;
  52724. /**
  52725. * @ignore
  52726. * ID of the Fast Approximate Anti-Aliasing post process;
  52727. */
  52728. readonly FxaaPostProcessId: string;
  52729. /**
  52730. * ID of the chromatic aberration post process,
  52731. */
  52732. private readonly ChromaticAberrationPostProcessId;
  52733. /**
  52734. * ID of the grain post process
  52735. */
  52736. private readonly GrainPostProcessId;
  52737. /**
  52738. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52739. */
  52740. sharpen: SharpenPostProcess;
  52741. private _sharpenEffect;
  52742. private bloom;
  52743. /**
  52744. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52745. */
  52746. depthOfField: DepthOfFieldEffect;
  52747. /**
  52748. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52749. */
  52750. fxaa: FxaaPostProcess;
  52751. /**
  52752. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52753. */
  52754. imageProcessing: ImageProcessingPostProcess;
  52755. /**
  52756. * Chromatic aberration post process which will shift rgb colors in the image
  52757. */
  52758. chromaticAberration: ChromaticAberrationPostProcess;
  52759. private _chromaticAberrationEffect;
  52760. /**
  52761. * Grain post process which add noise to the image
  52762. */
  52763. grain: GrainPostProcess;
  52764. private _grainEffect;
  52765. /**
  52766. * Glow post process which adds a glow to emissive areas of the image
  52767. */
  52768. private _glowLayer;
  52769. /**
  52770. * Animations which can be used to tweak settings over a period of time
  52771. */
  52772. animations: Animation[];
  52773. private _imageProcessingConfigurationObserver;
  52774. private _sharpenEnabled;
  52775. private _bloomEnabled;
  52776. private _depthOfFieldEnabled;
  52777. private _depthOfFieldBlurLevel;
  52778. private _fxaaEnabled;
  52779. private _imageProcessingEnabled;
  52780. private _defaultPipelineTextureType;
  52781. private _bloomScale;
  52782. private _chromaticAberrationEnabled;
  52783. private _grainEnabled;
  52784. private _buildAllowed;
  52785. /**
  52786. * Gets active scene
  52787. */
  52788. readonly scene: Scene;
  52789. /**
  52790. * Enable or disable the sharpen process from the pipeline
  52791. */
  52792. sharpenEnabled: boolean;
  52793. private _resizeObserver;
  52794. private _hardwareScaleLevel;
  52795. private _bloomKernel;
  52796. /**
  52797. * Specifies the size of the bloom blur kernel, relative to the final output size
  52798. */
  52799. bloomKernel: number;
  52800. /**
  52801. * Specifies the weight of the bloom in the final rendering
  52802. */
  52803. private _bloomWeight;
  52804. /**
  52805. * Specifies the luma threshold for the area that will be blurred by the bloom
  52806. */
  52807. private _bloomThreshold;
  52808. private _hdr;
  52809. /**
  52810. * The strength of the bloom.
  52811. */
  52812. bloomWeight: number;
  52813. /**
  52814. * The strength of the bloom.
  52815. */
  52816. bloomThreshold: number;
  52817. /**
  52818. * The scale of the bloom, lower value will provide better performance.
  52819. */
  52820. bloomScale: number;
  52821. /**
  52822. * Enable or disable the bloom from the pipeline
  52823. */
  52824. bloomEnabled: boolean;
  52825. private _rebuildBloom;
  52826. /**
  52827. * If the depth of field is enabled.
  52828. */
  52829. depthOfFieldEnabled: boolean;
  52830. /**
  52831. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52832. */
  52833. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52834. /**
  52835. * If the anti aliasing is enabled.
  52836. */
  52837. fxaaEnabled: boolean;
  52838. private _samples;
  52839. /**
  52840. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52841. */
  52842. samples: number;
  52843. /**
  52844. * If image processing is enabled.
  52845. */
  52846. imageProcessingEnabled: boolean;
  52847. /**
  52848. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52849. */
  52850. glowLayerEnabled: boolean;
  52851. /**
  52852. * Gets the glow layer (or null if not defined)
  52853. */
  52854. readonly glowLayer: Nullable<GlowLayer>;
  52855. /**
  52856. * Enable or disable the chromaticAberration process from the pipeline
  52857. */
  52858. chromaticAberrationEnabled: boolean;
  52859. /**
  52860. * Enable or disable the grain process from the pipeline
  52861. */
  52862. grainEnabled: boolean;
  52863. /**
  52864. * @constructor
  52865. * @param name - The rendering pipeline name (default: "")
  52866. * @param hdr - If high dynamic range textures should be used (default: true)
  52867. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52868. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52869. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52870. */
  52871. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52872. /**
  52873. * Get the class name
  52874. * @returns "DefaultRenderingPipeline"
  52875. */
  52876. getClassName(): string;
  52877. /**
  52878. * Force the compilation of the entire pipeline.
  52879. */
  52880. prepare(): void;
  52881. private _hasCleared;
  52882. private _prevPostProcess;
  52883. private _prevPrevPostProcess;
  52884. private _setAutoClearAndTextureSharing;
  52885. private _depthOfFieldSceneObserver;
  52886. private _buildPipeline;
  52887. private _disposePostProcesses;
  52888. /**
  52889. * Adds a camera to the pipeline
  52890. * @param camera the camera to be added
  52891. */
  52892. addCamera(camera: Camera): void;
  52893. /**
  52894. * Removes a camera from the pipeline
  52895. * @param camera the camera to remove
  52896. */
  52897. removeCamera(camera: Camera): void;
  52898. /**
  52899. * Dispose of the pipeline and stop all post processes
  52900. */
  52901. dispose(): void;
  52902. /**
  52903. * Serialize the rendering pipeline (Used when exporting)
  52904. * @returns the serialized object
  52905. */
  52906. serialize(): any;
  52907. /**
  52908. * Parse the serialized pipeline
  52909. * @param source Source pipeline.
  52910. * @param scene The scene to load the pipeline to.
  52911. * @param rootUrl The URL of the serialized pipeline.
  52912. * @returns An instantiated pipeline from the serialized object.
  52913. */
  52914. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52915. }
  52916. }
  52917. declare module BABYLON {
  52918. /** @hidden */
  52919. export var lensHighlightsPixelShader: {
  52920. name: string;
  52921. shader: string;
  52922. };
  52923. }
  52924. declare module BABYLON {
  52925. /** @hidden */
  52926. export var depthOfFieldPixelShader: {
  52927. name: string;
  52928. shader: string;
  52929. };
  52930. }
  52931. declare module BABYLON {
  52932. /**
  52933. * BABYLON.JS Chromatic Aberration GLSL Shader
  52934. * Author: Olivier Guyot
  52935. * Separates very slightly R, G and B colors on the edges of the screen
  52936. * Inspired by Francois Tarlier & Martins Upitis
  52937. */
  52938. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52939. /**
  52940. * @ignore
  52941. * The chromatic aberration PostProcess id in the pipeline
  52942. */
  52943. LensChromaticAberrationEffect: string;
  52944. /**
  52945. * @ignore
  52946. * The highlights enhancing PostProcess id in the pipeline
  52947. */
  52948. HighlightsEnhancingEffect: string;
  52949. /**
  52950. * @ignore
  52951. * The depth-of-field PostProcess id in the pipeline
  52952. */
  52953. LensDepthOfFieldEffect: string;
  52954. private _scene;
  52955. private _depthTexture;
  52956. private _grainTexture;
  52957. private _chromaticAberrationPostProcess;
  52958. private _highlightsPostProcess;
  52959. private _depthOfFieldPostProcess;
  52960. private _edgeBlur;
  52961. private _grainAmount;
  52962. private _chromaticAberration;
  52963. private _distortion;
  52964. private _highlightsGain;
  52965. private _highlightsThreshold;
  52966. private _dofDistance;
  52967. private _dofAperture;
  52968. private _dofDarken;
  52969. private _dofPentagon;
  52970. private _blurNoise;
  52971. /**
  52972. * @constructor
  52973. *
  52974. * Effect parameters are as follow:
  52975. * {
  52976. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52977. * edge_blur: number; // from 0 to x (1 for realism)
  52978. * distortion: number; // from 0 to x (1 for realism)
  52979. * grain_amount: number; // from 0 to 1
  52980. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52981. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52982. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52983. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52984. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52985. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52986. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52987. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52988. * }
  52989. * Note: if an effect parameter is unset, effect is disabled
  52990. *
  52991. * @param name The rendering pipeline name
  52992. * @param parameters - An object containing all parameters (see above)
  52993. * @param scene The scene linked to this pipeline
  52994. * @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)
  52995. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52996. */
  52997. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52998. /**
  52999. * Get the class name
  53000. * @returns "LensRenderingPipeline"
  53001. */
  53002. getClassName(): string;
  53003. /**
  53004. * Gets associated scene
  53005. */
  53006. readonly scene: Scene;
  53007. /**
  53008. * Gets or sets the edge blur
  53009. */
  53010. edgeBlur: number;
  53011. /**
  53012. * Gets or sets the grain amount
  53013. */
  53014. grainAmount: number;
  53015. /**
  53016. * Gets or sets the chromatic aberration amount
  53017. */
  53018. chromaticAberration: number;
  53019. /**
  53020. * Gets or sets the depth of field aperture
  53021. */
  53022. dofAperture: number;
  53023. /**
  53024. * Gets or sets the edge distortion
  53025. */
  53026. edgeDistortion: number;
  53027. /**
  53028. * Gets or sets the depth of field distortion
  53029. */
  53030. dofDistortion: number;
  53031. /**
  53032. * Gets or sets the darken out of focus amount
  53033. */
  53034. darkenOutOfFocus: number;
  53035. /**
  53036. * Gets or sets a boolean indicating if blur noise is enabled
  53037. */
  53038. blurNoise: boolean;
  53039. /**
  53040. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  53041. */
  53042. pentagonBokeh: boolean;
  53043. /**
  53044. * Gets or sets the highlight grain amount
  53045. */
  53046. highlightsGain: number;
  53047. /**
  53048. * Gets or sets the highlight threshold
  53049. */
  53050. highlightsThreshold: number;
  53051. /**
  53052. * Sets the amount of blur at the edges
  53053. * @param amount blur amount
  53054. */
  53055. setEdgeBlur(amount: number): void;
  53056. /**
  53057. * Sets edge blur to 0
  53058. */
  53059. disableEdgeBlur(): void;
  53060. /**
  53061. * Sets the amout of grain
  53062. * @param amount Amount of grain
  53063. */
  53064. setGrainAmount(amount: number): void;
  53065. /**
  53066. * Set grain amount to 0
  53067. */
  53068. disableGrain(): void;
  53069. /**
  53070. * Sets the chromatic aberration amount
  53071. * @param amount amount of chromatic aberration
  53072. */
  53073. setChromaticAberration(amount: number): void;
  53074. /**
  53075. * Sets chromatic aberration amount to 0
  53076. */
  53077. disableChromaticAberration(): void;
  53078. /**
  53079. * Sets the EdgeDistortion amount
  53080. * @param amount amount of EdgeDistortion
  53081. */
  53082. setEdgeDistortion(amount: number): void;
  53083. /**
  53084. * Sets edge distortion to 0
  53085. */
  53086. disableEdgeDistortion(): void;
  53087. /**
  53088. * Sets the FocusDistance amount
  53089. * @param amount amount of FocusDistance
  53090. */
  53091. setFocusDistance(amount: number): void;
  53092. /**
  53093. * Disables depth of field
  53094. */
  53095. disableDepthOfField(): void;
  53096. /**
  53097. * Sets the Aperture amount
  53098. * @param amount amount of Aperture
  53099. */
  53100. setAperture(amount: number): void;
  53101. /**
  53102. * Sets the DarkenOutOfFocus amount
  53103. * @param amount amount of DarkenOutOfFocus
  53104. */
  53105. setDarkenOutOfFocus(amount: number): void;
  53106. private _pentagonBokehIsEnabled;
  53107. /**
  53108. * Creates a pentagon bokeh effect
  53109. */
  53110. enablePentagonBokeh(): void;
  53111. /**
  53112. * Disables the pentagon bokeh effect
  53113. */
  53114. disablePentagonBokeh(): void;
  53115. /**
  53116. * Enables noise blur
  53117. */
  53118. enableNoiseBlur(): void;
  53119. /**
  53120. * Disables noise blur
  53121. */
  53122. disableNoiseBlur(): void;
  53123. /**
  53124. * Sets the HighlightsGain amount
  53125. * @param amount amount of HighlightsGain
  53126. */
  53127. setHighlightsGain(amount: number): void;
  53128. /**
  53129. * Sets the HighlightsThreshold amount
  53130. * @param amount amount of HighlightsThreshold
  53131. */
  53132. setHighlightsThreshold(amount: number): void;
  53133. /**
  53134. * Disables highlights
  53135. */
  53136. disableHighlights(): void;
  53137. /**
  53138. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  53139. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  53140. */
  53141. dispose(disableDepthRender?: boolean): void;
  53142. private _createChromaticAberrationPostProcess;
  53143. private _createHighlightsPostProcess;
  53144. private _createDepthOfFieldPostProcess;
  53145. private _createGrainTexture;
  53146. }
  53147. }
  53148. declare module BABYLON {
  53149. /** @hidden */
  53150. export var ssao2PixelShader: {
  53151. name: string;
  53152. shader: string;
  53153. };
  53154. }
  53155. declare module BABYLON {
  53156. /** @hidden */
  53157. export var ssaoCombinePixelShader: {
  53158. name: string;
  53159. shader: string;
  53160. };
  53161. }
  53162. declare module BABYLON {
  53163. /**
  53164. * Render pipeline to produce ssao effect
  53165. */
  53166. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  53167. /**
  53168. * @ignore
  53169. * The PassPostProcess id in the pipeline that contains the original scene color
  53170. */
  53171. SSAOOriginalSceneColorEffect: string;
  53172. /**
  53173. * @ignore
  53174. * The SSAO PostProcess id in the pipeline
  53175. */
  53176. SSAORenderEffect: string;
  53177. /**
  53178. * @ignore
  53179. * The horizontal blur PostProcess id in the pipeline
  53180. */
  53181. SSAOBlurHRenderEffect: string;
  53182. /**
  53183. * @ignore
  53184. * The vertical blur PostProcess id in the pipeline
  53185. */
  53186. SSAOBlurVRenderEffect: string;
  53187. /**
  53188. * @ignore
  53189. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53190. */
  53191. SSAOCombineRenderEffect: string;
  53192. /**
  53193. * The output strength of the SSAO post-process. Default value is 1.0.
  53194. */
  53195. totalStrength: number;
  53196. /**
  53197. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  53198. */
  53199. maxZ: number;
  53200. /**
  53201. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  53202. */
  53203. minZAspect: number;
  53204. private _samples;
  53205. /**
  53206. * Number of samples used for the SSAO calculations. Default value is 8
  53207. */
  53208. samples: number;
  53209. private _textureSamples;
  53210. /**
  53211. * Number of samples to use for antialiasing
  53212. */
  53213. textureSamples: number;
  53214. /**
  53215. * Ratio object used for SSAO ratio and blur ratio
  53216. */
  53217. private _ratio;
  53218. /**
  53219. * Dynamically generated sphere sampler.
  53220. */
  53221. private _sampleSphere;
  53222. /**
  53223. * Blur filter offsets
  53224. */
  53225. private _samplerOffsets;
  53226. private _expensiveBlur;
  53227. /**
  53228. * If bilateral blur should be used
  53229. */
  53230. expensiveBlur: boolean;
  53231. /**
  53232. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  53233. */
  53234. radius: number;
  53235. /**
  53236. * The base color of the SSAO post-process
  53237. * The final result is "base + ssao" between [0, 1]
  53238. */
  53239. base: number;
  53240. /**
  53241. * Support test.
  53242. */
  53243. static readonly IsSupported: boolean;
  53244. private _scene;
  53245. private _depthTexture;
  53246. private _normalTexture;
  53247. private _randomTexture;
  53248. private _originalColorPostProcess;
  53249. private _ssaoPostProcess;
  53250. private _blurHPostProcess;
  53251. private _blurVPostProcess;
  53252. private _ssaoCombinePostProcess;
  53253. private _firstUpdate;
  53254. /**
  53255. * Gets active scene
  53256. */
  53257. readonly scene: Scene;
  53258. /**
  53259. * @constructor
  53260. * @param name The rendering pipeline name
  53261. * @param scene The scene linked to this pipeline
  53262. * @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 }
  53263. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53264. */
  53265. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53266. /**
  53267. * Get the class name
  53268. * @returns "SSAO2RenderingPipeline"
  53269. */
  53270. getClassName(): string;
  53271. /**
  53272. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53273. */
  53274. dispose(disableGeometryBufferRenderer?: boolean): void;
  53275. private _createBlurPostProcess;
  53276. /** @hidden */ rebuild(): void;
  53277. private _bits;
  53278. private _radicalInverse_VdC;
  53279. private _hammersley;
  53280. private _hemisphereSample_uniform;
  53281. private _generateHemisphere;
  53282. private _createSSAOPostProcess;
  53283. private _createSSAOCombinePostProcess;
  53284. private _createRandomTexture;
  53285. /**
  53286. * Serialize the rendering pipeline (Used when exporting)
  53287. * @returns the serialized object
  53288. */
  53289. serialize(): any;
  53290. /**
  53291. * Parse the serialized pipeline
  53292. * @param source Source pipeline.
  53293. * @param scene The scene to load the pipeline to.
  53294. * @param rootUrl The URL of the serialized pipeline.
  53295. * @returns An instantiated pipeline from the serialized object.
  53296. */
  53297. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  53298. }
  53299. }
  53300. declare module BABYLON {
  53301. /** @hidden */
  53302. export var ssaoPixelShader: {
  53303. name: string;
  53304. shader: string;
  53305. };
  53306. }
  53307. declare module BABYLON {
  53308. /**
  53309. * Render pipeline to produce ssao effect
  53310. */
  53311. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  53312. /**
  53313. * @ignore
  53314. * The PassPostProcess id in the pipeline that contains the original scene color
  53315. */
  53316. SSAOOriginalSceneColorEffect: string;
  53317. /**
  53318. * @ignore
  53319. * The SSAO PostProcess id in the pipeline
  53320. */
  53321. SSAORenderEffect: string;
  53322. /**
  53323. * @ignore
  53324. * The horizontal blur PostProcess id in the pipeline
  53325. */
  53326. SSAOBlurHRenderEffect: string;
  53327. /**
  53328. * @ignore
  53329. * The vertical blur PostProcess id in the pipeline
  53330. */
  53331. SSAOBlurVRenderEffect: string;
  53332. /**
  53333. * @ignore
  53334. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  53335. */
  53336. SSAOCombineRenderEffect: string;
  53337. /**
  53338. * The output strength of the SSAO post-process. Default value is 1.0.
  53339. */
  53340. totalStrength: number;
  53341. /**
  53342. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  53343. */
  53344. radius: number;
  53345. /**
  53346. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  53347. * Must not be equal to fallOff and superior to fallOff.
  53348. * Default value is 0.0075
  53349. */
  53350. area: number;
  53351. /**
  53352. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  53353. * Must not be equal to area and inferior to area.
  53354. * Default value is 0.000001
  53355. */
  53356. fallOff: number;
  53357. /**
  53358. * The base color of the SSAO post-process
  53359. * The final result is "base + ssao" between [0, 1]
  53360. */
  53361. base: number;
  53362. private _scene;
  53363. private _depthTexture;
  53364. private _randomTexture;
  53365. private _originalColorPostProcess;
  53366. private _ssaoPostProcess;
  53367. private _blurHPostProcess;
  53368. private _blurVPostProcess;
  53369. private _ssaoCombinePostProcess;
  53370. private _firstUpdate;
  53371. /**
  53372. * Gets active scene
  53373. */
  53374. readonly scene: Scene;
  53375. /**
  53376. * @constructor
  53377. * @param name - The rendering pipeline name
  53378. * @param scene - The scene linked to this pipeline
  53379. * @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 }
  53380. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  53381. */
  53382. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  53383. /**
  53384. * Get the class name
  53385. * @returns "SSAORenderingPipeline"
  53386. */
  53387. getClassName(): string;
  53388. /**
  53389. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  53390. */
  53391. dispose(disableDepthRender?: boolean): void;
  53392. private _createBlurPostProcess;
  53393. /** @hidden */ rebuild(): void;
  53394. private _createSSAOPostProcess;
  53395. private _createSSAOCombinePostProcess;
  53396. private _createRandomTexture;
  53397. }
  53398. }
  53399. declare module BABYLON {
  53400. /** @hidden */
  53401. export var standardPixelShader: {
  53402. name: string;
  53403. shader: string;
  53404. };
  53405. }
  53406. declare module BABYLON {
  53407. /**
  53408. * Standard rendering pipeline
  53409. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53410. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  53411. */
  53412. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  53413. /**
  53414. * Public members
  53415. */
  53416. /**
  53417. * Post-process which contains the original scene color before the pipeline applies all the effects
  53418. */
  53419. originalPostProcess: Nullable<PostProcess>;
  53420. /**
  53421. * Post-process used to down scale an image x4
  53422. */
  53423. downSampleX4PostProcess: Nullable<PostProcess>;
  53424. /**
  53425. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  53426. */
  53427. brightPassPostProcess: Nullable<PostProcess>;
  53428. /**
  53429. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  53430. */
  53431. blurHPostProcesses: PostProcess[];
  53432. /**
  53433. * Post-process array storing all the vertical blur post-processes used by the pipeline
  53434. */
  53435. blurVPostProcesses: PostProcess[];
  53436. /**
  53437. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  53438. */
  53439. textureAdderPostProcess: Nullable<PostProcess>;
  53440. /**
  53441. * Post-process used to create volumetric lighting effect
  53442. */
  53443. volumetricLightPostProcess: Nullable<PostProcess>;
  53444. /**
  53445. * Post-process used to smooth the previous volumetric light post-process on the X axis
  53446. */
  53447. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  53448. /**
  53449. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  53450. */
  53451. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  53452. /**
  53453. * Post-process used to merge the volumetric light effect and the real scene color
  53454. */
  53455. volumetricLightMergePostProces: Nullable<PostProcess>;
  53456. /**
  53457. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  53458. */
  53459. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  53460. /**
  53461. * Base post-process used to calculate the average luminance of the final image for HDR
  53462. */
  53463. luminancePostProcess: Nullable<PostProcess>;
  53464. /**
  53465. * Post-processes used to create down sample post-processes in order to get
  53466. * the average luminance of the final image for HDR
  53467. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  53468. */
  53469. luminanceDownSamplePostProcesses: PostProcess[];
  53470. /**
  53471. * Post-process used to create a HDR effect (light adaptation)
  53472. */
  53473. hdrPostProcess: Nullable<PostProcess>;
  53474. /**
  53475. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  53476. */
  53477. textureAdderFinalPostProcess: Nullable<PostProcess>;
  53478. /**
  53479. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  53480. */
  53481. lensFlareFinalPostProcess: Nullable<PostProcess>;
  53482. /**
  53483. * Post-process used to merge the final HDR post-process and the real scene color
  53484. */
  53485. hdrFinalPostProcess: Nullable<PostProcess>;
  53486. /**
  53487. * Post-process used to create a lens flare effect
  53488. */
  53489. lensFlarePostProcess: Nullable<PostProcess>;
  53490. /**
  53491. * Post-process that merges the result of the lens flare post-process and the real scene color
  53492. */
  53493. lensFlareComposePostProcess: Nullable<PostProcess>;
  53494. /**
  53495. * Post-process used to create a motion blur effect
  53496. */
  53497. motionBlurPostProcess: Nullable<PostProcess>;
  53498. /**
  53499. * Post-process used to create a depth of field effect
  53500. */
  53501. depthOfFieldPostProcess: Nullable<PostProcess>;
  53502. /**
  53503. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  53504. */
  53505. fxaaPostProcess: Nullable<FxaaPostProcess>;
  53506. /**
  53507. * Represents the brightness threshold in order to configure the illuminated surfaces
  53508. */
  53509. brightThreshold: number;
  53510. /**
  53511. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  53512. */
  53513. blurWidth: number;
  53514. /**
  53515. * Sets if the blur for highlighted surfaces must be only horizontal
  53516. */
  53517. horizontalBlur: boolean;
  53518. /**
  53519. * Gets the overall exposure used by the pipeline
  53520. */
  53521. /**
  53522. * Sets the overall exposure used by the pipeline
  53523. */
  53524. exposure: number;
  53525. /**
  53526. * Texture used typically to simulate "dirty" on camera lens
  53527. */
  53528. lensTexture: Nullable<Texture>;
  53529. /**
  53530. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  53531. */
  53532. volumetricLightCoefficient: number;
  53533. /**
  53534. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  53535. */
  53536. volumetricLightPower: number;
  53537. /**
  53538. * Used the set the blur intensity to smooth the volumetric lights
  53539. */
  53540. volumetricLightBlurScale: number;
  53541. /**
  53542. * Light (spot or directional) used to generate the volumetric lights rays
  53543. * The source light must have a shadow generate so the pipeline can get its
  53544. * depth map
  53545. */
  53546. sourceLight: Nullable<SpotLight | DirectionalLight>;
  53547. /**
  53548. * For eye adaptation, represents the minimum luminance the eye can see
  53549. */
  53550. hdrMinimumLuminance: number;
  53551. /**
  53552. * For eye adaptation, represents the decrease luminance speed
  53553. */
  53554. hdrDecreaseRate: number;
  53555. /**
  53556. * For eye adaptation, represents the increase luminance speed
  53557. */
  53558. hdrIncreaseRate: number;
  53559. /**
  53560. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53561. */
  53562. /**
  53563. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  53564. */
  53565. hdrAutoExposure: boolean;
  53566. /**
  53567. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  53568. */
  53569. lensColorTexture: Nullable<Texture>;
  53570. /**
  53571. * The overall strengh for the lens flare effect
  53572. */
  53573. lensFlareStrength: number;
  53574. /**
  53575. * Dispersion coefficient for lens flare ghosts
  53576. */
  53577. lensFlareGhostDispersal: number;
  53578. /**
  53579. * Main lens flare halo width
  53580. */
  53581. lensFlareHaloWidth: number;
  53582. /**
  53583. * Based on the lens distortion effect, defines how much the lens flare result
  53584. * is distorted
  53585. */
  53586. lensFlareDistortionStrength: number;
  53587. /**
  53588. * Lens star texture must be used to simulate rays on the flares and is available
  53589. * in the documentation
  53590. */
  53591. lensStarTexture: Nullable<Texture>;
  53592. /**
  53593. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  53594. * flare effect by taking account of the dirt texture
  53595. */
  53596. lensFlareDirtTexture: Nullable<Texture>;
  53597. /**
  53598. * Represents the focal length for the depth of field effect
  53599. */
  53600. depthOfFieldDistance: number;
  53601. /**
  53602. * Represents the blur intensity for the blurred part of the depth of field effect
  53603. */
  53604. depthOfFieldBlurWidth: number;
  53605. /**
  53606. * For motion blur, defines how much the image is blurred by the movement
  53607. */
  53608. motionStrength: number;
  53609. /**
  53610. * List of animations for the pipeline (IAnimatable implementation)
  53611. */
  53612. animations: Animation[];
  53613. /**
  53614. * Private members
  53615. */
  53616. private _scene;
  53617. private _currentDepthOfFieldSource;
  53618. private _basePostProcess;
  53619. private _fixedExposure;
  53620. private _currentExposure;
  53621. private _hdrAutoExposure;
  53622. private _hdrCurrentLuminance;
  53623. private _floatTextureType;
  53624. private _ratio;
  53625. private _bloomEnabled;
  53626. private _depthOfFieldEnabled;
  53627. private _vlsEnabled;
  53628. private _lensFlareEnabled;
  53629. private _hdrEnabled;
  53630. private _motionBlurEnabled;
  53631. private _fxaaEnabled;
  53632. private _motionBlurSamples;
  53633. private _volumetricLightStepsCount;
  53634. private _samples;
  53635. /**
  53636. * @ignore
  53637. * Specifies if the bloom pipeline is enabled
  53638. */
  53639. BloomEnabled: boolean;
  53640. /**
  53641. * @ignore
  53642. * Specifies if the depth of field pipeline is enabed
  53643. */
  53644. DepthOfFieldEnabled: boolean;
  53645. /**
  53646. * @ignore
  53647. * Specifies if the lens flare pipeline is enabed
  53648. */
  53649. LensFlareEnabled: boolean;
  53650. /**
  53651. * @ignore
  53652. * Specifies if the HDR pipeline is enabled
  53653. */
  53654. HDREnabled: boolean;
  53655. /**
  53656. * @ignore
  53657. * Specifies if the volumetric lights scattering effect is enabled
  53658. */
  53659. VLSEnabled: boolean;
  53660. /**
  53661. * @ignore
  53662. * Specifies if the motion blur effect is enabled
  53663. */
  53664. MotionBlurEnabled: boolean;
  53665. /**
  53666. * Specifies if anti-aliasing is enabled
  53667. */
  53668. fxaaEnabled: boolean;
  53669. /**
  53670. * Specifies the number of steps used to calculate the volumetric lights
  53671. * Typically in interval [50, 200]
  53672. */
  53673. volumetricLightStepsCount: number;
  53674. /**
  53675. * Specifies the number of samples used for the motion blur effect
  53676. * Typically in interval [16, 64]
  53677. */
  53678. motionBlurSamples: number;
  53679. /**
  53680. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  53681. */
  53682. samples: number;
  53683. /**
  53684. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  53685. * @constructor
  53686. * @param name The rendering pipeline name
  53687. * @param scene The scene linked to this pipeline
  53688. * @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)
  53689. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  53690. * @param cameras The array of cameras that the rendering pipeline will be attached to
  53691. */
  53692. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  53693. private _buildPipeline;
  53694. private _createDownSampleX4PostProcess;
  53695. private _createBrightPassPostProcess;
  53696. private _createBlurPostProcesses;
  53697. private _createTextureAdderPostProcess;
  53698. private _createVolumetricLightPostProcess;
  53699. private _createLuminancePostProcesses;
  53700. private _createHdrPostProcess;
  53701. private _createLensFlarePostProcess;
  53702. private _createDepthOfFieldPostProcess;
  53703. private _createMotionBlurPostProcess;
  53704. private _getDepthTexture;
  53705. private _disposePostProcesses;
  53706. /**
  53707. * Dispose of the pipeline and stop all post processes
  53708. */
  53709. dispose(): void;
  53710. /**
  53711. * Serialize the rendering pipeline (Used when exporting)
  53712. * @returns the serialized object
  53713. */
  53714. serialize(): any;
  53715. /**
  53716. * Parse the serialized pipeline
  53717. * @param source Source pipeline.
  53718. * @param scene The scene to load the pipeline to.
  53719. * @param rootUrl The URL of the serialized pipeline.
  53720. * @returns An instantiated pipeline from the serialized object.
  53721. */
  53722. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53723. /**
  53724. * Luminance steps
  53725. */
  53726. static LuminanceSteps: number;
  53727. }
  53728. }
  53729. declare module BABYLON {
  53730. /** @hidden */
  53731. export var tonemapPixelShader: {
  53732. name: string;
  53733. shader: string;
  53734. };
  53735. }
  53736. declare module BABYLON {
  53737. /** Defines operator used for tonemapping */
  53738. export enum TonemappingOperator {
  53739. /** Hable */
  53740. Hable = 0,
  53741. /** Reinhard */
  53742. Reinhard = 1,
  53743. /** HejiDawson */
  53744. HejiDawson = 2,
  53745. /** Photographic */
  53746. Photographic = 3
  53747. }
  53748. /**
  53749. * Defines a post process to apply tone mapping
  53750. */
  53751. export class TonemapPostProcess extends PostProcess {
  53752. private _operator;
  53753. /** Defines the required exposure adjustement */
  53754. exposureAdjustment: number;
  53755. /**
  53756. * Creates a new TonemapPostProcess
  53757. * @param name defines the name of the postprocess
  53758. * @param _operator defines the operator to use
  53759. * @param exposureAdjustment defines the required exposure adjustement
  53760. * @param camera defines the camera to use (can be null)
  53761. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53762. * @param engine defines the hosting engine (can be ignore if camera is set)
  53763. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53764. */
  53765. constructor(name: string, _operator: TonemappingOperator,
  53766. /** Defines the required exposure adjustement */
  53767. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53768. }
  53769. }
  53770. declare module BABYLON {
  53771. /** @hidden */
  53772. export var depthVertexShader: {
  53773. name: string;
  53774. shader: string;
  53775. };
  53776. }
  53777. declare module BABYLON {
  53778. /** @hidden */
  53779. export var volumetricLightScatteringPixelShader: {
  53780. name: string;
  53781. shader: string;
  53782. };
  53783. }
  53784. declare module BABYLON {
  53785. /** @hidden */
  53786. export var volumetricLightScatteringPassPixelShader: {
  53787. name: string;
  53788. shader: string;
  53789. };
  53790. }
  53791. declare module BABYLON {
  53792. /**
  53793. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53794. */
  53795. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53796. private _volumetricLightScatteringPass;
  53797. private _volumetricLightScatteringRTT;
  53798. private _viewPort;
  53799. private _screenCoordinates;
  53800. private _cachedDefines;
  53801. /**
  53802. * If not undefined, the mesh position is computed from the attached node position
  53803. */
  53804. attachedNode: {
  53805. position: Vector3;
  53806. };
  53807. /**
  53808. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53809. */
  53810. customMeshPosition: Vector3;
  53811. /**
  53812. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53813. */
  53814. useCustomMeshPosition: boolean;
  53815. /**
  53816. * If the post-process should inverse the light scattering direction
  53817. */
  53818. invert: boolean;
  53819. /**
  53820. * The internal mesh used by the post-process
  53821. */
  53822. mesh: Mesh;
  53823. /**
  53824. * @hidden
  53825. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53826. */
  53827. useDiffuseColor: boolean;
  53828. /**
  53829. * Array containing the excluded meshes not rendered in the internal pass
  53830. */
  53831. excludedMeshes: AbstractMesh[];
  53832. /**
  53833. * Controls the overall intensity of the post-process
  53834. */
  53835. exposure: number;
  53836. /**
  53837. * Dissipates each sample's contribution in range [0, 1]
  53838. */
  53839. decay: number;
  53840. /**
  53841. * Controls the overall intensity of each sample
  53842. */
  53843. weight: number;
  53844. /**
  53845. * Controls the density of each sample
  53846. */
  53847. density: number;
  53848. /**
  53849. * @constructor
  53850. * @param name The post-process name
  53851. * @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)
  53852. * @param camera The camera that the post-process will be attached to
  53853. * @param mesh The mesh used to create the light scattering
  53854. * @param samples The post-process quality, default 100
  53855. * @param samplingModeThe post-process filtering mode
  53856. * @param engine The babylon engine
  53857. * @param reusable If the post-process is reusable
  53858. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53859. */
  53860. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53861. /**
  53862. * Returns the string "VolumetricLightScatteringPostProcess"
  53863. * @returns "VolumetricLightScatteringPostProcess"
  53864. */
  53865. getClassName(): string;
  53866. private _isReady;
  53867. /**
  53868. * Sets the new light position for light scattering effect
  53869. * @param position The new custom light position
  53870. */
  53871. setCustomMeshPosition(position: Vector3): void;
  53872. /**
  53873. * Returns the light position for light scattering effect
  53874. * @return Vector3 The custom light position
  53875. */
  53876. getCustomMeshPosition(): Vector3;
  53877. /**
  53878. * Disposes the internal assets and detaches the post-process from the camera
  53879. */
  53880. dispose(camera: Camera): void;
  53881. /**
  53882. * Returns the render target texture used by the post-process
  53883. * @return the render target texture used by the post-process
  53884. */
  53885. getPass(): RenderTargetTexture;
  53886. private _meshExcluded;
  53887. private _createPass;
  53888. private _updateMeshScreenCoordinates;
  53889. /**
  53890. * Creates a default mesh for the Volumeric Light Scattering post-process
  53891. * @param name The mesh name
  53892. * @param scene The scene where to create the mesh
  53893. * @return the default mesh
  53894. */
  53895. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53896. }
  53897. }
  53898. declare module BABYLON {
  53899. interface Scene {
  53900. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53901. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53902. /**
  53903. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53904. */
  53905. forceShowBoundingBoxes: boolean;
  53906. /**
  53907. * Gets the bounding box renderer associated with the scene
  53908. * @returns a BoundingBoxRenderer
  53909. */
  53910. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53911. }
  53912. interface AbstractMesh {
  53913. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53914. /**
  53915. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53916. */
  53917. showBoundingBox: boolean;
  53918. }
  53919. /**
  53920. * Component responsible of rendering the bounding box of the meshes in a scene.
  53921. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53922. */
  53923. export class BoundingBoxRenderer implements ISceneComponent {
  53924. /**
  53925. * The component name helpfull to identify the component in the list of scene components.
  53926. */
  53927. readonly name: string;
  53928. /**
  53929. * The scene the component belongs to.
  53930. */
  53931. scene: Scene;
  53932. /**
  53933. * Color of the bounding box lines placed in front of an object
  53934. */
  53935. frontColor: Color3;
  53936. /**
  53937. * Color of the bounding box lines placed behind an object
  53938. */
  53939. backColor: Color3;
  53940. /**
  53941. * Defines if the renderer should show the back lines or not
  53942. */
  53943. showBackLines: boolean;
  53944. /**
  53945. * @hidden
  53946. */
  53947. renderList: SmartArray<BoundingBox>;
  53948. private _colorShader;
  53949. private _vertexBuffers;
  53950. private _indexBuffer;
  53951. /**
  53952. * Instantiates a new bounding box renderer in a scene.
  53953. * @param scene the scene the renderer renders in
  53954. */
  53955. constructor(scene: Scene);
  53956. /**
  53957. * Registers the component in a given scene
  53958. */
  53959. register(): void;
  53960. private _evaluateSubMesh;
  53961. private _activeMesh;
  53962. private _prepareRessources;
  53963. private _createIndexBuffer;
  53964. /**
  53965. * Rebuilds the elements related to this component in case of
  53966. * context lost for instance.
  53967. */
  53968. rebuild(): void;
  53969. /**
  53970. * @hidden
  53971. */
  53972. reset(): void;
  53973. /**
  53974. * Render the bounding boxes of a specific rendering group
  53975. * @param renderingGroupId defines the rendering group to render
  53976. */
  53977. render(renderingGroupId: number): void;
  53978. /**
  53979. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53980. * @param mesh Define the mesh to render the occlusion bounding box for
  53981. */
  53982. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53983. /**
  53984. * Dispose and release the resources attached to this renderer.
  53985. */
  53986. dispose(): void;
  53987. }
  53988. }
  53989. declare module BABYLON {
  53990. /** @hidden */
  53991. export var depthPixelShader: {
  53992. name: string;
  53993. shader: string;
  53994. };
  53995. }
  53996. declare module BABYLON {
  53997. /**
  53998. * This represents a depth renderer in Babylon.
  53999. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54000. */
  54001. export class DepthRenderer {
  54002. private _scene;
  54003. private _depthMap;
  54004. private _effect;
  54005. private _cachedDefines;
  54006. private _camera;
  54007. /**
  54008. * Specifiess that the depth renderer will only be used within
  54009. * the camera it is created for.
  54010. * This can help forcing its rendering during the camera processing.
  54011. */
  54012. useOnlyInActiveCamera: boolean;
  54013. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  54014. /**
  54015. * Instantiates a depth renderer
  54016. * @param scene The scene the renderer belongs to
  54017. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54018. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54019. */
  54020. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  54021. /**
  54022. * Creates the depth rendering effect and checks if the effect is ready.
  54023. * @param subMesh The submesh to be used to render the depth map of
  54024. * @param useInstances If multiple world instances should be used
  54025. * @returns if the depth renderer is ready to render the depth map
  54026. */
  54027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54028. /**
  54029. * Gets the texture which the depth map will be written to.
  54030. * @returns The depth map texture
  54031. */
  54032. getDepthMap(): RenderTargetTexture;
  54033. /**
  54034. * Disposes of the depth renderer.
  54035. */
  54036. dispose(): void;
  54037. }
  54038. }
  54039. declare module BABYLON {
  54040. interface Scene {
  54041. /** @hidden (Backing field) */ depthRenderer: {
  54042. [id: string]: DepthRenderer;
  54043. };
  54044. /**
  54045. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  54046. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  54047. * @returns the created depth renderer
  54048. */
  54049. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  54050. /**
  54051. * Disables a depth renderer for a given camera
  54052. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  54053. */
  54054. disableDepthRenderer(camera?: Nullable<Camera>): void;
  54055. }
  54056. /**
  54057. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  54058. * in several rendering techniques.
  54059. */
  54060. export class DepthRendererSceneComponent implements ISceneComponent {
  54061. /**
  54062. * The component name helpfull to identify the component in the list of scene components.
  54063. */
  54064. readonly name: string;
  54065. /**
  54066. * The scene the component belongs to.
  54067. */
  54068. scene: Scene;
  54069. /**
  54070. * Creates a new instance of the component for the given scene
  54071. * @param scene Defines the scene to register the component in
  54072. */
  54073. constructor(scene: Scene);
  54074. /**
  54075. * Registers the component in a given scene
  54076. */
  54077. register(): void;
  54078. /**
  54079. * Rebuilds the elements related to this component in case of
  54080. * context lost for instance.
  54081. */
  54082. rebuild(): void;
  54083. /**
  54084. * Disposes the component and the associated ressources
  54085. */
  54086. dispose(): void;
  54087. private _gatherRenderTargets;
  54088. private _gatherActiveCameraRenderTargets;
  54089. }
  54090. }
  54091. declare module BABYLON {
  54092. /** @hidden */
  54093. export var outlinePixelShader: {
  54094. name: string;
  54095. shader: string;
  54096. };
  54097. }
  54098. declare module BABYLON {
  54099. /** @hidden */
  54100. export var outlineVertexShader: {
  54101. name: string;
  54102. shader: string;
  54103. };
  54104. }
  54105. declare module BABYLON {
  54106. interface Scene {
  54107. /** @hidden */ outlineRenderer: OutlineRenderer;
  54108. /**
  54109. * Gets the outline renderer associated with the scene
  54110. * @returns a OutlineRenderer
  54111. */
  54112. getOutlineRenderer(): OutlineRenderer;
  54113. }
  54114. interface AbstractMesh {
  54115. /** @hidden (Backing field) */ renderOutline: boolean;
  54116. /**
  54117. * Gets or sets a boolean indicating if the outline must be rendered as well
  54118. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  54119. */
  54120. renderOutline: boolean;
  54121. /** @hidden (Backing field) */ renderOverlay: boolean;
  54122. /**
  54123. * Gets or sets a boolean indicating if the overlay must be rendered as well
  54124. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  54125. */
  54126. renderOverlay: boolean;
  54127. }
  54128. /**
  54129. * This class is responsible to draw bothe outline/overlay of meshes.
  54130. * It should not be used directly but through the available method on mesh.
  54131. */
  54132. export class OutlineRenderer implements ISceneComponent {
  54133. /**
  54134. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  54135. */
  54136. private static _StencilReference;
  54137. /**
  54138. * The name of the component. Each component must have a unique name.
  54139. */
  54140. name: string;
  54141. /**
  54142. * The scene the component belongs to.
  54143. */
  54144. scene: Scene;
  54145. /**
  54146. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  54147. */
  54148. zOffset: number;
  54149. private _engine;
  54150. private _effect;
  54151. private _cachedDefines;
  54152. private _savedDepthWrite;
  54153. /**
  54154. * Instantiates a new outline renderer. (There could be only one per scene).
  54155. * @param scene Defines the scene it belongs to
  54156. */
  54157. constructor(scene: Scene);
  54158. /**
  54159. * Register the component to one instance of a scene.
  54160. */
  54161. register(): void;
  54162. /**
  54163. * Rebuilds the elements related to this component in case of
  54164. * context lost for instance.
  54165. */
  54166. rebuild(): void;
  54167. /**
  54168. * Disposes the component and the associated ressources.
  54169. */
  54170. dispose(): void;
  54171. /**
  54172. * Renders the outline in the canvas.
  54173. * @param subMesh Defines the sumesh to render
  54174. * @param batch Defines the batch of meshes in case of instances
  54175. * @param useOverlay Defines if the rendering is for the overlay or the outline
  54176. */
  54177. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  54178. /**
  54179. * Returns whether or not the outline renderer is ready for a given submesh.
  54180. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  54181. * @param subMesh Defines the submesh to check readyness for
  54182. * @param useInstances Defines wheter wee are trying to render instances or not
  54183. * @returns true if ready otherwise false
  54184. */
  54185. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54186. private _beforeRenderingMesh;
  54187. private _afterRenderingMesh;
  54188. }
  54189. }
  54190. declare module BABYLON {
  54191. /**
  54192. * Defines the list of states available for a task inside a AssetsManager
  54193. */
  54194. export enum AssetTaskState {
  54195. /**
  54196. * Initialization
  54197. */
  54198. INIT = 0,
  54199. /**
  54200. * Running
  54201. */
  54202. RUNNING = 1,
  54203. /**
  54204. * Done
  54205. */
  54206. DONE = 2,
  54207. /**
  54208. * Error
  54209. */
  54210. ERROR = 3
  54211. }
  54212. /**
  54213. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  54214. */
  54215. export abstract class AbstractAssetTask {
  54216. /**
  54217. * Task name
  54218. */ name: string;
  54219. /**
  54220. * Callback called when the task is successful
  54221. */
  54222. onSuccess: (task: any) => void;
  54223. /**
  54224. * Callback called when the task is not successful
  54225. */
  54226. onError: (task: any, message?: string, exception?: any) => void;
  54227. /**
  54228. * Creates a new AssetsManager
  54229. * @param name defines the name of the task
  54230. */
  54231. constructor(
  54232. /**
  54233. * Task name
  54234. */ name: string);
  54235. private _isCompleted;
  54236. private _taskState;
  54237. private _errorObject;
  54238. /**
  54239. * Get if the task is completed
  54240. */
  54241. readonly isCompleted: boolean;
  54242. /**
  54243. * Gets the current state of the task
  54244. */
  54245. readonly taskState: AssetTaskState;
  54246. /**
  54247. * Gets the current error object (if task is in error)
  54248. */
  54249. readonly errorObject: {
  54250. message?: string;
  54251. exception?: any;
  54252. };
  54253. /**
  54254. * Internal only
  54255. * @hidden
  54256. */ setErrorObject(message?: string, exception?: any): void;
  54257. /**
  54258. * Execute the current task
  54259. * @param scene defines the scene where you want your assets to be loaded
  54260. * @param onSuccess is a callback called when the task is successfully executed
  54261. * @param onError is a callback called if an error occurs
  54262. */
  54263. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54264. /**
  54265. * Execute the current task
  54266. * @param scene defines the scene where you want your assets to be loaded
  54267. * @param onSuccess is a callback called when the task is successfully executed
  54268. * @param onError is a callback called if an error occurs
  54269. */
  54270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54271. /**
  54272. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  54273. * This can be used with failed tasks that have the reason for failure fixed.
  54274. */
  54275. reset(): void;
  54276. private onErrorCallback;
  54277. private onDoneCallback;
  54278. }
  54279. /**
  54280. * Define the interface used by progress events raised during assets loading
  54281. */
  54282. export interface IAssetsProgressEvent {
  54283. /**
  54284. * Defines the number of remaining tasks to process
  54285. */
  54286. remainingCount: number;
  54287. /**
  54288. * Defines the total number of tasks
  54289. */
  54290. totalCount: number;
  54291. /**
  54292. * Defines the task that was just processed
  54293. */
  54294. task: AbstractAssetTask;
  54295. }
  54296. /**
  54297. * Class used to share progress information about assets loading
  54298. */
  54299. export class AssetsProgressEvent implements IAssetsProgressEvent {
  54300. /**
  54301. * Defines the number of remaining tasks to process
  54302. */
  54303. remainingCount: number;
  54304. /**
  54305. * Defines the total number of tasks
  54306. */
  54307. totalCount: number;
  54308. /**
  54309. * Defines the task that was just processed
  54310. */
  54311. task: AbstractAssetTask;
  54312. /**
  54313. * Creates a AssetsProgressEvent
  54314. * @param remainingCount defines the number of remaining tasks to process
  54315. * @param totalCount defines the total number of tasks
  54316. * @param task defines the task that was just processed
  54317. */
  54318. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  54319. }
  54320. /**
  54321. * Define a task used by AssetsManager to load meshes
  54322. */
  54323. export class MeshAssetTask extends AbstractAssetTask {
  54324. /**
  54325. * Defines the name of the task
  54326. */
  54327. name: string;
  54328. /**
  54329. * Defines the list of mesh's names you want to load
  54330. */
  54331. meshesNames: any;
  54332. /**
  54333. * Defines the root url to use as a base to load your meshes and associated resources
  54334. */
  54335. rootUrl: string;
  54336. /**
  54337. * Defines the filename of the scene to load from
  54338. */
  54339. sceneFilename: string;
  54340. /**
  54341. * Gets the list of loaded meshes
  54342. */
  54343. loadedMeshes: Array<AbstractMesh>;
  54344. /**
  54345. * Gets the list of loaded particle systems
  54346. */
  54347. loadedParticleSystems: Array<IParticleSystem>;
  54348. /**
  54349. * Gets the list of loaded skeletons
  54350. */
  54351. loadedSkeletons: Array<Skeleton>;
  54352. /**
  54353. * Gets the list of loaded animation groups
  54354. */
  54355. loadedAnimationGroups: Array<AnimationGroup>;
  54356. /**
  54357. * Callback called when the task is successful
  54358. */
  54359. onSuccess: (task: MeshAssetTask) => void;
  54360. /**
  54361. * Callback called when the task is successful
  54362. */
  54363. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  54364. /**
  54365. * Creates a new MeshAssetTask
  54366. * @param name defines the name of the task
  54367. * @param meshesNames defines the list of mesh's names you want to load
  54368. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  54369. * @param sceneFilename defines the filename of the scene to load from
  54370. */
  54371. constructor(
  54372. /**
  54373. * Defines the name of the task
  54374. */
  54375. name: string,
  54376. /**
  54377. * Defines the list of mesh's names you want to load
  54378. */
  54379. meshesNames: any,
  54380. /**
  54381. * Defines the root url to use as a base to load your meshes and associated resources
  54382. */
  54383. rootUrl: string,
  54384. /**
  54385. * Defines the filename of the scene to load from
  54386. */
  54387. sceneFilename: string);
  54388. /**
  54389. * Execute the current task
  54390. * @param scene defines the scene where you want your assets to be loaded
  54391. * @param onSuccess is a callback called when the task is successfully executed
  54392. * @param onError is a callback called if an error occurs
  54393. */
  54394. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54395. }
  54396. /**
  54397. * Define a task used by AssetsManager to load text content
  54398. */
  54399. export class TextFileAssetTask extends AbstractAssetTask {
  54400. /**
  54401. * Defines the name of the task
  54402. */
  54403. name: string;
  54404. /**
  54405. * Defines the location of the file to load
  54406. */
  54407. url: string;
  54408. /**
  54409. * Gets the loaded text string
  54410. */
  54411. text: string;
  54412. /**
  54413. * Callback called when the task is successful
  54414. */
  54415. onSuccess: (task: TextFileAssetTask) => void;
  54416. /**
  54417. * Callback called when the task is successful
  54418. */
  54419. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  54420. /**
  54421. * Creates a new TextFileAssetTask object
  54422. * @param name defines the name of the task
  54423. * @param url defines the location of the file to load
  54424. */
  54425. constructor(
  54426. /**
  54427. * Defines the name of the task
  54428. */
  54429. name: string,
  54430. /**
  54431. * Defines the location of the file to load
  54432. */
  54433. url: string);
  54434. /**
  54435. * Execute the current task
  54436. * @param scene defines the scene where you want your assets to be loaded
  54437. * @param onSuccess is a callback called when the task is successfully executed
  54438. * @param onError is a callback called if an error occurs
  54439. */
  54440. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54441. }
  54442. /**
  54443. * Define a task used by AssetsManager to load binary data
  54444. */
  54445. export class BinaryFileAssetTask extends AbstractAssetTask {
  54446. /**
  54447. * Defines the name of the task
  54448. */
  54449. name: string;
  54450. /**
  54451. * Defines the location of the file to load
  54452. */
  54453. url: string;
  54454. /**
  54455. * Gets the lodaded data (as an array buffer)
  54456. */
  54457. data: ArrayBuffer;
  54458. /**
  54459. * Callback called when the task is successful
  54460. */
  54461. onSuccess: (task: BinaryFileAssetTask) => void;
  54462. /**
  54463. * Callback called when the task is successful
  54464. */
  54465. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  54466. /**
  54467. * Creates a new BinaryFileAssetTask object
  54468. * @param name defines the name of the new task
  54469. * @param url defines the location of the file to load
  54470. */
  54471. constructor(
  54472. /**
  54473. * Defines the name of the task
  54474. */
  54475. name: string,
  54476. /**
  54477. * Defines the location of the file to load
  54478. */
  54479. url: string);
  54480. /**
  54481. * Execute the current task
  54482. * @param scene defines the scene where you want your assets to be loaded
  54483. * @param onSuccess is a callback called when the task is successfully executed
  54484. * @param onError is a callback called if an error occurs
  54485. */
  54486. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54487. }
  54488. /**
  54489. * Define a task used by AssetsManager to load images
  54490. */
  54491. export class ImageAssetTask extends AbstractAssetTask {
  54492. /**
  54493. * Defines the name of the task
  54494. */
  54495. name: string;
  54496. /**
  54497. * Defines the location of the image to load
  54498. */
  54499. url: string;
  54500. /**
  54501. * Gets the loaded images
  54502. */
  54503. image: HTMLImageElement;
  54504. /**
  54505. * Callback called when the task is successful
  54506. */
  54507. onSuccess: (task: ImageAssetTask) => void;
  54508. /**
  54509. * Callback called when the task is successful
  54510. */
  54511. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  54512. /**
  54513. * Creates a new ImageAssetTask
  54514. * @param name defines the name of the task
  54515. * @param url defines the location of the image to load
  54516. */
  54517. constructor(
  54518. /**
  54519. * Defines the name of the task
  54520. */
  54521. name: string,
  54522. /**
  54523. * Defines the location of the image to load
  54524. */
  54525. url: string);
  54526. /**
  54527. * Execute the current task
  54528. * @param scene defines the scene where you want your assets to be loaded
  54529. * @param onSuccess is a callback called when the task is successfully executed
  54530. * @param onError is a callback called if an error occurs
  54531. */
  54532. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54533. }
  54534. /**
  54535. * Defines the interface used by texture loading tasks
  54536. */
  54537. export interface ITextureAssetTask<TEX extends BaseTexture> {
  54538. /**
  54539. * Gets the loaded texture
  54540. */
  54541. texture: TEX;
  54542. }
  54543. /**
  54544. * Define a task used by AssetsManager to load 2D textures
  54545. */
  54546. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  54547. /**
  54548. * Defines the name of the task
  54549. */
  54550. name: string;
  54551. /**
  54552. * Defines the location of the file to load
  54553. */
  54554. url: string;
  54555. /**
  54556. * Defines if mipmap should not be generated (default is false)
  54557. */
  54558. noMipmap?: boolean | undefined;
  54559. /**
  54560. * Defines if texture must be inverted on Y axis (default is false)
  54561. */
  54562. invertY?: boolean | undefined;
  54563. /**
  54564. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54565. */
  54566. samplingMode: number;
  54567. /**
  54568. * Gets the loaded texture
  54569. */
  54570. texture: Texture;
  54571. /**
  54572. * Callback called when the task is successful
  54573. */
  54574. onSuccess: (task: TextureAssetTask) => void;
  54575. /**
  54576. * Callback called when the task is successful
  54577. */
  54578. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  54579. /**
  54580. * Creates a new TextureAssetTask object
  54581. * @param name defines the name of the task
  54582. * @param url defines the location of the file to load
  54583. * @param noMipmap defines if mipmap should not be generated (default is false)
  54584. * @param invertY defines if texture must be inverted on Y axis (default is false)
  54585. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54586. */
  54587. constructor(
  54588. /**
  54589. * Defines the name of the task
  54590. */
  54591. name: string,
  54592. /**
  54593. * Defines the location of the file to load
  54594. */
  54595. url: string,
  54596. /**
  54597. * Defines if mipmap should not be generated (default is false)
  54598. */
  54599. noMipmap?: boolean | undefined,
  54600. /**
  54601. * Defines if texture must be inverted on Y axis (default is false)
  54602. */
  54603. invertY?: boolean | undefined,
  54604. /**
  54605. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  54606. */
  54607. samplingMode?: number);
  54608. /**
  54609. * Execute the current task
  54610. * @param scene defines the scene where you want your assets to be loaded
  54611. * @param onSuccess is a callback called when the task is successfully executed
  54612. * @param onError is a callback called if an error occurs
  54613. */
  54614. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54615. }
  54616. /**
  54617. * Define a task used by AssetsManager to load cube textures
  54618. */
  54619. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  54620. /**
  54621. * Defines the name of the task
  54622. */
  54623. name: string;
  54624. /**
  54625. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54626. */
  54627. url: string;
  54628. /**
  54629. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54630. */
  54631. extensions?: string[] | undefined;
  54632. /**
  54633. * Defines if mipmaps should not be generated (default is false)
  54634. */
  54635. noMipmap?: boolean | undefined;
  54636. /**
  54637. * Defines the explicit list of files (undefined by default)
  54638. */
  54639. files?: string[] | undefined;
  54640. /**
  54641. * Gets the loaded texture
  54642. */
  54643. texture: CubeTexture;
  54644. /**
  54645. * Callback called when the task is successful
  54646. */
  54647. onSuccess: (task: CubeTextureAssetTask) => void;
  54648. /**
  54649. * Callback called when the task is successful
  54650. */
  54651. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  54652. /**
  54653. * Creates a new CubeTextureAssetTask
  54654. * @param name defines the name of the task
  54655. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54656. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54657. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54658. * @param files defines the explicit list of files (undefined by default)
  54659. */
  54660. constructor(
  54661. /**
  54662. * Defines the name of the task
  54663. */
  54664. name: string,
  54665. /**
  54666. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  54667. */
  54668. url: string,
  54669. /**
  54670. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  54671. */
  54672. extensions?: string[] | undefined,
  54673. /**
  54674. * Defines if mipmaps should not be generated (default is false)
  54675. */
  54676. noMipmap?: boolean | undefined,
  54677. /**
  54678. * Defines the explicit list of files (undefined by default)
  54679. */
  54680. files?: string[] | undefined);
  54681. /**
  54682. * Execute the current task
  54683. * @param scene defines the scene where you want your assets to be loaded
  54684. * @param onSuccess is a callback called when the task is successfully executed
  54685. * @param onError is a callback called if an error occurs
  54686. */
  54687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54688. }
  54689. /**
  54690. * Define a task used by AssetsManager to load HDR cube textures
  54691. */
  54692. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  54693. /**
  54694. * Defines the name of the task
  54695. */
  54696. name: string;
  54697. /**
  54698. * Defines the location of the file to load
  54699. */
  54700. url: string;
  54701. /**
  54702. * Defines the desired size (the more it increases the longer the generation will be)
  54703. */
  54704. size: number;
  54705. /**
  54706. * Defines if mipmaps should not be generated (default is false)
  54707. */
  54708. noMipmap: boolean;
  54709. /**
  54710. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54711. */
  54712. generateHarmonics: boolean;
  54713. /**
  54714. * 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)
  54715. */
  54716. gammaSpace: boolean;
  54717. /**
  54718. * Internal Use Only
  54719. */
  54720. reserved: boolean;
  54721. /**
  54722. * Gets the loaded texture
  54723. */
  54724. texture: HDRCubeTexture;
  54725. /**
  54726. * Callback called when the task is successful
  54727. */
  54728. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54729. /**
  54730. * Callback called when the task is successful
  54731. */
  54732. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54733. /**
  54734. * Creates a new HDRCubeTextureAssetTask object
  54735. * @param name defines the name of the task
  54736. * @param url defines the location of the file to load
  54737. * @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.
  54738. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54739. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54740. * @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)
  54741. * @param reserved Internal use only
  54742. */
  54743. constructor(
  54744. /**
  54745. * Defines the name of the task
  54746. */
  54747. name: string,
  54748. /**
  54749. * Defines the location of the file to load
  54750. */
  54751. url: string,
  54752. /**
  54753. * Defines the desired size (the more it increases the longer the generation will be)
  54754. */
  54755. size: number,
  54756. /**
  54757. * Defines if mipmaps should not be generated (default is false)
  54758. */
  54759. noMipmap?: boolean,
  54760. /**
  54761. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54762. */
  54763. generateHarmonics?: boolean,
  54764. /**
  54765. * 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)
  54766. */
  54767. gammaSpace?: boolean,
  54768. /**
  54769. * Internal Use Only
  54770. */
  54771. reserved?: boolean);
  54772. /**
  54773. * Execute the current task
  54774. * @param scene defines the scene where you want your assets to be loaded
  54775. * @param onSuccess is a callback called when the task is successfully executed
  54776. * @param onError is a callback called if an error occurs
  54777. */
  54778. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54779. }
  54780. /**
  54781. * Define a task used by AssetsManager to load Equirectangular cube textures
  54782. */
  54783. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54784. /**
  54785. * Defines the name of the task
  54786. */
  54787. name: string;
  54788. /**
  54789. * Defines the location of the file to load
  54790. */
  54791. url: string;
  54792. /**
  54793. * Defines the desired size (the more it increases the longer the generation will be)
  54794. */
  54795. size: number;
  54796. /**
  54797. * Defines if mipmaps should not be generated (default is false)
  54798. */
  54799. noMipmap: boolean;
  54800. /**
  54801. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54802. * but the standard material would require them in Gamma space) (default is true)
  54803. */
  54804. gammaSpace: boolean;
  54805. /**
  54806. * Gets the loaded texture
  54807. */
  54808. texture: EquiRectangularCubeTexture;
  54809. /**
  54810. * Callback called when the task is successful
  54811. */
  54812. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54813. /**
  54814. * Callback called when the task is successful
  54815. */
  54816. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54817. /**
  54818. * Creates a new EquiRectangularCubeTextureAssetTask object
  54819. * @param name defines the name of the task
  54820. * @param url defines the location of the file to load
  54821. * @param size defines the desired size (the more it increases the longer the generation will be)
  54822. * If the size is omitted this implies you are using a preprocessed cubemap.
  54823. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54824. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54825. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54826. * (default is true)
  54827. */
  54828. constructor(
  54829. /**
  54830. * Defines the name of the task
  54831. */
  54832. name: string,
  54833. /**
  54834. * Defines the location of the file to load
  54835. */
  54836. url: string,
  54837. /**
  54838. * Defines the desired size (the more it increases the longer the generation will be)
  54839. */
  54840. size: number,
  54841. /**
  54842. * Defines if mipmaps should not be generated (default is false)
  54843. */
  54844. noMipmap?: boolean,
  54845. /**
  54846. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54847. * but the standard material would require them in Gamma space) (default is true)
  54848. */
  54849. gammaSpace?: boolean);
  54850. /**
  54851. * Execute the current task
  54852. * @param scene defines the scene where you want your assets to be loaded
  54853. * @param onSuccess is a callback called when the task is successfully executed
  54854. * @param onError is a callback called if an error occurs
  54855. */
  54856. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54857. }
  54858. /**
  54859. * This class can be used to easily import assets into a scene
  54860. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54861. */
  54862. export class AssetsManager {
  54863. private _scene;
  54864. private _isLoading;
  54865. protected _tasks: AbstractAssetTask[];
  54866. protected _waitingTasksCount: number;
  54867. protected _totalTasksCount: number;
  54868. /**
  54869. * Callback called when all tasks are processed
  54870. */
  54871. onFinish: (tasks: AbstractAssetTask[]) => void;
  54872. /**
  54873. * Callback called when a task is successful
  54874. */
  54875. onTaskSuccess: (task: AbstractAssetTask) => void;
  54876. /**
  54877. * Callback called when a task had an error
  54878. */
  54879. onTaskError: (task: AbstractAssetTask) => void;
  54880. /**
  54881. * Callback called when a task is done (whatever the result is)
  54882. */
  54883. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54884. /**
  54885. * Observable called when all tasks are processed
  54886. */
  54887. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54888. /**
  54889. * Observable called when a task had an error
  54890. */
  54891. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54892. /**
  54893. * Observable called when all tasks were executed
  54894. */
  54895. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54896. /**
  54897. * Observable called when a task is done (whatever the result is)
  54898. */
  54899. onProgressObservable: Observable<IAssetsProgressEvent>;
  54900. /**
  54901. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54902. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54903. */
  54904. useDefaultLoadingScreen: boolean;
  54905. /**
  54906. * Creates a new AssetsManager
  54907. * @param scene defines the scene to work on
  54908. */
  54909. constructor(scene: Scene);
  54910. /**
  54911. * Add a MeshAssetTask to the list of active tasks
  54912. * @param taskName defines the name of the new task
  54913. * @param meshesNames defines the name of meshes to load
  54914. * @param rootUrl defines the root url to use to locate files
  54915. * @param sceneFilename defines the filename of the scene file
  54916. * @returns a new MeshAssetTask object
  54917. */
  54918. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54919. /**
  54920. * Add a TextFileAssetTask to the list of active tasks
  54921. * @param taskName defines the name of the new task
  54922. * @param url defines the url of the file to load
  54923. * @returns a new TextFileAssetTask object
  54924. */
  54925. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54926. /**
  54927. * Add a BinaryFileAssetTask to the list of active tasks
  54928. * @param taskName defines the name of the new task
  54929. * @param url defines the url of the file to load
  54930. * @returns a new BinaryFileAssetTask object
  54931. */
  54932. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54933. /**
  54934. * Add a ImageAssetTask to the list of active tasks
  54935. * @param taskName defines the name of the new task
  54936. * @param url defines the url of the file to load
  54937. * @returns a new ImageAssetTask object
  54938. */
  54939. addImageTask(taskName: string, url: string): ImageAssetTask;
  54940. /**
  54941. * Add a TextureAssetTask to the list of active tasks
  54942. * @param taskName defines the name of the new task
  54943. * @param url defines the url of the file to load
  54944. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54945. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54946. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54947. * @returns a new TextureAssetTask object
  54948. */
  54949. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54950. /**
  54951. * Add a CubeTextureAssetTask to the list of active tasks
  54952. * @param taskName defines the name of the new task
  54953. * @param url defines the url of the file to load
  54954. * @param extensions defines the extension to use to load the cube map (can be null)
  54955. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54956. * @param files defines the list of files to load (can be null)
  54957. * @returns a new CubeTextureAssetTask object
  54958. */
  54959. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54960. /**
  54961. *
  54962. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54963. * @param taskName defines the name of the new task
  54964. * @param url defines the url of the file to load
  54965. * @param size defines the size you want for the cubemap (can be null)
  54966. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54967. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54968. * @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)
  54969. * @param reserved Internal use only
  54970. * @returns a new HDRCubeTextureAssetTask object
  54971. */
  54972. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54973. /**
  54974. *
  54975. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54976. * @param taskName defines the name of the new task
  54977. * @param url defines the url of the file to load
  54978. * @param size defines the size you want for the cubemap (can be null)
  54979. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54980. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54981. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54982. * @returns a new EquiRectangularCubeTextureAssetTask object
  54983. */
  54984. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54985. /**
  54986. * Remove a task from the assets manager.
  54987. * @param task the task to remove
  54988. */
  54989. removeTask(task: AbstractAssetTask): void;
  54990. private _decreaseWaitingTasksCount;
  54991. private _runTask;
  54992. /**
  54993. * Reset the AssetsManager and remove all tasks
  54994. * @return the current instance of the AssetsManager
  54995. */
  54996. reset(): AssetsManager;
  54997. /**
  54998. * Start the loading process
  54999. * @return the current instance of the AssetsManager
  55000. */
  55001. load(): AssetsManager;
  55002. /**
  55003. * Start the loading process as an async operation
  55004. * @return a promise returning the list of failed tasks
  55005. */
  55006. loadAsync(): Promise<void>;
  55007. }
  55008. }
  55009. declare module BABYLON {
  55010. /**
  55011. * Wrapper class for promise with external resolve and reject.
  55012. */
  55013. export class Deferred<T> {
  55014. /**
  55015. * The promise associated with this deferred object.
  55016. */
  55017. readonly promise: Promise<T>;
  55018. private _resolve;
  55019. private _reject;
  55020. /**
  55021. * The resolve method of the promise associated with this deferred object.
  55022. */
  55023. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  55024. /**
  55025. * The reject method of the promise associated with this deferred object.
  55026. */
  55027. readonly reject: (reason?: any) => void;
  55028. /**
  55029. * Constructor for this deferred object.
  55030. */
  55031. constructor();
  55032. }
  55033. }
  55034. declare module BABYLON {
  55035. /**
  55036. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  55037. */
  55038. export class MeshExploder {
  55039. private _centerMesh;
  55040. private _meshes;
  55041. private _meshesOrigins;
  55042. private _toCenterVectors;
  55043. private _scaledDirection;
  55044. private _newPosition;
  55045. private _centerPosition;
  55046. /**
  55047. * Explodes meshes from a center mesh.
  55048. * @param meshes The meshes to explode.
  55049. * @param centerMesh The mesh to be center of explosion.
  55050. */
  55051. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  55052. private _setCenterMesh;
  55053. /**
  55054. * Get class name
  55055. * @returns "MeshExploder"
  55056. */
  55057. getClassName(): string;
  55058. /**
  55059. * "Exploded meshes"
  55060. * @returns Array of meshes with the centerMesh at index 0.
  55061. */
  55062. getMeshes(): Array<Mesh>;
  55063. /**
  55064. * Explodes meshes giving a specific direction
  55065. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  55066. */
  55067. explode(direction?: number): void;
  55068. }
  55069. }
  55070. declare module BABYLON {
  55071. /**
  55072. * Class used to help managing file picking and drag'n'drop
  55073. */
  55074. export class FilesInput {
  55075. /**
  55076. * List of files ready to be loaded
  55077. */
  55078. static readonly FilesToLoad: {
  55079. [key: string]: File;
  55080. };
  55081. /**
  55082. * Callback called when a file is processed
  55083. */
  55084. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  55085. private _engine;
  55086. private _currentScene;
  55087. private _sceneLoadedCallback;
  55088. private _progressCallback;
  55089. private _additionalRenderLoopLogicCallback;
  55090. private _textureLoadingCallback;
  55091. private _startingProcessingFilesCallback;
  55092. private _onReloadCallback;
  55093. private _errorCallback;
  55094. private _elementToMonitor;
  55095. private _sceneFileToLoad;
  55096. private _filesToLoad;
  55097. /**
  55098. * Creates a new FilesInput
  55099. * @param engine defines the rendering engine
  55100. * @param scene defines the hosting scene
  55101. * @param sceneLoadedCallback callback called when scene is loaded
  55102. * @param progressCallback callback called to track progress
  55103. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  55104. * @param textureLoadingCallback callback called when a texture is loading
  55105. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  55106. * @param onReloadCallback callback called when a reload is requested
  55107. * @param errorCallback callback call if an error occurs
  55108. */
  55109. 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);
  55110. private _dragEnterHandler;
  55111. private _dragOverHandler;
  55112. private _dropHandler;
  55113. /**
  55114. * Calls this function to listen to drag'n'drop events on a specific DOM element
  55115. * @param elementToMonitor defines the DOM element to track
  55116. */
  55117. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  55118. /**
  55119. * Release all associated resources
  55120. */
  55121. dispose(): void;
  55122. private renderFunction;
  55123. private drag;
  55124. private drop;
  55125. private _traverseFolder;
  55126. private _processFiles;
  55127. /**
  55128. * Load files from a drop event
  55129. * @param event defines the drop event to use as source
  55130. */
  55131. loadFiles(event: any): void;
  55132. private _processReload;
  55133. /**
  55134. * Reload the current scene from the loaded files
  55135. */
  55136. reload(): void;
  55137. }
  55138. }
  55139. declare module BABYLON {
  55140. /**
  55141. * Defines the root class used to create scene optimization to use with SceneOptimizer
  55142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55143. */
  55144. export class SceneOptimization {
  55145. /**
  55146. * Defines the priority of this optimization (0 by default which means first in the list)
  55147. */
  55148. priority: number;
  55149. /**
  55150. * Gets a string describing the action executed by the current optimization
  55151. * @returns description string
  55152. */
  55153. getDescription(): string;
  55154. /**
  55155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55156. * @param scene defines the current scene where to apply this optimization
  55157. * @param optimizer defines the current optimizer
  55158. * @returns true if everything that can be done was applied
  55159. */
  55160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55161. /**
  55162. * Creates the SceneOptimization object
  55163. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55164. * @param desc defines the description associated with the optimization
  55165. */
  55166. constructor(
  55167. /**
  55168. * Defines the priority of this optimization (0 by default which means first in the list)
  55169. */
  55170. priority?: number);
  55171. }
  55172. /**
  55173. * Defines an optimization used to reduce the size of render target textures
  55174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55175. */
  55176. export class TextureOptimization extends SceneOptimization {
  55177. /**
  55178. * Defines the priority of this optimization (0 by default which means first in the list)
  55179. */
  55180. priority: number;
  55181. /**
  55182. * 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
  55183. */
  55184. maximumSize: number;
  55185. /**
  55186. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55187. */
  55188. step: number;
  55189. /**
  55190. * Gets a string describing the action executed by the current optimization
  55191. * @returns description string
  55192. */
  55193. getDescription(): string;
  55194. /**
  55195. * Creates the TextureOptimization object
  55196. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55197. * @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
  55198. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55199. */
  55200. constructor(
  55201. /**
  55202. * Defines the priority of this optimization (0 by default which means first in the list)
  55203. */
  55204. priority?: number,
  55205. /**
  55206. * 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
  55207. */
  55208. maximumSize?: number,
  55209. /**
  55210. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  55211. */
  55212. step?: number);
  55213. /**
  55214. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55215. * @param scene defines the current scene where to apply this optimization
  55216. * @param optimizer defines the current optimizer
  55217. * @returns true if everything that can be done was applied
  55218. */
  55219. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55220. }
  55221. /**
  55222. * Defines an optimization used to increase or decrease the rendering resolution
  55223. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55224. */
  55225. export class HardwareScalingOptimization extends SceneOptimization {
  55226. /**
  55227. * Defines the priority of this optimization (0 by default which means first in the list)
  55228. */
  55229. priority: number;
  55230. /**
  55231. * Defines the maximum scale to use (2 by default)
  55232. */
  55233. maximumScale: number;
  55234. /**
  55235. * Defines the step to use between two passes (0.5 by default)
  55236. */
  55237. step: number;
  55238. private _currentScale;
  55239. private _directionOffset;
  55240. /**
  55241. * Gets a string describing the action executed by the current optimization
  55242. * @return description string
  55243. */
  55244. getDescription(): string;
  55245. /**
  55246. * Creates the HardwareScalingOptimization object
  55247. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55248. * @param maximumScale defines the maximum scale to use (2 by default)
  55249. * @param step defines the step to use between two passes (0.5 by default)
  55250. */
  55251. constructor(
  55252. /**
  55253. * Defines the priority of this optimization (0 by default which means first in the list)
  55254. */
  55255. priority?: number,
  55256. /**
  55257. * Defines the maximum scale to use (2 by default)
  55258. */
  55259. maximumScale?: number,
  55260. /**
  55261. * Defines the step to use between two passes (0.5 by default)
  55262. */
  55263. step?: number);
  55264. /**
  55265. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55266. * @param scene defines the current scene where to apply this optimization
  55267. * @param optimizer defines the current optimizer
  55268. * @returns true if everything that can be done was applied
  55269. */
  55270. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55271. }
  55272. /**
  55273. * Defines an optimization used to remove shadows
  55274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55275. */
  55276. export class ShadowsOptimization extends SceneOptimization {
  55277. /**
  55278. * Gets a string describing the action executed by the current optimization
  55279. * @return description string
  55280. */
  55281. getDescription(): string;
  55282. /**
  55283. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55284. * @param scene defines the current scene where to apply this optimization
  55285. * @param optimizer defines the current optimizer
  55286. * @returns true if everything that can be done was applied
  55287. */
  55288. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55289. }
  55290. /**
  55291. * Defines an optimization used to turn post-processes off
  55292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55293. */
  55294. export class PostProcessesOptimization extends SceneOptimization {
  55295. /**
  55296. * Gets a string describing the action executed by the current optimization
  55297. * @return description string
  55298. */
  55299. getDescription(): string;
  55300. /**
  55301. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55302. * @param scene defines the current scene where to apply this optimization
  55303. * @param optimizer defines the current optimizer
  55304. * @returns true if everything that can be done was applied
  55305. */
  55306. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55307. }
  55308. /**
  55309. * Defines an optimization used to turn lens flares off
  55310. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55311. */
  55312. export class LensFlaresOptimization extends SceneOptimization {
  55313. /**
  55314. * Gets a string describing the action executed by the current optimization
  55315. * @return description string
  55316. */
  55317. getDescription(): string;
  55318. /**
  55319. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55320. * @param scene defines the current scene where to apply this optimization
  55321. * @param optimizer defines the current optimizer
  55322. * @returns true if everything that can be done was applied
  55323. */
  55324. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55325. }
  55326. /**
  55327. * Defines an optimization based on user defined callback.
  55328. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55329. */
  55330. export class CustomOptimization extends SceneOptimization {
  55331. /**
  55332. * Callback called to apply the custom optimization.
  55333. */
  55334. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  55335. /**
  55336. * Callback called to get custom description
  55337. */
  55338. onGetDescription: () => string;
  55339. /**
  55340. * Gets a string describing the action executed by the current optimization
  55341. * @returns description string
  55342. */
  55343. getDescription(): string;
  55344. /**
  55345. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55346. * @param scene defines the current scene where to apply this optimization
  55347. * @param optimizer defines the current optimizer
  55348. * @returns true if everything that can be done was applied
  55349. */
  55350. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55351. }
  55352. /**
  55353. * Defines an optimization used to turn particles off
  55354. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55355. */
  55356. export class ParticlesOptimization extends SceneOptimization {
  55357. /**
  55358. * Gets a string describing the action executed by the current optimization
  55359. * @return description string
  55360. */
  55361. getDescription(): string;
  55362. /**
  55363. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55364. * @param scene defines the current scene where to apply this optimization
  55365. * @param optimizer defines the current optimizer
  55366. * @returns true if everything that can be done was applied
  55367. */
  55368. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55369. }
  55370. /**
  55371. * Defines an optimization used to turn render targets off
  55372. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55373. */
  55374. export class RenderTargetsOptimization extends SceneOptimization {
  55375. /**
  55376. * Gets a string describing the action executed by the current optimization
  55377. * @return description string
  55378. */
  55379. getDescription(): string;
  55380. /**
  55381. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55382. * @param scene defines the current scene where to apply this optimization
  55383. * @param optimizer defines the current optimizer
  55384. * @returns true if everything that can be done was applied
  55385. */
  55386. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  55387. }
  55388. /**
  55389. * Defines an optimization used to merge meshes with compatible materials
  55390. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55391. */
  55392. export class MergeMeshesOptimization extends SceneOptimization {
  55393. private static _UpdateSelectionTree;
  55394. /**
  55395. * Gets or sets a boolean which defines if optimization octree has to be updated
  55396. */
  55397. /**
  55398. * Gets or sets a boolean which defines if optimization octree has to be updated
  55399. */
  55400. static UpdateSelectionTree: boolean;
  55401. /**
  55402. * Gets a string describing the action executed by the current optimization
  55403. * @return description string
  55404. */
  55405. getDescription(): string;
  55406. private _canBeMerged;
  55407. /**
  55408. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  55409. * @param scene defines the current scene where to apply this optimization
  55410. * @param optimizer defines the current optimizer
  55411. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  55412. * @returns true if everything that can be done was applied
  55413. */
  55414. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  55415. }
  55416. /**
  55417. * Defines a list of options used by SceneOptimizer
  55418. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55419. */
  55420. export class SceneOptimizerOptions {
  55421. /**
  55422. * Defines the target frame rate to reach (60 by default)
  55423. */
  55424. targetFrameRate: number;
  55425. /**
  55426. * Defines the interval between two checkes (2000ms by default)
  55427. */
  55428. trackerDuration: number;
  55429. /**
  55430. * Gets the list of optimizations to apply
  55431. */
  55432. optimizations: SceneOptimization[];
  55433. /**
  55434. * Creates a new list of options used by SceneOptimizer
  55435. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  55436. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  55437. */
  55438. constructor(
  55439. /**
  55440. * Defines the target frame rate to reach (60 by default)
  55441. */
  55442. targetFrameRate?: number,
  55443. /**
  55444. * Defines the interval between two checkes (2000ms by default)
  55445. */
  55446. trackerDuration?: number);
  55447. /**
  55448. * Add a new optimization
  55449. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  55450. * @returns the current SceneOptimizerOptions
  55451. */
  55452. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  55453. /**
  55454. * Add a new custom optimization
  55455. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  55456. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  55457. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  55458. * @returns the current SceneOptimizerOptions
  55459. */
  55460. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  55461. /**
  55462. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  55463. * @param targetFrameRate defines the target frame rate (60 by default)
  55464. * @returns a SceneOptimizerOptions object
  55465. */
  55466. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55467. /**
  55468. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  55469. * @param targetFrameRate defines the target frame rate (60 by default)
  55470. * @returns a SceneOptimizerOptions object
  55471. */
  55472. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55473. /**
  55474. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  55475. * @param targetFrameRate defines the target frame rate (60 by default)
  55476. * @returns a SceneOptimizerOptions object
  55477. */
  55478. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  55479. }
  55480. /**
  55481. * Class used to run optimizations in order to reach a target frame rate
  55482. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  55483. */
  55484. export class SceneOptimizer implements IDisposable {
  55485. private _isRunning;
  55486. private _options;
  55487. private _scene;
  55488. private _currentPriorityLevel;
  55489. private _targetFrameRate;
  55490. private _trackerDuration;
  55491. private _currentFrameRate;
  55492. private _sceneDisposeObserver;
  55493. private _improvementMode;
  55494. /**
  55495. * Defines an observable called when the optimizer reaches the target frame rate
  55496. */
  55497. onSuccessObservable: Observable<SceneOptimizer>;
  55498. /**
  55499. * Defines an observable called when the optimizer enables an optimization
  55500. */
  55501. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  55502. /**
  55503. * Defines an observable called when the optimizer is not able to reach the target frame rate
  55504. */
  55505. onFailureObservable: Observable<SceneOptimizer>;
  55506. /**
  55507. * Gets a boolean indicating if the optimizer is in improvement mode
  55508. */
  55509. readonly isInImprovementMode: boolean;
  55510. /**
  55511. * Gets the current priority level (0 at start)
  55512. */
  55513. readonly currentPriorityLevel: number;
  55514. /**
  55515. * Gets the current frame rate checked by the SceneOptimizer
  55516. */
  55517. readonly currentFrameRate: number;
  55518. /**
  55519. * Gets or sets the current target frame rate (60 by default)
  55520. */
  55521. /**
  55522. * Gets or sets the current target frame rate (60 by default)
  55523. */
  55524. targetFrameRate: number;
  55525. /**
  55526. * Gets or sets the current interval between two checks (every 2000ms by default)
  55527. */
  55528. /**
  55529. * Gets or sets the current interval between two checks (every 2000ms by default)
  55530. */
  55531. trackerDuration: number;
  55532. /**
  55533. * Gets the list of active optimizations
  55534. */
  55535. readonly optimizations: SceneOptimization[];
  55536. /**
  55537. * Creates a new SceneOptimizer
  55538. * @param scene defines the scene to work on
  55539. * @param options defines the options to use with the SceneOptimizer
  55540. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  55541. * @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)
  55542. */
  55543. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  55544. /**
  55545. * Stops the current optimizer
  55546. */
  55547. stop(): void;
  55548. /**
  55549. * Reset the optimizer to initial step (current priority level = 0)
  55550. */
  55551. reset(): void;
  55552. /**
  55553. * Start the optimizer. By default it will try to reach a specific framerate
  55554. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  55555. */
  55556. start(): void;
  55557. private _checkCurrentState;
  55558. /**
  55559. * Release all resources
  55560. */
  55561. dispose(): void;
  55562. /**
  55563. * Helper function to create a SceneOptimizer with one single line of code
  55564. * @param scene defines the scene to work on
  55565. * @param options defines the options to use with the SceneOptimizer
  55566. * @param onSuccess defines a callback to call on success
  55567. * @param onFailure defines a callback to call on failure
  55568. * @returns the new SceneOptimizer object
  55569. */
  55570. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  55571. }
  55572. }
  55573. declare module BABYLON {
  55574. /**
  55575. * Class used to serialize a scene into a string
  55576. */
  55577. export class SceneSerializer {
  55578. /**
  55579. * Clear cache used by a previous serialization
  55580. */
  55581. static ClearCache(): void;
  55582. /**
  55583. * Serialize a scene into a JSON compatible object
  55584. * @param scene defines the scene to serialize
  55585. * @returns a JSON compatible object
  55586. */
  55587. static Serialize(scene: Scene): any;
  55588. /**
  55589. * Serialize a mesh into a JSON compatible object
  55590. * @param toSerialize defines the mesh to serialize
  55591. * @param withParents defines if parents must be serialized as well
  55592. * @param withChildren defines if children must be serialized as well
  55593. * @returns a JSON compatible object
  55594. */
  55595. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  55596. }
  55597. }
  55598. declare module BABYLON {
  55599. /**
  55600. * Class used to host texture specific utilities
  55601. */
  55602. export class TextureTools {
  55603. /**
  55604. * Uses the GPU to create a copy texture rescaled at a given size
  55605. * @param texture Texture to copy from
  55606. * @param width defines the desired width
  55607. * @param height defines the desired height
  55608. * @param useBilinearMode defines if bilinear mode has to be used
  55609. * @return the generated texture
  55610. */
  55611. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  55612. }
  55613. }
  55614. declare module BABYLON {
  55615. /**
  55616. * This represents the different options avilable for the video capture.
  55617. */
  55618. export interface VideoRecorderOptions {
  55619. /** Defines the mime type of the video */
  55620. mimeType: string;
  55621. /** Defines the video the video should be recorded at */
  55622. fps: number;
  55623. /** Defines the chunk size for the recording data */
  55624. recordChunckSize: number;
  55625. /** The audio tracks to attach to the record */
  55626. audioTracks?: MediaStreamTrack[];
  55627. }
  55628. /**
  55629. * This can helps recording videos from BabylonJS.
  55630. * This is based on the available WebRTC functionalities of the browser.
  55631. *
  55632. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  55633. */
  55634. export class VideoRecorder {
  55635. private static readonly _defaultOptions;
  55636. /**
  55637. * Returns wehther or not the VideoRecorder is available in your browser.
  55638. * @param engine Defines the Babylon Engine to check the support for
  55639. * @returns true if supported otherwise false
  55640. */
  55641. static IsSupported(engine: Engine): boolean;
  55642. private readonly _options;
  55643. private _canvas;
  55644. private _mediaRecorder;
  55645. private _recordedChunks;
  55646. private _fileName;
  55647. private _resolve;
  55648. private _reject;
  55649. /**
  55650. * True wether a recording is already in progress.
  55651. */
  55652. readonly isRecording: boolean;
  55653. /**
  55654. * Create a new VideoCapture object which can help converting what you see in Babylon to
  55655. * a video file.
  55656. * @param engine Defines the BabylonJS Engine you wish to record
  55657. * @param options Defines options that can be used to customized the capture
  55658. */
  55659. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  55660. /**
  55661. * Stops the current recording before the default capture timeout passed in the startRecording
  55662. * functions.
  55663. */
  55664. stopRecording(): void;
  55665. /**
  55666. * Starts recording the canvas for a max duration specified in parameters.
  55667. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  55668. * @param maxDuration Defines the maximum recording time in seconds.
  55669. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  55670. * @return a promise callback at the end of the recording with the video data in Blob.
  55671. */
  55672. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  55673. /**
  55674. * Releases internal resources used during the recording.
  55675. */
  55676. dispose(): void;
  55677. private _handleDataAvailable;
  55678. private _handleError;
  55679. private _handleStop;
  55680. }
  55681. }
  55682. declare module BABYLON {
  55683. /**
  55684. * Class containing a set of static utilities functions for screenshots
  55685. */
  55686. export class ScreenshotTools {
  55687. /**
  55688. * Captures a screenshot of the current rendering
  55689. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55690. * @param engine defines the rendering engine
  55691. * @param camera defines the source camera
  55692. * @param size This parameter can be set to a single number or to an object with the
  55693. * following (optional) properties: precision, width, height. If a single number is passed,
  55694. * it will be used for both width and height. If an object is passed, the screenshot size
  55695. * will be derived from the parameters. The precision property is a multiplier allowing
  55696. * rendering at a higher or lower resolution
  55697. * @param successCallback defines the callback receives a single parameter which contains the
  55698. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55699. * src parameter of an <img> to display it
  55700. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55701. * Check your browser for supported MIME types
  55702. */
  55703. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55704. /**
  55705. * Generates an image screenshot from the specified camera.
  55706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55707. * @param engine The engine to use for rendering
  55708. * @param camera The camera to use for rendering
  55709. * @param size This parameter can be set to a single number or to an object with the
  55710. * following (optional) properties: precision, width, height. If a single number is passed,
  55711. * it will be used for both width and height. If an object is passed, the screenshot size
  55712. * will be derived from the parameters. The precision property is a multiplier allowing
  55713. * rendering at a higher or lower resolution
  55714. * @param successCallback The callback receives a single parameter which contains the
  55715. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55716. * src parameter of an <img> to display it
  55717. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55718. * Check your browser for supported MIME types
  55719. * @param samples Texture samples (default: 1)
  55720. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55721. * @param fileName A name for for the downloaded file.
  55722. */
  55723. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55724. }
  55725. }
  55726. declare module BABYLON {
  55727. /**
  55728. * A cursor which tracks a point on a path
  55729. */
  55730. export class PathCursor {
  55731. private path;
  55732. /**
  55733. * Stores path cursor callbacks for when an onchange event is triggered
  55734. */
  55735. private _onchange;
  55736. /**
  55737. * The value of the path cursor
  55738. */
  55739. value: number;
  55740. /**
  55741. * The animation array of the path cursor
  55742. */
  55743. animations: Animation[];
  55744. /**
  55745. * Initializes the path cursor
  55746. * @param path The path to track
  55747. */
  55748. constructor(path: Path2);
  55749. /**
  55750. * Gets the cursor point on the path
  55751. * @returns A point on the path cursor at the cursor location
  55752. */
  55753. getPoint(): Vector3;
  55754. /**
  55755. * Moves the cursor ahead by the step amount
  55756. * @param step The amount to move the cursor forward
  55757. * @returns This path cursor
  55758. */
  55759. moveAhead(step?: number): PathCursor;
  55760. /**
  55761. * Moves the cursor behind by the step amount
  55762. * @param step The amount to move the cursor back
  55763. * @returns This path cursor
  55764. */
  55765. moveBack(step?: number): PathCursor;
  55766. /**
  55767. * Moves the cursor by the step amount
  55768. * If the step amount is greater than one, an exception is thrown
  55769. * @param step The amount to move the cursor
  55770. * @returns This path cursor
  55771. */
  55772. move(step: number): PathCursor;
  55773. /**
  55774. * Ensures that the value is limited between zero and one
  55775. * @returns This path cursor
  55776. */
  55777. private ensureLimits;
  55778. /**
  55779. * Runs onchange callbacks on change (used by the animation engine)
  55780. * @returns This path cursor
  55781. */
  55782. private raiseOnChange;
  55783. /**
  55784. * Executes a function on change
  55785. * @param f A path cursor onchange callback
  55786. * @returns This path cursor
  55787. */
  55788. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55789. }
  55790. }
  55791. declare module BABYLON {
  55792. /** @hidden */
  55793. export var blurPixelShader: {
  55794. name: string;
  55795. shader: string;
  55796. };
  55797. }
  55798. declare module BABYLON {
  55799. /** @hidden */
  55800. export var bones300Declaration: {
  55801. name: string;
  55802. shader: string;
  55803. };
  55804. }
  55805. declare module BABYLON {
  55806. /** @hidden */
  55807. export var instances300Declaration: {
  55808. name: string;
  55809. shader: string;
  55810. };
  55811. }
  55812. declare module BABYLON {
  55813. /** @hidden */
  55814. export var pointCloudVertexDeclaration: {
  55815. name: string;
  55816. shader: string;
  55817. };
  55818. }
  55819. // Mixins
  55820. interface Window {
  55821. mozIndexedDB: IDBFactory;
  55822. webkitIndexedDB: IDBFactory;
  55823. msIndexedDB: IDBFactory;
  55824. webkitURL: typeof URL;
  55825. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55826. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55827. WebGLRenderingContext: WebGLRenderingContext;
  55828. MSGesture: MSGesture;
  55829. CANNON: any;
  55830. AudioContext: AudioContext;
  55831. webkitAudioContext: AudioContext;
  55832. PointerEvent: any;
  55833. Math: Math;
  55834. Uint8Array: Uint8ArrayConstructor;
  55835. Float32Array: Float32ArrayConstructor;
  55836. mozURL: typeof URL;
  55837. msURL: typeof URL;
  55838. VRFrameData: any; // WebVR, from specs 1.1
  55839. DracoDecoderModule: any;
  55840. setImmediate(handler: (...args: any[]) => void): number;
  55841. }
  55842. interface HTMLCanvasElement {
  55843. requestPointerLock(): void;
  55844. msRequestPointerLock?(): void;
  55845. mozRequestPointerLock?(): void;
  55846. webkitRequestPointerLock?(): void;
  55847. /** Track wether a record is in progress */
  55848. isRecording: boolean;
  55849. /** Capture Stream method defined by some browsers */
  55850. captureStream(fps?: number): MediaStream;
  55851. }
  55852. interface CanvasRenderingContext2D {
  55853. msImageSmoothingEnabled: boolean;
  55854. }
  55855. interface MouseEvent {
  55856. mozMovementX: number;
  55857. mozMovementY: number;
  55858. webkitMovementX: number;
  55859. webkitMovementY: number;
  55860. msMovementX: number;
  55861. msMovementY: number;
  55862. }
  55863. interface Navigator {
  55864. mozGetVRDevices: (any: any) => any;
  55865. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55866. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55867. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55868. webkitGetGamepads(): Gamepad[];
  55869. msGetGamepads(): Gamepad[];
  55870. webkitGamepads(): Gamepad[];
  55871. }
  55872. interface HTMLVideoElement {
  55873. mozSrcObject: any;
  55874. }
  55875. interface Math {
  55876. fround(x: number): number;
  55877. imul(a: number, b: number): number;
  55878. }
  55879. interface WebGLRenderingContext {
  55880. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55881. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55882. vertexAttribDivisor(index: number, divisor: number): void;
  55883. createVertexArray(): any;
  55884. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55885. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55886. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55887. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55888. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55889. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55890. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55891. // Queries
  55892. createQuery(): WebGLQuery;
  55893. deleteQuery(query: WebGLQuery): void;
  55894. beginQuery(target: number, query: WebGLQuery): void;
  55895. endQuery(target: number): void;
  55896. getQueryParameter(query: WebGLQuery, pname: number): any;
  55897. getQuery(target: number, pname: number): any;
  55898. MAX_SAMPLES: number;
  55899. RGBA8: number;
  55900. READ_FRAMEBUFFER: number;
  55901. DRAW_FRAMEBUFFER: number;
  55902. UNIFORM_BUFFER: number;
  55903. HALF_FLOAT_OES: number;
  55904. RGBA16F: number;
  55905. RGBA32F: number;
  55906. R32F: number;
  55907. RG32F: number;
  55908. RGB32F: number;
  55909. R16F: number;
  55910. RG16F: number;
  55911. RGB16F: number;
  55912. RED: number;
  55913. RG: number;
  55914. R8: number;
  55915. RG8: number;
  55916. UNSIGNED_INT_24_8: number;
  55917. DEPTH24_STENCIL8: number;
  55918. /* Multiple Render Targets */
  55919. drawBuffers(buffers: number[]): void;
  55920. readBuffer(src: number): void;
  55921. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55922. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55923. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55924. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55925. // Occlusion Query
  55926. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55927. ANY_SAMPLES_PASSED: number;
  55928. QUERY_RESULT_AVAILABLE: number;
  55929. QUERY_RESULT: number;
  55930. }
  55931. interface WebGLProgram { private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55932. }
  55933. interface EXT_disjoint_timer_query {
  55934. QUERY_COUNTER_BITS_EXT: number;
  55935. TIME_ELAPSED_EXT: number;
  55936. TIMESTAMP_EXT: number;
  55937. GPU_DISJOINT_EXT: number;
  55938. QUERY_RESULT_EXT: number;
  55939. QUERY_RESULT_AVAILABLE_EXT: number;
  55940. queryCounterEXT(query: WebGLQuery, target: number): void;
  55941. createQueryEXT(): WebGLQuery;
  55942. beginQueryEXT(target: number, query: WebGLQuery): void;
  55943. endQueryEXT(target: number): void;
  55944. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55945. deleteQueryEXT(query: WebGLQuery): void;
  55946. }
  55947. interface WebGLUniformLocation { currentState: any;
  55948. }
  55949. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55950. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55951. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55952. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55953. interface WebGLRenderingContext {
  55954. readonly RASTERIZER_DISCARD: number;
  55955. readonly DEPTH_COMPONENT24: number;
  55956. readonly TEXTURE_3D: number;
  55957. readonly TEXTURE_2D_ARRAY: number;
  55958. readonly TEXTURE_COMPARE_FUNC: number;
  55959. readonly TEXTURE_COMPARE_MODE: number;
  55960. readonly COMPARE_REF_TO_TEXTURE: number;
  55961. readonly TEXTURE_WRAP_R: number;
  55962. readonly HALF_FLOAT: number;
  55963. readonly RGB8: number;
  55964. readonly RED_INTEGER: number;
  55965. readonly RG_INTEGER: number;
  55966. readonly RGB_INTEGER: number;
  55967. readonly RGBA_INTEGER: number;
  55968. readonly R8_SNORM: number;
  55969. readonly RG8_SNORM: number;
  55970. readonly RGB8_SNORM: number;
  55971. readonly RGBA8_SNORM: number;
  55972. readonly R8I: number;
  55973. readonly RG8I: number;
  55974. readonly RGB8I: number;
  55975. readonly RGBA8I: number;
  55976. readonly R8UI: number;
  55977. readonly RG8UI: number;
  55978. readonly RGB8UI: number;
  55979. readonly RGBA8UI: number;
  55980. readonly R16I: number;
  55981. readonly RG16I: number;
  55982. readonly RGB16I: number;
  55983. readonly RGBA16I: number;
  55984. readonly R16UI: number;
  55985. readonly RG16UI: number;
  55986. readonly RGB16UI: number;
  55987. readonly RGBA16UI: number;
  55988. readonly R32I: number;
  55989. readonly RG32I: number;
  55990. readonly RGB32I: number;
  55991. readonly RGBA32I: number;
  55992. readonly R32UI: number;
  55993. readonly RG32UI: number;
  55994. readonly RGB32UI: number;
  55995. readonly RGBA32UI: number;
  55996. readonly RGB10_A2UI: number;
  55997. readonly R11F_G11F_B10F: number;
  55998. readonly RGB9_E5: number;
  55999. readonly RGB10_A2: number;
  56000. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  56001. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  56002. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  56003. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  56004. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  56005. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  56006. 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;
  56007. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  56008. readonly TRANSFORM_FEEDBACK: number;
  56009. readonly INTERLEAVED_ATTRIBS: number;
  56010. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  56011. createTransformFeedback(): WebGLTransformFeedback;
  56012. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  56013. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  56014. beginTransformFeedback(primitiveMode: number): void;
  56015. endTransformFeedback(): void;
  56016. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  56017. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56018. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56019. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  56020. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  56021. }
  56022. interface ImageBitmap {
  56023. readonly width: number;
  56024. readonly height: number;
  56025. close(): void;
  56026. }
  56027. interface WebGLQuery extends WebGLObject {
  56028. }
  56029. declare var WebGLQuery: {
  56030. prototype: WebGLQuery;
  56031. new(): WebGLQuery;
  56032. };
  56033. interface WebGLSampler extends WebGLObject {
  56034. }
  56035. declare var WebGLSampler: {
  56036. prototype: WebGLSampler;
  56037. new(): WebGLSampler;
  56038. };
  56039. interface WebGLSync extends WebGLObject {
  56040. }
  56041. declare var WebGLSync: {
  56042. prototype: WebGLSync;
  56043. new(): WebGLSync;
  56044. };
  56045. interface WebGLTransformFeedback extends WebGLObject {
  56046. }
  56047. declare var WebGLTransformFeedback: {
  56048. prototype: WebGLTransformFeedback;
  56049. new(): WebGLTransformFeedback;
  56050. };
  56051. interface WebGLVertexArrayObject extends WebGLObject {
  56052. }
  56053. declare var WebGLVertexArrayObject: {
  56054. prototype: WebGLVertexArrayObject;
  56055. new(): WebGLVertexArrayObject;
  56056. };
  56057. // Type definitions for WebVR API
  56058. // Project: https://w3c.github.io/webvr/
  56059. // Definitions by: six a <https://github.com/lostfictions>
  56060. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  56061. interface VRDisplay extends EventTarget {
  56062. /**
  56063. * Dictionary of capabilities describing the VRDisplay.
  56064. */
  56065. readonly capabilities: VRDisplayCapabilities;
  56066. /**
  56067. * z-depth defining the far plane of the eye view frustum
  56068. * enables mapping of values in the render target depth
  56069. * attachment to scene coordinates. Initially set to 10000.0.
  56070. */
  56071. depthFar: number;
  56072. /**
  56073. * z-depth defining the near plane of the eye view frustum
  56074. * enables mapping of values in the render target depth
  56075. * attachment to scene coordinates. Initially set to 0.01.
  56076. */
  56077. depthNear: number;
  56078. /**
  56079. * An identifier for this distinct VRDisplay. Used as an
  56080. * association point in the Gamepad API.
  56081. */
  56082. readonly displayId: number;
  56083. /**
  56084. * A display name, a user-readable name identifying it.
  56085. */
  56086. readonly displayName: string;
  56087. readonly isConnected: boolean;
  56088. readonly isPresenting: boolean;
  56089. /**
  56090. * If this VRDisplay supports room-scale experiences, the optional
  56091. * stage attribute contains details on the room-scale parameters.
  56092. */
  56093. readonly stageParameters: VRStageParameters | null;
  56094. /**
  56095. * Passing the value returned by `requestAnimationFrame` to
  56096. * `cancelAnimationFrame` will unregister the callback.
  56097. * @param handle Define the hanle of the request to cancel
  56098. */
  56099. cancelAnimationFrame(handle: number): void;
  56100. /**
  56101. * Stops presenting to the VRDisplay.
  56102. * @returns a promise to know when it stopped
  56103. */
  56104. exitPresent(): Promise<void>;
  56105. /**
  56106. * Return the current VREyeParameters for the given eye.
  56107. * @param whichEye Define the eye we want the parameter for
  56108. * @returns the eye parameters
  56109. */
  56110. getEyeParameters(whichEye: string): VREyeParameters;
  56111. /**
  56112. * Populates the passed VRFrameData with the information required to render
  56113. * the current frame.
  56114. * @param frameData Define the data structure to populate
  56115. * @returns true if ok otherwise false
  56116. */
  56117. getFrameData(frameData: VRFrameData): boolean;
  56118. /**
  56119. * Get the layers currently being presented.
  56120. * @returns the list of VR layers
  56121. */
  56122. getLayers(): VRLayer[];
  56123. /**
  56124. * Return a VRPose containing the future predicted pose of the VRDisplay
  56125. * when the current frame will be presented. The value returned will not
  56126. * change until JavaScript has returned control to the browser.
  56127. *
  56128. * The VRPose will contain the position, orientation, velocity,
  56129. * and acceleration of each of these properties.
  56130. * @returns the pose object
  56131. */
  56132. getPose(): VRPose;
  56133. /**
  56134. * Return the current instantaneous pose of the VRDisplay, with no
  56135. * prediction applied.
  56136. * @returns the current instantaneous pose
  56137. */
  56138. getImmediatePose(): VRPose;
  56139. /**
  56140. * The callback passed to `requestAnimationFrame` will be called
  56141. * any time a new frame should be rendered. When the VRDisplay is
  56142. * presenting the callback will be called at the native refresh
  56143. * rate of the HMD. When not presenting this function acts
  56144. * identically to how window.requestAnimationFrame acts. Content should
  56145. * make no assumptions of frame rate or vsync behavior as the HMD runs
  56146. * asynchronously from other displays and at differing refresh rates.
  56147. * @param callback Define the eaction to run next frame
  56148. * @returns the request handle it
  56149. */
  56150. requestAnimationFrame(callback: FrameRequestCallback): number;
  56151. /**
  56152. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  56153. * Repeat calls while already presenting will update the VRLayers being displayed.
  56154. * @param layers Define the list of layer to present
  56155. * @returns a promise to know when the request has been fulfilled
  56156. */
  56157. requestPresent(layers: VRLayer[]): Promise<void>;
  56158. /**
  56159. * Reset the pose for this display, treating its current position and
  56160. * orientation as the "origin/zero" values. VRPose.position,
  56161. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  56162. * updated when calling resetPose(). This should be called in only
  56163. * sitting-space experiences.
  56164. */
  56165. resetPose(): void;
  56166. /**
  56167. * The VRLayer provided to the VRDisplay will be captured and presented
  56168. * in the HMD. Calling this function has the same effect on the source
  56169. * canvas as any other operation that uses its source image, and canvases
  56170. * created without preserveDrawingBuffer set to true will be cleared.
  56171. * @param pose Define the pose to submit
  56172. */
  56173. submitFrame(pose?: VRPose): void;
  56174. }
  56175. declare var VRDisplay: {
  56176. prototype: VRDisplay;
  56177. new(): VRDisplay;
  56178. };
  56179. interface VRLayer {
  56180. leftBounds?: number[] | Float32Array | null;
  56181. rightBounds?: number[] | Float32Array | null;
  56182. source?: HTMLCanvasElement | null;
  56183. }
  56184. interface VRDisplayCapabilities {
  56185. readonly canPresent: boolean;
  56186. readonly hasExternalDisplay: boolean;
  56187. readonly hasOrientation: boolean;
  56188. readonly hasPosition: boolean;
  56189. readonly maxLayers: number;
  56190. }
  56191. interface VREyeParameters {
  56192. /** @deprecated */
  56193. readonly fieldOfView: VRFieldOfView;
  56194. readonly offset: Float32Array;
  56195. readonly renderHeight: number;
  56196. readonly renderWidth: number;
  56197. }
  56198. interface VRFieldOfView {
  56199. readonly downDegrees: number;
  56200. readonly leftDegrees: number;
  56201. readonly rightDegrees: number;
  56202. readonly upDegrees: number;
  56203. }
  56204. interface VRFrameData {
  56205. readonly leftProjectionMatrix: Float32Array;
  56206. readonly leftViewMatrix: Float32Array;
  56207. readonly pose: VRPose;
  56208. readonly rightProjectionMatrix: Float32Array;
  56209. readonly rightViewMatrix: Float32Array;
  56210. readonly timestamp: number;
  56211. }
  56212. interface VRPose {
  56213. readonly angularAcceleration: Float32Array | null;
  56214. readonly angularVelocity: Float32Array | null;
  56215. readonly linearAcceleration: Float32Array | null;
  56216. readonly linearVelocity: Float32Array | null;
  56217. readonly orientation: Float32Array | null;
  56218. readonly position: Float32Array | null;
  56219. readonly timestamp: number;
  56220. }
  56221. interface VRStageParameters {
  56222. sittingToStandingTransform?: Float32Array;
  56223. sizeX?: number;
  56224. sizeY?: number;
  56225. }
  56226. interface Navigator {
  56227. getVRDisplays(): Promise<VRDisplay[]>;
  56228. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  56229. }
  56230. interface Window {
  56231. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  56232. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  56233. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  56234. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56235. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  56236. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  56237. }
  56238. interface Gamepad {
  56239. readonly displayId: number;
  56240. }
  56241. interface XRDevice {
  56242. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  56243. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  56244. }
  56245. interface XRSession {
  56246. getInputSources(): Array<any>;
  56247. baseLayer: XRWebGLLayer;
  56248. requestFrameOfReference(type: string): Promise<void>;
  56249. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  56250. end(): Promise<void>;
  56251. requestAnimationFrame: Function;
  56252. addEventListener: Function;
  56253. }
  56254. interface XRSessionCreationOptions {
  56255. outputContext?: WebGLRenderingContext | null;
  56256. immersive?: boolean;
  56257. environmentIntegration?: boolean;
  56258. }
  56259. interface XRLayer {
  56260. getViewport: Function;
  56261. framebufferWidth: number;
  56262. framebufferHeight: number;
  56263. }
  56264. interface XRView {
  56265. projectionMatrix: Float32Array;
  56266. }
  56267. interface XRFrame {
  56268. getDevicePose: Function;
  56269. getInputPose: Function;
  56270. views: Array<XRView>;
  56271. baseLayer: XRLayer;
  56272. }
  56273. interface XRFrameOfReference {
  56274. }
  56275. interface XRWebGLLayer extends XRLayer {
  56276. framebuffer: WebGLFramebuffer;
  56277. }
  56278. declare var XRWebGLLayer: {
  56279. prototype: XRWebGLLayer;
  56280. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  56281. };
  56282. declare module BABYLON.GUI {
  56283. /**
  56284. * Class used to specific a value and its associated unit
  56285. */
  56286. export class ValueAndUnit {
  56287. /** defines the unit to store */
  56288. unit: number;
  56289. /** defines a boolean indicating if the value can be negative */
  56290. negativeValueAllowed: boolean;
  56291. private _value;
  56292. private _originalUnit;
  56293. /**
  56294. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  56295. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56296. */
  56297. ignoreAdaptiveScaling: boolean;
  56298. /**
  56299. * Creates a new ValueAndUnit
  56300. * @param value defines the value to store
  56301. * @param unit defines the unit to store
  56302. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  56303. */
  56304. constructor(value: number,
  56305. /** defines the unit to store */
  56306. unit?: number,
  56307. /** defines a boolean indicating if the value can be negative */
  56308. negativeValueAllowed?: boolean);
  56309. /** Gets a boolean indicating if the value is a percentage */
  56310. readonly isPercentage: boolean;
  56311. /** Gets a boolean indicating if the value is store as pixel */
  56312. readonly isPixel: boolean;
  56313. /** Gets direct internal value */
  56314. readonly internalValue: number;
  56315. /**
  56316. * Gets value as pixel
  56317. * @param host defines the root host
  56318. * @param refValue defines the reference value for percentages
  56319. * @returns the value as pixel
  56320. */
  56321. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  56322. /**
  56323. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  56324. * @param value defines the value to store
  56325. * @param unit defines the unit to store
  56326. * @returns the current ValueAndUnit
  56327. */
  56328. updateInPlace(value: number, unit?: number): ValueAndUnit;
  56329. /**
  56330. * Gets the value accordingly to its unit
  56331. * @param host defines the root host
  56332. * @returns the value
  56333. */
  56334. getValue(host: AdvancedDynamicTexture): number;
  56335. /**
  56336. * Gets a string representation of the value
  56337. * @param host defines the root host
  56338. * @param decimals defines an optional number of decimals to display
  56339. * @returns a string
  56340. */
  56341. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  56342. /**
  56343. * Store a value parsed from a string
  56344. * @param source defines the source string
  56345. * @returns true if the value was successfully parsed
  56346. */
  56347. fromString(source: string | number): boolean;
  56348. private static _Regex;
  56349. private static _UNITMODE_PERCENTAGE;
  56350. private static _UNITMODE_PIXEL;
  56351. /** UNITMODE_PERCENTAGE */
  56352. static readonly UNITMODE_PERCENTAGE: number;
  56353. /** UNITMODE_PIXEL */
  56354. static readonly UNITMODE_PIXEL: number;
  56355. }
  56356. }
  56357. declare module BABYLON.GUI {
  56358. /**
  56359. * Define a style used by control to automatically setup properties based on a template.
  56360. * Only support font related properties so far
  56361. */
  56362. export class Style implements BABYLON.IDisposable {
  56363. private _fontFamily;
  56364. private _fontStyle;
  56365. private _fontWeight;
  56366. /** @hidden */ host: AdvancedDynamicTexture;
  56367. /** @hidden */ fontSize: ValueAndUnit;
  56368. /**
  56369. * BABYLON.Observable raised when the style values are changed
  56370. */
  56371. onChangedObservable: BABYLON.Observable<Style>;
  56372. /**
  56373. * Creates a new style object
  56374. * @param host defines the AdvancedDynamicTexture which hosts this style
  56375. */
  56376. constructor(host: AdvancedDynamicTexture);
  56377. /**
  56378. * Gets or sets the font size
  56379. */
  56380. fontSize: string | number;
  56381. /**
  56382. * Gets or sets the font family
  56383. */
  56384. fontFamily: string;
  56385. /**
  56386. * Gets or sets the font style
  56387. */
  56388. fontStyle: string;
  56389. /** Gets or sets font weight */
  56390. fontWeight: string;
  56391. /** Dispose all associated resources */
  56392. dispose(): void;
  56393. }
  56394. }
  56395. declare module BABYLON.GUI {
  56396. /**
  56397. * Class used to transport BABYLON.Vector2 information for pointer events
  56398. */
  56399. export class Vector2WithInfo extends BABYLON.Vector2 {
  56400. /** defines the current mouse button index */
  56401. buttonIndex: number;
  56402. /**
  56403. * Creates a new Vector2WithInfo
  56404. * @param source defines the vector2 data to transport
  56405. * @param buttonIndex defines the current mouse button index
  56406. */
  56407. constructor(source: BABYLON.Vector2,
  56408. /** defines the current mouse button index */
  56409. buttonIndex?: number);
  56410. }
  56411. /** Class used to provide 2D matrix features */
  56412. export class Matrix2D {
  56413. /** Gets the internal array of 6 floats used to store matrix data */
  56414. m: Float32Array;
  56415. /**
  56416. * Creates a new matrix
  56417. * @param m00 defines value for (0, 0)
  56418. * @param m01 defines value for (0, 1)
  56419. * @param m10 defines value for (1, 0)
  56420. * @param m11 defines value for (1, 1)
  56421. * @param m20 defines value for (2, 0)
  56422. * @param m21 defines value for (2, 1)
  56423. */
  56424. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  56425. /**
  56426. * Fills the matrix from direct values
  56427. * @param m00 defines value for (0, 0)
  56428. * @param m01 defines value for (0, 1)
  56429. * @param m10 defines value for (1, 0)
  56430. * @param m11 defines value for (1, 1)
  56431. * @param m20 defines value for (2, 0)
  56432. * @param m21 defines value for (2, 1)
  56433. * @returns the current modified matrix
  56434. */
  56435. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  56436. /**
  56437. * Gets matrix determinant
  56438. * @returns the determinant
  56439. */
  56440. determinant(): number;
  56441. /**
  56442. * Inverses the matrix and stores it in a target matrix
  56443. * @param result defines the target matrix
  56444. * @returns the current matrix
  56445. */
  56446. invertToRef(result: Matrix2D): Matrix2D;
  56447. /**
  56448. * Multiplies the current matrix with another one
  56449. * @param other defines the second operand
  56450. * @param result defines the target matrix
  56451. * @returns the current matrix
  56452. */
  56453. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  56454. /**
  56455. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  56456. * @param x defines the x coordinate to transform
  56457. * @param y defines the x coordinate to transform
  56458. * @param result defines the target vector2
  56459. * @returns the current matrix
  56460. */
  56461. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  56462. /**
  56463. * Creates an identity matrix
  56464. * @returns a new matrix
  56465. */
  56466. static Identity(): Matrix2D;
  56467. /**
  56468. * Creates a translation matrix and stores it in a target matrix
  56469. * @param x defines the x coordinate of the translation
  56470. * @param y defines the y coordinate of the translation
  56471. * @param result defines the target matrix
  56472. */
  56473. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  56474. /**
  56475. * Creates a scaling matrix and stores it in a target matrix
  56476. * @param x defines the x coordinate of the scaling
  56477. * @param y defines the y coordinate of the scaling
  56478. * @param result defines the target matrix
  56479. */
  56480. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  56481. /**
  56482. * Creates a rotation matrix and stores it in a target matrix
  56483. * @param angle defines the rotation angle
  56484. * @param result defines the target matrix
  56485. */
  56486. static RotationToRef(angle: number, result: Matrix2D): void;
  56487. private static _TempPreTranslationMatrix;
  56488. private static _TempPostTranslationMatrix;
  56489. private static _TempRotationMatrix;
  56490. private static _TempScalingMatrix;
  56491. private static _TempCompose0;
  56492. private static _TempCompose1;
  56493. private static _TempCompose2;
  56494. /**
  56495. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  56496. * @param tx defines the x coordinate of the translation
  56497. * @param ty defines the y coordinate of the translation
  56498. * @param angle defines the rotation angle
  56499. * @param scaleX defines the x coordinate of the scaling
  56500. * @param scaleY defines the y coordinate of the scaling
  56501. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  56502. * @param result defines the target matrix
  56503. */
  56504. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  56505. }
  56506. }
  56507. declare module BABYLON.GUI {
  56508. /**
  56509. * Class used to store 2D control sizes
  56510. */
  56511. export class Measure {
  56512. /** defines left coordinate */
  56513. left: number;
  56514. /** defines top coordinate */
  56515. top: number;
  56516. /** defines width dimension */
  56517. width: number;
  56518. /** defines height dimension */
  56519. height: number;
  56520. /**
  56521. * Creates a new measure
  56522. * @param left defines left coordinate
  56523. * @param top defines top coordinate
  56524. * @param width defines width dimension
  56525. * @param height defines height dimension
  56526. */
  56527. constructor(
  56528. /** defines left coordinate */
  56529. left: number,
  56530. /** defines top coordinate */
  56531. top: number,
  56532. /** defines width dimension */
  56533. width: number,
  56534. /** defines height dimension */
  56535. height: number);
  56536. /**
  56537. * Copy from another measure
  56538. * @param other defines the other measure to copy from
  56539. */
  56540. copyFrom(other: Measure): void;
  56541. /**
  56542. * Copy from a group of 4 floats
  56543. * @param left defines left coordinate
  56544. * @param top defines top coordinate
  56545. * @param width defines width dimension
  56546. * @param height defines height dimension
  56547. */
  56548. copyFromFloats(left: number, top: number, width: number, height: number): void;
  56549. /**
  56550. * Computes the axis aligned bounding box measure for two given measures
  56551. * @param a Input measure
  56552. * @param b Input measure
  56553. * @param result the resulting bounding measure
  56554. */
  56555. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  56556. /**
  56557. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  56558. * @param transform the matrix to transform the measure before computing the AABB
  56559. * @param result the resulting AABB
  56560. */
  56561. transformToRef(transform: Matrix2D, result: Measure): void;
  56562. /**
  56563. * Check equality between this measure and another one
  56564. * @param other defines the other measures
  56565. * @returns true if both measures are equals
  56566. */
  56567. isEqualsTo(other: Measure): boolean;
  56568. /**
  56569. * Creates an empty measure
  56570. * @returns a new measure
  56571. */
  56572. static Empty(): Measure;
  56573. }
  56574. }
  56575. declare module BABYLON.GUI {
  56576. /**
  56577. * Interface used to define a control that can receive focus
  56578. */
  56579. export interface IFocusableControl {
  56580. /**
  56581. * Function called when the control receives the focus
  56582. */
  56583. onFocus(): void;
  56584. /**
  56585. * Function called when the control loses the focus
  56586. */
  56587. onBlur(): void;
  56588. /**
  56589. * Function called to let the control handle keyboard events
  56590. * @param evt defines the current keyboard event
  56591. */
  56592. processKeyboard(evt: KeyboardEvent): void;
  56593. /**
  56594. * Function called to get the list of controls that should not steal the focus from this control
  56595. * @returns an array of controls
  56596. */
  56597. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  56598. }
  56599. /**
  56600. * Class used to create texture to support 2D GUI elements
  56601. * @see http://doc.babylonjs.com/how_to/gui
  56602. */
  56603. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  56604. private _isDirty;
  56605. private _renderObserver;
  56606. private _resizeObserver;
  56607. private _preKeyboardObserver;
  56608. private _pointerMoveObserver;
  56609. private _pointerObserver;
  56610. private _canvasPointerOutObserver;
  56611. private _background;
  56612. /** @hidden */ rootContainer: Container;
  56613. /** @hidden */ lastPickedControl: Control;
  56614. /** @hidden */ lastControlOver: {
  56615. [pointerId: number]: Control;
  56616. };
  56617. /** @hidden */ lastControlDown: {
  56618. [pointerId: number]: Control;
  56619. };
  56620. /** @hidden */ capturingControl: {
  56621. [pointerId: number]: Control;
  56622. };
  56623. /** @hidden */ shouldBlockPointer: boolean;
  56624. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  56625. /** @hidden */ linkedControls: Control[];
  56626. private _isFullscreen;
  56627. private _fullscreenViewport;
  56628. private _idealWidth;
  56629. private _idealHeight;
  56630. private _useSmallestIdeal;
  56631. private _renderAtIdealSize;
  56632. private _focusedControl;
  56633. private _blockNextFocusCheck;
  56634. private _renderScale;
  56635. private _rootCanvas;
  56636. private _cursorChanged;
  56637. /**
  56638. * Define type to string to ensure compatibility across browsers
  56639. * Safari doesn't support DataTransfer constructor
  56640. */
  56641. private _clipboardData;
  56642. /**
  56643. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  56644. */
  56645. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  56646. /**
  56647. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  56648. */
  56649. onControlPickedObservable: BABYLON.Observable<Control>;
  56650. /**
  56651. * BABYLON.Observable event triggered before layout is evaluated
  56652. */
  56653. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56654. /**
  56655. * BABYLON.Observable event triggered after the layout was evaluated
  56656. */
  56657. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56658. /**
  56659. * BABYLON.Observable event triggered before the texture is rendered
  56660. */
  56661. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56662. /**
  56663. * BABYLON.Observable event triggered after the texture was rendered
  56664. */
  56665. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  56666. /**
  56667. * Gets or sets a boolean defining if alpha is stored as premultiplied
  56668. */
  56669. premulAlpha: boolean;
  56670. /**
  56671. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  56672. * Useful when you want more antialiasing
  56673. */
  56674. renderScale: number;
  56675. /** Gets or sets the background color */
  56676. background: string;
  56677. /**
  56678. * Gets or sets the ideal width used to design controls.
  56679. * The GUI will then rescale everything accordingly
  56680. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56681. */
  56682. idealWidth: number;
  56683. /**
  56684. * Gets or sets the ideal height used to design controls.
  56685. * The GUI will then rescale everything accordingly
  56686. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56687. */
  56688. idealHeight: number;
  56689. /**
  56690. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56691. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56692. */
  56693. useSmallestIdeal: boolean;
  56694. /**
  56695. * Gets or sets a boolean indicating if adaptive scaling must be used
  56696. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56697. */
  56698. renderAtIdealSize: boolean;
  56699. /**
  56700. * Gets the underlying layer used to render the texture when in fullscreen mode
  56701. */
  56702. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56703. /**
  56704. * Gets the root container control
  56705. */
  56706. readonly rootContainer: Container;
  56707. /**
  56708. * Returns an array containing the root container.
  56709. * This is mostly used to let the Inspector introspects the ADT
  56710. * @returns an array containing the rootContainer
  56711. */
  56712. getChildren(): Array<Container>;
  56713. /**
  56714. * Will return all controls that are inside this texture
  56715. * @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
  56716. * @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
  56717. * @return all child controls
  56718. */
  56719. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56720. /**
  56721. * Gets or sets the current focused control
  56722. */
  56723. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56724. /**
  56725. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56726. */
  56727. isForeground: boolean;
  56728. /**
  56729. * Gets or set information about clipboardData
  56730. */
  56731. clipboardData: string;
  56732. /**
  56733. * Creates a new AdvancedDynamicTexture
  56734. * @param name defines the name of the texture
  56735. * @param width defines the width of the texture
  56736. * @param height defines the height of the texture
  56737. * @param scene defines the hosting scene
  56738. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56739. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56740. */
  56741. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56742. /**
  56743. * Get the current class name of the texture useful for serialization or dynamic coding.
  56744. * @returns "AdvancedDynamicTexture"
  56745. */
  56746. getClassName(): string;
  56747. /**
  56748. * Function used to execute a function on all controls
  56749. * @param func defines the function to execute
  56750. * @param container defines the container where controls belong. If null the root container will be used
  56751. */
  56752. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56753. private _useInvalidateRectOptimization;
  56754. /**
  56755. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56756. */
  56757. useInvalidateRectOptimization: boolean;
  56758. private _invalidatedRectangle;
  56759. /**
  56760. * Invalidates a rectangle area on the gui texture
  56761. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56762. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56763. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56764. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56765. */
  56766. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56767. /**
  56768. * Marks the texture as dirty forcing a complete update
  56769. */
  56770. markAsDirty(): void;
  56771. /**
  56772. * Helper function used to create a new style
  56773. * @returns a new style
  56774. * @see http://doc.babylonjs.com/how_to/gui#styles
  56775. */
  56776. createStyle(): Style;
  56777. /**
  56778. * Adds a new control to the root container
  56779. * @param control defines the control to add
  56780. * @returns the current texture
  56781. */
  56782. addControl(control: Control): AdvancedDynamicTexture;
  56783. /**
  56784. * Removes a control from the root container
  56785. * @param control defines the control to remove
  56786. * @returns the current texture
  56787. */
  56788. removeControl(control: Control): AdvancedDynamicTexture;
  56789. /**
  56790. * Release all resources
  56791. */
  56792. dispose(): void;
  56793. private _onResize;
  56794. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56795. /**
  56796. * Get screen coordinates for a vector3
  56797. * @param position defines the position to project
  56798. * @param worldMatrix defines the world matrix to use
  56799. * @returns the projected position
  56800. */
  56801. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56802. private _checkUpdate;
  56803. private _clearMeasure;
  56804. private _render;
  56805. /** @hidden */ changeCursor(cursor: string): void;
  56806. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56807. private _doPicking;
  56808. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56809. [pointerId: number]: Control;
  56810. }, control: Control): void;
  56811. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56812. /** Attach to all scene events required to support pointer events */
  56813. attach(): void;
  56814. /** @hidden */
  56815. private onClipboardCopy;
  56816. /** @hidden */
  56817. private onClipboardCut;
  56818. /** @hidden */
  56819. private onClipboardPaste;
  56820. /**
  56821. * Register the clipboard Events onto the canvas
  56822. */
  56823. registerClipboardEvents(): void;
  56824. /**
  56825. * Unregister the clipboard Events from the canvas
  56826. */
  56827. unRegisterClipboardEvents(): void;
  56828. /**
  56829. * Connect the texture to a hosting mesh to enable interactions
  56830. * @param mesh defines the mesh to attach to
  56831. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56832. */
  56833. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56834. /**
  56835. * Move the focus to a specific control
  56836. * @param control defines the control which will receive the focus
  56837. */
  56838. moveFocusToControl(control: IFocusableControl): void;
  56839. private _manageFocus;
  56840. private _attachToOnPointerOut;
  56841. /**
  56842. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56843. * @param mesh defines the mesh which will receive the texture
  56844. * @param width defines the texture width (1024 by default)
  56845. * @param height defines the texture height (1024 by default)
  56846. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56847. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56848. * @returns a new AdvancedDynamicTexture
  56849. */
  56850. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56851. /**
  56852. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56853. * In this mode the texture will rely on a layer for its rendering.
  56854. * This allows it to be treated like any other layer.
  56855. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56856. * LayerMask is set through advancedTexture.layer.layerMask
  56857. * @param name defines name for the texture
  56858. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56859. * @param scene defines the hsoting scene
  56860. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56861. * @returns a new AdvancedDynamicTexture
  56862. */
  56863. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56864. }
  56865. }
  56866. declare module BABYLON.GUI {
  56867. /**
  56868. * Root class used for all 2D controls
  56869. * @see http://doc.babylonjs.com/how_to/gui#controls
  56870. */
  56871. export class Control {
  56872. /** defines the name of the control */
  56873. name?: string | undefined;
  56874. /**
  56875. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56876. */
  56877. static AllowAlphaInheritance: boolean;
  56878. private _alpha;
  56879. private _alphaSet;
  56880. private _zIndex;
  56881. /** @hidden */ host: AdvancedDynamicTexture;
  56882. /** Gets or sets the control parent */
  56883. parent: BABYLON.Nullable<Container>;
  56884. /** @hidden */ currentMeasure: Measure;
  56885. private _fontFamily;
  56886. private _fontStyle;
  56887. private _fontWeight;
  56888. private _fontSize;
  56889. private _font;
  56890. /** @hidden */ width: ValueAndUnit;
  56891. /** @hidden */ height: ValueAndUnit;
  56892. /** @hidden */
  56893. protected _fontOffset: {
  56894. ascent: number;
  56895. height: number;
  56896. descent: number;
  56897. };
  56898. private _color;
  56899. private _style;
  56900. private _styleObserver;
  56901. /** @hidden */
  56902. protected _horizontalAlignment: number;
  56903. /** @hidden */
  56904. protected _verticalAlignment: number;
  56905. /** @hidden */
  56906. protected _isDirty: boolean;
  56907. /** @hidden */
  56908. protected _wasDirty: boolean;
  56909. /** @hidden */ tempParentMeasure: Measure;
  56910. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56911. /** @hidden */
  56912. protected _cachedParentMeasure: Measure;
  56913. private _paddingLeft;
  56914. private _paddingRight;
  56915. private _paddingTop;
  56916. private _paddingBottom;
  56917. /** @hidden */ left: ValueAndUnit;
  56918. /** @hidden */ top: ValueAndUnit;
  56919. private _scaleX;
  56920. private _scaleY;
  56921. private _rotation;
  56922. private _transformCenterX;
  56923. private _transformCenterY;
  56924. /** @hidden */ transformMatrix: Matrix2D;
  56925. /** @hidden */
  56926. protected _invertTransformMatrix: Matrix2D;
  56927. /** @hidden */
  56928. protected _transformedPosition: BABYLON.Vector2;
  56929. private _isMatrixDirty;
  56930. private _cachedOffsetX;
  56931. private _cachedOffsetY;
  56932. private _isVisible;
  56933. private _isHighlighted;
  56934. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56935. private _fontSet;
  56936. private _dummyVector2;
  56937. private _downCount;
  56938. private _enterCount;
  56939. private _doNotRender;
  56940. private _downPointerIds;
  56941. protected _isEnabled: boolean;
  56942. protected _disabledColor: string;
  56943. /** @hidden */
  56944. protected _rebuildLayout: boolean;
  56945. /** @hidden */ isClipped: boolean;
  56946. /** @hidden */ tag: any;
  56947. /**
  56948. * 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
  56949. */
  56950. uniqueId: number;
  56951. /**
  56952. * Gets or sets an object used to store user defined information for the node
  56953. */
  56954. metadata: any;
  56955. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56956. isHitTestVisible: boolean;
  56957. /** Gets or sets a boolean indicating if the control can block pointer events */
  56958. isPointerBlocker: boolean;
  56959. /** Gets or sets a boolean indicating if the control can be focusable */
  56960. isFocusInvisible: boolean;
  56961. /**
  56962. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56963. * 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
  56964. */
  56965. clipChildren: boolean;
  56966. /**
  56967. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56968. */
  56969. useBitmapCache: boolean;
  56970. private _cacheData;
  56971. private _shadowOffsetX;
  56972. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56973. shadowOffsetX: number;
  56974. private _shadowOffsetY;
  56975. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56976. shadowOffsetY: number;
  56977. private _shadowBlur;
  56978. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56979. shadowBlur: number;
  56980. private _shadowColor;
  56981. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56982. shadowColor: string;
  56983. /** Gets or sets the cursor to use when the control is hovered */
  56984. hoverCursor: string;
  56985. /** @hidden */
  56986. protected _linkOffsetX: ValueAndUnit;
  56987. /** @hidden */
  56988. protected _linkOffsetY: ValueAndUnit;
  56989. /** Gets the control type name */
  56990. readonly typeName: string;
  56991. /**
  56992. * Get the current class name of the control.
  56993. * @returns current class name
  56994. */
  56995. getClassName(): string;
  56996. /**
  56997. * An event triggered when the pointer move over the control.
  56998. */
  56999. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  57000. /**
  57001. * An event triggered when the pointer move out of the control.
  57002. */
  57003. onPointerOutObservable: BABYLON.Observable<Control>;
  57004. /**
  57005. * An event triggered when the pointer taps the control
  57006. */
  57007. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  57008. /**
  57009. * An event triggered when pointer up
  57010. */
  57011. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  57012. /**
  57013. * An event triggered when a control is clicked on
  57014. */
  57015. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  57016. /**
  57017. * An event triggered when pointer enters the control
  57018. */
  57019. onPointerEnterObservable: BABYLON.Observable<Control>;
  57020. /**
  57021. * An event triggered when the control is marked as dirty
  57022. */
  57023. onDirtyObservable: BABYLON.Observable<Control>;
  57024. /**
  57025. * An event triggered before drawing the control
  57026. */
  57027. onBeforeDrawObservable: BABYLON.Observable<Control>;
  57028. /**
  57029. * An event triggered after the control was drawn
  57030. */
  57031. onAfterDrawObservable: BABYLON.Observable<Control>;
  57032. /**
  57033. * Get the hosting AdvancedDynamicTexture
  57034. */
  57035. readonly host: AdvancedDynamicTexture;
  57036. /** Gets or set information about font offsets (used to render and align text) */
  57037. fontOffset: {
  57038. ascent: number;
  57039. height: number;
  57040. descent: number;
  57041. };
  57042. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  57043. alpha: number;
  57044. /**
  57045. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  57046. */
  57047. isHighlighted: boolean;
  57048. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  57049. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57050. */
  57051. scaleX: number;
  57052. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  57053. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57054. */
  57055. scaleY: number;
  57056. /** Gets or sets the rotation angle (0 by default)
  57057. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57058. */
  57059. rotation: number;
  57060. /** Gets or sets the transformation center on Y axis (0 by default)
  57061. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57062. */
  57063. transformCenterY: number;
  57064. /** Gets or sets the transformation center on X axis (0 by default)
  57065. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  57066. */
  57067. transformCenterX: number;
  57068. /**
  57069. * Gets or sets the horizontal alignment
  57070. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57071. */
  57072. horizontalAlignment: number;
  57073. /**
  57074. * Gets or sets the vertical alignment
  57075. * @see http://doc.babylonjs.com/how_to/gui#alignments
  57076. */
  57077. verticalAlignment: number;
  57078. /**
  57079. * Gets or sets control width
  57080. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57081. */
  57082. width: string | number;
  57083. /**
  57084. * Gets control width in pixel
  57085. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57086. */
  57087. readonly widthInPixels: number;
  57088. /**
  57089. * Gets or sets control height
  57090. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57091. */
  57092. height: string | number;
  57093. /**
  57094. * Gets control height in pixel
  57095. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57096. */
  57097. readonly heightInPixels: number;
  57098. /** Gets or set font family */
  57099. fontFamily: string;
  57100. /** Gets or sets font style */
  57101. fontStyle: string;
  57102. /** Gets or sets font weight */
  57103. fontWeight: string;
  57104. /**
  57105. * Gets or sets style
  57106. * @see http://doc.babylonjs.com/how_to/gui#styles
  57107. */
  57108. style: BABYLON.Nullable<Style>;
  57109. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  57110. /** Gets font size in pixels */
  57111. readonly fontSizeInPixels: number;
  57112. /** Gets or sets font size */
  57113. fontSize: string | number;
  57114. /** Gets or sets foreground color */
  57115. color: string;
  57116. /** Gets or sets z index which is used to reorder controls on the z axis */
  57117. zIndex: number;
  57118. /** Gets or sets a boolean indicating if the control can be rendered */
  57119. notRenderable: boolean;
  57120. /** Gets or sets a boolean indicating if the control is visible */
  57121. isVisible: boolean;
  57122. /** Gets a boolean indicating that the control needs to update its rendering */
  57123. readonly isDirty: boolean;
  57124. /**
  57125. * Gets the current linked mesh (or null if none)
  57126. */
  57127. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  57128. /**
  57129. * Gets or sets a value indicating the padding to use on the left of the control
  57130. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57131. */
  57132. paddingLeft: string | number;
  57133. /**
  57134. * Gets a value indicating the padding in pixels to use on the left of the control
  57135. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57136. */
  57137. readonly paddingLeftInPixels: number;
  57138. /**
  57139. * Gets or sets a value indicating the padding to use on the right of the control
  57140. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57141. */
  57142. paddingRight: string | number;
  57143. /**
  57144. * Gets a value indicating the padding in pixels to use on the right of the control
  57145. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57146. */
  57147. readonly paddingRightInPixels: number;
  57148. /**
  57149. * Gets or sets a value indicating the padding to use on the top of the control
  57150. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57151. */
  57152. paddingTop: string | number;
  57153. /**
  57154. * Gets a value indicating the padding in pixels to use on the top of the control
  57155. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57156. */
  57157. readonly paddingTopInPixels: number;
  57158. /**
  57159. * Gets or sets a value indicating the padding to use on the bottom of the control
  57160. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57161. */
  57162. paddingBottom: string | number;
  57163. /**
  57164. * Gets a value indicating the padding in pixels to use on the bottom of the control
  57165. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57166. */
  57167. readonly paddingBottomInPixels: number;
  57168. /**
  57169. * Gets or sets a value indicating the left coordinate of the control
  57170. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57171. */
  57172. left: string | number;
  57173. /**
  57174. * Gets a value indicating the left coordinate in pixels of the control
  57175. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57176. */
  57177. readonly leftInPixels: number;
  57178. /**
  57179. * Gets or sets a value indicating the top coordinate of the control
  57180. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57181. */
  57182. top: string | number;
  57183. /**
  57184. * Gets a value indicating the top coordinate in pixels of the control
  57185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57186. */
  57187. readonly topInPixels: number;
  57188. /**
  57189. * Gets or sets a value indicating the offset on X axis to the linked mesh
  57190. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57191. */
  57192. linkOffsetX: string | number;
  57193. /**
  57194. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  57195. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57196. */
  57197. readonly linkOffsetXInPixels: number;
  57198. /**
  57199. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  57200. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57201. */
  57202. linkOffsetY: string | number;
  57203. /**
  57204. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  57205. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57206. */
  57207. readonly linkOffsetYInPixels: number;
  57208. /** Gets the center coordinate on X axis */
  57209. readonly centerX: number;
  57210. /** Gets the center coordinate on Y axis */
  57211. readonly centerY: number;
  57212. /** Gets or sets if control is Enabled*/
  57213. isEnabled: boolean;
  57214. /** Gets or sets background color of control if it's disabled*/
  57215. disabledColor: string;
  57216. /**
  57217. * Creates a new control
  57218. * @param name defines the name of the control
  57219. */
  57220. constructor(
  57221. /** defines the name of the control */
  57222. name?: string | undefined);
  57223. /** @hidden */
  57224. protected _getTypeName(): string;
  57225. /**
  57226. * Gets the first ascendant in the hierarchy of the given type
  57227. * @param className defines the required type
  57228. * @returns the ascendant or null if not found
  57229. */
  57230. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  57231. /** @hidden */ resetFontCache(): void;
  57232. /**
  57233. * Determines if a container is an ascendant of the current control
  57234. * @param container defines the container to look for
  57235. * @returns true if the container is one of the ascendant of the control
  57236. */
  57237. isAscendant(container: Control): boolean;
  57238. /**
  57239. * Gets coordinates in local control space
  57240. * @param globalCoordinates defines the coordinates to transform
  57241. * @returns the new coordinates in local space
  57242. */
  57243. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57244. /**
  57245. * Gets coordinates in local control space
  57246. * @param globalCoordinates defines the coordinates to transform
  57247. * @param result defines the target vector2 where to store the result
  57248. * @returns the current control
  57249. */
  57250. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  57251. /**
  57252. * Gets coordinates in parent local control space
  57253. * @param globalCoordinates defines the coordinates to transform
  57254. * @returns the new coordinates in parent local space
  57255. */
  57256. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  57257. /**
  57258. * Move the current control to a vector3 position projected onto the screen.
  57259. * @param position defines the target position
  57260. * @param scene defines the hosting scene
  57261. */
  57262. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  57263. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57264. /**
  57265. * Will return all controls that have this control as ascendant
  57266. * @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
  57267. * @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
  57268. * @return all child controls
  57269. */
  57270. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  57271. /**
  57272. * Link current control with a target mesh
  57273. * @param mesh defines the mesh to link with
  57274. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  57275. */
  57276. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  57277. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  57278. /** @hidden */ offsetLeft(offset: number): void;
  57279. /** @hidden */ offsetTop(offset: number): void;
  57280. /** @hidden */ markMatrixAsDirty(): void;
  57281. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  57282. /** @hidden */ intersectsRect(rect: Measure): boolean;
  57283. /** @hidden */
  57284. protected invalidateRect(): void;
  57285. /** @hidden */ markAsDirty(force?: boolean): void;
  57286. /** @hidden */ markAllAsDirty(): void;
  57287. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57288. /** @hidden */
  57289. protected _transform(context?: CanvasRenderingContext2D): void;
  57290. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  57291. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57292. /** @hidden */
  57293. protected _applyStates(context: CanvasRenderingContext2D): void;
  57294. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57295. /** @hidden */
  57296. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57297. protected _evaluateClippingState(parentMeasure: Measure): void;
  57298. /** @hidden */ measure(): void;
  57299. /** @hidden */
  57300. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57301. /** @hidden */
  57302. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57303. /** @hidden */
  57304. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57305. /** @hidden */
  57306. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57307. private static _ClipMeasure;
  57308. private _tmpMeasureA;
  57309. private _clip;
  57310. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  57311. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  57312. /**
  57313. * Tests if a given coordinates belong to the current control
  57314. * @param x defines x coordinate to test
  57315. * @param y defines y coordinate to test
  57316. * @returns true if the coordinates are inside the control
  57317. */
  57318. contains(x: number, y: number): boolean;
  57319. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57320. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  57321. /** @hidden */ onPointerEnter(target: Control): boolean;
  57322. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57323. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57324. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57325. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  57326. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  57327. private _prepareFont;
  57328. /** Releases associated resources */
  57329. dispose(): void;
  57330. private static _HORIZONTAL_ALIGNMENT_LEFT;
  57331. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  57332. private static _HORIZONTAL_ALIGNMENT_CENTER;
  57333. private static _VERTICAL_ALIGNMENT_TOP;
  57334. private static _VERTICAL_ALIGNMENT_BOTTOM;
  57335. private static _VERTICAL_ALIGNMENT_CENTER;
  57336. /** HORIZONTAL_ALIGNMENT_LEFT */
  57337. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  57338. /** HORIZONTAL_ALIGNMENT_RIGHT */
  57339. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  57340. /** HORIZONTAL_ALIGNMENT_CENTER */
  57341. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  57342. /** VERTICAL_ALIGNMENT_TOP */
  57343. static readonly VERTICAL_ALIGNMENT_TOP: number;
  57344. /** VERTICAL_ALIGNMENT_BOTTOM */
  57345. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  57346. /** VERTICAL_ALIGNMENT_CENTER */
  57347. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  57348. private static _FontHeightSizes;
  57349. /** @hidden */ private static _GetFontOffset(font: string): {
  57350. ascent: number;
  57351. height: number;
  57352. descent: number;
  57353. };
  57354. /**
  57355. * Creates a stack panel that can be used to render headers
  57356. * @param control defines the control to associate with the header
  57357. * @param text defines the text of the header
  57358. * @param size defines the size of the header
  57359. * @param options defines options used to configure the header
  57360. * @returns a new StackPanel
  57361. * @ignore
  57362. * @hidden
  57363. */
  57364. static AddHeader: (control: Control, text: string, size: string | number, options: {
  57365. isHorizontal: boolean;
  57366. controlFirst: boolean;
  57367. }) => any;
  57368. /** @hidden */
  57369. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  57370. }
  57371. }
  57372. declare module BABYLON.GUI {
  57373. /**
  57374. * Root class for 2D containers
  57375. * @see http://doc.babylonjs.com/how_to/gui#containers
  57376. */
  57377. export class Container extends Control {
  57378. name?: string | undefined;
  57379. /** @hidden */
  57380. protected _children: Control[];
  57381. /** @hidden */
  57382. protected _measureForChildren: Measure;
  57383. /** @hidden */
  57384. protected _background: string;
  57385. /** @hidden */
  57386. protected _adaptWidthToChildren: boolean;
  57387. /** @hidden */
  57388. protected _adaptHeightToChildren: boolean;
  57389. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  57390. adaptHeightToChildren: boolean;
  57391. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  57392. adaptWidthToChildren: boolean;
  57393. /** Gets or sets background color */
  57394. background: string;
  57395. /** Gets the list of children */
  57396. readonly children: Control[];
  57397. /**
  57398. * Creates a new Container
  57399. * @param name defines the name of the container
  57400. */
  57401. constructor(name?: string | undefined);
  57402. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  57403. /**
  57404. * Gets a child using its name
  57405. * @param name defines the child name to look for
  57406. * @returns the child control if found
  57407. */
  57408. getChildByName(name: string): BABYLON.Nullable<Control>;
  57409. /**
  57410. * Gets a child using its type and its name
  57411. * @param name defines the child name to look for
  57412. * @param type defines the child type to look for
  57413. * @returns the child control if found
  57414. */
  57415. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  57416. /**
  57417. * Search for a specific control in children
  57418. * @param control defines the control to look for
  57419. * @returns true if the control is in child list
  57420. */
  57421. containsControl(control: Control): boolean;
  57422. /**
  57423. * Adds a new control to the current container
  57424. * @param control defines the control to add
  57425. * @returns the current container
  57426. */
  57427. addControl(control: BABYLON.Nullable<Control>): Container;
  57428. /**
  57429. * Removes all controls from the current container
  57430. * @returns the current container
  57431. */
  57432. clearControls(): Container;
  57433. /**
  57434. * Removes a control from the current container
  57435. * @param control defines the control to remove
  57436. * @returns the current container
  57437. */
  57438. removeControl(control: Control): Container;
  57439. /** @hidden */ reOrderControl(control: Control): void;
  57440. /** @hidden */ offsetLeft(offset: number): void;
  57441. /** @hidden */ offsetTop(offset: number): void;
  57442. /** @hidden */ markAllAsDirty(): void;
  57443. /** @hidden */
  57444. protected _localDraw(context: CanvasRenderingContext2D): void;
  57445. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  57446. /** @hidden */
  57447. protected _beforeLayout(): void;
  57448. /** @hidden */
  57449. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57450. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  57451. protected _postMeasure(): void;
  57452. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  57453. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  57454. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57455. /** @hidden */
  57456. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57457. /** Releases associated resources */
  57458. dispose(): void;
  57459. }
  57460. }
  57461. declare module BABYLON.GUI {
  57462. /** Class used to create rectangle container */
  57463. export class Rectangle extends Container {
  57464. name?: string | undefined;
  57465. private _thickness;
  57466. private _cornerRadius;
  57467. /** Gets or sets border thickness */
  57468. thickness: number;
  57469. /** Gets or sets the corner radius angle */
  57470. cornerRadius: number;
  57471. /**
  57472. * Creates a new Rectangle
  57473. * @param name defines the control name
  57474. */
  57475. constructor(name?: string | undefined);
  57476. protected _getTypeName(): string;
  57477. protected _localDraw(context: CanvasRenderingContext2D): void;
  57478. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57479. private _drawRoundedRect;
  57480. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57481. }
  57482. }
  57483. declare module BABYLON.GUI {
  57484. /**
  57485. * Enum that determines the text-wrapping mode to use.
  57486. */
  57487. export enum TextWrapping {
  57488. /**
  57489. * Clip the text when it's larger than Control.width; this is the default mode.
  57490. */
  57491. Clip = 0,
  57492. /**
  57493. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  57494. */
  57495. WordWrap = 1,
  57496. /**
  57497. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  57498. */
  57499. Ellipsis = 2
  57500. }
  57501. /**
  57502. * Class used to create text block control
  57503. */
  57504. export class TextBlock extends Control {
  57505. /**
  57506. * Defines the name of the control
  57507. */
  57508. name?: string | undefined;
  57509. private _text;
  57510. private _textWrapping;
  57511. private _textHorizontalAlignment;
  57512. private _textVerticalAlignment;
  57513. private _lines;
  57514. private _resizeToFit;
  57515. private _lineSpacing;
  57516. private _outlineWidth;
  57517. private _outlineColor;
  57518. /**
  57519. * An event triggered after the text is changed
  57520. */
  57521. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  57522. /**
  57523. * An event triggered after the text was broken up into lines
  57524. */
  57525. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  57526. /**
  57527. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  57528. */
  57529. readonly lines: any[];
  57530. /**
  57531. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57532. */
  57533. /**
  57534. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  57535. */
  57536. resizeToFit: boolean;
  57537. /**
  57538. * Gets or sets a boolean indicating if text must be wrapped
  57539. */
  57540. /**
  57541. * Gets or sets a boolean indicating if text must be wrapped
  57542. */
  57543. textWrapping: TextWrapping | boolean;
  57544. /**
  57545. * Gets or sets text to display
  57546. */
  57547. /**
  57548. * Gets or sets text to display
  57549. */
  57550. text: string;
  57551. /**
  57552. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57553. */
  57554. /**
  57555. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  57556. */
  57557. textHorizontalAlignment: number;
  57558. /**
  57559. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57560. */
  57561. /**
  57562. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  57563. */
  57564. textVerticalAlignment: number;
  57565. /**
  57566. * Gets or sets line spacing value
  57567. */
  57568. /**
  57569. * Gets or sets line spacing value
  57570. */
  57571. lineSpacing: string | number;
  57572. /**
  57573. * Gets or sets outlineWidth of the text to display
  57574. */
  57575. /**
  57576. * Gets or sets outlineWidth of the text to display
  57577. */
  57578. outlineWidth: number;
  57579. /**
  57580. * Gets or sets outlineColor of the text to display
  57581. */
  57582. /**
  57583. * Gets or sets outlineColor of the text to display
  57584. */
  57585. outlineColor: string;
  57586. /**
  57587. * Creates a new TextBlock object
  57588. * @param name defines the name of the control
  57589. * @param text defines the text to display (emptry string by default)
  57590. */
  57591. constructor(
  57592. /**
  57593. * Defines the name of the control
  57594. */
  57595. name?: string | undefined, text?: string);
  57596. protected _getTypeName(): string;
  57597. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57598. private _drawText;
  57599. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57600. protected _applyStates(context: CanvasRenderingContext2D): void;
  57601. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  57602. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  57603. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  57604. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  57605. protected _renderLines(context: CanvasRenderingContext2D): void;
  57606. /**
  57607. * Given a width constraint applied on the text block, find the expected height
  57608. * @returns expected height
  57609. */
  57610. computeExpectedHeight(): number;
  57611. dispose(): void;
  57612. }
  57613. }
  57614. declare module BABYLON.GUI {
  57615. /**
  57616. * Class used to create 2D images
  57617. */
  57618. export class Image extends Control {
  57619. name?: string | undefined;
  57620. private static _WorkingCanvas;
  57621. private _domImage;
  57622. private _imageWidth;
  57623. private _imageHeight;
  57624. private _loaded;
  57625. private _stretch;
  57626. private _source;
  57627. private _autoScale;
  57628. private _sourceLeft;
  57629. private _sourceTop;
  57630. private _sourceWidth;
  57631. private _sourceHeight;
  57632. private _cellWidth;
  57633. private _cellHeight;
  57634. private _cellId;
  57635. private _populateNinePatchSlicesFromImage;
  57636. private _sliceLeft;
  57637. private _sliceRight;
  57638. private _sliceTop;
  57639. private _sliceBottom;
  57640. private _detectPointerOnOpaqueOnly;
  57641. /**
  57642. * BABYLON.Observable notified when the content is loaded
  57643. */
  57644. onImageLoadedObservable: BABYLON.Observable<Image>;
  57645. /**
  57646. * Gets a boolean indicating that the content is loaded
  57647. */
  57648. readonly isLoaded: boolean;
  57649. /**
  57650. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  57651. */
  57652. populateNinePatchSlicesFromImage: boolean;
  57653. /**
  57654. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  57655. * Beware using this as this will comsume more memory as the image has to be stored twice
  57656. */
  57657. detectPointerOnOpaqueOnly: boolean;
  57658. /**
  57659. * Gets or sets the left value for slicing (9-patch)
  57660. */
  57661. sliceLeft: number;
  57662. /**
  57663. * Gets or sets the right value for slicing (9-patch)
  57664. */
  57665. sliceRight: number;
  57666. /**
  57667. * Gets or sets the top value for slicing (9-patch)
  57668. */
  57669. sliceTop: number;
  57670. /**
  57671. * Gets or sets the bottom value for slicing (9-patch)
  57672. */
  57673. sliceBottom: number;
  57674. /**
  57675. * Gets or sets the left coordinate in the source image
  57676. */
  57677. sourceLeft: number;
  57678. /**
  57679. * Gets or sets the top coordinate in the source image
  57680. */
  57681. sourceTop: number;
  57682. /**
  57683. * Gets or sets the width to capture in the source image
  57684. */
  57685. sourceWidth: number;
  57686. /**
  57687. * Gets or sets the height to capture in the source image
  57688. */
  57689. sourceHeight: number;
  57690. /**
  57691. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57692. * @see http://doc.babylonjs.com/how_to/gui#image
  57693. */
  57694. autoScale: boolean;
  57695. /** Gets or sets the streching mode used by the image */
  57696. stretch: number;
  57697. /**
  57698. * Gets or sets the internal DOM image used to render the control
  57699. */
  57700. domImage: HTMLImageElement;
  57701. private _onImageLoaded;
  57702. private _extractNinePatchSliceDataFromImage;
  57703. /**
  57704. * Gets or sets image source url
  57705. */
  57706. source: BABYLON.Nullable<string>;
  57707. /**
  57708. * Gets or sets the cell width to use when animation sheet is enabled
  57709. * @see http://doc.babylonjs.com/how_to/gui#image
  57710. */
  57711. cellWidth: number;
  57712. /**
  57713. * Gets or sets the cell height to use when animation sheet is enabled
  57714. * @see http://doc.babylonjs.com/how_to/gui#image
  57715. */
  57716. cellHeight: number;
  57717. /**
  57718. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57719. * @see http://doc.babylonjs.com/how_to/gui#image
  57720. */
  57721. cellId: number;
  57722. /**
  57723. * Creates a new Image
  57724. * @param name defines the control name
  57725. * @param url defines the image url
  57726. */
  57727. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57728. /**
  57729. * Tests if a given coordinates belong to the current control
  57730. * @param x defines x coordinate to test
  57731. * @param y defines y coordinate to test
  57732. * @returns true if the coordinates are inside the control
  57733. */
  57734. contains(x: number, y: number): boolean;
  57735. protected _getTypeName(): string;
  57736. /** Force the control to synchronize with its content */
  57737. synchronizeSizeWithContent(): void;
  57738. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57739. private _prepareWorkingCanvasForOpaqueDetection;
  57740. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57741. private _renderCornerPatch;
  57742. private _renderNinePatch;
  57743. dispose(): void;
  57744. /** STRETCH_NONE */
  57745. static readonly STRETCH_NONE: number;
  57746. /** STRETCH_FILL */
  57747. static readonly STRETCH_FILL: number;
  57748. /** STRETCH_UNIFORM */
  57749. static readonly STRETCH_UNIFORM: number;
  57750. /** STRETCH_EXTEND */
  57751. static readonly STRETCH_EXTEND: number;
  57752. /** NINE_PATCH */
  57753. static readonly STRETCH_NINE_PATCH: number;
  57754. }
  57755. }
  57756. declare module BABYLON.GUI {
  57757. /**
  57758. * Class used to create 2D buttons
  57759. */
  57760. export class Button extends Rectangle {
  57761. name?: string | undefined;
  57762. /**
  57763. * Function called to generate a pointer enter animation
  57764. */
  57765. pointerEnterAnimation: () => void;
  57766. /**
  57767. * Function called to generate a pointer out animation
  57768. */
  57769. pointerOutAnimation: () => void;
  57770. /**
  57771. * Function called to generate a pointer down animation
  57772. */
  57773. pointerDownAnimation: () => void;
  57774. /**
  57775. * Function called to generate a pointer up animation
  57776. */
  57777. pointerUpAnimation: () => void;
  57778. private _image;
  57779. /**
  57780. * Returns the image part of the button (if any)
  57781. */
  57782. readonly image: BABYLON.Nullable<Image>;
  57783. private _textBlock;
  57784. /**
  57785. * Returns the image part of the button (if any)
  57786. */
  57787. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57788. /**
  57789. * Creates a new Button
  57790. * @param name defines the name of the button
  57791. */
  57792. constructor(name?: string | undefined);
  57793. protected _getTypeName(): string;
  57794. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57795. /** @hidden */ onPointerEnter(target: Control): boolean;
  57796. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57797. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57798. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57799. /**
  57800. * Creates a new button made with an image and a text
  57801. * @param name defines the name of the button
  57802. * @param text defines the text of the button
  57803. * @param imageUrl defines the url of the image
  57804. * @returns a new Button
  57805. */
  57806. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57807. /**
  57808. * Creates a new button made with an image
  57809. * @param name defines the name of the button
  57810. * @param imageUrl defines the url of the image
  57811. * @returns a new Button
  57812. */
  57813. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57814. /**
  57815. * Creates a new button made with a text
  57816. * @param name defines the name of the button
  57817. * @param text defines the text of the button
  57818. * @returns a new Button
  57819. */
  57820. static CreateSimpleButton(name: string, text: string): Button;
  57821. /**
  57822. * Creates a new button made with an image and a centered text
  57823. * @param name defines the name of the button
  57824. * @param text defines the text of the button
  57825. * @param imageUrl defines the url of the image
  57826. * @returns a new Button
  57827. */
  57828. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57829. }
  57830. }
  57831. declare module BABYLON.GUI {
  57832. /**
  57833. * Class used to create a 2D stack panel container
  57834. */
  57835. export class StackPanel extends Container {
  57836. name?: string | undefined;
  57837. private _isVertical;
  57838. private _manualWidth;
  57839. private _manualHeight;
  57840. private _doNotTrackManualChanges;
  57841. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57842. isVertical: boolean;
  57843. /**
  57844. * Gets or sets panel width.
  57845. * This value should not be set when in horizontal mode as it will be computed automatically
  57846. */
  57847. width: string | number;
  57848. /**
  57849. * Gets or sets panel height.
  57850. * This value should not be set when in vertical mode as it will be computed automatically
  57851. */
  57852. height: string | number;
  57853. /**
  57854. * Creates a new StackPanel
  57855. * @param name defines control name
  57856. */
  57857. constructor(name?: string | undefined);
  57858. protected _getTypeName(): string;
  57859. /** @hidden */
  57860. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57861. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57862. protected _postMeasure(): void;
  57863. }
  57864. }
  57865. declare module BABYLON.GUI {
  57866. /**
  57867. * Class used to represent a 2D checkbox
  57868. */
  57869. export class Checkbox extends Control {
  57870. name?: string | undefined;
  57871. private _isChecked;
  57872. private _background;
  57873. private _checkSizeRatio;
  57874. private _thickness;
  57875. /** Gets or sets border thickness */
  57876. thickness: number;
  57877. /**
  57878. * BABYLON.Observable raised when isChecked property changes
  57879. */
  57880. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57881. /** Gets or sets a value indicating the ratio between overall size and check size */
  57882. checkSizeRatio: number;
  57883. /** Gets or sets background color */
  57884. background: string;
  57885. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57886. isChecked: boolean;
  57887. /**
  57888. * Creates a new CheckBox
  57889. * @param name defines the control name
  57890. */
  57891. constructor(name?: string | undefined);
  57892. protected _getTypeName(): string;
  57893. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57894. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57895. /**
  57896. * Utility function to easily create a checkbox with a header
  57897. * @param title defines the label to use for the header
  57898. * @param onValueChanged defines the callback to call when value changes
  57899. * @returns a StackPanel containing the checkbox and a textBlock
  57900. */
  57901. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57902. }
  57903. }
  57904. declare module BABYLON.GUI {
  57905. /**
  57906. * Class used to store key control properties
  57907. */
  57908. export class KeyPropertySet {
  57909. /** Width */
  57910. width?: string;
  57911. /** Height */
  57912. height?: string;
  57913. /** Left padding */
  57914. paddingLeft?: string;
  57915. /** Right padding */
  57916. paddingRight?: string;
  57917. /** Top padding */
  57918. paddingTop?: string;
  57919. /** Bottom padding */
  57920. paddingBottom?: string;
  57921. /** Foreground color */
  57922. color?: string;
  57923. /** Background color */
  57924. background?: string;
  57925. }
  57926. /**
  57927. * Class used to create virtual keyboard
  57928. */
  57929. export class VirtualKeyboard extends StackPanel {
  57930. /** BABYLON.Observable raised when a key is pressed */
  57931. onKeyPressObservable: BABYLON.Observable<string>;
  57932. /** Gets or sets default key button width */
  57933. defaultButtonWidth: string;
  57934. /** Gets or sets default key button height */
  57935. defaultButtonHeight: string;
  57936. /** Gets or sets default key button left padding */
  57937. defaultButtonPaddingLeft: string;
  57938. /** Gets or sets default key button right padding */
  57939. defaultButtonPaddingRight: string;
  57940. /** Gets or sets default key button top padding */
  57941. defaultButtonPaddingTop: string;
  57942. /** Gets or sets default key button bottom padding */
  57943. defaultButtonPaddingBottom: string;
  57944. /** Gets or sets default key button foreground color */
  57945. defaultButtonColor: string;
  57946. /** Gets or sets default key button background color */
  57947. defaultButtonBackground: string;
  57948. /** Gets or sets shift button foreground color */
  57949. shiftButtonColor: string;
  57950. /** Gets or sets shift button thickness*/
  57951. selectedShiftThickness: number;
  57952. /** Gets shift key state */
  57953. shiftState: number;
  57954. protected _getTypeName(): string;
  57955. private _createKey;
  57956. /**
  57957. * Adds a new row of keys
  57958. * @param keys defines the list of keys to add
  57959. * @param propertySets defines the associated property sets
  57960. */
  57961. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57962. /**
  57963. * Set the shift key to a specific state
  57964. * @param shiftState defines the new shift state
  57965. */
  57966. applyShiftState(shiftState: number): void;
  57967. private _currentlyConnectedInputText;
  57968. private _connectedInputTexts;
  57969. private _onKeyPressObserver;
  57970. /** Gets the input text control currently attached to the keyboard */
  57971. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57972. /**
  57973. * Connects the keyboard with an input text control
  57974. *
  57975. * @param input defines the target control
  57976. */
  57977. connect(input: InputText): void;
  57978. /**
  57979. * Disconnects the keyboard from connected InputText controls
  57980. *
  57981. * @param input optionally defines a target control, otherwise all are disconnected
  57982. */
  57983. disconnect(input?: InputText): void;
  57984. private _removeConnectedInputObservables;
  57985. /**
  57986. * Release all resources
  57987. */
  57988. dispose(): void;
  57989. /**
  57990. * Creates a new keyboard using a default layout
  57991. *
  57992. * @param name defines control name
  57993. * @returns a new VirtualKeyboard
  57994. */
  57995. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57996. }
  57997. }
  57998. declare module BABYLON.GUI {
  57999. /**
  58000. * Class used to create input text control
  58001. */
  58002. export class InputText extends Control implements IFocusableControl {
  58003. name?: string | undefined;
  58004. private _text;
  58005. private _placeholderText;
  58006. private _background;
  58007. private _focusedBackground;
  58008. private _focusedColor;
  58009. private _placeholderColor;
  58010. private _thickness;
  58011. private _margin;
  58012. private _autoStretchWidth;
  58013. private _maxWidth;
  58014. private _isFocused;
  58015. private _blinkTimeout;
  58016. private _blinkIsEven;
  58017. private _cursorOffset;
  58018. private _scrollLeft;
  58019. private _textWidth;
  58020. private _clickedCoordinate;
  58021. private _deadKey;
  58022. private _addKey;
  58023. private _currentKey;
  58024. private _isTextHighlightOn;
  58025. private _textHighlightColor;
  58026. private _highligherOpacity;
  58027. private _highlightedText;
  58028. private _startHighlightIndex;
  58029. private _endHighlightIndex;
  58030. private _cursorIndex;
  58031. private _onFocusSelectAll;
  58032. private _isPointerDown;
  58033. private _onClipboardObserver;
  58034. private _onPointerDblTapObserver;
  58035. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  58036. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  58037. promptMessage: string;
  58038. /** BABYLON.Observable raised when the text changes */
  58039. onTextChangedObservable: BABYLON.Observable<InputText>;
  58040. /** BABYLON.Observable raised just before an entered character is to be added */
  58041. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  58042. /** BABYLON.Observable raised when the control gets the focus */
  58043. onFocusObservable: BABYLON.Observable<InputText>;
  58044. /** BABYLON.Observable raised when the control loses the focus */
  58045. onBlurObservable: BABYLON.Observable<InputText>;
  58046. /**Observable raised when the text is highlighted */
  58047. onTextHighlightObservable: BABYLON.Observable<InputText>;
  58048. /**Observable raised when copy event is triggered */
  58049. onTextCopyObservable: BABYLON.Observable<InputText>;
  58050. /** BABYLON.Observable raised when cut event is triggered */
  58051. onTextCutObservable: BABYLON.Observable<InputText>;
  58052. /** BABYLON.Observable raised when paste event is triggered */
  58053. onTextPasteObservable: BABYLON.Observable<InputText>;
  58054. /** BABYLON.Observable raised when a key event was processed */
  58055. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  58056. /** Gets or sets the maximum width allowed by the control */
  58057. maxWidth: string | number;
  58058. /** Gets the maximum width allowed by the control in pixels */
  58059. readonly maxWidthInPixels: number;
  58060. /** Gets or sets the text highlighter transparency; default: 0.4 */
  58061. highligherOpacity: number;
  58062. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  58063. onFocusSelectAll: boolean;
  58064. /** Gets or sets the text hightlight color */
  58065. textHighlightColor: string;
  58066. /** Gets or sets control margin */
  58067. margin: string;
  58068. /** Gets control margin in pixels */
  58069. readonly marginInPixels: number;
  58070. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  58071. autoStretchWidth: boolean;
  58072. /** Gets or sets border thickness */
  58073. thickness: number;
  58074. /** Gets or sets the background color when focused */
  58075. focusedBackground: string;
  58076. /** Gets or sets the background color when focused */
  58077. focusedColor: string;
  58078. /** Gets or sets the background color */
  58079. background: string;
  58080. /** Gets or sets the placeholder color */
  58081. placeholderColor: string;
  58082. /** Gets or sets the text displayed when the control is empty */
  58083. placeholderText: string;
  58084. /** Gets or sets the dead key flag */
  58085. deadKey: boolean;
  58086. /** Gets or sets the highlight text */
  58087. highlightedText: string;
  58088. /** Gets or sets if the current key should be added */
  58089. addKey: boolean;
  58090. /** Gets or sets the value of the current key being entered */
  58091. currentKey: string;
  58092. /** Gets or sets the text displayed in the control */
  58093. text: string;
  58094. /** Gets or sets control width */
  58095. width: string | number;
  58096. /**
  58097. * Creates a new InputText
  58098. * @param name defines the control name
  58099. * @param text defines the text of the control
  58100. */
  58101. constructor(name?: string | undefined, text?: string);
  58102. /** @hidden */
  58103. onBlur(): void;
  58104. /** @hidden */
  58105. onFocus(): void;
  58106. protected _getTypeName(): string;
  58107. /**
  58108. * Function called to get the list of controls that should not steal the focus from this control
  58109. * @returns an array of controls
  58110. */
  58111. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  58112. /** @hidden */
  58113. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  58114. /** @hidden */
  58115. private _updateValueFromCursorIndex;
  58116. /** @hidden */
  58117. private _processDblClick;
  58118. /** @hidden */
  58119. private _selectAllText;
  58120. /**
  58121. * Handles the keyboard event
  58122. * @param evt Defines the KeyboardEvent
  58123. */
  58124. processKeyboard(evt: KeyboardEvent): void;
  58125. /** @hidden */
  58126. private _onCopyText;
  58127. /** @hidden */
  58128. private _onCutText;
  58129. /** @hidden */
  58130. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58131. protected _beforeRenderText(text: string): string;
  58132. dispose(): void;
  58133. }
  58134. }
  58135. declare module BABYLON.GUI {
  58136. /**
  58137. * Class used to create a 2D grid container
  58138. */
  58139. export class Grid extends Container {
  58140. name?: string | undefined;
  58141. private _rowDefinitions;
  58142. private _columnDefinitions;
  58143. private _cells;
  58144. private _childControls;
  58145. /**
  58146. * Gets the number of columns
  58147. */
  58148. readonly columnCount: number;
  58149. /**
  58150. * Gets the number of rows
  58151. */
  58152. readonly rowCount: number;
  58153. /** Gets the list of children */
  58154. readonly children: Control[];
  58155. /**
  58156. * Gets the definition of a specific row
  58157. * @param index defines the index of the row
  58158. * @returns the row definition
  58159. */
  58160. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58161. /**
  58162. * Gets the definition of a specific column
  58163. * @param index defines the index of the column
  58164. * @returns the column definition
  58165. */
  58166. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  58167. /**
  58168. * Adds a new row to the grid
  58169. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58170. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  58171. * @returns the current grid
  58172. */
  58173. addRowDefinition(height: number, isPixel?: boolean): Grid;
  58174. /**
  58175. * Adds a new column to the grid
  58176. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58177. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58178. * @returns the current grid
  58179. */
  58180. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  58181. /**
  58182. * Update a row definition
  58183. * @param index defines the index of the row to update
  58184. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  58185. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  58186. * @returns the current grid
  58187. */
  58188. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  58189. /**
  58190. * Update a column definition
  58191. * @param index defines the index of the column to update
  58192. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  58193. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  58194. * @returns the current grid
  58195. */
  58196. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  58197. /**
  58198. * Gets the list of children stored in a specific cell
  58199. * @param row defines the row to check
  58200. * @param column defines the column to check
  58201. * @returns the list of controls
  58202. */
  58203. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  58204. /**
  58205. * Gets a string representing the child cell info (row x column)
  58206. * @param child defines the control to get info from
  58207. * @returns a string containing the child cell info (row x column)
  58208. */
  58209. getChildCellInfo(child: Control): string;
  58210. private _removeCell;
  58211. private _offsetCell;
  58212. /**
  58213. * Remove a column definition at specified index
  58214. * @param index defines the index of the column to remove
  58215. * @returns the current grid
  58216. */
  58217. removeColumnDefinition(index: number): Grid;
  58218. /**
  58219. * Remove a row definition at specified index
  58220. * @param index defines the index of the row to remove
  58221. * @returns the current grid
  58222. */
  58223. removeRowDefinition(index: number): Grid;
  58224. /**
  58225. * Adds a new control to the current grid
  58226. * @param control defines the control to add
  58227. * @param row defines the row where to add the control (0 by default)
  58228. * @param column defines the column where to add the control (0 by default)
  58229. * @returns the current grid
  58230. */
  58231. addControl(control: Control, row?: number, column?: number): Grid;
  58232. /**
  58233. * Removes a control from the current container
  58234. * @param control defines the control to remove
  58235. * @returns the current container
  58236. */
  58237. removeControl(control: Control): Container;
  58238. /**
  58239. * Creates a new Grid
  58240. * @param name defines control name
  58241. */
  58242. constructor(name?: string | undefined);
  58243. protected _getTypeName(): string;
  58244. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  58245. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58246. /** Releases associated resources */
  58247. dispose(): void;
  58248. }
  58249. }
  58250. declare module BABYLON.GUI {
  58251. /** Class used to create color pickers */
  58252. export class ColorPicker extends Control {
  58253. name?: string | undefined;
  58254. private static _Epsilon;
  58255. private _colorWheelCanvas;
  58256. private _value;
  58257. private _tmpColor;
  58258. private _pointerStartedOnSquare;
  58259. private _pointerStartedOnWheel;
  58260. private _squareLeft;
  58261. private _squareTop;
  58262. private _squareSize;
  58263. private _h;
  58264. private _s;
  58265. private _v;
  58266. private _lastPointerDownID;
  58267. /**
  58268. * BABYLON.Observable raised when the value changes
  58269. */
  58270. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  58271. /** Gets or sets the color of the color picker */
  58272. value: BABYLON.Color3;
  58273. /**
  58274. * Gets or sets control width
  58275. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58276. */
  58277. width: string | number;
  58278. /**
  58279. * Gets or sets control height
  58280. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58281. */
  58282. /** Gets or sets control height */
  58283. height: string | number;
  58284. /** Gets or sets control size */
  58285. size: string | number;
  58286. /**
  58287. * Creates a new ColorPicker
  58288. * @param name defines the control name
  58289. */
  58290. constructor(name?: string | undefined);
  58291. protected _getTypeName(): string;
  58292. /** @hidden */
  58293. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58294. private _updateSquareProps;
  58295. private _drawGradientSquare;
  58296. private _drawCircle;
  58297. private _createColorWheelCanvas;
  58298. private _RGBtoHSV;
  58299. private _HSVtoRGB;
  58300. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  58301. private _pointerIsDown;
  58302. private _updateValueFromPointer;
  58303. private _isPointOnSquare;
  58304. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58305. /**
  58306. * This function expands the color picker by creating a color picker dialog with manual
  58307. * color value input and the ability to save colors into an array to be used later in
  58308. * subsequent launches of the dialogue.
  58309. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  58310. * @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.
  58311. * @returns picked color as a hex string and the saved colors array as hex strings.
  58312. */
  58313. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  58314. pickerWidth?: string;
  58315. pickerHeight?: string;
  58316. headerHeight?: string;
  58317. lastColor?: string;
  58318. swatchLimit?: number;
  58319. numSwatchesPerLine?: number;
  58320. savedColors?: Array<string>;
  58321. }): Promise<{
  58322. savedColors?: string[];
  58323. pickedColor: string;
  58324. }>;
  58325. }
  58326. }
  58327. declare module BABYLON.GUI {
  58328. /** Class used to create 2D ellipse containers */
  58329. export class Ellipse extends Container {
  58330. name?: string | undefined;
  58331. private _thickness;
  58332. /** Gets or sets border thickness */
  58333. thickness: number;
  58334. /**
  58335. * Creates a new Ellipse
  58336. * @param name defines the control name
  58337. */
  58338. constructor(name?: string | undefined);
  58339. protected _getTypeName(): string;
  58340. protected _localDraw(context: CanvasRenderingContext2D): void;
  58341. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58342. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  58343. }
  58344. }
  58345. declare module BABYLON.GUI {
  58346. /**
  58347. * Class used to create a password control
  58348. */
  58349. export class InputPassword extends InputText {
  58350. protected _beforeRenderText(text: string): string;
  58351. }
  58352. }
  58353. declare module BABYLON.GUI {
  58354. /** Class used to render 2D lines */
  58355. export class Line extends Control {
  58356. name?: string | undefined;
  58357. private _lineWidth;
  58358. private _x1;
  58359. private _y1;
  58360. private _x2;
  58361. private _y2;
  58362. private _dash;
  58363. private _connectedControl;
  58364. private _connectedControlDirtyObserver;
  58365. /** Gets or sets the dash pattern */
  58366. dash: Array<number>;
  58367. /** Gets or sets the control connected with the line end */
  58368. connectedControl: Control;
  58369. /** Gets or sets start coordinates on X axis */
  58370. x1: string | number;
  58371. /** Gets or sets start coordinates on Y axis */
  58372. y1: string | number;
  58373. /** Gets or sets end coordinates on X axis */
  58374. x2: string | number;
  58375. /** Gets or sets end coordinates on Y axis */
  58376. y2: string | number;
  58377. /** Gets or sets line width */
  58378. lineWidth: number;
  58379. /** Gets or sets horizontal alignment */
  58380. horizontalAlignment: number;
  58381. /** Gets or sets vertical alignment */
  58382. verticalAlignment: number;
  58383. private readonly _effectiveX2;
  58384. private readonly _effectiveY2;
  58385. /**
  58386. * Creates a new Line
  58387. * @param name defines the control name
  58388. */
  58389. constructor(name?: string | undefined);
  58390. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  58391. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58392. /**
  58393. * Move one end of the line given 3D cartesian coordinates.
  58394. * @param position Targeted world position
  58395. * @param scene BABYLON.Scene
  58396. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58397. */
  58398. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  58399. /**
  58400. * Move one end of the line to a position in screen absolute space.
  58401. * @param projectedPosition Position in screen absolute space (X, Y)
  58402. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  58403. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  58404. }
  58405. }
  58406. declare module BABYLON.GUI {
  58407. /**
  58408. * Class used to store a point for a MultiLine object.
  58409. * The point can be pure 2D coordinates, a mesh or a control
  58410. */
  58411. export class MultiLinePoint {
  58412. private _multiLine;
  58413. private _x;
  58414. private _y;
  58415. private _control;
  58416. private _mesh;
  58417. private _controlObserver;
  58418. private _meshObserver;
  58419. /** @hidden */ point: BABYLON.Vector2;
  58420. /**
  58421. * Creates a new MultiLinePoint
  58422. * @param multiLine defines the source MultiLine object
  58423. */
  58424. constructor(multiLine: MultiLine);
  58425. /** Gets or sets x coordinate */
  58426. x: string | number;
  58427. /** Gets or sets y coordinate */
  58428. y: string | number;
  58429. /** Gets or sets the control associated with this point */
  58430. control: BABYLON.Nullable<Control>;
  58431. /** Gets or sets the mesh associated with this point */
  58432. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58433. /** Resets links */
  58434. resetLinks(): void;
  58435. /**
  58436. * Gets a translation vector
  58437. * @returns the translation vector
  58438. */
  58439. translate(): BABYLON.Vector2;
  58440. private _translatePoint;
  58441. /** Release associated resources */
  58442. dispose(): void;
  58443. }
  58444. }
  58445. declare module BABYLON.GUI {
  58446. /**
  58447. * Class used to create multi line control
  58448. */
  58449. export class MultiLine extends Control {
  58450. name?: string | undefined;
  58451. private _lineWidth;
  58452. private _dash;
  58453. private _points;
  58454. private _minX;
  58455. private _minY;
  58456. private _maxX;
  58457. private _maxY;
  58458. /**
  58459. * Creates a new MultiLine
  58460. * @param name defines the control name
  58461. */
  58462. constructor(name?: string | undefined);
  58463. /** Gets or sets dash pattern */
  58464. dash: Array<number>;
  58465. /**
  58466. * Gets point stored at specified index
  58467. * @param index defines the index to look for
  58468. * @returns the requested point if found
  58469. */
  58470. getAt(index: number): MultiLinePoint;
  58471. /** Function called when a point is updated */
  58472. onPointUpdate: () => void;
  58473. /**
  58474. * Adds new points to the point collection
  58475. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  58476. * @returns the list of created MultiLinePoint
  58477. */
  58478. add(...items: (AbstractMesh | Control | {
  58479. x: string | number;
  58480. y: string | number;
  58481. })[]): MultiLinePoint[];
  58482. /**
  58483. * Adds a new point to the point collection
  58484. * @param item defines the item (mesh, control or 2d coordiantes) to add
  58485. * @returns the created MultiLinePoint
  58486. */
  58487. push(item?: (AbstractMesh | Control | {
  58488. x: string | number;
  58489. y: string | number;
  58490. })): MultiLinePoint;
  58491. /**
  58492. * Remove a specific value or point from the active point collection
  58493. * @param value defines the value or point to remove
  58494. */
  58495. remove(value: number | MultiLinePoint): void;
  58496. /**
  58497. * Resets this object to initial state (no point)
  58498. */
  58499. reset(): void;
  58500. /**
  58501. * Resets all links
  58502. */
  58503. resetLinks(): void;
  58504. /** Gets or sets line width */
  58505. lineWidth: number;
  58506. horizontalAlignment: number;
  58507. verticalAlignment: number;
  58508. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58509. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  58510. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58511. dispose(): void;
  58512. }
  58513. }
  58514. declare module BABYLON.GUI {
  58515. /**
  58516. * Class used to create radio button controls
  58517. */
  58518. export class RadioButton extends Control {
  58519. name?: string | undefined;
  58520. private _isChecked;
  58521. private _background;
  58522. private _checkSizeRatio;
  58523. private _thickness;
  58524. /** Gets or sets border thickness */
  58525. thickness: number;
  58526. /** Gets or sets group name */
  58527. group: string;
  58528. /** BABYLON.Observable raised when isChecked is changed */
  58529. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  58530. /** Gets or sets a value indicating the ratio between overall size and check size */
  58531. checkSizeRatio: number;
  58532. /** Gets or sets background color */
  58533. background: string;
  58534. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  58535. isChecked: boolean;
  58536. /**
  58537. * Creates a new RadioButton
  58538. * @param name defines the control name
  58539. */
  58540. constructor(name?: string | undefined);
  58541. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58542. /**
  58543. * Utility function to easily create a radio button with a header
  58544. * @param title defines the label to use for the header
  58545. * @param group defines the group to use for the radio button
  58546. * @param isChecked defines the initial state of the radio button
  58547. * @param onValueChanged defines the callback to call when value changes
  58548. * @returns a StackPanel containing the radio button and a textBlock
  58549. */
  58550. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  58551. }
  58552. }
  58553. declare module BABYLON.GUI {
  58554. /**
  58555. * Class used to create slider controls
  58556. */
  58557. export class BaseSlider extends Control {
  58558. name?: string | undefined;
  58559. protected _thumbWidth: ValueAndUnit;
  58560. private _minimum;
  58561. private _maximum;
  58562. private _value;
  58563. private _isVertical;
  58564. protected _barOffset: ValueAndUnit;
  58565. private _isThumbClamped;
  58566. protected _displayThumb: boolean;
  58567. private _step;
  58568. private _lastPointerDownID;
  58569. protected _effectiveBarOffset: number;
  58570. protected _renderLeft: number;
  58571. protected _renderTop: number;
  58572. protected _renderWidth: number;
  58573. protected _renderHeight: number;
  58574. protected _backgroundBoxLength: number;
  58575. protected _backgroundBoxThickness: number;
  58576. protected _effectiveThumbThickness: number;
  58577. /** BABYLON.Observable raised when the sldier value changes */
  58578. onValueChangedObservable: BABYLON.Observable<number>;
  58579. /** Gets or sets a boolean indicating if the thumb must be rendered */
  58580. displayThumb: boolean;
  58581. /** Gets or sets a step to apply to values (0 by default) */
  58582. step: number;
  58583. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  58584. barOffset: string | number;
  58585. /** Gets main bar offset in pixels*/
  58586. readonly barOffsetInPixels: number;
  58587. /** Gets or sets thumb width */
  58588. thumbWidth: string | number;
  58589. /** Gets thumb width in pixels */
  58590. readonly thumbWidthInPixels: number;
  58591. /** Gets or sets minimum value */
  58592. minimum: number;
  58593. /** Gets or sets maximum value */
  58594. maximum: number;
  58595. /** Gets or sets current value */
  58596. value: number;
  58597. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  58598. isVertical: boolean;
  58599. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  58600. isThumbClamped: boolean;
  58601. /**
  58602. * Creates a new BaseSlider
  58603. * @param name defines the control name
  58604. */
  58605. constructor(name?: string | undefined);
  58606. protected _getTypeName(): string;
  58607. protected _getThumbPosition(): number;
  58608. protected _getThumbThickness(type: string): number;
  58609. protected _prepareRenderingData(type: string): void;
  58610. private _pointerIsDown;
  58611. /** @hidden */
  58612. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58613. }
  58614. }
  58615. declare module BABYLON.GUI {
  58616. /**
  58617. * Class used to create slider controls
  58618. */
  58619. export class Slider extends BaseSlider {
  58620. name?: string | undefined;
  58621. private _background;
  58622. private _borderColor;
  58623. private _isThumbCircle;
  58624. protected _displayValueBar: boolean;
  58625. /** Gets or sets a boolean indicating if the value bar must be rendered */
  58626. displayValueBar: boolean;
  58627. /** Gets or sets border color */
  58628. borderColor: string;
  58629. /** Gets or sets background color */
  58630. background: string;
  58631. /** Gets or sets a boolean indicating if the thumb should be round or square */
  58632. isThumbCircle: boolean;
  58633. /**
  58634. * Creates a new Slider
  58635. * @param name defines the control name
  58636. */
  58637. constructor(name?: string | undefined);
  58638. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58639. }
  58640. }
  58641. declare module BABYLON.GUI {
  58642. /** Class used to create a RadioGroup
  58643. * which contains groups of radio buttons
  58644. */
  58645. export class SelectorGroup {
  58646. /** name of SelectorGroup */
  58647. name: string;
  58648. private _groupPanel;
  58649. private _selectors;
  58650. private _groupHeader;
  58651. /**
  58652. * Creates a new SelectorGroup
  58653. * @param name of group, used as a group heading
  58654. */
  58655. constructor(
  58656. /** name of SelectorGroup */
  58657. name: string);
  58658. /** Gets the groupPanel of the SelectorGroup */
  58659. readonly groupPanel: StackPanel;
  58660. /** Gets the selectors array */
  58661. readonly selectors: StackPanel[];
  58662. /** Gets and sets the group header */
  58663. header: string;
  58664. /** @hidden */
  58665. private _addGroupHeader;
  58666. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  58667. /** Removes the selector at the given position
  58668. * @param selectorNb the position of the selector within the group
  58669. */
  58670. removeSelector(selectorNb: number): void;
  58671. }
  58672. /** Class used to create a CheckboxGroup
  58673. * which contains groups of checkbox buttons
  58674. */
  58675. export class CheckboxGroup extends SelectorGroup {
  58676. /** Adds a checkbox as a control
  58677. * @param text is the label for the selector
  58678. * @param func is the function called when the Selector is checked
  58679. * @param checked is true when Selector is checked
  58680. */
  58681. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  58682. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58683. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58684. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58685. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58686. }
  58687. /** Class used to create a RadioGroup
  58688. * which contains groups of radio buttons
  58689. */
  58690. export class RadioGroup extends SelectorGroup {
  58691. private _selectNb;
  58692. /** Adds a radio button as a control
  58693. * @param label is the label for the selector
  58694. * @param func is the function called when the Selector is checked
  58695. * @param checked is true when Selector is checked
  58696. */
  58697. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58698. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58699. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58700. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58701. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58702. }
  58703. /** Class used to create a SliderGroup
  58704. * which contains groups of slider buttons
  58705. */
  58706. export class SliderGroup extends SelectorGroup {
  58707. /**
  58708. * Adds a slider to the SelectorGroup
  58709. * @param label is the label for the SliderBar
  58710. * @param func is the function called when the Slider moves
  58711. * @param unit is a string describing the units used, eg degrees or metres
  58712. * @param min is the minimum value for the Slider
  58713. * @param max is the maximum value for the Slider
  58714. * @param value is the start value for the Slider between min and max
  58715. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58716. */
  58717. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58718. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58719. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58720. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58721. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58722. }
  58723. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58724. * @see http://doc.babylonjs.com/how_to/selector
  58725. */
  58726. export class SelectionPanel extends Rectangle {
  58727. /** name of SelectionPanel */
  58728. name: string;
  58729. /** an array of SelectionGroups */
  58730. groups: SelectorGroup[];
  58731. private _panel;
  58732. private _buttonColor;
  58733. private _buttonBackground;
  58734. private _headerColor;
  58735. private _barColor;
  58736. private _barHeight;
  58737. private _spacerHeight;
  58738. private _labelColor;
  58739. private _groups;
  58740. private _bars;
  58741. /**
  58742. * Creates a new SelectionPanel
  58743. * @param name of SelectionPanel
  58744. * @param groups is an array of SelectionGroups
  58745. */
  58746. constructor(
  58747. /** name of SelectionPanel */
  58748. name: string,
  58749. /** an array of SelectionGroups */
  58750. groups?: SelectorGroup[]);
  58751. protected _getTypeName(): string;
  58752. /** Gets or sets the headerColor */
  58753. headerColor: string;
  58754. private _setHeaderColor;
  58755. /** Gets or sets the button color */
  58756. buttonColor: string;
  58757. private _setbuttonColor;
  58758. /** Gets or sets the label color */
  58759. labelColor: string;
  58760. private _setLabelColor;
  58761. /** Gets or sets the button background */
  58762. buttonBackground: string;
  58763. private _setButtonBackground;
  58764. /** Gets or sets the color of separator bar */
  58765. barColor: string;
  58766. private _setBarColor;
  58767. /** Gets or sets the height of separator bar */
  58768. barHeight: string;
  58769. private _setBarHeight;
  58770. /** Gets or sets the height of spacers*/
  58771. spacerHeight: string;
  58772. private _setSpacerHeight;
  58773. /** Adds a bar between groups */
  58774. private _addSpacer;
  58775. /** Add a group to the selection panel
  58776. * @param group is the selector group to add
  58777. */
  58778. addGroup(group: SelectorGroup): void;
  58779. /** Remove the group from the given position
  58780. * @param groupNb is the position of the group in the list
  58781. */
  58782. removeGroup(groupNb: number): void;
  58783. /** Change a group header label
  58784. * @param label is the new group header label
  58785. * @param groupNb is the number of the group to relabel
  58786. * */
  58787. setHeaderName(label: string, groupNb: number): void;
  58788. /** Change selector label to the one given
  58789. * @param label is the new selector label
  58790. * @param groupNb is the number of the groupcontaining the selector
  58791. * @param selectorNb is the number of the selector within a group to relabel
  58792. * */
  58793. relabel(label: string, groupNb: number, selectorNb: number): void;
  58794. /** For a given group position remove the selector at the given position
  58795. * @param groupNb is the number of the group to remove the selector from
  58796. * @param selectorNb is the number of the selector within the group
  58797. */
  58798. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58799. /** For a given group position of correct type add a checkbox button
  58800. * @param groupNb is the number of the group to remove the selector from
  58801. * @param label is the label for the selector
  58802. * @param func is the function called when the Selector is checked
  58803. * @param checked is true when Selector is checked
  58804. */
  58805. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58806. /** For a given group position of correct type add a radio button
  58807. * @param groupNb is the number of the group to remove the selector from
  58808. * @param label is the label for the selector
  58809. * @param func is the function called when the Selector is checked
  58810. * @param checked is true when Selector is checked
  58811. */
  58812. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58813. /**
  58814. * For a given slider group add a slider
  58815. * @param groupNb is the number of the group to add the slider to
  58816. * @param label is the label for the Slider
  58817. * @param func is the function called when the Slider moves
  58818. * @param unit is a string describing the units used, eg degrees or metres
  58819. * @param min is the minimum value for the Slider
  58820. * @param max is the maximum value for the Slider
  58821. * @param value is the start value for the Slider between min and max
  58822. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58823. */
  58824. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58825. }
  58826. }
  58827. declare module BABYLON.GUI {
  58828. /**
  58829. * Class used to hold a the container for ScrollViewer
  58830. * @hidden
  58831. */
  58832. export class _ScrollViewerWindow extends Container {
  58833. parentClientWidth: number;
  58834. parentClientHeight: number;
  58835. /**
  58836. * Creates a new ScrollViewerWindow
  58837. * @param name of ScrollViewerWindow
  58838. */
  58839. constructor(name?: string);
  58840. protected _getTypeName(): string;
  58841. /** @hidden */
  58842. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58843. protected _postMeasure(): void;
  58844. }
  58845. }
  58846. declare module BABYLON.GUI {
  58847. /**
  58848. * Class used to create slider controls
  58849. */
  58850. export class ScrollBar extends BaseSlider {
  58851. name?: string | undefined;
  58852. private _background;
  58853. private _borderColor;
  58854. private _thumbMeasure;
  58855. /** Gets or sets border color */
  58856. borderColor: string;
  58857. /** Gets or sets background color */
  58858. background: string;
  58859. /**
  58860. * Creates a new Slider
  58861. * @param name defines the control name
  58862. */
  58863. constructor(name?: string | undefined);
  58864. protected _getTypeName(): string;
  58865. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58866. private _first;
  58867. private _originX;
  58868. private _originY;
  58869. /** @hidden */
  58870. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58871. }
  58872. }
  58873. declare module BABYLON.GUI {
  58874. /**
  58875. * Class used to hold a viewer window and sliders in a grid
  58876. */
  58877. export class ScrollViewer extends Rectangle {
  58878. private _grid;
  58879. private _horizontalBarSpace;
  58880. private _verticalBarSpace;
  58881. private _dragSpace;
  58882. private _horizontalBar;
  58883. private _verticalBar;
  58884. private _barColor;
  58885. private _barBackground;
  58886. private _barSize;
  58887. private _endLeft;
  58888. private _endTop;
  58889. private _window;
  58890. private _pointerIsOver;
  58891. private _wheelPrecision;
  58892. private _onPointerObserver;
  58893. private _clientWidth;
  58894. private _clientHeight;
  58895. /**
  58896. * Gets the horizontal scrollbar
  58897. */
  58898. readonly horizontalBar: ScrollBar;
  58899. /**
  58900. * Gets the vertical scrollbar
  58901. */
  58902. readonly verticalBar: ScrollBar;
  58903. /**
  58904. * Adds a new control to the current container
  58905. * @param control defines the control to add
  58906. * @returns the current container
  58907. */
  58908. addControl(control: BABYLON.Nullable<Control>): Container;
  58909. /**
  58910. * Removes a control from the current container
  58911. * @param control defines the control to remove
  58912. * @returns the current container
  58913. */
  58914. removeControl(control: Control): Container;
  58915. /** Gets the list of children */
  58916. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58917. /**
  58918. * Creates a new ScrollViewer
  58919. * @param name of ScrollViewer
  58920. */
  58921. constructor(name?: string);
  58922. /** Reset the scroll viewer window to initial size */
  58923. resetWindow(): void;
  58924. protected _getTypeName(): string;
  58925. private _buildClientSizes;
  58926. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58927. protected _postMeasure(): void;
  58928. /**
  58929. * Gets or sets the mouse wheel precision
  58930. * from 0 to 1 with a default value of 0.05
  58931. * */
  58932. wheelPrecision: number;
  58933. /** Gets or sets the bar color */
  58934. barColor: string;
  58935. /** Gets or sets the size of the bar */
  58936. barSize: number;
  58937. /** Gets or sets the bar background */
  58938. barBackground: string;
  58939. /** @hidden */
  58940. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58941. /** @hidden */
  58942. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58943. /** Releases associated resources */
  58944. dispose(): void;
  58945. }
  58946. }
  58947. declare module BABYLON.GUI {
  58948. /** Class used to render a grid */
  58949. export class DisplayGrid extends Control {
  58950. name?: string | undefined;
  58951. private _cellWidth;
  58952. private _cellHeight;
  58953. private _minorLineTickness;
  58954. private _minorLineColor;
  58955. private _majorLineTickness;
  58956. private _majorLineColor;
  58957. private _majorLineFrequency;
  58958. private _background;
  58959. private _displayMajorLines;
  58960. private _displayMinorLines;
  58961. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58962. displayMinorLines: boolean;
  58963. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58964. displayMajorLines: boolean;
  58965. /** Gets or sets background color (Black by default) */
  58966. background: string;
  58967. /** Gets or sets the width of each cell (20 by default) */
  58968. cellWidth: number;
  58969. /** Gets or sets the height of each cell (20 by default) */
  58970. cellHeight: number;
  58971. /** Gets or sets the tickness of minor lines (1 by default) */
  58972. minorLineTickness: number;
  58973. /** Gets or sets the color of minor lines (DarkGray by default) */
  58974. minorLineColor: string;
  58975. /** Gets or sets the tickness of major lines (2 by default) */
  58976. majorLineTickness: number;
  58977. /** Gets or sets the color of major lines (White by default) */
  58978. majorLineColor: string;
  58979. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58980. majorLineFrequency: number;
  58981. /**
  58982. * Creates a new GridDisplayRectangle
  58983. * @param name defines the control name
  58984. */
  58985. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58986. protected _getTypeName(): string;
  58987. }
  58988. }
  58989. declare module BABYLON.GUI {
  58990. /**
  58991. * Class used to create slider controls based on images
  58992. */
  58993. export class ImageBasedSlider extends BaseSlider {
  58994. name?: string | undefined;
  58995. private _backgroundImage;
  58996. private _thumbImage;
  58997. private _valueBarImage;
  58998. private _tempMeasure;
  58999. displayThumb: boolean;
  59000. /**
  59001. * Gets or sets the image used to render the background
  59002. */
  59003. backgroundImage: Image;
  59004. /**
  59005. * Gets or sets the image used to render the value bar
  59006. */
  59007. valueBarImage: Image;
  59008. /**
  59009. * Gets or sets the image used to render the thumb
  59010. */
  59011. thumbImage: Image;
  59012. /**
  59013. * Creates a new ImageBasedSlider
  59014. * @param name defines the control name
  59015. */
  59016. constructor(name?: string | undefined);
  59017. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  59018. }
  59019. }
  59020. declare module BABYLON.GUI {
  59021. /**
  59022. * Forcing an export so that this code will execute
  59023. * @hidden
  59024. */
  59025. const name = "Statics";
  59026. }
  59027. declare module BABYLON.GUI {
  59028. /**
  59029. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  59030. */
  59031. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  59032. /**
  59033. * Define the instrumented AdvancedDynamicTexture.
  59034. */
  59035. texture: AdvancedDynamicTexture;
  59036. private _captureRenderTime;
  59037. private _renderTime;
  59038. private _captureLayoutTime;
  59039. private _layoutTime;
  59040. private _onBeginRenderObserver;
  59041. private _onEndRenderObserver;
  59042. private _onBeginLayoutObserver;
  59043. private _onEndLayoutObserver;
  59044. /**
  59045. * Gets the perf counter used to capture render time
  59046. */
  59047. readonly renderTimeCounter: BABYLON.PerfCounter;
  59048. /**
  59049. * Gets the perf counter used to capture layout time
  59050. */
  59051. readonly layoutTimeCounter: BABYLON.PerfCounter;
  59052. /**
  59053. * Enable or disable the render time capture
  59054. */
  59055. captureRenderTime: boolean;
  59056. /**
  59057. * Enable or disable the layout time capture
  59058. */
  59059. captureLayoutTime: boolean;
  59060. /**
  59061. * Instantiates a new advanced dynamic texture instrumentation.
  59062. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  59063. * @param texture Defines the AdvancedDynamicTexture to instrument
  59064. */
  59065. constructor(
  59066. /**
  59067. * Define the instrumented AdvancedDynamicTexture.
  59068. */
  59069. texture: AdvancedDynamicTexture);
  59070. /**
  59071. * Dispose and release associated resources.
  59072. */
  59073. dispose(): void;
  59074. }
  59075. }
  59076. declare module BABYLON.GUI {
  59077. /**
  59078. * Class used to create containers for controls
  59079. */
  59080. export class Container3D extends Control3D {
  59081. private _blockLayout;
  59082. /**
  59083. * Gets the list of child controls
  59084. */
  59085. protected _children: Control3D[];
  59086. /**
  59087. * Gets the list of child controls
  59088. */
  59089. readonly children: Array<Control3D>;
  59090. /**
  59091. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  59092. * This is helpful to optimize layout operation when adding multiple children in a row
  59093. */
  59094. blockLayout: boolean;
  59095. /**
  59096. * Creates a new container
  59097. * @param name defines the container name
  59098. */
  59099. constructor(name?: string);
  59100. /**
  59101. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  59102. * @returns the current container
  59103. */
  59104. updateLayout(): Container3D;
  59105. /**
  59106. * Gets a boolean indicating if the given control is in the children of this control
  59107. * @param control defines the control to check
  59108. * @returns true if the control is in the child list
  59109. */
  59110. containsControl(control: Control3D): boolean;
  59111. /**
  59112. * Adds a control to the children of this control
  59113. * @param control defines the control to add
  59114. * @returns the current container
  59115. */
  59116. addControl(control: Control3D): Container3D;
  59117. /**
  59118. * This function will be called everytime a new control is added
  59119. */
  59120. protected _arrangeChildren(): void;
  59121. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59122. /**
  59123. * Removes a control from the children of this control
  59124. * @param control defines the control to remove
  59125. * @returns the current container
  59126. */
  59127. removeControl(control: Control3D): Container3D;
  59128. protected _getTypeName(): string;
  59129. /**
  59130. * Releases all associated resources
  59131. */
  59132. dispose(): void;
  59133. /** Control rotation will remain unchanged */
  59134. static readonly UNSET_ORIENTATION: number;
  59135. /** Control will rotate to make it look at sphere central axis */
  59136. static readonly FACEORIGIN_ORIENTATION: number;
  59137. /** Control will rotate to make it look back at sphere central axis */
  59138. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  59139. /** Control will rotate to look at z axis (0, 0, 1) */
  59140. static readonly FACEFORWARD_ORIENTATION: number;
  59141. /** Control will rotate to look at negative z axis (0, 0, -1) */
  59142. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  59143. }
  59144. }
  59145. declare module BABYLON.GUI {
  59146. /**
  59147. * Class used to manage 3D user interface
  59148. * @see http://doc.babylonjs.com/how_to/gui3d
  59149. */
  59150. export class GUI3DManager implements BABYLON.IDisposable {
  59151. private _scene;
  59152. private _sceneDisposeObserver;
  59153. private _utilityLayer;
  59154. private _rootContainer;
  59155. private _pointerObserver;
  59156. private _pointerOutObserver;
  59157. /** @hidden */ lastPickedControl: Control3D;
  59158. /** @hidden */ lastControlOver: {
  59159. [pointerId: number]: Control3D;
  59160. };
  59161. /** @hidden */ lastControlDown: {
  59162. [pointerId: number]: Control3D;
  59163. };
  59164. /**
  59165. * BABYLON.Observable raised when the point picked by the pointer events changed
  59166. */
  59167. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  59168. /** @hidden */ sharedMaterials: {
  59169. [key: string]: BABYLON.Material;
  59170. };
  59171. /** Gets the hosting scene */
  59172. readonly scene: BABYLON.Scene;
  59173. /** Gets associated utility layer */
  59174. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  59175. /**
  59176. * Creates a new GUI3DManager
  59177. * @param scene
  59178. */
  59179. constructor(scene?: BABYLON.Scene);
  59180. private _handlePointerOut;
  59181. private _doPicking;
  59182. /**
  59183. * Gets the root container
  59184. */
  59185. readonly rootContainer: Container3D;
  59186. /**
  59187. * Gets a boolean indicating if the given control is in the root child list
  59188. * @param control defines the control to check
  59189. * @returns true if the control is in the root child list
  59190. */
  59191. containsControl(control: Control3D): boolean;
  59192. /**
  59193. * Adds a control to the root child list
  59194. * @param control defines the control to add
  59195. * @returns the current manager
  59196. */
  59197. addControl(control: Control3D): GUI3DManager;
  59198. /**
  59199. * Removes a control from the root child list
  59200. * @param control defines the control to remove
  59201. * @returns the current container
  59202. */
  59203. removeControl(control: Control3D): GUI3DManager;
  59204. /**
  59205. * Releases all associated resources
  59206. */
  59207. dispose(): void;
  59208. }
  59209. }
  59210. declare module BABYLON.GUI {
  59211. /**
  59212. * Class used to transport BABYLON.Vector3 information for pointer events
  59213. */
  59214. export class Vector3WithInfo extends BABYLON.Vector3 {
  59215. /** defines the current mouse button index */
  59216. buttonIndex: number;
  59217. /**
  59218. * Creates a new Vector3WithInfo
  59219. * @param source defines the vector3 data to transport
  59220. * @param buttonIndex defines the current mouse button index
  59221. */
  59222. constructor(source: BABYLON.Vector3,
  59223. /** defines the current mouse button index */
  59224. buttonIndex?: number);
  59225. }
  59226. }
  59227. declare module BABYLON.GUI {
  59228. /**
  59229. * Class used as base class for controls
  59230. */
  59231. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  59232. /** Defines the control name */
  59233. name?: string | undefined;
  59234. /** @hidden */ host: GUI3DManager;
  59235. private _node;
  59236. private _downCount;
  59237. private _enterCount;
  59238. private _downPointerIds;
  59239. private _isVisible;
  59240. /** Gets or sets the control position in world space */
  59241. position: BABYLON.Vector3;
  59242. /** Gets or sets the control scaling in world space */
  59243. scaling: BABYLON.Vector3;
  59244. /** Callback used to start pointer enter animation */
  59245. pointerEnterAnimation: () => void;
  59246. /** Callback used to start pointer out animation */
  59247. pointerOutAnimation: () => void;
  59248. /** Callback used to start pointer down animation */
  59249. pointerDownAnimation: () => void;
  59250. /** Callback used to start pointer up animation */
  59251. pointerUpAnimation: () => void;
  59252. /**
  59253. * An event triggered when the pointer move over the control
  59254. */
  59255. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  59256. /**
  59257. * An event triggered when the pointer move out of the control
  59258. */
  59259. onPointerOutObservable: BABYLON.Observable<Control3D>;
  59260. /**
  59261. * An event triggered when the pointer taps the control
  59262. */
  59263. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  59264. /**
  59265. * An event triggered when pointer is up
  59266. */
  59267. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  59268. /**
  59269. * An event triggered when a control is clicked on (with a mouse)
  59270. */
  59271. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  59272. /**
  59273. * An event triggered when pointer enters the control
  59274. */
  59275. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  59276. /**
  59277. * Gets or sets the parent container
  59278. */
  59279. parent: BABYLON.Nullable<Container3D>;
  59280. private _behaviors;
  59281. /**
  59282. * Gets the list of attached behaviors
  59283. * @see http://doc.babylonjs.com/features/behaviour
  59284. */
  59285. readonly behaviors: BABYLON.Behavior<Control3D>[];
  59286. /**
  59287. * Attach a behavior to the control
  59288. * @see http://doc.babylonjs.com/features/behaviour
  59289. * @param behavior defines the behavior to attach
  59290. * @returns the current control
  59291. */
  59292. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59293. /**
  59294. * Remove an attached behavior
  59295. * @see http://doc.babylonjs.com/features/behaviour
  59296. * @param behavior defines the behavior to attach
  59297. * @returns the current control
  59298. */
  59299. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  59300. /**
  59301. * Gets an attached behavior by name
  59302. * @param name defines the name of the behavior to look for
  59303. * @see http://doc.babylonjs.com/features/behaviour
  59304. * @returns null if behavior was not found else the requested behavior
  59305. */
  59306. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  59307. /** Gets or sets a boolean indicating if the control is visible */
  59308. isVisible: boolean;
  59309. /**
  59310. * Creates a new control
  59311. * @param name defines the control name
  59312. */
  59313. constructor(
  59314. /** Defines the control name */
  59315. name?: string | undefined);
  59316. /**
  59317. * Gets a string representing the class name
  59318. */
  59319. readonly typeName: string;
  59320. /**
  59321. * Get the current class name of the control.
  59322. * @returns current class name
  59323. */
  59324. getClassName(): string;
  59325. protected _getTypeName(): string;
  59326. /**
  59327. * Gets the transform node used by this control
  59328. */
  59329. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  59330. /**
  59331. * Gets the mesh used to render this control
  59332. */
  59333. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  59334. /**
  59335. * Link the control as child of the given node
  59336. * @param node defines the node to link to. Use null to unlink the control
  59337. * @returns the current control
  59338. */
  59339. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  59340. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  59341. /**
  59342. * Node creation.
  59343. * Can be overriden by children
  59344. * @param scene defines the scene where the node must be attached
  59345. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  59346. */
  59347. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  59348. /**
  59349. * Affect a material to the given mesh
  59350. * @param mesh defines the mesh which will represent the control
  59351. */
  59352. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59353. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  59354. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  59355. /** @hidden */ onPointerOut(target: Control3D): void;
  59356. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59357. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59358. /** @hidden */
  59359. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59360. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  59361. /** @hidden */ disposeNode(): void;
  59362. /**
  59363. * Releases all associated resources
  59364. */
  59365. dispose(): void;
  59366. }
  59367. }
  59368. declare module BABYLON.GUI {
  59369. /**
  59370. * Class used as a root to all buttons
  59371. */
  59372. export class AbstractButton3D extends Control3D {
  59373. /**
  59374. * Creates a new button
  59375. * @param name defines the control name
  59376. */
  59377. constructor(name?: string);
  59378. protected _getTypeName(): string;
  59379. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59380. }
  59381. }
  59382. declare module BABYLON.GUI {
  59383. /**
  59384. * Class used to create a button in 3D
  59385. */
  59386. export class Button3D extends AbstractButton3D {
  59387. /** @hidden */
  59388. protected _currentMaterial: BABYLON.Material;
  59389. private _facadeTexture;
  59390. private _content;
  59391. private _contentResolution;
  59392. private _contentScaleRatio;
  59393. /**
  59394. * Gets or sets the texture resolution used to render content (512 by default)
  59395. */
  59396. contentResolution: BABYLON.int;
  59397. /**
  59398. * Gets or sets the texture scale ratio used to render content (2 by default)
  59399. */
  59400. contentScaleRatio: number;
  59401. protected _disposeFacadeTexture(): void;
  59402. protected _resetContent(): void;
  59403. /**
  59404. * Creates a new button
  59405. * @param name defines the control name
  59406. */
  59407. constructor(name?: string);
  59408. /**
  59409. * Gets or sets the GUI 2D content used to display the button's facade
  59410. */
  59411. content: Control;
  59412. /**
  59413. * Apply the facade texture (created from the content property).
  59414. * This function can be overloaded by child classes
  59415. * @param facadeTexture defines the AdvancedDynamicTexture to use
  59416. */
  59417. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59418. protected _getTypeName(): string;
  59419. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59420. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59421. /**
  59422. * Releases all associated resources
  59423. */
  59424. dispose(): void;
  59425. }
  59426. }
  59427. declare module BABYLON.GUI {
  59428. /**
  59429. * Abstract class used to create a container panel deployed on the surface of a volume
  59430. */
  59431. export abstract class VolumeBasedPanel extends Container3D {
  59432. private _columns;
  59433. private _rows;
  59434. private _rowThenColum;
  59435. private _orientation;
  59436. protected _cellWidth: number;
  59437. protected _cellHeight: number;
  59438. /**
  59439. * Gets or sets the distance between elements
  59440. */
  59441. margin: number;
  59442. /**
  59443. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  59444. * | Value | Type | Description |
  59445. * | ----- | ----------------------------------- | ----------- |
  59446. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  59447. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  59448. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  59449. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  59450. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  59451. */
  59452. orientation: number;
  59453. /**
  59454. * Gets or sets the number of columns requested (10 by default).
  59455. * The panel will automatically compute the number of rows based on number of child controls.
  59456. */
  59457. columns: BABYLON.int;
  59458. /**
  59459. * Gets or sets a the number of rows requested.
  59460. * The panel will automatically compute the number of columns based on number of child controls.
  59461. */
  59462. rows: BABYLON.int;
  59463. /**
  59464. * Creates new VolumeBasedPanel
  59465. */
  59466. constructor();
  59467. protected _arrangeChildren(): void;
  59468. /** Child classes must implement this function to provide correct control positioning */
  59469. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59470. /** Child classes can implement this function to provide additional processing */
  59471. protected _finalProcessing(): void;
  59472. }
  59473. }
  59474. declare module BABYLON.GUI {
  59475. /**
  59476. * Class used to create a container panel deployed on the surface of a cylinder
  59477. */
  59478. export class CylinderPanel extends VolumeBasedPanel {
  59479. private _radius;
  59480. /**
  59481. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  59482. */
  59483. radius: BABYLON.float;
  59484. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59485. private _cylindricalMapping;
  59486. }
  59487. }
  59488. declare module BABYLON.GUI {
  59489. /** @hidden */
  59490. export var fluentVertexShader: {
  59491. name: string;
  59492. shader: string;
  59493. };
  59494. }
  59495. declare module BABYLON.GUI {
  59496. /** @hidden */
  59497. export var fluentPixelShader: {
  59498. name: string;
  59499. shader: string;
  59500. };
  59501. }
  59502. declare module BABYLON.GUI {
  59503. /** @hidden */
  59504. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  59505. INNERGLOW: boolean;
  59506. BORDER: boolean;
  59507. HOVERLIGHT: boolean;
  59508. TEXTURE: boolean;
  59509. constructor();
  59510. }
  59511. /**
  59512. * Class used to render controls with fluent desgin
  59513. */
  59514. export class FluentMaterial extends BABYLON.PushMaterial {
  59515. /**
  59516. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  59517. */
  59518. innerGlowColorIntensity: number;
  59519. /**
  59520. * Gets or sets the inner glow color (white by default)
  59521. */
  59522. innerGlowColor: BABYLON.Color3;
  59523. /**
  59524. * Gets or sets alpha value (default is 1.0)
  59525. */
  59526. alpha: number;
  59527. /**
  59528. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  59529. */
  59530. albedoColor: BABYLON.Color3;
  59531. /**
  59532. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  59533. */
  59534. renderBorders: boolean;
  59535. /**
  59536. * Gets or sets border width (default is 0.5)
  59537. */
  59538. borderWidth: number;
  59539. /**
  59540. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  59541. */
  59542. edgeSmoothingValue: number;
  59543. /**
  59544. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  59545. */
  59546. borderMinValue: number;
  59547. /**
  59548. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  59549. */
  59550. renderHoverLight: boolean;
  59551. /**
  59552. * Gets or sets the radius used to render the hover light (default is 1.0)
  59553. */
  59554. hoverRadius: number;
  59555. /**
  59556. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  59557. */
  59558. hoverColor: BABYLON.Color4;
  59559. /**
  59560. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  59561. */
  59562. hoverPosition: BABYLON.Vector3;
  59563. private _albedoTexture;
  59564. /** Gets or sets the texture to use for albedo color */
  59565. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  59566. /**
  59567. * Creates a new Fluent material
  59568. * @param name defines the name of the material
  59569. * @param scene defines the hosting scene
  59570. */
  59571. constructor(name: string, scene: BABYLON.Scene);
  59572. needAlphaBlending(): boolean;
  59573. needAlphaTesting(): boolean;
  59574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  59575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  59576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  59577. getActiveTextures(): BABYLON.BaseTexture[];
  59578. hasTexture(texture: BABYLON.BaseTexture): boolean;
  59579. dispose(forceDisposeEffect?: boolean): void;
  59580. clone(name: string): FluentMaterial;
  59581. serialize(): any;
  59582. getClassName(): string;
  59583. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  59584. }
  59585. }
  59586. declare module BABYLON.GUI {
  59587. /**
  59588. * Class used to create a holographic button in 3D
  59589. */
  59590. export class HolographicButton extends Button3D {
  59591. private _backPlate;
  59592. private _textPlate;
  59593. private _frontPlate;
  59594. private _text;
  59595. private _imageUrl;
  59596. private _shareMaterials;
  59597. private _frontMaterial;
  59598. private _backMaterial;
  59599. private _plateMaterial;
  59600. private _pickedPointObserver;
  59601. private _tooltipFade;
  59602. private _tooltipTextBlock;
  59603. private _tooltipTexture;
  59604. private _tooltipMesh;
  59605. private _tooltipHoverObserver;
  59606. private _tooltipOutObserver;
  59607. private _disposeTooltip;
  59608. /**
  59609. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  59610. */
  59611. tooltipText: BABYLON.Nullable<string>;
  59612. /**
  59613. * Gets or sets text for the button
  59614. */
  59615. text: string;
  59616. /**
  59617. * Gets or sets the image url for the button
  59618. */
  59619. imageUrl: string;
  59620. /**
  59621. * Gets the back material used by this button
  59622. */
  59623. readonly backMaterial: FluentMaterial;
  59624. /**
  59625. * Gets the front material used by this button
  59626. */
  59627. readonly frontMaterial: FluentMaterial;
  59628. /**
  59629. * Gets the plate material used by this button
  59630. */
  59631. readonly plateMaterial: BABYLON.StandardMaterial;
  59632. /**
  59633. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  59634. */
  59635. readonly shareMaterials: boolean;
  59636. /**
  59637. * Creates a new button
  59638. * @param name defines the control name
  59639. */
  59640. constructor(name?: string, shareMaterials?: boolean);
  59641. protected _getTypeName(): string;
  59642. private _rebuildContent;
  59643. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59644. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  59645. private _createBackMaterial;
  59646. private _createFrontMaterial;
  59647. private _createPlateMaterial;
  59648. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  59649. /**
  59650. * Releases all associated resources
  59651. */
  59652. dispose(): void;
  59653. }
  59654. }
  59655. declare module BABYLON.GUI {
  59656. /**
  59657. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  59658. */
  59659. export class MeshButton3D extends Button3D {
  59660. /** @hidden */
  59661. protected _currentMesh: BABYLON.Mesh;
  59662. /**
  59663. * Creates a new 3D button based on a mesh
  59664. * @param mesh mesh to become a 3D button
  59665. * @param name defines the control name
  59666. */
  59667. constructor(mesh: BABYLON.Mesh, name?: string);
  59668. protected _getTypeName(): string;
  59669. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  59670. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  59671. }
  59672. }
  59673. declare module BABYLON.GUI {
  59674. /**
  59675. * Class used to create a container panel deployed on the surface of a plane
  59676. */
  59677. export class PlanePanel extends VolumeBasedPanel {
  59678. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59679. }
  59680. }
  59681. declare module BABYLON.GUI {
  59682. /**
  59683. * Class used to create a container panel where items get randomized planar mapping
  59684. */
  59685. export class ScatterPanel extends VolumeBasedPanel {
  59686. private _iteration;
  59687. /**
  59688. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59689. */
  59690. iteration: BABYLON.float;
  59691. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59692. private _scatterMapping;
  59693. protected _finalProcessing(): void;
  59694. }
  59695. }
  59696. declare module BABYLON.GUI {
  59697. /**
  59698. * Class used to create a container panel deployed on the surface of a sphere
  59699. */
  59700. export class SpherePanel extends VolumeBasedPanel {
  59701. private _radius;
  59702. /**
  59703. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59704. */
  59705. radius: BABYLON.float;
  59706. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59707. private _sphericalMapping;
  59708. }
  59709. }
  59710. declare module BABYLON.GUI {
  59711. /**
  59712. * Class used to create a stack panel in 3D on XY plane
  59713. */
  59714. export class StackPanel3D extends Container3D {
  59715. private _isVertical;
  59716. /**
  59717. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59718. */
  59719. isVertical: boolean;
  59720. /**
  59721. * Gets or sets the distance between elements
  59722. */
  59723. margin: number;
  59724. /**
  59725. * Creates new StackPanel
  59726. * @param isVertical
  59727. */
  59728. constructor(isVertical?: boolean);
  59729. protected _arrangeChildren(): void;
  59730. }
  59731. }
  59732. declare module BABYLON {
  59733. /**
  59734. * Mode that determines the coordinate system to use.
  59735. */
  59736. export enum GLTFLoaderCoordinateSystemMode {
  59737. /**
  59738. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59739. */
  59740. AUTO = 0,
  59741. /**
  59742. * Sets the useRightHandedSystem flag on the scene.
  59743. */
  59744. FORCE_RIGHT_HANDED = 1
  59745. }
  59746. /**
  59747. * Mode that determines what animations will start.
  59748. */
  59749. export enum GLTFLoaderAnimationStartMode {
  59750. /**
  59751. * No animation will start.
  59752. */
  59753. NONE = 0,
  59754. /**
  59755. * The first animation will start.
  59756. */
  59757. FIRST = 1,
  59758. /**
  59759. * All animations will start.
  59760. */
  59761. ALL = 2
  59762. }
  59763. /**
  59764. * Interface that contains the data for the glTF asset.
  59765. */
  59766. export interface IGLTFLoaderData {
  59767. /**
  59768. * Object that represents the glTF JSON.
  59769. */
  59770. json: Object;
  59771. /**
  59772. * The BIN chunk of a binary glTF.
  59773. */
  59774. bin: Nullable<ArrayBufferView>;
  59775. }
  59776. /**
  59777. * Interface for extending the loader.
  59778. */
  59779. export interface IGLTFLoaderExtension {
  59780. /**
  59781. * The name of this extension.
  59782. */
  59783. readonly name: string;
  59784. /**
  59785. * Defines whether this extension is enabled.
  59786. */
  59787. enabled: boolean;
  59788. }
  59789. /**
  59790. * Loader state.
  59791. */
  59792. export enum GLTFLoaderState {
  59793. /**
  59794. * The asset is loading.
  59795. */
  59796. LOADING = 0,
  59797. /**
  59798. * The asset is ready for rendering.
  59799. */
  59800. READY = 1,
  59801. /**
  59802. * The asset is completely loaded.
  59803. */
  59804. COMPLETE = 2
  59805. }
  59806. /** @hidden */
  59807. export interface IGLTFLoader extends IDisposable {
  59808. readonly state: Nullable<GLTFLoaderState>;
  59809. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59810. meshes: AbstractMesh[];
  59811. particleSystems: IParticleSystem[];
  59812. skeletons: Skeleton[];
  59813. animationGroups: AnimationGroup[];
  59814. }>;
  59815. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59816. }
  59817. /**
  59818. * File loader for loading glTF files into a scene.
  59819. */
  59820. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59821. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59822. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59823. /**
  59824. * Raised when the asset has been parsed
  59825. */
  59826. onParsedObservable: Observable<IGLTFLoaderData>;
  59827. private _onParsedObserver;
  59828. /**
  59829. * Raised when the asset has been parsed
  59830. */
  59831. onParsed: (loaderData: IGLTFLoaderData) => void;
  59832. /**
  59833. * 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.
  59834. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59835. * Defaults to true.
  59836. * @hidden
  59837. */
  59838. static IncrementalLoading: boolean;
  59839. /**
  59840. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59841. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59842. * @hidden
  59843. */
  59844. static HomogeneousCoordinates: boolean;
  59845. /**
  59846. * The coordinate system mode. Defaults to AUTO.
  59847. */
  59848. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59849. /**
  59850. * The animation start mode. Defaults to FIRST.
  59851. */
  59852. animationStartMode: GLTFLoaderAnimationStartMode;
  59853. /**
  59854. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59855. */
  59856. compileMaterials: boolean;
  59857. /**
  59858. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59859. */
  59860. useClipPlane: boolean;
  59861. /**
  59862. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59863. */
  59864. compileShadowGenerators: boolean;
  59865. /**
  59866. * Defines if the Alpha blended materials are only applied as coverage.
  59867. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59868. * If true, no extra effects are applied to transparent pixels.
  59869. */
  59870. transparencyAsCoverage: boolean;
  59871. /**
  59872. * Function called before loading a url referenced by the asset.
  59873. */
  59874. preprocessUrlAsync: (url: string) => Promise<string>;
  59875. /**
  59876. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59877. */
  59878. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59879. private _onMeshLoadedObserver;
  59880. /**
  59881. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59882. */
  59883. onMeshLoaded: (mesh: AbstractMesh) => void;
  59884. /**
  59885. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59886. */
  59887. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59888. private _onTextureLoadedObserver;
  59889. /**
  59890. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59891. */
  59892. onTextureLoaded: (texture: BaseTexture) => void;
  59893. /**
  59894. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59895. */
  59896. readonly onMaterialLoadedObservable: Observable<Material>;
  59897. private _onMaterialLoadedObserver;
  59898. /**
  59899. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59900. */
  59901. onMaterialLoaded: (material: Material) => void;
  59902. /**
  59903. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59904. */
  59905. readonly onCameraLoadedObservable: Observable<Camera>;
  59906. private _onCameraLoadedObserver;
  59907. /**
  59908. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59909. */
  59910. onCameraLoaded: (camera: Camera) => void;
  59911. /**
  59912. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59913. * For assets with LODs, raised when all of the LODs are complete.
  59914. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59915. */
  59916. readonly onCompleteObservable: Observable<void>;
  59917. private _onCompleteObserver;
  59918. /**
  59919. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59920. * For assets with LODs, raised when all of the LODs are complete.
  59921. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59922. */
  59923. onComplete: () => void;
  59924. /**
  59925. * Observable raised when an error occurs.
  59926. */
  59927. readonly onErrorObservable: Observable<any>;
  59928. private _onErrorObserver;
  59929. /**
  59930. * Callback raised when an error occurs.
  59931. */
  59932. onError: (reason: any) => void;
  59933. /**
  59934. * Observable raised after the loader is disposed.
  59935. */
  59936. readonly onDisposeObservable: Observable<void>;
  59937. private _onDisposeObserver;
  59938. /**
  59939. * Callback raised after the loader is disposed.
  59940. */
  59941. onDispose: () => void;
  59942. /**
  59943. * Observable raised after a loader extension is created.
  59944. * Set additional options for a loader extension in this event.
  59945. */
  59946. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59947. private _onExtensionLoadedObserver;
  59948. /**
  59949. * Callback raised after a loader extension is created.
  59950. */
  59951. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59952. /**
  59953. * Defines if the loader logging is enabled.
  59954. */
  59955. loggingEnabled: boolean;
  59956. /**
  59957. * Defines if the loader should capture performance counters.
  59958. */
  59959. capturePerformanceCounters: boolean;
  59960. /**
  59961. * Defines if the loader should validate the asset.
  59962. */
  59963. validate: boolean;
  59964. /**
  59965. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59966. */
  59967. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59968. private _onValidatedObserver;
  59969. /**
  59970. * Callback raised after a loader extension is created.
  59971. */
  59972. onValidated: (results: IGLTFValidationResults) => void;
  59973. private _loader;
  59974. /**
  59975. * Name of the loader ("gltf")
  59976. */
  59977. name: string;
  59978. /**
  59979. * Supported file extensions of the loader (.gltf, .glb)
  59980. */
  59981. extensions: ISceneLoaderPluginExtensions;
  59982. /**
  59983. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59984. */
  59985. dispose(): void;
  59986. /** @hidden */ clear(): void;
  59987. /**
  59988. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59989. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59990. * @param scene the scene the meshes should be added to
  59991. * @param data the glTF data to load
  59992. * @param rootUrl root url to load from
  59993. * @param onProgress event that fires when loading progress has occured
  59994. * @param fileName Defines the name of the file to load
  59995. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59996. */
  59997. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59998. meshes: AbstractMesh[];
  59999. particleSystems: IParticleSystem[];
  60000. skeletons: Skeleton[];
  60001. animationGroups: AnimationGroup[];
  60002. }>;
  60003. /**
  60004. * Imports all objects from the loaded glTF data and adds them to the scene
  60005. * @param scene the scene the objects should be added to
  60006. * @param data the glTF data to load
  60007. * @param rootUrl root url to load from
  60008. * @param onProgress event that fires when loading progress has occured
  60009. * @param fileName Defines the name of the file to load
  60010. * @returns a promise which completes when objects have been loaded to the scene
  60011. */
  60012. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60013. /**
  60014. * Load into an asset container.
  60015. * @param scene The scene to load into
  60016. * @param data The data to import
  60017. * @param rootUrl The root url for scene and resources
  60018. * @param onProgress The callback when the load progresses
  60019. * @param fileName Defines the name of the file to load
  60020. * @returns The loaded asset container
  60021. */
  60022. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  60023. /**
  60024. * If the data string can be loaded directly.
  60025. * @param data string contianing the file data
  60026. * @returns if the data can be loaded directly
  60027. */
  60028. canDirectLoad(data: string): boolean;
  60029. /**
  60030. * Rewrites a url by combining a root url and response url.
  60031. */
  60032. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  60033. /**
  60034. * Instantiates a glTF file loader plugin.
  60035. * @returns the created plugin
  60036. */
  60037. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  60038. /**
  60039. * The loader state or null if the loader is not active.
  60040. */
  60041. readonly loaderState: Nullable<GLTFLoaderState>;
  60042. /**
  60043. * Returns a promise that resolves when the asset is completely loaded.
  60044. * @returns a promise that resolves when the asset is completely loaded.
  60045. */
  60046. whenCompleteAsync(): Promise<void>;
  60047. private _parseAsync;
  60048. private _validateAsync;
  60049. private _getLoader;
  60050. private _unpackBinary;
  60051. private _unpackBinaryV1;
  60052. private _unpackBinaryV2;
  60053. private static _parseVersion;
  60054. private static _compareVersion;
  60055. private static _decodeBufferToText;
  60056. private static readonly _logSpaces;
  60057. private _logIndentLevel;
  60058. private _loggingEnabled;
  60059. /** @hidden */ log: (message: string) => void;
  60060. /** @hidden */ logOpen(message: string): void;
  60061. /** @hidden */ logClose(): void;
  60062. private _logEnabled;
  60063. private _logDisabled;
  60064. private _capturePerformanceCounters;
  60065. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  60066. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  60067. private _startPerformanceCounterEnabled;
  60068. private _startPerformanceCounterDisabled;
  60069. private _endPerformanceCounterEnabled;
  60070. private _endPerformanceCounterDisabled;
  60071. }
  60072. }
  60073. declare module BABYLON.GLTF1 {
  60074. /**
  60075. * Enums
  60076. * @hidden
  60077. */
  60078. export enum EComponentType {
  60079. BYTE = 5120,
  60080. UNSIGNED_BYTE = 5121,
  60081. SHORT = 5122,
  60082. UNSIGNED_SHORT = 5123,
  60083. FLOAT = 5126
  60084. }
  60085. /** @hidden */
  60086. export enum EShaderType {
  60087. FRAGMENT = 35632,
  60088. VERTEX = 35633
  60089. }
  60090. /** @hidden */
  60091. export enum EParameterType {
  60092. BYTE = 5120,
  60093. UNSIGNED_BYTE = 5121,
  60094. SHORT = 5122,
  60095. UNSIGNED_SHORT = 5123,
  60096. INT = 5124,
  60097. UNSIGNED_INT = 5125,
  60098. FLOAT = 5126,
  60099. FLOAT_VEC2 = 35664,
  60100. FLOAT_VEC3 = 35665,
  60101. FLOAT_VEC4 = 35666,
  60102. INT_VEC2 = 35667,
  60103. INT_VEC3 = 35668,
  60104. INT_VEC4 = 35669,
  60105. BOOL = 35670,
  60106. BOOL_VEC2 = 35671,
  60107. BOOL_VEC3 = 35672,
  60108. BOOL_VEC4 = 35673,
  60109. FLOAT_MAT2 = 35674,
  60110. FLOAT_MAT3 = 35675,
  60111. FLOAT_MAT4 = 35676,
  60112. SAMPLER_2D = 35678
  60113. }
  60114. /** @hidden */
  60115. export enum ETextureWrapMode {
  60116. CLAMP_TO_EDGE = 33071,
  60117. MIRRORED_REPEAT = 33648,
  60118. REPEAT = 10497
  60119. }
  60120. /** @hidden */
  60121. export enum ETextureFilterType {
  60122. NEAREST = 9728,
  60123. LINEAR = 9728,
  60124. NEAREST_MIPMAP_NEAREST = 9984,
  60125. LINEAR_MIPMAP_NEAREST = 9985,
  60126. NEAREST_MIPMAP_LINEAR = 9986,
  60127. LINEAR_MIPMAP_LINEAR = 9987
  60128. }
  60129. /** @hidden */
  60130. export enum ETextureFormat {
  60131. ALPHA = 6406,
  60132. RGB = 6407,
  60133. RGBA = 6408,
  60134. LUMINANCE = 6409,
  60135. LUMINANCE_ALPHA = 6410
  60136. }
  60137. /** @hidden */
  60138. export enum ECullingType {
  60139. FRONT = 1028,
  60140. BACK = 1029,
  60141. FRONT_AND_BACK = 1032
  60142. }
  60143. /** @hidden */
  60144. export enum EBlendingFunction {
  60145. ZERO = 0,
  60146. ONE = 1,
  60147. SRC_COLOR = 768,
  60148. ONE_MINUS_SRC_COLOR = 769,
  60149. DST_COLOR = 774,
  60150. ONE_MINUS_DST_COLOR = 775,
  60151. SRC_ALPHA = 770,
  60152. ONE_MINUS_SRC_ALPHA = 771,
  60153. DST_ALPHA = 772,
  60154. ONE_MINUS_DST_ALPHA = 773,
  60155. CONSTANT_COLOR = 32769,
  60156. ONE_MINUS_CONSTANT_COLOR = 32770,
  60157. CONSTANT_ALPHA = 32771,
  60158. ONE_MINUS_CONSTANT_ALPHA = 32772,
  60159. SRC_ALPHA_SATURATE = 776
  60160. }
  60161. /** @hidden */
  60162. export interface IGLTFProperty {
  60163. extensions?: {
  60164. [key: string]: any;
  60165. };
  60166. extras?: Object;
  60167. }
  60168. /** @hidden */
  60169. export interface IGLTFChildRootProperty extends IGLTFProperty {
  60170. name?: string;
  60171. }
  60172. /** @hidden */
  60173. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  60174. bufferView: string;
  60175. byteOffset: number;
  60176. byteStride: number;
  60177. count: number;
  60178. type: string;
  60179. componentType: EComponentType;
  60180. max?: number[];
  60181. min?: number[];
  60182. name?: string;
  60183. }
  60184. /** @hidden */
  60185. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  60186. buffer: string;
  60187. byteOffset: number;
  60188. byteLength: number;
  60189. byteStride: number;
  60190. target?: number;
  60191. }
  60192. /** @hidden */
  60193. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  60194. uri: string;
  60195. byteLength?: number;
  60196. type?: string;
  60197. }
  60198. /** @hidden */
  60199. export interface IGLTFShader extends IGLTFChildRootProperty {
  60200. uri: string;
  60201. type: EShaderType;
  60202. }
  60203. /** @hidden */
  60204. export interface IGLTFProgram extends IGLTFChildRootProperty {
  60205. attributes: string[];
  60206. fragmentShader: string;
  60207. vertexShader: string;
  60208. }
  60209. /** @hidden */
  60210. export interface IGLTFTechniqueParameter {
  60211. type: number;
  60212. count?: number;
  60213. semantic?: string;
  60214. node?: string;
  60215. value?: number | boolean | string | Array<any>;
  60216. source?: string;
  60217. babylonValue?: any;
  60218. }
  60219. /** @hidden */
  60220. export interface IGLTFTechniqueCommonProfile {
  60221. lightingModel: string;
  60222. texcoordBindings: Object;
  60223. parameters?: Array<any>;
  60224. }
  60225. /** @hidden */
  60226. export interface IGLTFTechniqueStatesFunctions {
  60227. blendColor?: number[];
  60228. blendEquationSeparate?: number[];
  60229. blendFuncSeparate?: number[];
  60230. colorMask: boolean[];
  60231. cullFace: number[];
  60232. }
  60233. /** @hidden */
  60234. export interface IGLTFTechniqueStates {
  60235. enable: number[];
  60236. functions: IGLTFTechniqueStatesFunctions;
  60237. }
  60238. /** @hidden */
  60239. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  60240. parameters: {
  60241. [key: string]: IGLTFTechniqueParameter;
  60242. };
  60243. program: string;
  60244. attributes: {
  60245. [key: string]: string;
  60246. };
  60247. uniforms: {
  60248. [key: string]: string;
  60249. };
  60250. states: IGLTFTechniqueStates;
  60251. }
  60252. /** @hidden */
  60253. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  60254. technique?: string;
  60255. values: string[];
  60256. }
  60257. /** @hidden */
  60258. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  60259. attributes: {
  60260. [key: string]: string;
  60261. };
  60262. indices: string;
  60263. material: string;
  60264. mode?: number;
  60265. }
  60266. /** @hidden */
  60267. export interface IGLTFMesh extends IGLTFChildRootProperty {
  60268. primitives: IGLTFMeshPrimitive[];
  60269. }
  60270. /** @hidden */
  60271. export interface IGLTFImage extends IGLTFChildRootProperty {
  60272. uri: string;
  60273. }
  60274. /** @hidden */
  60275. export interface IGLTFSampler extends IGLTFChildRootProperty {
  60276. magFilter?: number;
  60277. minFilter?: number;
  60278. wrapS?: number;
  60279. wrapT?: number;
  60280. }
  60281. /** @hidden */
  60282. export interface IGLTFTexture extends IGLTFChildRootProperty {
  60283. sampler: string;
  60284. source: string;
  60285. format?: ETextureFormat;
  60286. internalFormat?: ETextureFormat;
  60287. target?: number;
  60288. type?: number;
  60289. babylonTexture?: Texture;
  60290. }
  60291. /** @hidden */
  60292. export interface IGLTFAmbienLight {
  60293. color?: number[];
  60294. }
  60295. /** @hidden */
  60296. export interface IGLTFDirectionalLight {
  60297. color?: number[];
  60298. }
  60299. /** @hidden */
  60300. export interface IGLTFPointLight {
  60301. color?: number[];
  60302. constantAttenuation?: number;
  60303. linearAttenuation?: number;
  60304. quadraticAttenuation?: number;
  60305. }
  60306. /** @hidden */
  60307. export interface IGLTFSpotLight {
  60308. color?: number[];
  60309. constantAttenuation?: number;
  60310. fallOfAngle?: number;
  60311. fallOffExponent?: number;
  60312. linearAttenuation?: number;
  60313. quadraticAttenuation?: number;
  60314. }
  60315. /** @hidden */
  60316. export interface IGLTFLight extends IGLTFChildRootProperty {
  60317. type: string;
  60318. }
  60319. /** @hidden */
  60320. export interface IGLTFCameraOrthographic {
  60321. xmag: number;
  60322. ymag: number;
  60323. zfar: number;
  60324. znear: number;
  60325. }
  60326. /** @hidden */
  60327. export interface IGLTFCameraPerspective {
  60328. aspectRatio: number;
  60329. yfov: number;
  60330. zfar: number;
  60331. znear: number;
  60332. }
  60333. /** @hidden */
  60334. export interface IGLTFCamera extends IGLTFChildRootProperty {
  60335. type: string;
  60336. }
  60337. /** @hidden */
  60338. export interface IGLTFAnimationChannelTarget {
  60339. id: string;
  60340. path: string;
  60341. }
  60342. /** @hidden */
  60343. export interface IGLTFAnimationChannel {
  60344. sampler: string;
  60345. target: IGLTFAnimationChannelTarget;
  60346. }
  60347. /** @hidden */
  60348. export interface IGLTFAnimationSampler {
  60349. input: string;
  60350. output: string;
  60351. interpolation?: string;
  60352. }
  60353. /** @hidden */
  60354. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  60355. channels?: IGLTFAnimationChannel[];
  60356. parameters?: {
  60357. [key: string]: string;
  60358. };
  60359. samplers?: {
  60360. [key: string]: IGLTFAnimationSampler;
  60361. };
  60362. }
  60363. /** @hidden */
  60364. export interface IGLTFNodeInstanceSkin {
  60365. skeletons: string[];
  60366. skin: string;
  60367. meshes: string[];
  60368. }
  60369. /** @hidden */
  60370. export interface IGLTFSkins extends IGLTFChildRootProperty {
  60371. bindShapeMatrix: number[];
  60372. inverseBindMatrices: string;
  60373. jointNames: string[];
  60374. babylonSkeleton?: Skeleton;
  60375. }
  60376. /** @hidden */
  60377. export interface IGLTFNode extends IGLTFChildRootProperty {
  60378. camera?: string;
  60379. children: string[];
  60380. skin?: string;
  60381. jointName?: string;
  60382. light?: string;
  60383. matrix: number[];
  60384. mesh?: string;
  60385. meshes?: string[];
  60386. rotation?: number[];
  60387. scale?: number[];
  60388. translation?: number[];
  60389. babylonNode?: Node;
  60390. }
  60391. /** @hidden */
  60392. export interface IGLTFScene extends IGLTFChildRootProperty {
  60393. nodes: string[];
  60394. }
  60395. /** @hidden */
  60396. export interface IGLTFRuntime {
  60397. extensions: {
  60398. [key: string]: any;
  60399. };
  60400. accessors: {
  60401. [key: string]: IGLTFAccessor;
  60402. };
  60403. buffers: {
  60404. [key: string]: IGLTFBuffer;
  60405. };
  60406. bufferViews: {
  60407. [key: string]: IGLTFBufferView;
  60408. };
  60409. meshes: {
  60410. [key: string]: IGLTFMesh;
  60411. };
  60412. lights: {
  60413. [key: string]: IGLTFLight;
  60414. };
  60415. cameras: {
  60416. [key: string]: IGLTFCamera;
  60417. };
  60418. nodes: {
  60419. [key: string]: IGLTFNode;
  60420. };
  60421. images: {
  60422. [key: string]: IGLTFImage;
  60423. };
  60424. textures: {
  60425. [key: string]: IGLTFTexture;
  60426. };
  60427. shaders: {
  60428. [key: string]: IGLTFShader;
  60429. };
  60430. programs: {
  60431. [key: string]: IGLTFProgram;
  60432. };
  60433. samplers: {
  60434. [key: string]: IGLTFSampler;
  60435. };
  60436. techniques: {
  60437. [key: string]: IGLTFTechnique;
  60438. };
  60439. materials: {
  60440. [key: string]: IGLTFMaterial;
  60441. };
  60442. animations: {
  60443. [key: string]: IGLTFAnimation;
  60444. };
  60445. skins: {
  60446. [key: string]: IGLTFSkins;
  60447. };
  60448. currentScene?: Object;
  60449. scenes: {
  60450. [key: string]: IGLTFScene;
  60451. };
  60452. extensionsUsed: string[];
  60453. extensionsRequired?: string[];
  60454. buffersCount: number;
  60455. shaderscount: number;
  60456. scene: Scene;
  60457. rootUrl: string;
  60458. loadedBufferCount: number;
  60459. loadedBufferViews: {
  60460. [name: string]: ArrayBufferView;
  60461. };
  60462. loadedShaderCount: number;
  60463. importOnlyMeshes: boolean;
  60464. importMeshesNames?: string[];
  60465. dummyNodes: Node[];
  60466. }
  60467. /** @hidden */
  60468. export interface INodeToRoot {
  60469. bone: Bone;
  60470. node: IGLTFNode;
  60471. id: string;
  60472. }
  60473. /** @hidden */
  60474. export interface IJointNode {
  60475. node: IGLTFNode;
  60476. id: string;
  60477. }
  60478. }
  60479. declare module BABYLON.GLTF1 {
  60480. /**
  60481. * Utils functions for GLTF
  60482. * @hidden
  60483. */
  60484. export class GLTFUtils {
  60485. /**
  60486. * Sets the given "parameter" matrix
  60487. * @param scene: the Scene object
  60488. * @param source: the source node where to pick the matrix
  60489. * @param parameter: the GLTF technique parameter
  60490. * @param uniformName: the name of the shader's uniform
  60491. * @param shaderMaterial: the shader material
  60492. */
  60493. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  60494. /**
  60495. * Sets the given "parameter" matrix
  60496. * @param shaderMaterial: the shader material
  60497. * @param uniform: the name of the shader's uniform
  60498. * @param value: the value of the uniform
  60499. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  60500. */
  60501. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  60502. /**
  60503. * Returns the wrap mode of the texture
  60504. * @param mode: the mode value
  60505. */
  60506. static GetWrapMode(mode: number): number;
  60507. /**
  60508. * Returns the byte stride giving an accessor
  60509. * @param accessor: the GLTF accessor objet
  60510. */
  60511. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  60512. /**
  60513. * Returns the texture filter mode giving a mode value
  60514. * @param mode: the filter mode value
  60515. */
  60516. static GetTextureFilterMode(mode: number): ETextureFilterType;
  60517. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  60518. /**
  60519. * Returns a buffer from its accessor
  60520. * @param gltfRuntime: the GLTF runtime
  60521. * @param accessor: the GLTF accessor
  60522. */
  60523. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  60524. /**
  60525. * Decodes a buffer view into a string
  60526. * @param view: the buffer view
  60527. */
  60528. static DecodeBufferToText(view: ArrayBufferView): string;
  60529. /**
  60530. * Returns the default material of gltf. Related to
  60531. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  60532. * @param scene: the Babylon.js scene
  60533. */
  60534. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  60535. private static _DefaultMaterial;
  60536. }
  60537. }
  60538. declare module BABYLON.GLTF1 {
  60539. /**
  60540. * Implementation of the base glTF spec
  60541. * @hidden
  60542. */
  60543. export class GLTFLoaderBase {
  60544. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  60545. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60546. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  60547. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60548. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  60549. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60550. }
  60551. /**
  60552. * glTF V1 Loader
  60553. * @hidden
  60554. */
  60555. export class GLTFLoader implements IGLTFLoader {
  60556. static Extensions: {
  60557. [name: string]: GLTFLoaderExtension;
  60558. };
  60559. static RegisterExtension(extension: GLTFLoaderExtension): void;
  60560. state: Nullable<GLTFLoaderState>;
  60561. dispose(): void;
  60562. private _importMeshAsync;
  60563. /**
  60564. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  60565. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60566. * @param scene the scene the meshes should be added to
  60567. * @param data gltf data containing information of the meshes in a loaded file
  60568. * @param rootUrl root url to load from
  60569. * @param onProgress event that fires when loading progress has occured
  60570. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60571. */
  60572. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  60573. meshes: AbstractMesh[];
  60574. particleSystems: IParticleSystem[];
  60575. skeletons: Skeleton[];
  60576. animationGroups: AnimationGroup[];
  60577. }>;
  60578. private _loadAsync;
  60579. /**
  60580. * Imports all objects from a loaded gltf file and adds them to the scene
  60581. * @param scene the scene the objects should be added to
  60582. * @param data gltf data containing information of the meshes in a loaded file
  60583. * @param rootUrl root url to load from
  60584. * @param onProgress event that fires when loading progress has occured
  60585. * @returns a promise which completes when objects have been loaded to the scene
  60586. */
  60587. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  60588. private _loadShadersAsync;
  60589. private _loadBuffersAsync;
  60590. private _createNodes;
  60591. }
  60592. /** @hidden */
  60593. export abstract class GLTFLoaderExtension {
  60594. private _name;
  60595. constructor(name: string);
  60596. readonly name: string;
  60597. /**
  60598. * Defines an override for loading the runtime
  60599. * Return true to stop further extensions from loading the runtime
  60600. */
  60601. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  60602. /**
  60603. * Defines an onverride for creating gltf runtime
  60604. * Return true to stop further extensions from creating the runtime
  60605. */
  60606. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  60607. /**
  60608. * Defines an override for loading buffers
  60609. * Return true to stop further extensions from loading this buffer
  60610. */
  60611. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  60612. /**
  60613. * Defines an override for loading texture buffers
  60614. * Return true to stop further extensions from loading this texture data
  60615. */
  60616. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60617. /**
  60618. * Defines an override for creating textures
  60619. * Return true to stop further extensions from loading this texture
  60620. */
  60621. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  60622. /**
  60623. * Defines an override for loading shader strings
  60624. * Return true to stop further extensions from loading this shader data
  60625. */
  60626. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60627. /**
  60628. * Defines an override for loading materials
  60629. * Return true to stop further extensions from loading this material
  60630. */
  60631. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60632. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  60633. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  60634. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  60635. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  60636. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  60637. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  60638. private static LoadTextureBufferAsync;
  60639. private static CreateTextureAsync;
  60640. private static ApplyExtensions;
  60641. }
  60642. }
  60643. declare module BABYLON.GLTF1 {
  60644. /** @hidden */
  60645. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  60646. private _bin;
  60647. constructor();
  60648. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  60649. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60650. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  60651. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  60652. }
  60653. }
  60654. declare module BABYLON.GLTF1 {
  60655. /** @hidden */
  60656. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  60657. constructor();
  60658. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  60659. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  60660. private _loadTexture;
  60661. }
  60662. }
  60663. declare module BABYLON.GLTF2.Loader {
  60664. /**
  60665. * Loader interface with an index field.
  60666. */
  60667. export interface IArrayItem {
  60668. /**
  60669. * The index of this item in the array.
  60670. */
  60671. index: number;
  60672. }
  60673. /**
  60674. * Loader interface with additional members.
  60675. */
  60676. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  60677. /** @hidden */ data?: Promise<ArrayBufferView>;
  60678. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  60679. }
  60680. /**
  60681. * Loader interface with additional members.
  60682. */
  60683. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  60684. }
  60685. /** @hidden */
  60686. export interface _IAnimationSamplerData {
  60687. input: Float32Array;
  60688. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60689. output: Float32Array;
  60690. }
  60691. /**
  60692. * Loader interface with additional members.
  60693. */
  60694. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60695. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60696. }
  60697. /**
  60698. * Loader interface with additional members.
  60699. */
  60700. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60701. channels: IAnimationChannel[];
  60702. samplers: IAnimationSampler[];
  60703. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60704. }
  60705. /**
  60706. * Loader interface with additional members.
  60707. */
  60708. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60709. /** @hidden */ data?: Promise<ArrayBufferView>;
  60710. }
  60711. /**
  60712. * Loader interface with additional members.
  60713. */
  60714. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60715. /** @hidden */ data?: Promise<ArrayBufferView>;
  60716. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60717. }
  60718. /**
  60719. * Loader interface with additional members.
  60720. */
  60721. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60722. }
  60723. /**
  60724. * Loader interface with additional members.
  60725. */
  60726. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60727. /** @hidden */ data?: Promise<ArrayBufferView>;
  60728. }
  60729. /**
  60730. * Loader interface with additional members.
  60731. */
  60732. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60733. }
  60734. /**
  60735. * Loader interface with additional members.
  60736. */
  60737. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60738. }
  60739. /**
  60740. * Loader interface with additional members.
  60741. */
  60742. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60743. baseColorTexture?: ITextureInfo;
  60744. metallicRoughnessTexture?: ITextureInfo;
  60745. }
  60746. /**
  60747. * Loader interface with additional members.
  60748. */
  60749. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60750. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60751. normalTexture?: IMaterialNormalTextureInfo;
  60752. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60753. emissiveTexture?: ITextureInfo;
  60754. /** @hidden */ data?: {
  60755. [babylonDrawMode: number]: {
  60756. babylonMaterial: Material;
  60757. babylonMeshes: AbstractMesh[];
  60758. promise: Promise<void>;
  60759. };
  60760. };
  60761. }
  60762. /**
  60763. * Loader interface with additional members.
  60764. */
  60765. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60766. primitives: IMeshPrimitive[];
  60767. }
  60768. /**
  60769. * Loader interface with additional members.
  60770. */
  60771. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60772. /** @hidden */ instanceData?: {
  60773. babylonSourceMesh: Mesh;
  60774. promise: Promise<any>;
  60775. };
  60776. }
  60777. /**
  60778. * Loader interface with additional members.
  60779. */
  60780. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60781. /**
  60782. * The parent glTF node.
  60783. */
  60784. parent?: INode;
  60785. /** @hidden */ babylonTransformNode?: TransformNode;
  60786. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60787. /** @hidden */ babylonBones?: Bone[];
  60788. /** @hidden */ numMorphTargets?: number;
  60789. }
  60790. /** @hidden */
  60791. export interface _ISamplerData {
  60792. noMipMaps: boolean;
  60793. samplingMode: number;
  60794. wrapU: number;
  60795. wrapV: number;
  60796. }
  60797. /**
  60798. * Loader interface with additional members.
  60799. */
  60800. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60801. /** @hidden */ data?: _ISamplerData;
  60802. }
  60803. /**
  60804. * Loader interface with additional members.
  60805. */
  60806. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60807. }
  60808. /**
  60809. * Loader interface with additional members.
  60810. */
  60811. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60812. /** @hidden */ data?: {
  60813. babylonSkeleton: Skeleton;
  60814. promise: Promise<void>;
  60815. };
  60816. }
  60817. /**
  60818. * Loader interface with additional members.
  60819. */
  60820. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60821. }
  60822. /**
  60823. * Loader interface with additional members.
  60824. */
  60825. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60826. }
  60827. /**
  60828. * Loader interface with additional members.
  60829. */
  60830. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60831. accessors?: IAccessor[];
  60832. animations?: IAnimation[];
  60833. buffers?: IBuffer[];
  60834. bufferViews?: IBufferView[];
  60835. cameras?: ICamera[];
  60836. images?: IImage[];
  60837. materials?: IMaterial[];
  60838. meshes?: IMesh[];
  60839. nodes?: INode[];
  60840. samplers?: ISampler[];
  60841. scenes?: IScene[];
  60842. skins?: ISkin[];
  60843. textures?: ITexture[];
  60844. }
  60845. }
  60846. declare module BABYLON.GLTF2 {
  60847. /**
  60848. * Interface for a glTF loader extension.
  60849. */
  60850. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60851. /**
  60852. * Called after the loader state changes to LOADING.
  60853. */
  60854. onLoading?(): void;
  60855. /**
  60856. * Called after the loader state changes to READY.
  60857. */
  60858. onReady?(): void;
  60859. /**
  60860. * Define this method to modify the default behavior when loading scenes.
  60861. * @param context The context when loading the asset
  60862. * @param scene The glTF scene property
  60863. * @returns A promise that resolves when the load is complete or null if not handled
  60864. */
  60865. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60866. /**
  60867. * Define this method to modify the default behavior when loading nodes.
  60868. * @param context The context when loading the asset
  60869. * @param node The glTF node property
  60870. * @param assign A function called synchronously after parsing the glTF properties
  60871. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60872. */
  60873. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60874. /**
  60875. * Define this method to modify the default behavior when loading cameras.
  60876. * @param context The context when loading the asset
  60877. * @param camera The glTF camera property
  60878. * @param assign A function called synchronously after parsing the glTF properties
  60879. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60880. */
  60881. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60882. /**
  60883. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60884. * @param context The context when loading the asset
  60885. * @param primitive The glTF mesh primitive property
  60886. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60887. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60888. /**
  60889. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  60890. * @param context The context when loading the asset
  60891. * @param name The mesh name when loading the asset
  60892. * @param node The glTF node when loading the asset
  60893. * @param mesh The glTF mesh when loading the asset
  60894. * @param primitive The glTF mesh primitive property
  60895. * @param assign A function called synchronously after parsing the glTF properties
  60896. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  60897. */ loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  60898. /**
  60899. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60900. * @param context The context when loading the asset
  60901. * @param material The glTF material property
  60902. * @param assign A function called synchronously after parsing the glTF properties
  60903. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60904. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60905. /**
  60906. * Define this method to modify the default behavior when creating materials.
  60907. * @param context The context when loading the asset
  60908. * @param material The glTF material property
  60909. * @param babylonDrawMode The draw mode for the Babylon material
  60910. * @returns The Babylon material or null if not handled
  60911. */
  60912. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60913. /**
  60914. * Define this method to modify the default behavior when loading material properties.
  60915. * @param context The context when loading the asset
  60916. * @param material The glTF material property
  60917. * @param babylonMaterial The Babylon material
  60918. * @returns A promise that resolves when the load is complete or null if not handled
  60919. */
  60920. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60921. /**
  60922. * Define this method to modify the default behavior when loading texture infos.
  60923. * @param context The context when loading the asset
  60924. * @param textureInfo The glTF texture info property
  60925. * @param assign A function called synchronously after parsing the glTF properties
  60926. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60927. */
  60928. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60929. /**
  60930. * Define this method to modify the default behavior when loading animations.
  60931. * @param context The context when loading the asset
  60932. * @param animation The glTF animation property
  60933. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60934. */
  60935. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60936. /**
  60937. * @hidden Define this method to modify the default behavior when loading skins.
  60938. * @param context The context when loading the asset
  60939. * @param node The glTF node property
  60940. * @param skin The glTF skin property
  60941. * @returns A promise that resolves when the load is complete or null if not handled
  60942. */ loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  60943. /**
  60944. * @hidden Define this method to modify the default behavior when loading uris.
  60945. * @param context The context when loading the asset
  60946. * @param property The glTF property associated with the uri
  60947. * @param uri The uri to load
  60948. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60949. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60950. }
  60951. }
  60952. declare module BABYLON.GLTF2 {
  60953. /**
  60954. * Helper class for working with arrays when loading the glTF asset
  60955. */
  60956. export class ArrayItem {
  60957. /**
  60958. * Gets an item from the given array.
  60959. * @param context The context when loading the asset
  60960. * @param array The array to get the item from
  60961. * @param index The index to the array
  60962. * @returns The array item
  60963. */
  60964. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60965. /**
  60966. * Assign an `index` field to each item of the given array.
  60967. * @param array The array of items
  60968. */
  60969. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60970. }
  60971. /**
  60972. * The glTF 2.0 loader
  60973. */
  60974. export class GLTFLoader implements IGLTFLoader {
  60975. /** @hidden */ completePromises: Promise<any>[];
  60976. private _disposed;
  60977. private _parent;
  60978. private _state;
  60979. private _extensions;
  60980. private _rootUrl;
  60981. private _fileName;
  60982. private _uniqueRootUrl;
  60983. private _gltf;
  60984. private _babylonScene;
  60985. private _rootBabylonMesh;
  60986. private _defaultBabylonMaterialData;
  60987. private _progressCallback?;
  60988. private _requests;
  60989. private static readonly _DefaultSampler;
  60990. private static _ExtensionNames;
  60991. private static _ExtensionFactories;
  60992. /**
  60993. * Registers a loader extension.
  60994. * @param name The name of the loader extension.
  60995. * @param factory The factory function that creates the loader extension.
  60996. */
  60997. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60998. /**
  60999. * Unregisters a loader extension.
  61000. * @param name The name of the loader extenion.
  61001. * @returns A boolean indicating whether the extension has been unregistered
  61002. */
  61003. static UnregisterExtension(name: string): boolean;
  61004. /**
  61005. * Gets the loader state.
  61006. */
  61007. readonly state: Nullable<GLTFLoaderState>;
  61008. /**
  61009. * The glTF object parsed from the JSON.
  61010. */
  61011. readonly gltf: IGLTF;
  61012. /**
  61013. * The Babylon scene when loading the asset.
  61014. */
  61015. readonly babylonScene: Scene;
  61016. /**
  61017. * The root Babylon mesh when loading the asset.
  61018. */
  61019. readonly rootBabylonMesh: Mesh;
  61020. /** @hidden */
  61021. constructor(parent: GLTFFileLoader);
  61022. /** @hidden */
  61023. dispose(): void;
  61024. /** @hidden */
  61025. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61026. meshes: AbstractMesh[];
  61027. particleSystems: IParticleSystem[];
  61028. skeletons: Skeleton[];
  61029. animationGroups: AnimationGroup[];
  61030. }>;
  61031. /** @hidden */
  61032. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61033. private _loadAsync;
  61034. private _loadData;
  61035. private _setupData;
  61036. private _loadExtensions;
  61037. private _checkExtensions;
  61038. private _setState;
  61039. private _createRootNode;
  61040. /**
  61041. * Loads a glTF scene.
  61042. * @param context The context when loading the asset
  61043. * @param scene The glTF scene property
  61044. * @returns A promise that resolves when the load is complete
  61045. */
  61046. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  61047. private _forEachPrimitive;
  61048. private _getMeshes;
  61049. private _getSkeletons;
  61050. private _getAnimationGroups;
  61051. private _startAnimations;
  61052. /**
  61053. * Loads a glTF node.
  61054. * @param context The context when loading the asset
  61055. * @param node The glTF node property
  61056. * @param assign A function called synchronously after parsing the glTF properties
  61057. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  61058. */
  61059. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  61060. private _loadMeshAsync;
  61061. /**
  61062. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  61063. * @param context The context when loading the asset
  61064. * @param name The mesh name when loading the asset
  61065. * @param node The glTF node when loading the asset
  61066. * @param mesh The glTF mesh when loading the asset
  61067. * @param primitive The glTF mesh primitive property
  61068. * @param assign A function called synchronously after parsing the glTF properties
  61069. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  61070. */ loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  61071. private _loadVertexDataAsync;
  61072. private _createMorphTargets;
  61073. private _loadMorphTargetsAsync;
  61074. private _loadMorphTargetVertexDataAsync;
  61075. private static _LoadTransform;
  61076. private _loadSkinAsync;
  61077. private _loadBones;
  61078. private _loadBone;
  61079. private _loadSkinInverseBindMatricesDataAsync;
  61080. private _updateBoneMatrices;
  61081. private _getNodeMatrix;
  61082. /**
  61083. * Loads a glTF camera.
  61084. * @param context The context when loading the asset
  61085. * @param camera The glTF camera property
  61086. * @param assign A function called synchronously after parsing the glTF properties
  61087. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  61088. */
  61089. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  61090. private _loadAnimationsAsync;
  61091. /**
  61092. * Loads a glTF animation.
  61093. * @param context The context when loading the asset
  61094. * @param animation The glTF animation property
  61095. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  61096. */
  61097. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  61098. /**
  61099. * @hidden Loads a glTF animation channel.
  61100. * @param context The context when loading the asset
  61101. * @param animationContext The context of the animation when loading the asset
  61102. * @param animation The glTF animation property
  61103. * @param channel The glTF animation channel property
  61104. * @param babylonAnimationGroup The babylon animation group property
  61105. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  61106. * @returns A void promise when the channel load is complete
  61107. */ loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  61108. private _loadAnimationSamplerAsync;
  61109. private _loadBufferAsync;
  61110. /**
  61111. * Loads a glTF buffer view.
  61112. * @param context The context when loading the asset
  61113. * @param bufferView The glTF buffer view property
  61114. * @returns A promise that resolves with the loaded data when the load is complete
  61115. */
  61116. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  61117. private _loadIndicesAccessorAsync;
  61118. private _loadFloatAccessorAsync;
  61119. private _loadVertexBufferViewAsync;
  61120. private _loadVertexAccessorAsync;
  61121. private _loadMaterialMetallicRoughnessPropertiesAsync;
  61122. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  61123. private _createDefaultMaterial;
  61124. /**
  61125. * Creates a Babylon material from a glTF material.
  61126. * @param context The context when loading the asset
  61127. * @param material The glTF material property
  61128. * @param babylonDrawMode The draw mode for the Babylon material
  61129. * @returns The Babylon material
  61130. */
  61131. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  61132. /**
  61133. * Loads properties from a glTF material into a Babylon material.
  61134. * @param context The context when loading the asset
  61135. * @param material The glTF material property
  61136. * @param babylonMaterial The Babylon material
  61137. * @returns A promise that resolves when the load is complete
  61138. */
  61139. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61140. /**
  61141. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  61142. * @param context The context when loading the asset
  61143. * @param material The glTF material property
  61144. * @param babylonMaterial The Babylon material
  61145. * @returns A promise that resolves when the load is complete
  61146. */
  61147. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  61148. /**
  61149. * Loads the alpha properties from a glTF material into a Babylon material.
  61150. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  61151. * @param context The context when loading the asset
  61152. * @param material The glTF material property
  61153. * @param babylonMaterial The Babylon material
  61154. */
  61155. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  61156. /**
  61157. * Loads a glTF texture info.
  61158. * @param context The context when loading the asset
  61159. * @param textureInfo The glTF texture info property
  61160. * @param assign A function called synchronously after parsing the glTF properties
  61161. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  61162. */
  61163. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  61164. private _loadTextureAsync;
  61165. private _loadSampler;
  61166. /**
  61167. * Loads a glTF image.
  61168. * @param context The context when loading the asset
  61169. * @param image The glTF image property
  61170. * @returns A promise that resolves with the loaded data when the load is complete
  61171. */
  61172. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  61173. /**
  61174. * Loads a glTF uri.
  61175. * @param context The context when loading the asset
  61176. * @param property The glTF property associated with the uri
  61177. * @param uri The base64 or relative uri
  61178. * @returns A promise that resolves with the loaded data when the load is complete
  61179. */
  61180. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  61181. private _onProgress;
  61182. /**
  61183. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  61184. * @param babylonObject the Babylon object with metadata
  61185. * @param pointer the JSON pointer
  61186. */
  61187. static AddPointerMetadata(babylonObject: {
  61188. metadata: any;
  61189. }, pointer: string): void;
  61190. private static _GetTextureWrapMode;
  61191. private static _GetTextureSamplingMode;
  61192. private static _GetTypedArray;
  61193. private static _GetNumComponents;
  61194. private static _ValidateUri;
  61195. private static _GetDrawMode;
  61196. private _compileMaterialsAsync;
  61197. private _compileShadowGeneratorsAsync;
  61198. private _forEachExtensions;
  61199. private _applyExtensions;
  61200. private _extensionsOnLoading;
  61201. private _extensionsOnReady;
  61202. private _extensionsLoadSceneAsync;
  61203. private _extensionsLoadNodeAsync;
  61204. private _extensionsLoadCameraAsync;
  61205. private _extensionsLoadVertexDataAsync;
  61206. private _extensionsLoadMeshPrimitiveAsync;
  61207. private _extensionsLoadMaterialAsync;
  61208. private _extensionsCreateMaterial;
  61209. private _extensionsLoadMaterialPropertiesAsync;
  61210. private _extensionsLoadTextureInfoAsync;
  61211. private _extensionsLoadAnimationAsync;
  61212. private _extensionsLoadSkinAsync;
  61213. private _extensionsLoadUriAsync;
  61214. /**
  61215. * Helper method called by a loader extension to load an glTF extension.
  61216. * @param context The context when loading the asset
  61217. * @param property The glTF property to load the extension from
  61218. * @param extensionName The name of the extension to load
  61219. * @param actionAsync The action to run
  61220. * @returns The promise returned by actionAsync or null if the extension does not exist
  61221. */
  61222. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61223. /**
  61224. * Helper method called by a loader extension to load a glTF extra.
  61225. * @param context The context when loading the asset
  61226. * @param property The glTF property to load the extra from
  61227. * @param extensionName The name of the extension to load
  61228. * @param actionAsync The action to run
  61229. * @returns The promise returned by actionAsync or null if the extra does not exist
  61230. */
  61231. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  61232. /**
  61233. * Increments the indentation level and logs a message.
  61234. * @param message The message to log
  61235. */
  61236. logOpen(message: string): void;
  61237. /**
  61238. * Decrements the indentation level.
  61239. */
  61240. logClose(): void;
  61241. /**
  61242. * Logs a message
  61243. * @param message The message to log
  61244. */
  61245. log(message: string): void;
  61246. /**
  61247. * Starts a performance counter.
  61248. * @param counterName The name of the performance counter
  61249. */
  61250. startPerformanceCounter(counterName: string): void;
  61251. /**
  61252. * Ends a performance counter.
  61253. * @param counterName The name of the performance counter
  61254. */
  61255. endPerformanceCounter(counterName: string): void;
  61256. }
  61257. }
  61258. declare module BABYLON.GLTF2.Loader.Extensions {
  61259. /**
  61260. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  61261. */
  61262. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  61263. /** The name of this extension. */
  61264. readonly name: string;
  61265. /** Defines whether this extension is enabled. */
  61266. enabled: boolean;
  61267. private _loader;
  61268. private _lights?;
  61269. /** @hidden */
  61270. constructor(loader: GLTFLoader);
  61271. /** @hidden */
  61272. dispose(): void;
  61273. /** @hidden */
  61274. onLoading(): void;
  61275. /** @hidden */
  61276. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61277. private _loadLightAsync;
  61278. }
  61279. }
  61280. declare module BABYLON.GLTF2.Loader.Extensions {
  61281. /**
  61282. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  61283. */
  61284. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  61285. /** The name of this extension. */
  61286. readonly name: string;
  61287. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  61288. dracoCompression?: DracoCompression;
  61289. /** Defines whether this extension is enabled. */
  61290. enabled: boolean;
  61291. private _loader;
  61292. /** @hidden */
  61293. constructor(loader: GLTFLoader);
  61294. /** @hidden */
  61295. dispose(): void;
  61296. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  61297. }
  61298. }
  61299. declare module BABYLON.GLTF2.Loader.Extensions {
  61300. /**
  61301. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  61302. */
  61303. export class KHR_lights implements IGLTFLoaderExtension {
  61304. /** The name of this extension. */
  61305. readonly name: string;
  61306. /** Defines whether this extension is enabled. */
  61307. enabled: boolean;
  61308. private _loader;
  61309. private _lights?;
  61310. /** @hidden */
  61311. constructor(loader: GLTFLoader);
  61312. /** @hidden */
  61313. dispose(): void;
  61314. /** @hidden */
  61315. onLoading(): void;
  61316. /** @hidden */
  61317. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61318. }
  61319. }
  61320. declare module BABYLON.GLTF2.Loader.Extensions {
  61321. /**
  61322. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  61323. */
  61324. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  61325. /** The name of this extension. */
  61326. readonly name: string;
  61327. /** Defines whether this extension is enabled. */
  61328. enabled: boolean;
  61329. private _loader;
  61330. /** @hidden */
  61331. constructor(loader: GLTFLoader);
  61332. /** @hidden */
  61333. dispose(): void;
  61334. /** @hidden */
  61335. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61336. private _loadSpecularGlossinessPropertiesAsync;
  61337. }
  61338. }
  61339. declare module BABYLON.GLTF2.Loader.Extensions {
  61340. /**
  61341. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  61342. */
  61343. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  61344. /** The name of this extension. */
  61345. readonly name: string;
  61346. /** Defines whether this extension is enabled. */
  61347. enabled: boolean;
  61348. private _loader;
  61349. /** @hidden */
  61350. constructor(loader: GLTFLoader);
  61351. /** @hidden */
  61352. dispose(): void;
  61353. /** @hidden */
  61354. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61355. private _loadUnlitPropertiesAsync;
  61356. }
  61357. }
  61358. declare module BABYLON.GLTF2.Loader.Extensions {
  61359. /**
  61360. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  61361. */
  61362. export class KHR_texture_transform implements IGLTFLoaderExtension {
  61363. /** The name of this extension. */
  61364. readonly name: string;
  61365. /** Defines whether this extension is enabled. */
  61366. enabled: boolean;
  61367. private _loader;
  61368. /** @hidden */
  61369. constructor(loader: GLTFLoader);
  61370. /** @hidden */
  61371. dispose(): void;
  61372. /** @hidden */
  61373. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  61374. }
  61375. }
  61376. declare module BABYLON.GLTF2.Loader.Extensions {
  61377. /**
  61378. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  61379. */
  61380. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  61381. /** The name of this extension. */
  61382. readonly name: string;
  61383. /** Defines whether this extension is enabled. */
  61384. enabled: boolean;
  61385. private _loader;
  61386. private _clips;
  61387. private _emitters;
  61388. /** @hidden */
  61389. constructor(loader: GLTFLoader);
  61390. /** @hidden */
  61391. dispose(): void;
  61392. /** @hidden */
  61393. onLoading(): void;
  61394. /** @hidden */
  61395. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  61396. /** @hidden */
  61397. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61398. /** @hidden */
  61399. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  61400. private _loadClipAsync;
  61401. private _loadEmitterAsync;
  61402. private _getEventAction;
  61403. private _loadAnimationEventAsync;
  61404. }
  61405. }
  61406. declare module BABYLON.GLTF2.Loader.Extensions {
  61407. /**
  61408. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  61409. */
  61410. export class MSFT_lod implements IGLTFLoaderExtension {
  61411. /** The name of this extension. */
  61412. readonly name: string;
  61413. /** Defines whether this extension is enabled. */
  61414. enabled: boolean;
  61415. /**
  61416. * Maximum number of LODs to load, starting from the lowest LOD.
  61417. */
  61418. maxLODsToLoad: number;
  61419. /**
  61420. * Observable raised when all node LODs of one level are loaded.
  61421. * The event data is the index of the loaded LOD starting from zero.
  61422. * Dispose the loader to cancel the loading of the next level of LODs.
  61423. */
  61424. onNodeLODsLoadedObservable: Observable<number>;
  61425. /**
  61426. * Observable raised when all material LODs of one level are loaded.
  61427. * The event data is the index of the loaded LOD starting from zero.
  61428. * Dispose the loader to cancel the loading of the next level of LODs.
  61429. */
  61430. onMaterialLODsLoadedObservable: Observable<number>;
  61431. private _loader;
  61432. private _nodeIndexLOD;
  61433. private _nodeSignalLODs;
  61434. private _nodePromiseLODs;
  61435. private _materialIndexLOD;
  61436. private _materialSignalLODs;
  61437. private _materialPromiseLODs;
  61438. /** @hidden */
  61439. constructor(loader: GLTFLoader);
  61440. /** @hidden */
  61441. dispose(): void;
  61442. /** @hidden */
  61443. onReady(): void;
  61444. /** @hidden */
  61445. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  61446. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  61447. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  61448. /**
  61449. * Gets an array of LOD properties from lowest to highest.
  61450. */
  61451. private _getLODs;
  61452. private _disposeUnusedMaterials;
  61453. }
  61454. }
  61455. declare module BABYLON.GLTF2.Loader.Extensions {
  61456. /** @hidden */
  61457. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  61458. readonly name: string;
  61459. enabled: boolean;
  61460. private _loader;
  61461. constructor(loader: GLTFLoader);
  61462. dispose(): void;
  61463. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61464. }
  61465. }
  61466. declare module BABYLON.GLTF2.Loader.Extensions {
  61467. /** @hidden */
  61468. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  61469. readonly name: string;
  61470. enabled: boolean;
  61471. private _loader;
  61472. constructor(loader: GLTFLoader);
  61473. dispose(): void;
  61474. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  61475. }
  61476. }
  61477. declare module BABYLON {
  61478. /**
  61479. * Class reading and parsing the MTL file bundled with the obj file.
  61480. */
  61481. export class MTLFileLoader {
  61482. /**
  61483. * All material loaded from the mtl will be set here
  61484. */
  61485. materials: StandardMaterial[];
  61486. /**
  61487. * This function will read the mtl file and create each material described inside
  61488. * This function could be improve by adding :
  61489. * -some component missing (Ni, Tf...)
  61490. * -including the specific options available
  61491. *
  61492. * @param scene defines the scene the material will be created in
  61493. * @param data defines the mtl data to parse
  61494. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  61495. */
  61496. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  61497. /**
  61498. * Gets the texture for the material.
  61499. *
  61500. * If the material is imported from input file,
  61501. * We sanitize the url to ensure it takes the textre from aside the material.
  61502. *
  61503. * @param rootUrl The root url to load from
  61504. * @param value The value stored in the mtl
  61505. * @return The Texture
  61506. */
  61507. private static _getTexture;
  61508. }
  61509. /**
  61510. * Options for loading OBJ/MTL files
  61511. */
  61512. type MeshLoadOptions = {
  61513. /**
  61514. * Defines if UVs are optimized by default during load.
  61515. */
  61516. OptimizeWithUV: boolean;
  61517. /**
  61518. * Defines custom scaling of UV coordinates of loaded meshes.
  61519. */
  61520. UVScaling: Vector2;
  61521. /**
  61522. * Invert model on y-axis (does a model scaling inversion)
  61523. */
  61524. InvertY: boolean;
  61525. /**
  61526. * Invert Y-Axis of referenced textures on load
  61527. */
  61528. InvertTextureY: boolean;
  61529. /**
  61530. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61531. */
  61532. ImportVertexColors: boolean;
  61533. /**
  61534. * Compute the normals for the model, even if normals are present in the file.
  61535. */
  61536. ComputeNormals: boolean;
  61537. /**
  61538. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61539. */
  61540. SkipMaterials: boolean;
  61541. /**
  61542. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61543. */
  61544. MaterialLoadingFailsSilently: boolean;
  61545. };
  61546. /**
  61547. * OBJ file type loader.
  61548. * This is a babylon scene loader plugin.
  61549. */
  61550. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61551. /**
  61552. * Defines if UVs are optimized by default during load.
  61553. */
  61554. static OPTIMIZE_WITH_UV: boolean;
  61555. /**
  61556. * Invert model on y-axis (does a model scaling inversion)
  61557. */
  61558. static INVERT_Y: boolean;
  61559. /**
  61560. * Invert Y-Axis of referenced textures on load
  61561. */
  61562. static INVERT_TEXTURE_Y: boolean;
  61563. /**
  61564. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  61565. */
  61566. static IMPORT_VERTEX_COLORS: boolean;
  61567. /**
  61568. * Compute the normals for the model, even if normals are present in the file.
  61569. */
  61570. static COMPUTE_NORMALS: boolean;
  61571. /**
  61572. * Defines custom scaling of UV coordinates of loaded meshes.
  61573. */
  61574. static UV_SCALING: Vector2;
  61575. /**
  61576. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  61577. */
  61578. static SKIP_MATERIALS: boolean;
  61579. /**
  61580. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  61581. *
  61582. * Defaults to true for backwards compatibility.
  61583. */
  61584. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  61585. /**
  61586. * Defines the name of the plugin.
  61587. */
  61588. name: string;
  61589. /**
  61590. * Defines the extension the plugin is able to load.
  61591. */
  61592. extensions: string;
  61593. /** @hidden */
  61594. obj: RegExp;
  61595. /** @hidden */
  61596. group: RegExp;
  61597. /** @hidden */
  61598. mtllib: RegExp;
  61599. /** @hidden */
  61600. usemtl: RegExp;
  61601. /** @hidden */
  61602. smooth: RegExp;
  61603. /** @hidden */
  61604. vertexPattern: RegExp;
  61605. /** @hidden */
  61606. normalPattern: RegExp;
  61607. /** @hidden */
  61608. uvPattern: RegExp;
  61609. /** @hidden */
  61610. facePattern1: RegExp;
  61611. /** @hidden */
  61612. facePattern2: RegExp;
  61613. /** @hidden */
  61614. facePattern3: RegExp;
  61615. /** @hidden */
  61616. facePattern4: RegExp;
  61617. /** @hidden */
  61618. facePattern5: RegExp;
  61619. private _meshLoadOptions;
  61620. /**
  61621. * Creates loader for .OBJ files
  61622. *
  61623. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  61624. */
  61625. constructor(meshLoadOptions?: MeshLoadOptions);
  61626. private static readonly currentMeshLoadOptions;
  61627. /**
  61628. * Calls synchronously the MTL file attached to this obj.
  61629. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  61630. * Without this function materials are not displayed in the first frame (but displayed after).
  61631. * In consequence it is impossible to get material information in your HTML file
  61632. *
  61633. * @param url The URL of the MTL file
  61634. * @param rootUrl
  61635. * @param onSuccess Callback function to be called when the MTL file is loaded
  61636. * @private
  61637. */
  61638. private _loadMTL;
  61639. /**
  61640. * Instantiates a OBJ file loader plugin.
  61641. * @returns the created plugin
  61642. */
  61643. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  61644. /**
  61645. * If the data string can be loaded directly.
  61646. *
  61647. * @param data string containing the file data
  61648. * @returns if the data can be loaded directly
  61649. */
  61650. canDirectLoad(data: string): boolean;
  61651. /**
  61652. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  61653. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61654. * @param scene the scene the meshes should be added to
  61655. * @param data the OBJ data to load
  61656. * @param rootUrl root url to load from
  61657. * @param onProgress event that fires when loading progress has occured
  61658. * @param fileName Defines the name of the file to load
  61659. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61660. */
  61661. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61662. meshes: AbstractMesh[];
  61663. particleSystems: IParticleSystem[];
  61664. skeletons: Skeleton[];
  61665. animationGroups: AnimationGroup[];
  61666. }>;
  61667. /**
  61668. * Imports all objects from the loaded OBJ data and adds them to the scene
  61669. * @param scene the scene the objects should be added to
  61670. * @param data the OBJ data to load
  61671. * @param rootUrl root url to load from
  61672. * @param onProgress event that fires when loading progress has occured
  61673. * @param fileName Defines the name of the file to load
  61674. * @returns a promise which completes when objects have been loaded to the scene
  61675. */
  61676. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61677. /**
  61678. * Load into an asset container.
  61679. * @param scene The scene to load into
  61680. * @param data The data to import
  61681. * @param rootUrl The root url for scene and resources
  61682. * @param onProgress The callback when the load progresses
  61683. * @param fileName Defines the name of the file to load
  61684. * @returns The loaded asset container
  61685. */
  61686. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61687. /**
  61688. * Read the OBJ file and create an Array of meshes.
  61689. * Each mesh contains all information given by the OBJ and the MTL file.
  61690. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  61691. *
  61692. * @param meshesNames
  61693. * @param scene Scene The scene where are displayed the data
  61694. * @param data String The content of the obj file
  61695. * @param rootUrl String The path to the folder
  61696. * @returns Array<AbstractMesh>
  61697. * @private
  61698. */
  61699. private _parseSolid;
  61700. }
  61701. }
  61702. declare module BABYLON {
  61703. /**
  61704. * STL file type loader.
  61705. * This is a babylon scene loader plugin.
  61706. */
  61707. export class STLFileLoader implements ISceneLoaderPlugin {
  61708. /** @hidden */
  61709. solidPattern: RegExp;
  61710. /** @hidden */
  61711. facetsPattern: RegExp;
  61712. /** @hidden */
  61713. normalPattern: RegExp;
  61714. /** @hidden */
  61715. vertexPattern: RegExp;
  61716. /**
  61717. * Defines the name of the plugin.
  61718. */
  61719. name: string;
  61720. /**
  61721. * Defines the extensions the stl loader is able to load.
  61722. * force data to come in as an ArrayBuffer
  61723. * we'll convert to string if it looks like it's an ASCII .stl
  61724. */
  61725. extensions: ISceneLoaderPluginExtensions;
  61726. /**
  61727. * Import meshes into a scene.
  61728. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  61729. * @param scene The scene to import into
  61730. * @param data The data to import
  61731. * @param rootUrl The root url for scene and resources
  61732. * @param meshes The meshes array to import into
  61733. * @param particleSystems The particle systems array to import into
  61734. * @param skeletons The skeletons array to import into
  61735. * @param onError The callback when import fails
  61736. * @returns True if successful or false otherwise
  61737. */
  61738. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  61739. /**
  61740. * Load into a scene.
  61741. * @param scene The scene to load into
  61742. * @param data The data to import
  61743. * @param rootUrl The root url for scene and resources
  61744. * @param onError The callback when import fails
  61745. * @returns true if successful or false otherwise
  61746. */
  61747. load(scene: Scene, data: any, rootUrl: string): boolean;
  61748. /**
  61749. * Load into an asset container.
  61750. * @param scene The scene to load into
  61751. * @param data The data to import
  61752. * @param rootUrl The root url for scene and resources
  61753. * @param onError The callback when import fails
  61754. * @returns The loaded asset container
  61755. */
  61756. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61757. private _isBinary;
  61758. private _parseBinary;
  61759. private _parseASCII;
  61760. }
  61761. }
  61762. declare module BABYLON {
  61763. /**
  61764. * Class for generating OBJ data from a Babylon scene.
  61765. */
  61766. export class OBJExport {
  61767. /**
  61768. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61769. * @param mesh defines the list of meshes to serialize
  61770. * @param materials defines if materials should be exported
  61771. * @param matlibname defines the name of the associated mtl file
  61772. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61773. * @returns the OBJ content
  61774. */
  61775. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61776. /**
  61777. * Exports the material(s) of a mesh in .MTL file format (text)
  61778. * @param mesh defines the mesh to extract the material from
  61779. * @returns the mtl content
  61780. */
  61781. static MTL(mesh: Mesh): string;
  61782. }
  61783. }
  61784. declare module BABYLON {
  61785. /** @hidden */
  61786. export var __IGLTFExporterExtension: number;
  61787. /**
  61788. * Interface for extending the exporter
  61789. * @hidden
  61790. */
  61791. export interface IGLTFExporterExtension {
  61792. /**
  61793. * The name of this extension
  61794. */
  61795. readonly name: string;
  61796. /**
  61797. * Defines whether this extension is enabled
  61798. */
  61799. enabled: boolean;
  61800. /**
  61801. * Defines whether this extension is required
  61802. */
  61803. required: boolean;
  61804. }
  61805. }
  61806. declare module BABYLON.GLTF2.Exporter {
  61807. /** @hidden */
  61808. export var __IGLTFExporterExtensionV2: number;
  61809. /**
  61810. * Interface for a glTF exporter extension
  61811. * @hidden
  61812. */
  61813. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61814. /**
  61815. * Define this method to modify the default behavior before exporting a texture
  61816. * @param context The context when loading the asset
  61817. * @param babylonTexture The glTF texture info property
  61818. * @param mimeType The mime-type of the generated image
  61819. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61820. */
  61821. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61822. /**
  61823. * Define this method to modify the default behavior when exporting texture info
  61824. * @param context The context when loading the asset
  61825. * @param meshPrimitive glTF mesh primitive
  61826. * @param babylonSubMesh Babylon submesh
  61827. * @param binaryWriter glTF serializer binary writer instance
  61828. * @returns nullable IMeshPrimitive promise
  61829. */
  61830. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61831. /**
  61832. * Define this method to modify the default behavior when exporting a node
  61833. * @param context The context when exporting the node
  61834. * @param node glTF node
  61835. * @param babylonNode BabylonJS node
  61836. * @returns nullable INode promise
  61837. */
  61838. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61839. /**
  61840. * Called after the exporter state changes to EXPORTING
  61841. */
  61842. onExporting?(): void;
  61843. }
  61844. }
  61845. declare module BABYLON.GLTF2.Exporter {
  61846. /**
  61847. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61848. * @hidden
  61849. */
  61850. export class _GLTFMaterialExporter {
  61851. /**
  61852. * Represents the dielectric specular values for R, G and B
  61853. */
  61854. private static readonly _DielectricSpecular;
  61855. /**
  61856. * Allows the maximum specular power to be defined for material calculations
  61857. */
  61858. private static readonly _MaxSpecularPower;
  61859. /**
  61860. * Mapping to store textures
  61861. */
  61862. private _textureMap;
  61863. /**
  61864. * Numeric tolerance value
  61865. */
  61866. private static readonly _Epsilon;
  61867. /**
  61868. * Reference to the glTF Exporter
  61869. */
  61870. private _exporter;
  61871. constructor(exporter: _Exporter);
  61872. /**
  61873. * Specifies if two colors are approximately equal in value
  61874. * @param color1 first color to compare to
  61875. * @param color2 second color to compare to
  61876. * @param epsilon threshold value
  61877. */
  61878. private static FuzzyEquals;
  61879. /**
  61880. * Gets the materials from a Babylon scene and converts them to glTF materials
  61881. * @param scene babylonjs scene
  61882. * @param mimeType texture mime type
  61883. * @param images array of images
  61884. * @param textures array of textures
  61885. * @param materials array of materials
  61886. * @param imageData mapping of texture names to base64 textures
  61887. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61888. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61889. /**
  61890. * Makes a copy of the glTF material without the texture parameters
  61891. * @param originalMaterial original glTF material
  61892. * @returns glTF material without texture parameters
  61893. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61894. /**
  61895. * Specifies if the material has any texture parameters present
  61896. * @param material glTF Material
  61897. * @returns boolean specifying if texture parameters are present
  61898. */ hasTexturesPresent(material: IMaterial): boolean;
  61899. /**
  61900. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61901. * @param babylonStandardMaterial
  61902. * @returns glTF Metallic Roughness Material representation
  61903. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61904. /**
  61905. * Computes the metallic factor
  61906. * @param diffuse diffused value
  61907. * @param specular specular value
  61908. * @param oneMinusSpecularStrength one minus the specular strength
  61909. * @returns metallic value
  61910. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61911. /**
  61912. * Gets the glTF alpha mode from the Babylon Material
  61913. * @param babylonMaterial Babylon Material
  61914. * @returns The Babylon alpha mode value
  61915. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61916. /**
  61917. * Converts a Babylon Standard Material to a glTF Material
  61918. * @param babylonStandardMaterial BJS Standard Material
  61919. * @param mimeType mime type to use for the textures
  61920. * @param images array of glTF image interfaces
  61921. * @param textures array of glTF texture interfaces
  61922. * @param materials array of glTF material interfaces
  61923. * @param imageData map of image file name to data
  61924. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61925. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61926. /**
  61927. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61928. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61929. * @param mimeType mime type to use for the textures
  61930. * @param images array of glTF image interfaces
  61931. * @param textures array of glTF texture interfaces
  61932. * @param materials array of glTF material interfaces
  61933. * @param imageData map of image file name to data
  61934. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61935. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61936. /**
  61937. * Converts an image typed array buffer to a base64 image
  61938. * @param buffer typed array buffer
  61939. * @param width width of the image
  61940. * @param height height of the image
  61941. * @param mimeType mimetype of the image
  61942. * @returns base64 image string
  61943. */
  61944. private _createBase64FromCanvasAsync;
  61945. /**
  61946. * Generates a white texture based on the specified width and height
  61947. * @param width width of the texture in pixels
  61948. * @param height height of the texture in pixels
  61949. * @param scene babylonjs scene
  61950. * @returns white texture
  61951. */
  61952. private _createWhiteTexture;
  61953. /**
  61954. * 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
  61955. * @param texture1 first texture to resize
  61956. * @param texture2 second texture to resize
  61957. * @param scene babylonjs scene
  61958. * @returns resized textures or null
  61959. */
  61960. private _resizeTexturesToSameDimensions;
  61961. /**
  61962. * Converts an array of pixels to a Float32Array
  61963. * Throws an error if the pixel format is not supported
  61964. * @param pixels - array buffer containing pixel values
  61965. * @returns Float32 of pixels
  61966. */
  61967. private _convertPixelArrayToFloat32;
  61968. /**
  61969. * Convert Specular Glossiness Textures to Metallic Roughness
  61970. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61971. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61972. * @param diffuseTexture texture used to store diffuse information
  61973. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61974. * @param factors specular glossiness material factors
  61975. * @param mimeType the mime type to use for the texture
  61976. * @returns pbr metallic roughness interface or null
  61977. */
  61978. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61979. /**
  61980. * Converts specular glossiness material properties to metallic roughness
  61981. * @param specularGlossiness interface with specular glossiness material properties
  61982. * @returns interface with metallic roughness material properties
  61983. */
  61984. private _convertSpecularGlossinessToMetallicRoughness;
  61985. /**
  61986. * Calculates the surface reflectance, independent of lighting conditions
  61987. * @param color Color source to calculate brightness from
  61988. * @returns number representing the perceived brightness, or zero if color is undefined
  61989. */
  61990. private _getPerceivedBrightness;
  61991. /**
  61992. * Returns the maximum color component value
  61993. * @param color
  61994. * @returns maximum color component value, or zero if color is null or undefined
  61995. */
  61996. private _getMaxComponent;
  61997. /**
  61998. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61999. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  62000. * @param mimeType mime type to use for the textures
  62001. * @param images array of glTF image interfaces
  62002. * @param textures array of glTF texture interfaces
  62003. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  62004. * @param imageData map of image file name to data
  62005. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62006. * @returns glTF PBR Metallic Roughness factors
  62007. */
  62008. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  62009. private _getGLTFTextureSampler;
  62010. private _getGLTFTextureWrapMode;
  62011. private _getGLTFTextureWrapModesSampler;
  62012. /**
  62013. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  62014. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  62015. * @param mimeType mime type to use for the textures
  62016. * @param images array of glTF image interfaces
  62017. * @param textures array of glTF texture interfaces
  62018. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  62019. * @param imageData map of image file name to data
  62020. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62021. * @returns glTF PBR Metallic Roughness factors
  62022. */
  62023. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  62024. /**
  62025. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  62026. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  62027. * @param mimeType mime type to use for the textures
  62028. * @param images array of glTF image interfaces
  62029. * @param textures array of glTF texture interfaces
  62030. * @param materials array of glTF material interfaces
  62031. * @param imageData map of image file name to data
  62032. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  62033. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  62034. private setMetallicRoughnessPbrMaterial;
  62035. private getPixelsFromTexture;
  62036. /**
  62037. * Extracts a texture from a Babylon texture into file data and glTF data
  62038. * @param babylonTexture Babylon texture to extract
  62039. * @param mimeType Mime Type of the babylonTexture
  62040. * @return glTF texture info, or null if the texture format is not supported
  62041. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  62042. /**
  62043. * Builds a texture from base64 string
  62044. * @param base64Texture base64 texture string
  62045. * @param baseTextureName Name to use for the texture
  62046. * @param mimeType image mime type for the texture
  62047. * @param images array of images
  62048. * @param textures array of textures
  62049. * @param imageData map of image data
  62050. * @returns glTF texture info, or null if the texture format is not supported
  62051. */
  62052. private _getTextureInfoFromBase64;
  62053. }
  62054. }
  62055. declare module BABYLON {
  62056. /**
  62057. * Class for holding and downloading glTF file data
  62058. */
  62059. export class GLTFData {
  62060. /**
  62061. * Object which contains the file name as the key and its data as the value
  62062. */
  62063. glTFFiles: {
  62064. [fileName: string]: string | Blob;
  62065. };
  62066. /**
  62067. * Initializes the glTF file object
  62068. */
  62069. constructor();
  62070. /**
  62071. * Downloads the glTF data as files based on their names and data
  62072. */
  62073. downloadFiles(): void;
  62074. }
  62075. }
  62076. declare module BABYLON {
  62077. /**
  62078. * Holds a collection of exporter options and parameters
  62079. */
  62080. export interface IExportOptions {
  62081. /**
  62082. * Function which indicates whether a babylon node should be exported or not
  62083. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  62084. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  62085. */
  62086. shouldExportNode?(node: Node): boolean;
  62087. /**
  62088. * The sample rate to bake animation curves
  62089. */
  62090. animationSampleRate?: number;
  62091. /**
  62092. * Begin serialization without waiting for the scene to be ready
  62093. */
  62094. exportWithoutWaitingForScene?: boolean;
  62095. }
  62096. /**
  62097. * Class for generating glTF data from a Babylon scene.
  62098. */
  62099. export class GLTF2Export {
  62100. /**
  62101. * Exports the geometry of the scene to .gltf file format asynchronously
  62102. * @param scene Babylon scene with scene hierarchy information
  62103. * @param filePrefix File prefix to use when generating the glTF file
  62104. * @param options Exporter options
  62105. * @returns Returns an object with a .gltf file and associates texture names
  62106. * as keys and their data and paths as values
  62107. */
  62108. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62109. private static _PreExportAsync;
  62110. private static _PostExportAsync;
  62111. /**
  62112. * Exports the geometry of the scene to .glb file format asychronously
  62113. * @param scene Babylon scene with scene hierarchy information
  62114. * @param filePrefix File prefix to use when generating glb file
  62115. * @param options Exporter options
  62116. * @returns Returns an object with a .glb filename as key and data as value
  62117. */
  62118. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  62119. }
  62120. }
  62121. declare module BABYLON.GLTF2.Exporter {
  62122. /**
  62123. * @hidden
  62124. */
  62125. export class _GLTFUtilities {
  62126. /**
  62127. * Creates a buffer view based on the supplied arguments
  62128. * @param bufferIndex index value of the specified buffer
  62129. * @param byteOffset byte offset value
  62130. * @param byteLength byte length of the bufferView
  62131. * @param byteStride byte distance between conequential elements
  62132. * @param name name of the buffer view
  62133. * @returns bufferView for glTF
  62134. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  62135. /**
  62136. * Creates an accessor based on the supplied arguments
  62137. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  62138. * @param name The name of the accessor
  62139. * @param type The type of the accessor
  62140. * @param componentType The datatype of components in the attribute
  62141. * @param count The number of attributes referenced by this accessor
  62142. * @param byteOffset The offset relative to the start of the bufferView in bytes
  62143. * @param min Minimum value of each component in this attribute
  62144. * @param max Maximum value of each component in this attribute
  62145. * @returns accessor for glTF
  62146. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  62147. /**
  62148. * Calculates the minimum and maximum values of an array of position floats
  62149. * @param positions Positions array of a mesh
  62150. * @param vertexStart Starting vertex offset to calculate min and max values
  62151. * @param vertexCount Number of vertices to check for min and max values
  62152. * @returns min number array and max number array
  62153. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  62154. min: number[];
  62155. max: number[];
  62156. };
  62157. /**
  62158. * Converts a new right-handed Vector3
  62159. * @param vector vector3 array
  62160. * @returns right-handed Vector3
  62161. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  62162. /**
  62163. * Converts a Vector3 to right-handed
  62164. * @param vector Vector3 to convert to right-handed
  62165. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  62166. /**
  62167. * Converts a three element number array to right-handed
  62168. * @param vector number array to convert to right-handed
  62169. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  62170. /**
  62171. * Converts a new right-handed Vector3
  62172. * @param vector vector3 array
  62173. * @returns right-handed Vector3
  62174. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  62175. /**
  62176. * Converts a Vector3 to right-handed
  62177. * @param vector Vector3 to convert to right-handed
  62178. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  62179. /**
  62180. * Converts a three element number array to right-handed
  62181. * @param vector number array to convert to right-handed
  62182. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  62183. /**
  62184. * Converts a Vector4 to right-handed
  62185. * @param vector Vector4 to convert to right-handed
  62186. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  62187. /**
  62188. * Converts a Vector4 to right-handed
  62189. * @param vector Vector4 to convert to right-handed
  62190. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  62191. /**
  62192. * Converts a Quaternion to right-handed
  62193. * @param quaternion Source quaternion to convert to right-handed
  62194. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  62195. /**
  62196. * Converts a Quaternion to right-handed
  62197. * @param quaternion Source quaternion to convert to right-handed
  62198. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  62199. }
  62200. }
  62201. declare module BABYLON.GLTF2.Exporter {
  62202. /**
  62203. * Converts Babylon Scene into glTF 2.0.
  62204. * @hidden
  62205. */
  62206. export class _Exporter {
  62207. /**
  62208. * Stores the glTF to export
  62209. */ glTF: IGLTF;
  62210. /**
  62211. * Stores all generated buffer views, which represents views into the main glTF buffer data
  62212. */ bufferViews: IBufferView[];
  62213. /**
  62214. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  62215. */ accessors: IAccessor[];
  62216. /**
  62217. * Stores all the generated nodes, which contains transform and/or mesh information per node
  62218. */
  62219. private _nodes;
  62220. /**
  62221. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  62222. */
  62223. private _scenes;
  62224. /**
  62225. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  62226. */
  62227. private _meshes;
  62228. /**
  62229. * Stores all the generated material information, which represents the appearance of each primitive
  62230. */ materials: IMaterial[]; materialMap: {
  62231. [materialID: number]: number;
  62232. };
  62233. /**
  62234. * Stores all the generated texture information, which is referenced by glTF materials
  62235. */ textures: ITexture[];
  62236. /**
  62237. * Stores all the generated image information, which is referenced by glTF textures
  62238. */ images: IImage[];
  62239. /**
  62240. * Stores all the texture samplers
  62241. */ samplers: ISampler[];
  62242. /**
  62243. * Stores all the generated animation samplers, which is referenced by glTF animations
  62244. */
  62245. /**
  62246. * Stores the animations for glTF models
  62247. */
  62248. private _animations;
  62249. /**
  62250. * Stores the total amount of bytes stored in the glTF buffer
  62251. */
  62252. private _totalByteLength;
  62253. /**
  62254. * Stores a reference to the Babylon scene containing the source geometry and material information
  62255. */ babylonScene: Scene;
  62256. /**
  62257. * Stores a map of the image data, where the key is the file name and the value
  62258. * is the image data
  62259. */ imageData: {
  62260. [fileName: string]: {
  62261. data: Uint8Array;
  62262. mimeType: ImageMimeType;
  62263. };
  62264. };
  62265. /**
  62266. * Stores a map of the unique id of a node to its index in the node array
  62267. */
  62268. private _nodeMap;
  62269. /**
  62270. * Specifies if the Babylon scene should be converted to right-handed on export
  62271. */ convertToRightHandedSystem: boolean;
  62272. /**
  62273. * Baked animation sample rate
  62274. */
  62275. private _animationSampleRate;
  62276. /**
  62277. * Callback which specifies if a node should be exported or not
  62278. */
  62279. private _shouldExportNode;
  62280. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  62281. private _extensions;
  62282. private static _ExtensionNames;
  62283. private static _ExtensionFactories;
  62284. private _applyExtensions; extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62285. private _forEachExtensions;
  62286. private _extensionsOnExporting;
  62287. /**
  62288. * Load glTF serializer extensions
  62289. */
  62290. private _loadExtensions;
  62291. /**
  62292. * Creates a glTF Exporter instance, which can accept optional exporter options
  62293. * @param babylonScene Babylon scene object
  62294. * @param options Options to modify the behavior of the exporter
  62295. */
  62296. constructor(babylonScene: Scene, options?: IExportOptions);
  62297. /**
  62298. * Registers a glTF exporter extension
  62299. * @param name Name of the extension to export
  62300. * @param factory The factory function that creates the exporter extension
  62301. */
  62302. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  62303. /**
  62304. * Un-registers an exporter extension
  62305. * @param name The name fo the exporter extension
  62306. * @returns A boolean indicating whether the extension has been un-registered
  62307. */
  62308. static UnregisterExtension(name: string): boolean;
  62309. /**
  62310. * Lazy load a local engine with premultiplied alpha set to false
  62311. */ getLocalEngine(): Engine;
  62312. private reorderIndicesBasedOnPrimitiveMode;
  62313. /**
  62314. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  62315. * clock-wise during export to glTF
  62316. * @param submesh BabylonJS submesh
  62317. * @param primitiveMode Primitive mode of the mesh
  62318. * @param sideOrientation the winding order of the submesh
  62319. * @param vertexBufferKind The type of vertex attribute
  62320. * @param meshAttributeArray The vertex attribute data
  62321. * @param byteOffset The offset to the binary data
  62322. * @param binaryWriter The binary data for the glTF file
  62323. */
  62324. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  62325. /**
  62326. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  62327. * clock-wise during export to glTF
  62328. * @param submesh BabylonJS submesh
  62329. * @param primitiveMode Primitive mode of the mesh
  62330. * @param sideOrientation the winding order of the submesh
  62331. * @param vertexBufferKind The type of vertex attribute
  62332. * @param meshAttributeArray The vertex attribute data
  62333. * @param byteOffset The offset to the binary data
  62334. * @param binaryWriter The binary data for the glTF file
  62335. */
  62336. private reorderTriangleFillMode;
  62337. /**
  62338. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  62339. * clock-wise during export to glTF
  62340. * @param submesh BabylonJS submesh
  62341. * @param primitiveMode Primitive mode of the mesh
  62342. * @param sideOrientation the winding order of the submesh
  62343. * @param vertexBufferKind The type of vertex attribute
  62344. * @param meshAttributeArray The vertex attribute data
  62345. * @param byteOffset The offset to the binary data
  62346. * @param binaryWriter The binary data for the glTF file
  62347. */
  62348. private reorderTriangleStripDrawMode;
  62349. /**
  62350. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  62351. * clock-wise during export to glTF
  62352. * @param submesh BabylonJS submesh
  62353. * @param primitiveMode Primitive mode of the mesh
  62354. * @param sideOrientation the winding order of the submesh
  62355. * @param vertexBufferKind The type of vertex attribute
  62356. * @param meshAttributeArray The vertex attribute data
  62357. * @param byteOffset The offset to the binary data
  62358. * @param binaryWriter The binary data for the glTF file
  62359. */
  62360. private reorderTriangleFanMode;
  62361. /**
  62362. * Writes the vertex attribute data to binary
  62363. * @param vertices The vertices to write to the binary writer
  62364. * @param byteOffset The offset into the binary writer to overwrite binary data
  62365. * @param vertexAttributeKind The vertex attribute type
  62366. * @param meshAttributeArray The vertex attribute data
  62367. * @param binaryWriter The writer containing the binary data
  62368. */
  62369. private writeVertexAttributeData;
  62370. /**
  62371. * Writes mesh attribute data to a data buffer
  62372. * Returns the bytelength of the data
  62373. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  62374. * @param meshAttributeArray Array containing the attribute data
  62375. * @param binaryWriter The buffer to write the binary data to
  62376. * @param indices Used to specify the order of the vertex data
  62377. */
  62378. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  62379. /**
  62380. * Generates glTF json data
  62381. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  62382. * @param glTFPrefix Text to use when prefixing a glTF file
  62383. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  62384. * @returns json data as string
  62385. */
  62386. private generateJSON;
  62387. /**
  62388. * Generates data for .gltf and .bin files based on the glTF prefix string
  62389. * @param glTFPrefix Text to use when prefixing a glTF file
  62390. * @returns GLTFData with glTF file data
  62391. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  62392. /**
  62393. * Creates a binary buffer for glTF
  62394. * @returns array buffer for binary data
  62395. */
  62396. private _generateBinaryAsync;
  62397. /**
  62398. * Pads the number to a multiple of 4
  62399. * @param num number to pad
  62400. * @returns padded number
  62401. */
  62402. private _getPadding;
  62403. /**
  62404. * Generates a glb file from the json and binary data
  62405. * Returns an object with the glb file name as the key and data as the value
  62406. * @param glTFPrefix
  62407. * @returns object with glb filename as key and data as value
  62408. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  62409. /**
  62410. * Sets the TRS for each node
  62411. * @param node glTF Node for storing the transformation data
  62412. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  62413. */
  62414. private setNodeTransformation;
  62415. private getVertexBufferFromMesh;
  62416. /**
  62417. * Creates a bufferview based on the vertices type for the Babylon mesh
  62418. * @param kind Indicates the type of vertices data
  62419. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  62420. * @param binaryWriter The buffer to write the bufferview data to
  62421. */
  62422. private createBufferViewKind;
  62423. /**
  62424. * The primitive mode of the Babylon mesh
  62425. * @param babylonMesh The BabylonJS mesh
  62426. */
  62427. private getMeshPrimitiveMode;
  62428. /**
  62429. * Sets the primitive mode of the glTF mesh primitive
  62430. * @param meshPrimitive glTF mesh primitive
  62431. * @param primitiveMode The primitive mode
  62432. */
  62433. private setPrimitiveMode;
  62434. /**
  62435. * Sets the vertex attribute accessor based of the glTF mesh primitive
  62436. * @param meshPrimitive glTF mesh primitive
  62437. * @param attributeKind vertex attribute
  62438. * @returns boolean specifying if uv coordinates are present
  62439. */
  62440. private setAttributeKind;
  62441. /**
  62442. * Sets data for the primitive attributes of each submesh
  62443. * @param mesh glTF Mesh object to store the primitive attribute information
  62444. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  62445. * @param binaryWriter Buffer to write the attribute data to
  62446. */
  62447. private setPrimitiveAttributesAsync;
  62448. /**
  62449. * Creates a glTF scene based on the array of meshes
  62450. * Returns the the total byte offset
  62451. * @param babylonScene Babylon scene to get the mesh data from
  62452. * @param binaryWriter Buffer to write binary data to
  62453. */
  62454. private createSceneAsync;
  62455. /**
  62456. * Creates a mapping of Node unique id to node index and handles animations
  62457. * @param babylonScene Babylon Scene
  62458. * @param nodes Babylon transform nodes
  62459. * @param shouldExportNode Callback specifying if a transform node should be exported
  62460. * @param binaryWriter Buffer to write binary data to
  62461. * @returns Node mapping of unique id to index
  62462. */
  62463. private createNodeMapAndAnimationsAsync;
  62464. /**
  62465. * Creates a glTF node from a Babylon mesh
  62466. * @param babylonMesh Source Babylon mesh
  62467. * @param binaryWriter Buffer for storing geometry data
  62468. * @returns glTF node
  62469. */
  62470. private createNodeAsync;
  62471. }
  62472. /**
  62473. * @hidden
  62474. *
  62475. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  62476. */
  62477. export class _BinaryWriter {
  62478. /**
  62479. * Array buffer which stores all binary data
  62480. */
  62481. private _arrayBuffer;
  62482. /**
  62483. * View of the array buffer
  62484. */
  62485. private _dataView;
  62486. /**
  62487. * byte offset of data in array buffer
  62488. */
  62489. private _byteOffset;
  62490. /**
  62491. * Initialize binary writer with an initial byte length
  62492. * @param byteLength Initial byte length of the array buffer
  62493. */
  62494. constructor(byteLength: number);
  62495. /**
  62496. * Resize the array buffer to the specified byte length
  62497. * @param byteLength
  62498. */
  62499. private resizeBuffer;
  62500. /**
  62501. * Get an array buffer with the length of the byte offset
  62502. * @returns ArrayBuffer resized to the byte offset
  62503. */
  62504. getArrayBuffer(): ArrayBuffer;
  62505. /**
  62506. * Get the byte offset of the array buffer
  62507. * @returns byte offset
  62508. */
  62509. getByteOffset(): number;
  62510. /**
  62511. * Stores an UInt8 in the array buffer
  62512. * @param entry
  62513. * @param byteOffset If defined, specifies where to set the value as an offset.
  62514. */
  62515. setUInt8(entry: number, byteOffset?: number): void;
  62516. /**
  62517. * Gets an UInt32 in the array buffer
  62518. * @param entry
  62519. * @param byteOffset If defined, specifies where to set the value as an offset.
  62520. */
  62521. getUInt32(byteOffset: number): number;
  62522. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62523. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  62524. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62525. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  62526. /**
  62527. * Stores a Float32 in the array buffer
  62528. * @param entry
  62529. */
  62530. setFloat32(entry: number, byteOffset?: number): void;
  62531. /**
  62532. * Stores an UInt32 in the array buffer
  62533. * @param entry
  62534. * @param byteOffset If defined, specifies where to set the value as an offset.
  62535. */
  62536. setUInt32(entry: number, byteOffset?: number): void;
  62537. }
  62538. }
  62539. declare module BABYLON.GLTF2.Exporter {
  62540. /**
  62541. * @hidden
  62542. * Interface to store animation data.
  62543. */
  62544. export interface _IAnimationData {
  62545. /**
  62546. * Keyframe data.
  62547. */
  62548. inputs: number[];
  62549. /**
  62550. * Value data.
  62551. */
  62552. outputs: number[][];
  62553. /**
  62554. * Animation interpolation data.
  62555. */
  62556. samplerInterpolation: AnimationSamplerInterpolation;
  62557. /**
  62558. * Minimum keyframe value.
  62559. */
  62560. inputsMin: number;
  62561. /**
  62562. * Maximum keyframe value.
  62563. */
  62564. inputsMax: number;
  62565. }
  62566. /**
  62567. * @hidden
  62568. */
  62569. export interface _IAnimationInfo {
  62570. /**
  62571. * The target channel for the animation
  62572. */
  62573. animationChannelTargetPath: AnimationChannelTargetPath;
  62574. /**
  62575. * The glTF accessor type for the data.
  62576. */
  62577. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  62578. /**
  62579. * Specifies if quaternions should be used.
  62580. */
  62581. useQuaternion: boolean;
  62582. }
  62583. /**
  62584. * @hidden
  62585. * Utility class for generating glTF animation data from BabylonJS.
  62586. */
  62587. export class _GLTFAnimation {
  62588. /**
  62589. * @ignore
  62590. *
  62591. * Creates glTF channel animation from BabylonJS animation.
  62592. * @param babylonTransformNode - BabylonJS mesh.
  62593. * @param animation - animation.
  62594. * @param animationChannelTargetPath - The target animation channel.
  62595. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  62596. * @param useQuaternion - Specifies if quaternions are used.
  62597. * @returns nullable IAnimationData
  62598. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  62599. private static _DeduceAnimationInfo;
  62600. /**
  62601. * @ignore
  62602. * Create node animations from the transform node animations
  62603. * @param babylonNode
  62604. * @param runtimeGLTFAnimation
  62605. * @param idleGLTFAnimations
  62606. * @param nodeMap
  62607. * @param nodes
  62608. * @param binaryWriter
  62609. * @param bufferViews
  62610. * @param accessors
  62611. * @param convertToRightHandedSystem
  62612. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  62613. [key: number]: number;
  62614. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62615. /**
  62616. * @ignore
  62617. * Create node animations from the animation groups
  62618. * @param babylonScene
  62619. * @param glTFAnimations
  62620. * @param nodeMap
  62621. * @param nodes
  62622. * @param binaryWriter
  62623. * @param bufferViews
  62624. * @param accessors
  62625. * @param convertToRightHandedSystem
  62626. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  62627. [key: number]: number;
  62628. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  62629. private static AddAnimation;
  62630. /**
  62631. * Create a baked animation
  62632. * @param babylonTransformNode BabylonJS mesh
  62633. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  62634. * @param animationChannelTargetPath animation target channel
  62635. * @param minFrame minimum animation frame
  62636. * @param maxFrame maximum animation frame
  62637. * @param fps frames per second of the animation
  62638. * @param inputs input key frames of the animation
  62639. * @param outputs output key frame data of the animation
  62640. * @param convertToRightHandedSystem converts the values to right-handed
  62641. * @param useQuaternion specifies if quaternions should be used
  62642. */
  62643. private static _CreateBakedAnimation;
  62644. private static _ConvertFactorToVector3OrQuaternion;
  62645. private static _SetInterpolatedValue;
  62646. /**
  62647. * Creates linear animation from the animation key frames
  62648. * @param babylonTransformNode BabylonJS mesh
  62649. * @param animation BabylonJS animation
  62650. * @param animationChannelTargetPath The target animation channel
  62651. * @param frameDelta The difference between the last and first frame of the animation
  62652. * @param inputs Array to store the key frame times
  62653. * @param outputs Array to store the key frame data
  62654. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62655. * @param useQuaternion Specifies if quaternions are used in the animation
  62656. */
  62657. private static _CreateLinearOrStepAnimation;
  62658. /**
  62659. * Creates cubic spline animation from the animation key frames
  62660. * @param babylonTransformNode BabylonJS mesh
  62661. * @param animation BabylonJS animation
  62662. * @param animationChannelTargetPath The target animation channel
  62663. * @param frameDelta The difference between the last and first frame of the animation
  62664. * @param inputs Array to store the key frame times
  62665. * @param outputs Array to store the key frame data
  62666. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  62667. * @param useQuaternion Specifies if quaternions are used in the animation
  62668. */
  62669. private static _CreateCubicSplineAnimation;
  62670. private static _GetBasePositionRotationOrScale;
  62671. /**
  62672. * Adds a key frame value
  62673. * @param keyFrame
  62674. * @param animation
  62675. * @param outputs
  62676. * @param animationChannelTargetPath
  62677. * @param basePositionRotationOrScale
  62678. * @param convertToRightHandedSystem
  62679. * @param useQuaternion
  62680. */
  62681. private static _AddKeyframeValue;
  62682. /**
  62683. * Determine the interpolation based on the key frames
  62684. * @param keyFrames
  62685. * @param animationChannelTargetPath
  62686. * @param useQuaternion
  62687. */
  62688. private static _DeduceInterpolation;
  62689. /**
  62690. * Adds an input tangent or output tangent to the output data
  62691. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  62692. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  62693. * @param outputs The animation data by keyframe
  62694. * @param animationChannelTargetPath The target animation channel
  62695. * @param interpolation The interpolation type
  62696. * @param keyFrame The key frame with the animation data
  62697. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  62698. * @param useQuaternion Specifies if quaternions are used
  62699. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  62700. */
  62701. private static AddSplineTangent;
  62702. /**
  62703. * Get the minimum and maximum key frames' frame values
  62704. * @param keyFrames animation key frames
  62705. * @returns the minimum and maximum key frame value
  62706. */
  62707. private static calculateMinMaxKeyFrames;
  62708. }
  62709. }
  62710. declare module BABYLON.GLTF2.Exporter {
  62711. /** @hidden */
  62712. export var textureTransformPixelShader: {
  62713. name: string;
  62714. shader: string;
  62715. };
  62716. }
  62717. declare module BABYLON.GLTF2.Exporter.Extensions {
  62718. /**
  62719. * @hidden
  62720. */
  62721. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  62722. /** Name of this extension */
  62723. readonly name: string;
  62724. /** Defines whether this extension is enabled */
  62725. enabled: boolean;
  62726. /** Defines whether this extension is required */
  62727. required: boolean;
  62728. /** Reference to the glTF exporter */
  62729. private _exporter;
  62730. constructor(exporter: _Exporter);
  62731. dispose(): void;
  62732. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  62733. /**
  62734. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  62735. * @param babylonTexture
  62736. * @param offset
  62737. * @param rotation
  62738. * @param scale
  62739. * @param scene
  62740. */
  62741. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62742. }
  62743. }
  62744. declare module BABYLON.GLTF2.Exporter.Extensions {
  62745. /**
  62746. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62747. */
  62748. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62749. /** The name of this extension. */
  62750. readonly name: string;
  62751. /** Defines whether this extension is enabled. */
  62752. enabled: boolean;
  62753. /** Defines whether this extension is required */
  62754. required: boolean;
  62755. /** Reference to the glTF exporter */
  62756. private _exporter;
  62757. private _lights;
  62758. /** @hidden */
  62759. constructor(exporter: _Exporter);
  62760. /** @hidden */
  62761. dispose(): void;
  62762. /** @hidden */
  62763. onExporting(): void;
  62764. /**
  62765. * Define this method to modify the default behavior when exporting a node
  62766. * @param context The context when exporting the node
  62767. * @param node glTF node
  62768. * @param babylonNode BabylonJS node
  62769. * @returns nullable INode promise
  62770. */
  62771. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62772. }
  62773. }
  62774. declare module BABYLON {
  62775. /**
  62776. * Class for generating STL data from a Babylon scene.
  62777. */
  62778. export class STLExport {
  62779. /**
  62780. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62781. * @param meshes list defines the mesh to serialize
  62782. * @param download triggers the automatic download of the file.
  62783. * @param fileName changes the downloads fileName.
  62784. * @param binary changes the STL to a binary type.
  62785. * @param isLittleEndian toggle for binary type exporter.
  62786. * @returns the STL as UTF8 string
  62787. */
  62788. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62789. }
  62790. }
  62791. /**
  62792. * @ignoreChildren
  62793. * @ignore
  62794. */
  62795. declare module "babylonjs-gltf2interface" {
  62796. export = BABYLON.GLTF2;
  62797. }
  62798. /**
  62799. * Module for glTF 2.0 Interface
  62800. * @ignoreChildren
  62801. * @ignore
  62802. */
  62803. declare module BABYLON.GLTF2 {
  62804. /**
  62805. * The datatype of the components in the attribute
  62806. */
  62807. const enum AccessorComponentType {
  62808. /**
  62809. * Byte
  62810. */
  62811. BYTE = 5120,
  62812. /**
  62813. * Unsigned Byte
  62814. */
  62815. UNSIGNED_BYTE = 5121,
  62816. /**
  62817. * Short
  62818. */
  62819. SHORT = 5122,
  62820. /**
  62821. * Unsigned Short
  62822. */
  62823. UNSIGNED_SHORT = 5123,
  62824. /**
  62825. * Unsigned Int
  62826. */
  62827. UNSIGNED_INT = 5125,
  62828. /**
  62829. * Float
  62830. */
  62831. FLOAT = 5126,
  62832. }
  62833. /**
  62834. * Specifies if the attirbute is a scalar, vector, or matrix
  62835. */
  62836. const enum AccessorType {
  62837. /**
  62838. * Scalar
  62839. */
  62840. SCALAR = "SCALAR",
  62841. /**
  62842. * Vector2
  62843. */
  62844. VEC2 = "VEC2",
  62845. /**
  62846. * Vector3
  62847. */
  62848. VEC3 = "VEC3",
  62849. /**
  62850. * Vector4
  62851. */
  62852. VEC4 = "VEC4",
  62853. /**
  62854. * Matrix2x2
  62855. */
  62856. MAT2 = "MAT2",
  62857. /**
  62858. * Matrix3x3
  62859. */
  62860. MAT3 = "MAT3",
  62861. /**
  62862. * Matrix4x4
  62863. */
  62864. MAT4 = "MAT4",
  62865. }
  62866. /**
  62867. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62868. */
  62869. const enum AnimationChannelTargetPath {
  62870. /**
  62871. * Translation
  62872. */
  62873. TRANSLATION = "translation",
  62874. /**
  62875. * Rotation
  62876. */
  62877. ROTATION = "rotation",
  62878. /**
  62879. * Scale
  62880. */
  62881. SCALE = "scale",
  62882. /**
  62883. * Weights
  62884. */
  62885. WEIGHTS = "weights",
  62886. }
  62887. /**
  62888. * Interpolation algorithm
  62889. */
  62890. const enum AnimationSamplerInterpolation {
  62891. /**
  62892. * The animated values are linearly interpolated between keyframes
  62893. */
  62894. LINEAR = "LINEAR",
  62895. /**
  62896. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62897. */
  62898. STEP = "STEP",
  62899. /**
  62900. * The animation's interpolation is computed using a cubic spline with specified tangents
  62901. */
  62902. CUBICSPLINE = "CUBICSPLINE",
  62903. }
  62904. /**
  62905. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62906. */
  62907. const enum CameraType {
  62908. /**
  62909. * A perspective camera containing properties to create a perspective projection matrix
  62910. */
  62911. PERSPECTIVE = "perspective",
  62912. /**
  62913. * An orthographic camera containing properties to create an orthographic projection matrix
  62914. */
  62915. ORTHOGRAPHIC = "orthographic",
  62916. }
  62917. /**
  62918. * The mime-type of the image
  62919. */
  62920. const enum ImageMimeType {
  62921. /**
  62922. * JPEG Mime-type
  62923. */
  62924. JPEG = "image/jpeg",
  62925. /**
  62926. * PNG Mime-type
  62927. */
  62928. PNG = "image/png",
  62929. }
  62930. /**
  62931. * The alpha rendering mode of the material
  62932. */
  62933. const enum MaterialAlphaMode {
  62934. /**
  62935. * The alpha value is ignored and the rendered output is fully opaque
  62936. */
  62937. OPAQUE = "OPAQUE",
  62938. /**
  62939. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62940. */
  62941. MASK = "MASK",
  62942. /**
  62943. * 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)
  62944. */
  62945. BLEND = "BLEND",
  62946. }
  62947. /**
  62948. * The type of the primitives to render
  62949. */
  62950. const enum MeshPrimitiveMode {
  62951. /**
  62952. * Points
  62953. */
  62954. POINTS = 0,
  62955. /**
  62956. * Lines
  62957. */
  62958. LINES = 1,
  62959. /**
  62960. * Line Loop
  62961. */
  62962. LINE_LOOP = 2,
  62963. /**
  62964. * Line Strip
  62965. */
  62966. LINE_STRIP = 3,
  62967. /**
  62968. * Triangles
  62969. */
  62970. TRIANGLES = 4,
  62971. /**
  62972. * Triangle Strip
  62973. */
  62974. TRIANGLE_STRIP = 5,
  62975. /**
  62976. * Triangle Fan
  62977. */
  62978. TRIANGLE_FAN = 6,
  62979. }
  62980. /**
  62981. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62982. */
  62983. const enum TextureMagFilter {
  62984. /**
  62985. * Nearest
  62986. */
  62987. NEAREST = 9728,
  62988. /**
  62989. * Linear
  62990. */
  62991. LINEAR = 9729,
  62992. }
  62993. /**
  62994. * Minification filter. All valid values correspond to WebGL enums
  62995. */
  62996. const enum TextureMinFilter {
  62997. /**
  62998. * Nearest
  62999. */
  63000. NEAREST = 9728,
  63001. /**
  63002. * Linear
  63003. */
  63004. LINEAR = 9729,
  63005. /**
  63006. * Nearest Mip-Map Nearest
  63007. */
  63008. NEAREST_MIPMAP_NEAREST = 9984,
  63009. /**
  63010. * Linear Mipmap Nearest
  63011. */
  63012. LINEAR_MIPMAP_NEAREST = 9985,
  63013. /**
  63014. * Nearest Mipmap Linear
  63015. */
  63016. NEAREST_MIPMAP_LINEAR = 9986,
  63017. /**
  63018. * Linear Mipmap Linear
  63019. */
  63020. LINEAR_MIPMAP_LINEAR = 9987,
  63021. }
  63022. /**
  63023. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63024. */
  63025. const enum TextureWrapMode {
  63026. /**
  63027. * Clamp to Edge
  63028. */
  63029. CLAMP_TO_EDGE = 33071,
  63030. /**
  63031. * Mirrored Repeat
  63032. */
  63033. MIRRORED_REPEAT = 33648,
  63034. /**
  63035. * Repeat
  63036. */
  63037. REPEAT = 10497,
  63038. }
  63039. /**
  63040. * glTF Property
  63041. */
  63042. interface IProperty {
  63043. /**
  63044. * Dictionary object with extension-specific objects
  63045. */
  63046. extensions?: {
  63047. [key: string]: any;
  63048. };
  63049. /**
  63050. * Application-Specific data
  63051. */
  63052. extras?: any;
  63053. }
  63054. /**
  63055. * glTF Child of Root Property
  63056. */
  63057. interface IChildRootProperty extends IProperty {
  63058. /**
  63059. * The user-defined name of this object
  63060. */
  63061. name?: string;
  63062. }
  63063. /**
  63064. * Indices of those attributes that deviate from their initialization value
  63065. */
  63066. interface IAccessorSparseIndices extends IProperty {
  63067. /**
  63068. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63069. */
  63070. bufferView: number;
  63071. /**
  63072. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63073. */
  63074. byteOffset?: number;
  63075. /**
  63076. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  63077. */
  63078. componentType: AccessorComponentType;
  63079. }
  63080. /**
  63081. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  63082. */
  63083. interface IAccessorSparseValues extends IProperty {
  63084. /**
  63085. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  63086. */
  63087. bufferView: number;
  63088. /**
  63089. * The offset relative to the start of the bufferView in bytes. Must be aligned
  63090. */
  63091. byteOffset?: number;
  63092. }
  63093. /**
  63094. * Sparse storage of attributes that deviate from their initialization value
  63095. */
  63096. interface IAccessorSparse extends IProperty {
  63097. /**
  63098. * The number of attributes encoded in this sparse accessor
  63099. */
  63100. count: number;
  63101. /**
  63102. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  63103. */
  63104. indices: IAccessorSparseIndices;
  63105. /**
  63106. * 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
  63107. */
  63108. values: IAccessorSparseValues;
  63109. }
  63110. /**
  63111. * 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
  63112. */
  63113. interface IAccessor extends IChildRootProperty {
  63114. /**
  63115. * The index of the bufferview
  63116. */
  63117. bufferView?: number;
  63118. /**
  63119. * The offset relative to the start of the bufferView in bytes
  63120. */
  63121. byteOffset?: number;
  63122. /**
  63123. * The datatype of components in the attribute
  63124. */
  63125. componentType: AccessorComponentType;
  63126. /**
  63127. * Specifies whether integer data values should be normalized
  63128. */
  63129. normalized?: boolean;
  63130. /**
  63131. * The number of attributes referenced by this accessor
  63132. */
  63133. count: number;
  63134. /**
  63135. * Specifies if the attribute is a scalar, vector, or matrix
  63136. */
  63137. type: AccessorType;
  63138. /**
  63139. * Maximum value of each component in this attribute
  63140. */
  63141. max?: number[];
  63142. /**
  63143. * Minimum value of each component in this attribute
  63144. */
  63145. min?: number[];
  63146. /**
  63147. * Sparse storage of attributes that deviate from their initialization value
  63148. */
  63149. sparse?: IAccessorSparse;
  63150. }
  63151. /**
  63152. * Targets an animation's sampler at a node's property
  63153. */
  63154. interface IAnimationChannel extends IProperty {
  63155. /**
  63156. * The index of a sampler in this animation used to compute the value for the target
  63157. */
  63158. sampler: number;
  63159. /**
  63160. * The index of the node and TRS property to target
  63161. */
  63162. target: IAnimationChannelTarget;
  63163. }
  63164. /**
  63165. * The index of the node and TRS property that an animation channel targets
  63166. */
  63167. interface IAnimationChannelTarget extends IProperty {
  63168. /**
  63169. * The index of the node to target
  63170. */
  63171. node: number;
  63172. /**
  63173. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  63174. */
  63175. path: AnimationChannelTargetPath;
  63176. }
  63177. /**
  63178. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63179. */
  63180. interface IAnimationSampler extends IProperty {
  63181. /**
  63182. * The index of an accessor containing keyframe input values, e.g., time
  63183. */
  63184. input: number;
  63185. /**
  63186. * Interpolation algorithm
  63187. */
  63188. interpolation?: AnimationSamplerInterpolation;
  63189. /**
  63190. * The index of an accessor, containing keyframe output values
  63191. */
  63192. output: number;
  63193. }
  63194. /**
  63195. * A keyframe animation
  63196. */
  63197. interface IAnimation extends IChildRootProperty {
  63198. /**
  63199. * An array of channels, each of which targets an animation's sampler at a node's property
  63200. */
  63201. channels: IAnimationChannel[];
  63202. /**
  63203. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  63204. */
  63205. samplers: IAnimationSampler[];
  63206. }
  63207. /**
  63208. * Metadata about the glTF asset
  63209. */
  63210. interface IAsset extends IChildRootProperty {
  63211. /**
  63212. * A copyright message suitable for display to credit the content creator
  63213. */
  63214. copyright?: string;
  63215. /**
  63216. * Tool that generated this glTF model. Useful for debugging
  63217. */
  63218. generator?: string;
  63219. /**
  63220. * The glTF version that this asset targets
  63221. */
  63222. version: string;
  63223. /**
  63224. * The minimum glTF version that this asset targets
  63225. */
  63226. minVersion?: string;
  63227. }
  63228. /**
  63229. * A buffer points to binary geometry, animation, or skins
  63230. */
  63231. interface IBuffer extends IChildRootProperty {
  63232. /**
  63233. * 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
  63234. */
  63235. uri?: string;
  63236. /**
  63237. * The length of the buffer in bytes
  63238. */
  63239. byteLength: number;
  63240. }
  63241. /**
  63242. * A view into a buffer generally representing a subset of the buffer
  63243. */
  63244. interface IBufferView extends IChildRootProperty {
  63245. /**
  63246. * The index of the buffer
  63247. */
  63248. buffer: number;
  63249. /**
  63250. * The offset into the buffer in bytes
  63251. */
  63252. byteOffset?: number;
  63253. /**
  63254. * The lenth of the bufferView in bytes
  63255. */
  63256. byteLength: number;
  63257. /**
  63258. * The stride, in bytes
  63259. */
  63260. byteStride?: number;
  63261. }
  63262. /**
  63263. * An orthographic camera containing properties to create an orthographic projection matrix
  63264. */
  63265. interface ICameraOrthographic extends IProperty {
  63266. /**
  63267. * The floating-point horizontal magnification of the view. Must not be zero
  63268. */
  63269. xmag: number;
  63270. /**
  63271. * The floating-point vertical magnification of the view. Must not be zero
  63272. */
  63273. ymag: number;
  63274. /**
  63275. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  63276. */
  63277. zfar: number;
  63278. /**
  63279. * The floating-point distance to the near clipping plane
  63280. */
  63281. znear: number;
  63282. }
  63283. /**
  63284. * A perspective camera containing properties to create a perspective projection matrix
  63285. */
  63286. interface ICameraPerspective extends IProperty {
  63287. /**
  63288. * The floating-point aspect ratio of the field of view
  63289. */
  63290. aspectRatio?: number;
  63291. /**
  63292. * The floating-point vertical field of view in radians
  63293. */
  63294. yfov: number;
  63295. /**
  63296. * The floating-point distance to the far clipping plane
  63297. */
  63298. zfar?: number;
  63299. /**
  63300. * The floating-point distance to the near clipping plane
  63301. */
  63302. znear: number;
  63303. }
  63304. /**
  63305. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  63306. */
  63307. interface ICamera extends IChildRootProperty {
  63308. /**
  63309. * An orthographic camera containing properties to create an orthographic projection matrix
  63310. */
  63311. orthographic?: ICameraOrthographic;
  63312. /**
  63313. * A perspective camera containing properties to create a perspective projection matrix
  63314. */
  63315. perspective?: ICameraPerspective;
  63316. /**
  63317. * Specifies if the camera uses a perspective or orthographic projection
  63318. */
  63319. type: CameraType;
  63320. }
  63321. /**
  63322. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  63323. */
  63324. interface IImage extends IChildRootProperty {
  63325. /**
  63326. * 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
  63327. */
  63328. uri?: string;
  63329. /**
  63330. * The image's MIME type
  63331. */
  63332. mimeType?: ImageMimeType;
  63333. /**
  63334. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  63335. */
  63336. bufferView?: number;
  63337. }
  63338. /**
  63339. * Material Normal Texture Info
  63340. */
  63341. interface IMaterialNormalTextureInfo extends ITextureInfo {
  63342. /**
  63343. * The scalar multiplier applied to each normal vector of the normal texture
  63344. */
  63345. scale?: number;
  63346. }
  63347. /**
  63348. * Material Occlusion Texture Info
  63349. */
  63350. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  63351. /**
  63352. * A scalar multiplier controlling the amount of occlusion applied
  63353. */
  63354. strength?: number;
  63355. }
  63356. /**
  63357. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  63358. */
  63359. interface IMaterialPbrMetallicRoughness {
  63360. /**
  63361. * The material's base color factor
  63362. */
  63363. baseColorFactor?: number[];
  63364. /**
  63365. * The base color texture
  63366. */
  63367. baseColorTexture?: ITextureInfo;
  63368. /**
  63369. * The metalness of the material
  63370. */
  63371. metallicFactor?: number;
  63372. /**
  63373. * The roughness of the material
  63374. */
  63375. roughnessFactor?: number;
  63376. /**
  63377. * The metallic-roughness texture
  63378. */
  63379. metallicRoughnessTexture?: ITextureInfo;
  63380. }
  63381. /**
  63382. * The material appearance of a primitive
  63383. */
  63384. interface IMaterial extends IChildRootProperty {
  63385. /**
  63386. * 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
  63387. */
  63388. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  63389. /**
  63390. * The normal map texture
  63391. */
  63392. normalTexture?: IMaterialNormalTextureInfo;
  63393. /**
  63394. * The occlusion map texture
  63395. */
  63396. occlusionTexture?: IMaterialOcclusionTextureInfo;
  63397. /**
  63398. * The emissive map texture
  63399. */
  63400. emissiveTexture?: ITextureInfo;
  63401. /**
  63402. * 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
  63403. */
  63404. emissiveFactor?: number[];
  63405. /**
  63406. * The alpha rendering mode of the material
  63407. */
  63408. alphaMode?: MaterialAlphaMode;
  63409. /**
  63410. * The alpha cutoff value of the material
  63411. */
  63412. alphaCutoff?: number;
  63413. /**
  63414. * Specifies whether the material is double sided
  63415. */
  63416. doubleSided?: boolean;
  63417. }
  63418. /**
  63419. * Geometry to be rendered with the given material
  63420. */
  63421. interface IMeshPrimitive extends IProperty {
  63422. /**
  63423. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  63424. */
  63425. attributes: {
  63426. [name: string]: number;
  63427. };
  63428. /**
  63429. * The index of the accessor that contains the indices
  63430. */
  63431. indices?: number;
  63432. /**
  63433. * The index of the material to apply to this primitive when rendering
  63434. */
  63435. material?: number;
  63436. /**
  63437. * The type of primitives to render. All valid values correspond to WebGL enums
  63438. */
  63439. mode?: MeshPrimitiveMode;
  63440. /**
  63441. * 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
  63442. */
  63443. targets?: {
  63444. [name: string]: number;
  63445. }[];
  63446. }
  63447. /**
  63448. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  63449. */
  63450. interface IMesh extends IChildRootProperty {
  63451. /**
  63452. * An array of primitives, each defining geometry to be rendered with a material
  63453. */
  63454. primitives: IMeshPrimitive[];
  63455. /**
  63456. * Array of weights to be applied to the Morph Targets
  63457. */
  63458. weights?: number[];
  63459. }
  63460. /**
  63461. * A node in the node hierarchy
  63462. */
  63463. interface INode extends IChildRootProperty {
  63464. /**
  63465. * The index of the camera referenced by this node
  63466. */
  63467. camera?: number;
  63468. /**
  63469. * The indices of this node's children
  63470. */
  63471. children?: number[];
  63472. /**
  63473. * The index of the skin referenced by this node
  63474. */
  63475. skin?: number;
  63476. /**
  63477. * A floating-point 4x4 transformation matrix stored in column-major order
  63478. */
  63479. matrix?: number[];
  63480. /**
  63481. * The index of the mesh in this node
  63482. */
  63483. mesh?: number;
  63484. /**
  63485. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  63486. */
  63487. rotation?: number[];
  63488. /**
  63489. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  63490. */
  63491. scale?: number[];
  63492. /**
  63493. * The node's translation along the x, y, and z axes
  63494. */
  63495. translation?: number[];
  63496. /**
  63497. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  63498. */
  63499. weights?: number[];
  63500. }
  63501. /**
  63502. * Texture sampler properties for filtering and wrapping modes
  63503. */
  63504. interface ISampler extends IChildRootProperty {
  63505. /**
  63506. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  63507. */
  63508. magFilter?: TextureMagFilter;
  63509. /**
  63510. * Minification filter. All valid values correspond to WebGL enums
  63511. */
  63512. minFilter?: TextureMinFilter;
  63513. /**
  63514. * S (U) wrapping mode. All valid values correspond to WebGL enums
  63515. */
  63516. wrapS?: TextureWrapMode;
  63517. /**
  63518. * T (V) wrapping mode. All valid values correspond to WebGL enums
  63519. */
  63520. wrapT?: TextureWrapMode;
  63521. }
  63522. /**
  63523. * The root nodes of a scene
  63524. */
  63525. interface IScene extends IChildRootProperty {
  63526. /**
  63527. * The indices of each root node
  63528. */
  63529. nodes: number[];
  63530. }
  63531. /**
  63532. * Joints and matrices defining a skin
  63533. */
  63534. interface ISkin extends IChildRootProperty {
  63535. /**
  63536. * 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
  63537. */
  63538. inverseBindMatrices?: number;
  63539. /**
  63540. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  63541. */
  63542. skeleton?: number;
  63543. /**
  63544. * 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)
  63545. */
  63546. joints: number[];
  63547. }
  63548. /**
  63549. * A texture and its sampler
  63550. */
  63551. interface ITexture extends IChildRootProperty {
  63552. /**
  63553. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  63554. */
  63555. sampler?: number;
  63556. /**
  63557. * The index of the image used by this texture
  63558. */
  63559. source: number;
  63560. }
  63561. /**
  63562. * Reference to a texture
  63563. */
  63564. interface ITextureInfo extends IProperty {
  63565. /**
  63566. * The index of the texture
  63567. */
  63568. index: number;
  63569. /**
  63570. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  63571. */
  63572. texCoord?: number;
  63573. }
  63574. /**
  63575. * The root object for a glTF asset
  63576. */
  63577. interface IGLTF extends IProperty {
  63578. /**
  63579. * An array of accessors. An accessor is a typed view into a bufferView
  63580. */
  63581. accessors?: IAccessor[];
  63582. /**
  63583. * An array of keyframe animations
  63584. */
  63585. animations?: IAnimation[];
  63586. /**
  63587. * Metadata about the glTF asset
  63588. */
  63589. asset: IAsset;
  63590. /**
  63591. * An array of buffers. A buffer points to binary geometry, animation, or skins
  63592. */
  63593. buffers?: IBuffer[];
  63594. /**
  63595. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  63596. */
  63597. bufferViews?: IBufferView[];
  63598. /**
  63599. * An array of cameras
  63600. */
  63601. cameras?: ICamera[];
  63602. /**
  63603. * Names of glTF extensions used somewhere in this asset
  63604. */
  63605. extensionsUsed?: string[];
  63606. /**
  63607. * Names of glTF extensions required to properly load this asset
  63608. */
  63609. extensionsRequired?: string[];
  63610. /**
  63611. * An array of images. An image defines data used to create a texture
  63612. */
  63613. images?: IImage[];
  63614. /**
  63615. * An array of materials. A material defines the appearance of a primitive
  63616. */
  63617. materials?: IMaterial[];
  63618. /**
  63619. * An array of meshes. A mesh is a set of primitives to be rendered
  63620. */
  63621. meshes?: IMesh[];
  63622. /**
  63623. * An array of nodes
  63624. */
  63625. nodes?: INode[];
  63626. /**
  63627. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  63628. */
  63629. samplers?: ISampler[];
  63630. /**
  63631. * The index of the default scene
  63632. */
  63633. scene?: number;
  63634. /**
  63635. * An array of scenes
  63636. */
  63637. scenes?: IScene[];
  63638. /**
  63639. * An array of skins. A skin is defined by joints and matrices
  63640. */
  63641. skins?: ISkin[];
  63642. /**
  63643. * An array of textures
  63644. */
  63645. textures?: ITexture[];
  63646. }
  63647. /**
  63648. * Interface for glTF validation results
  63649. */
  63650. interface IGLTFValidationResults {
  63651. info: {
  63652. generator: string;
  63653. hasAnimations: boolean;
  63654. hasDefaultScene: boolean;
  63655. hasMaterials: boolean;
  63656. hasMorphTargets: boolean;
  63657. hasSkins: boolean;
  63658. hasTextures: boolean;
  63659. maxAttributesUsed: number;
  63660. primitivesCount: number
  63661. };
  63662. issues: {
  63663. messages: Array<string>;
  63664. numErrors: number;
  63665. numHints: number;
  63666. numInfos: number;
  63667. numWarnings: number;
  63668. truncated: boolean
  63669. };
  63670. mimeType: string;
  63671. uri: string;
  63672. validatedAt: string;
  63673. validatorVersion: string;
  63674. }
  63675. /**
  63676. * Interface for glTF validation options
  63677. */
  63678. interface IGLTFValidationOptions {
  63679. uri?: string;
  63680. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63681. validateAccessorData?: boolean;
  63682. maxIssues?: number;
  63683. ignoredIssues?: Array<string>;
  63684. severityOverrides?: Object;
  63685. }
  63686. /**
  63687. * glTF validator object Tyyings
  63688. */
  63689. interface IGLTFValidatorTypings {
  63690. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63691. }
  63692. }
  63693. /**
  63694. * Interface for glTF validation results
  63695. */
  63696. interface IGLTFValidationResults {
  63697. info: {
  63698. generator: string;
  63699. hasAnimations: boolean;
  63700. hasDefaultScene: boolean;
  63701. hasMaterials: boolean;
  63702. hasMorphTargets: boolean;
  63703. hasSkins: boolean;
  63704. hasTextures: boolean;
  63705. maxAttributesUsed: number;
  63706. primitivesCount: number
  63707. };
  63708. issues: {
  63709. messages: Array<string>;
  63710. numErrors: number;
  63711. numHints: number;
  63712. numInfos: number;
  63713. numWarnings: number;
  63714. truncated: boolean
  63715. };
  63716. mimeType: string;
  63717. uri: string;
  63718. validatedAt: string;
  63719. validatorVersion: string;
  63720. }
  63721. /**
  63722. * Interface for glTF validation options
  63723. */
  63724. interface IGLTFValidationOptions {
  63725. uri?: string;
  63726. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  63727. validateAccessorData?: boolean;
  63728. maxIssues?: number;
  63729. ignoredIssues?: Array<string>;
  63730. severityOverrides?: Object;
  63731. }
  63732. /**
  63733. * glTF validator object Tyyings
  63734. */
  63735. interface IGLTFValidatorTypings {
  63736. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  63737. }
  63738. declare module BABYLON {
  63739. /** @hidden */
  63740. export var cellPixelShader: {
  63741. name: string;
  63742. shader: string;
  63743. };
  63744. }
  63745. declare module BABYLON {
  63746. /** @hidden */
  63747. export var cellVertexShader: {
  63748. name: string;
  63749. shader: string;
  63750. };
  63751. }
  63752. declare module BABYLON {
  63753. export class CellMaterial extends BABYLON.PushMaterial {
  63754. private _diffuseTexture;
  63755. diffuseTexture: BABYLON.BaseTexture;
  63756. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63757. computeHighLevel: boolean;
  63758. private _disableLighting;
  63759. disableLighting: boolean;
  63760. private _maxSimultaneousLights;
  63761. maxSimultaneousLights: number;
  63762. private _renderId;
  63763. constructor(name: string, scene: BABYLON.Scene);
  63764. needAlphaBlending(): boolean;
  63765. needAlphaTesting(): boolean;
  63766. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63767. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63768. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63769. getAnimatables(): BABYLON.IAnimatable[];
  63770. getActiveTextures(): BABYLON.BaseTexture[];
  63771. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63772. dispose(forceDisposeEffect?: boolean): void;
  63773. getClassName(): string;
  63774. clone(name: string): CellMaterial;
  63775. serialize(): any;
  63776. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63777. }
  63778. }
  63779. declare module BABYLON {
  63780. export class CustomShaderStructure {
  63781. FragmentStore: string;
  63782. VertexStore: string;
  63783. constructor();
  63784. }
  63785. export class ShaderSpecialParts {
  63786. constructor();
  63787. Fragment_Begin: string;
  63788. Fragment_Definitions: string;
  63789. Fragment_MainBegin: string;
  63790. Fragment_Custom_Diffuse: string;
  63791. Fragment_Before_Lights: string;
  63792. Fragment_Before_Fog: string;
  63793. Fragment_Custom_Alpha: string;
  63794. Fragment_Before_FragColor: string;
  63795. Vertex_Begin: string;
  63796. Vertex_Definitions: string;
  63797. Vertex_MainBegin: string;
  63798. Vertex_Before_PositionUpdated: string;
  63799. Vertex_Before_NormalUpdated: string;
  63800. Vertex_MainEnd: string;
  63801. }
  63802. export class CustomMaterial extends BABYLON.StandardMaterial {
  63803. static ShaderIndexer: number;
  63804. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63805. FragmentShader: string;
  63806. VertexShader: string;
  63807. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63808. ReviewUniform(name: string, arr: string[]): string[];
  63809. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63810. constructor(name: string, scene: BABYLON.Scene);
  63811. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63812. Fragment_Begin(shaderPart: string): CustomMaterial;
  63813. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63814. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63815. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63816. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63817. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63818. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63819. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63820. Vertex_Begin(shaderPart: string): CustomMaterial;
  63821. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63822. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63823. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63824. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63825. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63826. }
  63827. }
  63828. declare module BABYLON {
  63829. export class ShaderAlebdoParts {
  63830. constructor();
  63831. Fragment_Begin: string;
  63832. Fragment_Definitions: string;
  63833. Fragment_MainBegin: string;
  63834. Fragment_Custom_Albedo: string;
  63835. Fragment_Before_Lights: string;
  63836. Fragment_Custom_MetallicRoughness: string;
  63837. Fragment_Custom_MicroSurface: string;
  63838. Fragment_Before_Fog: string;
  63839. Fragment_Custom_Alpha: string;
  63840. Fragment_Before_FragColor: string;
  63841. Vertex_Begin: string;
  63842. Vertex_Definitions: string;
  63843. Vertex_MainBegin: string;
  63844. Vertex_Before_PositionUpdated: string;
  63845. Vertex_Before_NormalUpdated: string;
  63846. Vertex_MainEnd: string;
  63847. }
  63848. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63849. static ShaderIndexer: number;
  63850. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63851. FragmentShader: string;
  63852. VertexShader: string;
  63853. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63854. ReviewUniform(name: string, arr: string[]): string[];
  63855. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63856. constructor(name: string, scene: BABYLON.Scene);
  63857. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63858. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63859. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63860. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63861. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63862. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63863. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63864. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  63865. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  63866. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63867. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63868. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63869. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63870. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63871. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63872. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63873. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63874. }
  63875. }
  63876. declare module BABYLON {
  63877. /** @hidden */
  63878. export var firePixelShader: {
  63879. name: string;
  63880. shader: string;
  63881. };
  63882. }
  63883. declare module BABYLON {
  63884. /** @hidden */
  63885. export var fireVertexShader: {
  63886. name: string;
  63887. shader: string;
  63888. };
  63889. }
  63890. declare module BABYLON {
  63891. export class FireMaterial extends BABYLON.PushMaterial {
  63892. private _diffuseTexture;
  63893. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63894. private _distortionTexture;
  63895. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63896. private _opacityTexture;
  63897. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63898. diffuseColor: BABYLON.Color3;
  63899. speed: number;
  63900. private _scaledDiffuse;
  63901. private _renderId;
  63902. private _lastTime;
  63903. constructor(name: string, scene: BABYLON.Scene);
  63904. needAlphaBlending(): boolean;
  63905. needAlphaTesting(): boolean;
  63906. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63907. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63908. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63909. getAnimatables(): BABYLON.IAnimatable[];
  63910. getActiveTextures(): BABYLON.BaseTexture[];
  63911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63912. getClassName(): string;
  63913. dispose(forceDisposeEffect?: boolean): void;
  63914. clone(name: string): FireMaterial;
  63915. serialize(): any;
  63916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63917. }
  63918. }
  63919. declare module BABYLON {
  63920. /** @hidden */
  63921. export var furPixelShader: {
  63922. name: string;
  63923. shader: string;
  63924. };
  63925. }
  63926. declare module BABYLON {
  63927. /** @hidden */
  63928. export var furVertexShader: {
  63929. name: string;
  63930. shader: string;
  63931. };
  63932. }
  63933. declare module BABYLON {
  63934. export class FurMaterial extends BABYLON.PushMaterial {
  63935. private _diffuseTexture;
  63936. diffuseTexture: BABYLON.BaseTexture;
  63937. private _heightTexture;
  63938. heightTexture: BABYLON.BaseTexture;
  63939. diffuseColor: BABYLON.Color3;
  63940. furLength: number;
  63941. furAngle: number;
  63942. furColor: BABYLON.Color3;
  63943. furOffset: number;
  63944. furSpacing: number;
  63945. furGravity: BABYLON.Vector3;
  63946. furSpeed: number;
  63947. furDensity: number;
  63948. furOcclusion: number;
  63949. furTexture: BABYLON.DynamicTexture;
  63950. private _disableLighting;
  63951. disableLighting: boolean;
  63952. private _maxSimultaneousLights;
  63953. maxSimultaneousLights: number;
  63954. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63955. private _renderId;
  63956. private _furTime;
  63957. constructor(name: string, scene: BABYLON.Scene);
  63958. furTime: number;
  63959. needAlphaBlending(): boolean;
  63960. needAlphaTesting(): boolean;
  63961. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63962. updateFur(): void;
  63963. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63964. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63965. getAnimatables(): BABYLON.IAnimatable[];
  63966. getActiveTextures(): BABYLON.BaseTexture[];
  63967. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63968. dispose(forceDisposeEffect?: boolean): void;
  63969. clone(name: string): FurMaterial;
  63970. serialize(): any;
  63971. getClassName(): string;
  63972. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63973. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63974. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63975. }
  63976. }
  63977. declare module BABYLON {
  63978. /** @hidden */
  63979. export var gradientPixelShader: {
  63980. name: string;
  63981. shader: string;
  63982. };
  63983. }
  63984. declare module BABYLON {
  63985. /** @hidden */
  63986. export var gradientVertexShader: {
  63987. name: string;
  63988. shader: string;
  63989. };
  63990. }
  63991. declare module BABYLON {
  63992. export class GradientMaterial extends BABYLON.PushMaterial {
  63993. private _maxSimultaneousLights;
  63994. maxSimultaneousLights: number;
  63995. topColor: BABYLON.Color3;
  63996. topColorAlpha: number;
  63997. bottomColor: BABYLON.Color3;
  63998. bottomColorAlpha: number;
  63999. offset: number;
  64000. scale: number;
  64001. smoothness: number;
  64002. private _disableLighting;
  64003. disableLighting: boolean;
  64004. private _renderId;
  64005. constructor(name: string, scene: BABYLON.Scene);
  64006. needAlphaBlending(): boolean;
  64007. needAlphaTesting(): boolean;
  64008. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64009. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64010. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64011. getAnimatables(): BABYLON.IAnimatable[];
  64012. dispose(forceDisposeEffect?: boolean): void;
  64013. clone(name: string): GradientMaterial;
  64014. serialize(): any;
  64015. getClassName(): string;
  64016. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  64017. }
  64018. }
  64019. declare module BABYLON {
  64020. /** @hidden */
  64021. export var gridPixelShader: {
  64022. name: string;
  64023. shader: string;
  64024. };
  64025. }
  64026. declare module BABYLON {
  64027. /** @hidden */
  64028. export var gridVertexShader: {
  64029. name: string;
  64030. shader: string;
  64031. };
  64032. }
  64033. declare module BABYLON {
  64034. /**
  64035. * The grid materials allows you to wrap any shape with a grid.
  64036. * Colors are customizable.
  64037. */
  64038. export class GridMaterial extends BABYLON.PushMaterial {
  64039. /**
  64040. * Main color of the grid (e.g. between lines)
  64041. */
  64042. mainColor: BABYLON.Color3;
  64043. /**
  64044. * Color of the grid lines.
  64045. */
  64046. lineColor: BABYLON.Color3;
  64047. /**
  64048. * The scale of the grid compared to unit.
  64049. */
  64050. gridRatio: number;
  64051. /**
  64052. * Allows setting an offset for the grid lines.
  64053. */
  64054. gridOffset: BABYLON.Vector3;
  64055. /**
  64056. * The frequency of thicker lines.
  64057. */
  64058. majorUnitFrequency: number;
  64059. /**
  64060. * The visibility of minor units in the grid.
  64061. */
  64062. minorUnitVisibility: number;
  64063. /**
  64064. * The grid opacity outside of the lines.
  64065. */
  64066. opacity: number;
  64067. /**
  64068. * Determine RBG output is premultiplied by alpha value.
  64069. */
  64070. preMultiplyAlpha: boolean;
  64071. private _opacityTexture;
  64072. opacityTexture: BABYLON.BaseTexture;
  64073. private _gridControl;
  64074. private _renderId;
  64075. /**
  64076. * constructor
  64077. * @param name The name given to the material in order to identify it afterwards.
  64078. * @param scene The scene the material is used in.
  64079. */
  64080. constructor(name: string, scene: BABYLON.Scene);
  64081. /**
  64082. * Returns wehter or not the grid requires alpha blending.
  64083. */
  64084. needAlphaBlending(): boolean;
  64085. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64087. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64088. /**
  64089. * Dispose the material and its associated resources.
  64090. * @param forceDisposeEffect will also dispose the used effect when true
  64091. */
  64092. dispose(forceDisposeEffect?: boolean): void;
  64093. clone(name: string): GridMaterial;
  64094. serialize(): any;
  64095. getClassName(): string;
  64096. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  64097. }
  64098. }
  64099. declare module BABYLON {
  64100. /** @hidden */
  64101. export var lavaPixelShader: {
  64102. name: string;
  64103. shader: string;
  64104. };
  64105. }
  64106. declare module BABYLON {
  64107. /** @hidden */
  64108. export var lavaVertexShader: {
  64109. name: string;
  64110. shader: string;
  64111. };
  64112. }
  64113. declare module BABYLON {
  64114. export class LavaMaterial extends BABYLON.PushMaterial {
  64115. private _diffuseTexture;
  64116. diffuseTexture: BABYLON.BaseTexture;
  64117. noiseTexture: BABYLON.BaseTexture;
  64118. fogColor: BABYLON.Color3;
  64119. speed: number;
  64120. movingSpeed: number;
  64121. lowFrequencySpeed: number;
  64122. fogDensity: number;
  64123. private _lastTime;
  64124. diffuseColor: BABYLON.Color3;
  64125. private _disableLighting;
  64126. disableLighting: boolean;
  64127. private _unlit;
  64128. unlit: boolean;
  64129. private _maxSimultaneousLights;
  64130. maxSimultaneousLights: number;
  64131. private _scaledDiffuse;
  64132. private _renderId;
  64133. constructor(name: string, scene: BABYLON.Scene);
  64134. needAlphaBlending(): boolean;
  64135. needAlphaTesting(): boolean;
  64136. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64137. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64138. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64139. getAnimatables(): BABYLON.IAnimatable[];
  64140. getActiveTextures(): BABYLON.BaseTexture[];
  64141. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64142. dispose(forceDisposeEffect?: boolean): void;
  64143. clone(name: string): LavaMaterial;
  64144. serialize(): any;
  64145. getClassName(): string;
  64146. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  64147. }
  64148. }
  64149. declare module BABYLON {
  64150. /** @hidden */
  64151. export var mixPixelShader: {
  64152. name: string;
  64153. shader: string;
  64154. };
  64155. }
  64156. declare module BABYLON {
  64157. /** @hidden */
  64158. export var mixVertexShader: {
  64159. name: string;
  64160. shader: string;
  64161. };
  64162. }
  64163. declare module BABYLON {
  64164. export class MixMaterial extends BABYLON.PushMaterial {
  64165. /**
  64166. * Mix textures
  64167. */
  64168. private _mixTexture1;
  64169. mixTexture1: BABYLON.BaseTexture;
  64170. private _mixTexture2;
  64171. mixTexture2: BABYLON.BaseTexture;
  64172. /**
  64173. * Diffuse textures
  64174. */
  64175. private _diffuseTexture1;
  64176. diffuseTexture1: BABYLON.Texture;
  64177. private _diffuseTexture2;
  64178. diffuseTexture2: BABYLON.Texture;
  64179. private _diffuseTexture3;
  64180. diffuseTexture3: BABYLON.Texture;
  64181. private _diffuseTexture4;
  64182. diffuseTexture4: BABYLON.Texture;
  64183. private _diffuseTexture5;
  64184. diffuseTexture5: BABYLON.Texture;
  64185. private _diffuseTexture6;
  64186. diffuseTexture6: BABYLON.Texture;
  64187. private _diffuseTexture7;
  64188. diffuseTexture7: BABYLON.Texture;
  64189. private _diffuseTexture8;
  64190. diffuseTexture8: BABYLON.Texture;
  64191. /**
  64192. * Uniforms
  64193. */
  64194. diffuseColor: BABYLON.Color3;
  64195. specularColor: BABYLON.Color3;
  64196. specularPower: number;
  64197. private _disableLighting;
  64198. disableLighting: boolean;
  64199. private _maxSimultaneousLights;
  64200. maxSimultaneousLights: number;
  64201. private _renderId;
  64202. constructor(name: string, scene: BABYLON.Scene);
  64203. needAlphaBlending(): boolean;
  64204. needAlphaTesting(): boolean;
  64205. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64206. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64207. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64208. getAnimatables(): BABYLON.IAnimatable[];
  64209. getActiveTextures(): BABYLON.BaseTexture[];
  64210. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64211. dispose(forceDisposeEffect?: boolean): void;
  64212. clone(name: string): MixMaterial;
  64213. serialize(): any;
  64214. getClassName(): string;
  64215. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  64216. }
  64217. }
  64218. declare module BABYLON {
  64219. /** @hidden */
  64220. export var normalPixelShader: {
  64221. name: string;
  64222. shader: string;
  64223. };
  64224. }
  64225. declare module BABYLON {
  64226. /** @hidden */
  64227. export var normalVertexShader: {
  64228. name: string;
  64229. shader: string;
  64230. };
  64231. }
  64232. declare module BABYLON {
  64233. export class NormalMaterial extends BABYLON.PushMaterial {
  64234. private _diffuseTexture;
  64235. diffuseTexture: BABYLON.BaseTexture;
  64236. diffuseColor: BABYLON.Color3;
  64237. private _disableLighting;
  64238. disableLighting: boolean;
  64239. private _maxSimultaneousLights;
  64240. maxSimultaneousLights: number;
  64241. private _renderId;
  64242. constructor(name: string, scene: BABYLON.Scene);
  64243. needAlphaBlending(): boolean;
  64244. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  64245. needAlphaTesting(): boolean;
  64246. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64247. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64248. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64249. getAnimatables(): BABYLON.IAnimatable[];
  64250. getActiveTextures(): BABYLON.BaseTexture[];
  64251. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64252. dispose(forceDisposeEffect?: boolean): void;
  64253. clone(name: string): NormalMaterial;
  64254. serialize(): any;
  64255. getClassName(): string;
  64256. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  64257. }
  64258. }
  64259. declare module BABYLON {
  64260. /** @hidden */
  64261. export var shadowOnlyPixelShader: {
  64262. name: string;
  64263. shader: string;
  64264. };
  64265. }
  64266. declare module BABYLON {
  64267. /** @hidden */
  64268. export var shadowOnlyVertexShader: {
  64269. name: string;
  64270. shader: string;
  64271. };
  64272. }
  64273. declare module BABYLON {
  64274. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  64275. private _renderId;
  64276. private _activeLight;
  64277. constructor(name: string, scene: BABYLON.Scene);
  64278. shadowColor: BABYLON.Color3;
  64279. needAlphaBlending(): boolean;
  64280. needAlphaTesting(): boolean;
  64281. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64282. activeLight: BABYLON.IShadowLight;
  64283. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64284. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64285. clone(name: string): ShadowOnlyMaterial;
  64286. serialize(): any;
  64287. getClassName(): string;
  64288. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  64289. }
  64290. }
  64291. declare module BABYLON {
  64292. /** @hidden */
  64293. export var simplePixelShader: {
  64294. name: string;
  64295. shader: string;
  64296. };
  64297. }
  64298. declare module BABYLON {
  64299. /** @hidden */
  64300. export var simpleVertexShader: {
  64301. name: string;
  64302. shader: string;
  64303. };
  64304. }
  64305. declare module BABYLON {
  64306. export class SimpleMaterial extends BABYLON.PushMaterial {
  64307. private _diffuseTexture;
  64308. diffuseTexture: BABYLON.BaseTexture;
  64309. diffuseColor: BABYLON.Color3;
  64310. private _disableLighting;
  64311. disableLighting: boolean;
  64312. private _maxSimultaneousLights;
  64313. maxSimultaneousLights: number;
  64314. private _renderId;
  64315. constructor(name: string, scene: BABYLON.Scene);
  64316. needAlphaBlending(): boolean;
  64317. needAlphaTesting(): boolean;
  64318. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64319. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64320. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64321. getAnimatables(): BABYLON.IAnimatable[];
  64322. getActiveTextures(): BABYLON.BaseTexture[];
  64323. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64324. dispose(forceDisposeEffect?: boolean): void;
  64325. clone(name: string): SimpleMaterial;
  64326. serialize(): any;
  64327. getClassName(): string;
  64328. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  64329. }
  64330. }
  64331. declare module BABYLON {
  64332. /** @hidden */
  64333. export var skyPixelShader: {
  64334. name: string;
  64335. shader: string;
  64336. };
  64337. }
  64338. declare module BABYLON {
  64339. /** @hidden */
  64340. export var skyVertexShader: {
  64341. name: string;
  64342. shader: string;
  64343. };
  64344. }
  64345. declare module BABYLON {
  64346. /**
  64347. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  64348. * @see https://doc.babylonjs.com/extensions/sky
  64349. */
  64350. export class SkyMaterial extends BABYLON.PushMaterial {
  64351. /**
  64352. * Defines the overall luminance of sky in interval ]0, 1[.
  64353. */
  64354. luminance: number;
  64355. /**
  64356. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  64357. */
  64358. turbidity: number;
  64359. /**
  64360. * Defines the sky appearance (light intensity).
  64361. */
  64362. rayleigh: number;
  64363. /**
  64364. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  64365. */
  64366. mieCoefficient: number;
  64367. /**
  64368. * Defines the amount of haze particles following the Mie scattering theory.
  64369. */
  64370. mieDirectionalG: number;
  64371. /**
  64372. * Defines the distance of the sun according to the active scene camera.
  64373. */
  64374. distance: number;
  64375. /**
  64376. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  64377. * "inclined".
  64378. */
  64379. inclination: number;
  64380. /**
  64381. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  64382. * an object direction and a reference direction.
  64383. */
  64384. azimuth: number;
  64385. /**
  64386. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  64387. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  64388. */
  64389. sunPosition: BABYLON.Vector3;
  64390. /**
  64391. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  64392. * .sunPosition property.
  64393. */
  64394. useSunPosition: boolean;
  64395. /**
  64396. * Defines an offset vector used to get a horizon offset.
  64397. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  64398. */
  64399. cameraOffset: BABYLON.Vector3;
  64400. private _cameraPosition;
  64401. private _renderId;
  64402. /**
  64403. * Instantiates a new sky material.
  64404. * This material allows to create dynamic and texture free
  64405. * effects for skyboxes by taking care of the atmosphere state.
  64406. * @see https://doc.babylonjs.com/extensions/sky
  64407. * @param name Define the name of the material in the scene
  64408. * @param scene Define the scene the material belong to
  64409. */
  64410. constructor(name: string, scene: BABYLON.Scene);
  64411. /**
  64412. * Specifies if the material will require alpha blending
  64413. * @returns a boolean specifying if alpha blending is needed
  64414. */
  64415. needAlphaBlending(): boolean;
  64416. /**
  64417. * Specifies if this material should be rendered in alpha test mode
  64418. * @returns false as the sky material doesn't need alpha testing.
  64419. */
  64420. needAlphaTesting(): boolean;
  64421. /**
  64422. * Get the texture used for alpha test purpose.
  64423. * @returns null as the sky material has no texture.
  64424. */
  64425. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64426. /**
  64427. * Get if the submesh is ready to be used and all its information available.
  64428. * Child classes can use it to update shaders
  64429. * @param mesh defines the mesh to check
  64430. * @param subMesh defines which submesh to check
  64431. * @param useInstances specifies that instances should be used
  64432. * @returns a boolean indicating that the submesh is ready or not
  64433. */
  64434. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64435. /**
  64436. * Binds the submesh to this material by preparing the effect and shader to draw
  64437. * @param world defines the world transformation matrix
  64438. * @param mesh defines the mesh containing the submesh
  64439. * @param subMesh defines the submesh to bind the material to
  64440. */
  64441. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64442. /**
  64443. * Get the list of animatables in the material.
  64444. * @returns the list of animatables object used in the material
  64445. */
  64446. getAnimatables(): BABYLON.IAnimatable[];
  64447. /**
  64448. * Disposes the material
  64449. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  64450. */
  64451. dispose(forceDisposeEffect?: boolean): void;
  64452. /**
  64453. * Makes a duplicate of the material, and gives it a new name
  64454. * @param name defines the new name for the duplicated material
  64455. * @returns the cloned material
  64456. */
  64457. clone(name: string): SkyMaterial;
  64458. /**
  64459. * Serializes this material in a JSON representation
  64460. * @returns the serialized material object
  64461. */
  64462. serialize(): any;
  64463. /**
  64464. * Gets the current class name of the material e.g. "SkyMaterial"
  64465. * Mainly use in serialization.
  64466. * @returns the class name
  64467. */
  64468. getClassName(): string;
  64469. /**
  64470. * Creates a sky material from parsed material data
  64471. * @param source defines the JSON representation of the material
  64472. * @param scene defines the hosting scene
  64473. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  64474. * @returns a new sky material
  64475. */
  64476. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  64477. }
  64478. }
  64479. declare module BABYLON {
  64480. /** @hidden */
  64481. export var terrainPixelShader: {
  64482. name: string;
  64483. shader: string;
  64484. };
  64485. }
  64486. declare module BABYLON {
  64487. /** @hidden */
  64488. export var terrainVertexShader: {
  64489. name: string;
  64490. shader: string;
  64491. };
  64492. }
  64493. declare module BABYLON {
  64494. export class TerrainMaterial extends BABYLON.PushMaterial {
  64495. private _mixTexture;
  64496. mixTexture: BABYLON.BaseTexture;
  64497. private _diffuseTexture1;
  64498. diffuseTexture1: BABYLON.Texture;
  64499. private _diffuseTexture2;
  64500. diffuseTexture2: BABYLON.Texture;
  64501. private _diffuseTexture3;
  64502. diffuseTexture3: BABYLON.Texture;
  64503. private _bumpTexture1;
  64504. bumpTexture1: BABYLON.Texture;
  64505. private _bumpTexture2;
  64506. bumpTexture2: BABYLON.Texture;
  64507. private _bumpTexture3;
  64508. bumpTexture3: BABYLON.Texture;
  64509. diffuseColor: BABYLON.Color3;
  64510. specularColor: BABYLON.Color3;
  64511. specularPower: number;
  64512. private _disableLighting;
  64513. disableLighting: boolean;
  64514. private _maxSimultaneousLights;
  64515. maxSimultaneousLights: number;
  64516. private _renderId;
  64517. constructor(name: string, scene: BABYLON.Scene);
  64518. needAlphaBlending(): boolean;
  64519. needAlphaTesting(): boolean;
  64520. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64521. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64522. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64523. getAnimatables(): BABYLON.IAnimatable[];
  64524. getActiveTextures(): BABYLON.BaseTexture[];
  64525. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64526. dispose(forceDisposeEffect?: boolean): void;
  64527. clone(name: string): TerrainMaterial;
  64528. serialize(): any;
  64529. getClassName(): string;
  64530. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  64531. }
  64532. }
  64533. declare module BABYLON {
  64534. /** @hidden */
  64535. export var triplanarPixelShader: {
  64536. name: string;
  64537. shader: string;
  64538. };
  64539. }
  64540. declare module BABYLON {
  64541. /** @hidden */
  64542. export var triplanarVertexShader: {
  64543. name: string;
  64544. shader: string;
  64545. };
  64546. }
  64547. declare module BABYLON {
  64548. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  64549. mixTexture: BABYLON.BaseTexture;
  64550. private _diffuseTextureX;
  64551. diffuseTextureX: BABYLON.BaseTexture;
  64552. private _diffuseTextureY;
  64553. diffuseTextureY: BABYLON.BaseTexture;
  64554. private _diffuseTextureZ;
  64555. diffuseTextureZ: BABYLON.BaseTexture;
  64556. private _normalTextureX;
  64557. normalTextureX: BABYLON.BaseTexture;
  64558. private _normalTextureY;
  64559. normalTextureY: BABYLON.BaseTexture;
  64560. private _normalTextureZ;
  64561. normalTextureZ: BABYLON.BaseTexture;
  64562. tileSize: number;
  64563. diffuseColor: BABYLON.Color3;
  64564. specularColor: BABYLON.Color3;
  64565. specularPower: number;
  64566. private _disableLighting;
  64567. disableLighting: boolean;
  64568. private _maxSimultaneousLights;
  64569. maxSimultaneousLights: number;
  64570. private _renderId;
  64571. constructor(name: string, scene: BABYLON.Scene);
  64572. needAlphaBlending(): boolean;
  64573. needAlphaTesting(): boolean;
  64574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64577. getAnimatables(): BABYLON.IAnimatable[];
  64578. getActiveTextures(): BABYLON.BaseTexture[];
  64579. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64580. dispose(forceDisposeEffect?: boolean): void;
  64581. clone(name: string): TriPlanarMaterial;
  64582. serialize(): any;
  64583. getClassName(): string;
  64584. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  64585. }
  64586. }
  64587. declare module BABYLON {
  64588. /** @hidden */
  64589. export var waterPixelShader: {
  64590. name: string;
  64591. shader: string;
  64592. };
  64593. }
  64594. declare module BABYLON {
  64595. /** @hidden */
  64596. export var waterVertexShader: {
  64597. name: string;
  64598. shader: string;
  64599. };
  64600. }
  64601. declare module BABYLON {
  64602. export class WaterMaterial extends BABYLON.PushMaterial {
  64603. renderTargetSize: BABYLON.Vector2;
  64604. private _bumpTexture;
  64605. bumpTexture: BABYLON.BaseTexture;
  64606. diffuseColor: BABYLON.Color3;
  64607. specularColor: BABYLON.Color3;
  64608. specularPower: number;
  64609. private _disableLighting;
  64610. disableLighting: boolean;
  64611. private _maxSimultaneousLights;
  64612. maxSimultaneousLights: number;
  64613. /**
  64614. * @param {number}: Represents the wind force
  64615. */
  64616. windForce: number;
  64617. /**
  64618. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  64619. */
  64620. windDirection: BABYLON.Vector2;
  64621. /**
  64622. * @param {number}: Wave height, represents the height of the waves
  64623. */
  64624. waveHeight: number;
  64625. /**
  64626. * @param {number}: Bump height, represents the bump height related to the bump map
  64627. */
  64628. bumpHeight: number;
  64629. /**
  64630. * @param {boolean}: Add a smaller moving bump to less steady waves.
  64631. */
  64632. private _bumpSuperimpose;
  64633. bumpSuperimpose: boolean;
  64634. /**
  64635. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  64636. */
  64637. private _fresnelSeparate;
  64638. fresnelSeparate: boolean;
  64639. /**
  64640. * @param {boolean}: bump Waves modify the reflection.
  64641. */
  64642. private _bumpAffectsReflection;
  64643. bumpAffectsReflection: boolean;
  64644. /**
  64645. * @param {number}: The water color blended with the refraction (near)
  64646. */
  64647. waterColor: BABYLON.Color3;
  64648. /**
  64649. * @param {number}: The blend factor related to the water color
  64650. */
  64651. colorBlendFactor: number;
  64652. /**
  64653. * @param {number}: The water color blended with the reflection (far)
  64654. */
  64655. waterColor2: BABYLON.Color3;
  64656. /**
  64657. * @param {number}: The blend factor related to the water color (reflection, far)
  64658. */
  64659. colorBlendFactor2: number;
  64660. /**
  64661. * @param {number}: Represents the maximum length of a wave
  64662. */
  64663. waveLength: number;
  64664. /**
  64665. * @param {number}: Defines the waves speed
  64666. */
  64667. waveSpeed: number;
  64668. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  64669. private _mesh;
  64670. private _refractionRTT;
  64671. private _reflectionRTT;
  64672. private _reflectionTransform;
  64673. private _lastTime;
  64674. private _lastDeltaTime;
  64675. private _renderId;
  64676. private _useLogarithmicDepth;
  64677. private _waitingRenderList;
  64678. /**
  64679. * Gets a boolean indicating that current material needs to register RTT
  64680. */
  64681. readonly hasRenderTargetTextures: boolean;
  64682. /**
  64683. * Constructor
  64684. */
  64685. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  64686. useLogarithmicDepth: boolean;
  64687. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64688. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  64689. addToRenderList(node: any): void;
  64690. enableRenderTargets(enable: boolean): void;
  64691. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  64692. readonly renderTargetsEnabled: boolean;
  64693. needAlphaBlending(): boolean;
  64694. needAlphaTesting(): boolean;
  64695. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64696. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64698. private _createRenderTargets;
  64699. getAnimatables(): BABYLON.IAnimatable[];
  64700. getActiveTextures(): BABYLON.BaseTexture[];
  64701. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64702. dispose(forceDisposeEffect?: boolean): void;
  64703. clone(name: string): WaterMaterial;
  64704. serialize(): any;
  64705. getClassName(): string;
  64706. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  64707. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  64708. }
  64709. }
  64710. declare module BABYLON {
  64711. /** @hidden */
  64712. export var asciiartPixelShader: {
  64713. name: string;
  64714. shader: string;
  64715. };
  64716. }
  64717. declare module BABYLON {
  64718. /**
  64719. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  64720. *
  64721. * It basically takes care rendering the font front the given font size to a texture.
  64722. * This is used later on in the postprocess.
  64723. */
  64724. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  64725. private _font;
  64726. private _text;
  64727. private _charSize;
  64728. /**
  64729. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64730. */
  64731. readonly charSize: number;
  64732. /**
  64733. * Create a new instance of the Ascii Art FontTexture class
  64734. * @param name the name of the texture
  64735. * @param font the font to use, use the W3C CSS notation
  64736. * @param text the caracter set to use in the rendering.
  64737. * @param scene the scene that owns the texture
  64738. */
  64739. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64740. /**
  64741. * Gets the max char width of a font.
  64742. * @param font the font to use, use the W3C CSS notation
  64743. * @return the max char width
  64744. */
  64745. private getFontWidth;
  64746. /**
  64747. * Gets the max char height of a font.
  64748. * @param font the font to use, use the W3C CSS notation
  64749. * @return the max char height
  64750. */
  64751. private getFontHeight;
  64752. /**
  64753. * Clones the current AsciiArtTexture.
  64754. * @return the clone of the texture.
  64755. */
  64756. clone(): AsciiArtFontTexture;
  64757. /**
  64758. * Parses a json object representing the texture and returns an instance of it.
  64759. * @param source the source JSON representation
  64760. * @param scene the scene to create the texture for
  64761. * @return the parsed texture
  64762. */
  64763. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64764. }
  64765. /**
  64766. * Option available in the Ascii Art Post Process.
  64767. */
  64768. export interface IAsciiArtPostProcessOptions {
  64769. /**
  64770. * The font to use following the w3c font definition.
  64771. */
  64772. font?: string;
  64773. /**
  64774. * The character set to use in the postprocess.
  64775. */
  64776. characterSet?: string;
  64777. /**
  64778. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64779. * This number is defined between 0 and 1;
  64780. */
  64781. mixToTile?: number;
  64782. /**
  64783. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64784. * This number is defined between 0 and 1;
  64785. */
  64786. mixToNormal?: number;
  64787. }
  64788. /**
  64789. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64790. *
  64791. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64792. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64793. */
  64794. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64795. /**
  64796. * The font texture used to render the char in the post process.
  64797. */
  64798. private _asciiArtFontTexture;
  64799. /**
  64800. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64801. * This number is defined between 0 and 1;
  64802. */
  64803. mixToTile: number;
  64804. /**
  64805. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64806. * This number is defined between 0 and 1;
  64807. */
  64808. mixToNormal: number;
  64809. /**
  64810. * Instantiates a new Ascii Art Post Process.
  64811. * @param name the name to give to the postprocess
  64812. * @camera the camera to apply the post process to.
  64813. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64814. */
  64815. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64816. }
  64817. }
  64818. declare module BABYLON {
  64819. /** @hidden */
  64820. export var digitalrainPixelShader: {
  64821. name: string;
  64822. shader: string;
  64823. };
  64824. }
  64825. declare module BABYLON {
  64826. /**
  64827. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64828. *
  64829. * It basically takes care rendering the font front the given font size to a texture.
  64830. * This is used later on in the postprocess.
  64831. */
  64832. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64833. private _font;
  64834. private _text;
  64835. private _charSize;
  64836. /**
  64837. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64838. */
  64839. readonly charSize: number;
  64840. /**
  64841. * Create a new instance of the Digital Rain FontTexture class
  64842. * @param name the name of the texture
  64843. * @param font the font to use, use the W3C CSS notation
  64844. * @param text the caracter set to use in the rendering.
  64845. * @param scene the scene that owns the texture
  64846. */
  64847. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64848. /**
  64849. * Gets the max char width of a font.
  64850. * @param font the font to use, use the W3C CSS notation
  64851. * @return the max char width
  64852. */
  64853. private getFontWidth;
  64854. /**
  64855. * Gets the max char height of a font.
  64856. * @param font the font to use, use the W3C CSS notation
  64857. * @return the max char height
  64858. */
  64859. private getFontHeight;
  64860. /**
  64861. * Clones the current DigitalRainFontTexture.
  64862. * @return the clone of the texture.
  64863. */
  64864. clone(): DigitalRainFontTexture;
  64865. /**
  64866. * Parses a json object representing the texture and returns an instance of it.
  64867. * @param source the source JSON representation
  64868. * @param scene the scene to create the texture for
  64869. * @return the parsed texture
  64870. */
  64871. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64872. }
  64873. /**
  64874. * Option available in the Digital Rain Post Process.
  64875. */
  64876. export interface IDigitalRainPostProcessOptions {
  64877. /**
  64878. * The font to use following the w3c font definition.
  64879. */
  64880. font?: string;
  64881. /**
  64882. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64883. * This number is defined between 0 and 1;
  64884. */
  64885. mixToTile?: number;
  64886. /**
  64887. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64888. * This number is defined between 0 and 1;
  64889. */
  64890. mixToNormal?: number;
  64891. }
  64892. /**
  64893. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64894. *
  64895. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64896. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64897. */
  64898. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64899. /**
  64900. * The font texture used to render the char in the post process.
  64901. */
  64902. private _digitalRainFontTexture;
  64903. /**
  64904. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64905. * This number is defined between 0 and 1;
  64906. */
  64907. mixToTile: number;
  64908. /**
  64909. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64910. * This number is defined between 0 and 1;
  64911. */
  64912. mixToNormal: number;
  64913. /**
  64914. * Instantiates a new Digital Rain Post Process.
  64915. * @param name the name to give to the postprocess
  64916. * @camera the camera to apply the post process to.
  64917. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64918. */
  64919. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64920. }
  64921. }
  64922. declare module BABYLON {
  64923. /** @hidden */
  64924. export var oceanPostProcessPixelShader: {
  64925. name: string;
  64926. shader: string;
  64927. };
  64928. }
  64929. declare module BABYLON {
  64930. /**
  64931. * Option available in the Ocean Post Process.
  64932. */
  64933. export interface IOceanPostProcessOptions {
  64934. /**
  64935. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64936. */
  64937. reflectionSize?: number | {
  64938. width: number;
  64939. height: number;
  64940. } | {
  64941. ratio: number;
  64942. };
  64943. /**
  64944. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64945. */
  64946. refractionSize?: number | {
  64947. width: number;
  64948. height: number;
  64949. } | {
  64950. ratio: number;
  64951. };
  64952. }
  64953. /**
  64954. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64955. *
  64956. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64957. * Example usage:
  64958. * var pp = new OceanPostProcess("myOcean", camera);
  64959. * pp.reflectionEnabled = true;
  64960. * pp.refractionEnabled = true;
  64961. */
  64962. export class OceanPostProcess extends BABYLON.PostProcess {
  64963. /**
  64964. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64965. */
  64966. /**
  64967. * Sets weither or not the real-time reflection is enabled on the ocean.
  64968. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64969. */
  64970. reflectionEnabled: boolean;
  64971. /**
  64972. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64973. */
  64974. /**
  64975. * Sets weither or not the real-time refraction is enabled on the ocean.
  64976. * Is set to true, the refraction render target texture will be used as refraction texture.
  64977. */
  64978. refractionEnabled: boolean;
  64979. /**
  64980. * Gets wether or not the post-processes is supported by the running hardware.
  64981. * This requires draw buffer supports.
  64982. */
  64983. readonly isSupported: boolean;
  64984. /**
  64985. * This is the reflection mirror texture used to display reflections on the ocean.
  64986. * By default, render list is empty.
  64987. */
  64988. reflectionTexture: BABYLON.MirrorTexture;
  64989. /**
  64990. * This is the refraction render target texture used to display refraction on the ocean.
  64991. * By default, render list is empty.
  64992. */
  64993. refractionTexture: BABYLON.RenderTargetTexture;
  64994. private _time;
  64995. private _cameraRotation;
  64996. private _cameraViewMatrix;
  64997. private _reflectionEnabled;
  64998. private _refractionEnabled;
  64999. private _geometryRenderer;
  65000. /**
  65001. * Instantiates a new Ocean Post Process.
  65002. * @param name the name to give to the postprocess.
  65003. * @camera the camera to apply the post process to.
  65004. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  65005. */
  65006. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  65007. /**
  65008. * Returns the appropriate defines according to the current configuration.
  65009. */
  65010. private _getDefines;
  65011. /**
  65012. * Computes the current camera rotation as the shader requires a camera rotation.
  65013. */
  65014. private _computeCameraRotation;
  65015. }
  65016. }
  65017. declare module BABYLON {
  65018. /** @hidden */
  65019. export var brickProceduralTexturePixelShader: {
  65020. name: string;
  65021. shader: string;
  65022. };
  65023. }
  65024. declare module BABYLON {
  65025. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  65026. private _numberOfBricksHeight;
  65027. private _numberOfBricksWidth;
  65028. private _jointColor;
  65029. private _brickColor;
  65030. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65031. updateShaderUniforms(): void;
  65032. numberOfBricksHeight: number;
  65033. numberOfBricksWidth: number;
  65034. jointColor: BABYLON.Color3;
  65035. brickColor: BABYLON.Color3;
  65036. /**
  65037. * Serializes this brick procedural texture
  65038. * @returns a serialized brick procedural texture object
  65039. */
  65040. serialize(): any;
  65041. /**
  65042. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  65043. * @param parsedTexture defines parsed texture data
  65044. * @param scene defines the current scene
  65045. * @param rootUrl defines the root URL containing brick procedural texture information
  65046. * @returns a parsed Brick Procedural BABYLON.Texture
  65047. */
  65048. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  65049. }
  65050. }
  65051. declare module BABYLON {
  65052. /** @hidden */
  65053. export var cloudProceduralTexturePixelShader: {
  65054. name: string;
  65055. shader: string;
  65056. };
  65057. }
  65058. declare module BABYLON {
  65059. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  65060. private _skyColor;
  65061. private _cloudColor;
  65062. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65063. updateShaderUniforms(): void;
  65064. skyColor: BABYLON.Color4;
  65065. cloudColor: BABYLON.Color4;
  65066. /**
  65067. * Serializes this cloud procedural texture
  65068. * @returns a serialized cloud procedural texture object
  65069. */
  65070. serialize(): any;
  65071. /**
  65072. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  65073. * @param parsedTexture defines parsed texture data
  65074. * @param scene defines the current scene
  65075. * @param rootUrl defines the root URL containing cloud procedural texture information
  65076. * @returns a parsed Cloud Procedural BABYLON.Texture
  65077. */
  65078. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  65079. }
  65080. }
  65081. declare module BABYLON {
  65082. /** @hidden */
  65083. export var fireProceduralTexturePixelShader: {
  65084. name: string;
  65085. shader: string;
  65086. };
  65087. }
  65088. declare module BABYLON {
  65089. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  65090. private _time;
  65091. private _speed;
  65092. private _autoGenerateTime;
  65093. private _fireColors;
  65094. private _alphaThreshold;
  65095. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65096. updateShaderUniforms(): void;
  65097. render(useCameraPostProcess?: boolean): void;
  65098. static readonly PurpleFireColors: BABYLON.Color3[];
  65099. static readonly GreenFireColors: BABYLON.Color3[];
  65100. static readonly RedFireColors: BABYLON.Color3[];
  65101. static readonly BlueFireColors: BABYLON.Color3[];
  65102. autoGenerateTime: boolean;
  65103. fireColors: BABYLON.Color3[];
  65104. time: number;
  65105. speed: BABYLON.Vector2;
  65106. alphaThreshold: number;
  65107. /**
  65108. * Serializes this fire procedural texture
  65109. * @returns a serialized fire procedural texture object
  65110. */
  65111. serialize(): any;
  65112. /**
  65113. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  65114. * @param parsedTexture defines parsed texture data
  65115. * @param scene defines the current scene
  65116. * @param rootUrl defines the root URL containing fire procedural texture information
  65117. * @returns a parsed Fire Procedural BABYLON.Texture
  65118. */
  65119. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  65120. }
  65121. }
  65122. declare module BABYLON {
  65123. /** @hidden */
  65124. export var grassProceduralTexturePixelShader: {
  65125. name: string;
  65126. shader: string;
  65127. };
  65128. }
  65129. declare module BABYLON {
  65130. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  65131. private _grassColors;
  65132. private _groundColor;
  65133. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65134. updateShaderUniforms(): void;
  65135. grassColors: BABYLON.Color3[];
  65136. groundColor: BABYLON.Color3;
  65137. /**
  65138. * Serializes this grass procedural texture
  65139. * @returns a serialized grass procedural texture object
  65140. */
  65141. serialize(): any;
  65142. /**
  65143. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  65144. * @param parsedTexture defines parsed texture data
  65145. * @param scene defines the current scene
  65146. * @param rootUrl defines the root URL containing grass procedural texture information
  65147. * @returns a parsed Grass Procedural BABYLON.Texture
  65148. */
  65149. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  65150. }
  65151. }
  65152. declare module BABYLON {
  65153. /** @hidden */
  65154. export var marbleProceduralTexturePixelShader: {
  65155. name: string;
  65156. shader: string;
  65157. };
  65158. }
  65159. declare module BABYLON {
  65160. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  65161. private _numberOfTilesHeight;
  65162. private _numberOfTilesWidth;
  65163. private _amplitude;
  65164. private _jointColor;
  65165. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65166. updateShaderUniforms(): void;
  65167. numberOfTilesHeight: number;
  65168. amplitude: number;
  65169. numberOfTilesWidth: number;
  65170. jointColor: BABYLON.Color3;
  65171. /**
  65172. * Serializes this marble procedural texture
  65173. * @returns a serialized marble procedural texture object
  65174. */
  65175. serialize(): any;
  65176. /**
  65177. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  65178. * @param parsedTexture defines parsed texture data
  65179. * @param scene defines the current scene
  65180. * @param rootUrl defines the root URL containing marble procedural texture information
  65181. * @returns a parsed Marble Procedural BABYLON.Texture
  65182. */
  65183. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  65184. }
  65185. }
  65186. declare module BABYLON {
  65187. /** @hidden */
  65188. export var normalMapProceduralTexturePixelShader: {
  65189. name: string;
  65190. shader: string;
  65191. };
  65192. }
  65193. declare module BABYLON {
  65194. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  65195. private _baseTexture;
  65196. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65197. updateShaderUniforms(): void;
  65198. render(useCameraPostProcess?: boolean): void;
  65199. resize(size: any, generateMipMaps: any): void;
  65200. baseTexture: BABYLON.Texture;
  65201. /**
  65202. * Serializes this normal map procedural texture
  65203. * @returns a serialized normal map procedural texture object
  65204. */
  65205. serialize(): any;
  65206. /**
  65207. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  65208. * @param parsedTexture defines parsed texture data
  65209. * @param scene defines the current scene
  65210. * @param rootUrl defines the root URL containing normal map procedural texture information
  65211. * @returns a parsed Normal Map Procedural BABYLON.Texture
  65212. */
  65213. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  65214. }
  65215. }
  65216. declare module BABYLON {
  65217. /** @hidden */
  65218. export var perlinNoiseProceduralTexturePixelShader: {
  65219. name: string;
  65220. shader: string;
  65221. };
  65222. }
  65223. declare module BABYLON {
  65224. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  65225. time: number;
  65226. timeScale: number;
  65227. translationSpeed: number;
  65228. private _currentTranslation;
  65229. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65230. updateShaderUniforms(): void;
  65231. render(useCameraPostProcess?: boolean): void;
  65232. resize(size: any, generateMipMaps: any): void;
  65233. /**
  65234. * Serializes this perlin noise procedural texture
  65235. * @returns a serialized perlin noise procedural texture object
  65236. */
  65237. serialize(): any;
  65238. /**
  65239. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  65240. * @param parsedTexture defines parsed texture data
  65241. * @param scene defines the current scene
  65242. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  65243. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  65244. */
  65245. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  65246. }
  65247. }
  65248. declare module BABYLON {
  65249. /** @hidden */
  65250. export var roadProceduralTexturePixelShader: {
  65251. name: string;
  65252. shader: string;
  65253. };
  65254. }
  65255. declare module BABYLON {
  65256. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  65257. private _roadColor;
  65258. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65259. updateShaderUniforms(): void;
  65260. roadColor: BABYLON.Color3;
  65261. /**
  65262. * Serializes this road procedural texture
  65263. * @returns a serialized road procedural texture object
  65264. */
  65265. serialize(): any;
  65266. /**
  65267. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  65268. * @param parsedTexture defines parsed texture data
  65269. * @param scene defines the current scene
  65270. * @param rootUrl defines the root URL containing road procedural texture information
  65271. * @returns a parsed Road Procedural BABYLON.Texture
  65272. */
  65273. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  65274. }
  65275. }
  65276. declare module BABYLON {
  65277. /** @hidden */
  65278. export var starfieldProceduralTexturePixelShader: {
  65279. name: string;
  65280. shader: string;
  65281. };
  65282. }
  65283. declare module BABYLON {
  65284. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  65285. private _time;
  65286. private _alpha;
  65287. private _beta;
  65288. private _zoom;
  65289. private _formuparam;
  65290. private _stepsize;
  65291. private _tile;
  65292. private _brightness;
  65293. private _darkmatter;
  65294. private _distfading;
  65295. private _saturation;
  65296. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65297. updateShaderUniforms(): void;
  65298. time: number;
  65299. alpha: number;
  65300. beta: number;
  65301. formuparam: number;
  65302. stepsize: number;
  65303. zoom: number;
  65304. tile: number;
  65305. brightness: number;
  65306. darkmatter: number;
  65307. distfading: number;
  65308. saturation: number;
  65309. /**
  65310. * Serializes this starfield procedural texture
  65311. * @returns a serialized starfield procedural texture object
  65312. */
  65313. serialize(): any;
  65314. /**
  65315. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  65316. * @param parsedTexture defines parsed texture data
  65317. * @param scene defines the current scene
  65318. * @param rootUrl defines the root URL containing startfield procedural texture information
  65319. * @returns a parsed Starfield Procedural BABYLON.Texture
  65320. */
  65321. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  65322. }
  65323. }
  65324. declare module BABYLON {
  65325. /** @hidden */
  65326. export var woodProceduralTexturePixelShader: {
  65327. name: string;
  65328. shader: string;
  65329. };
  65330. }
  65331. declare module BABYLON {
  65332. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  65333. private _ampScale;
  65334. private _woodColor;
  65335. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  65336. updateShaderUniforms(): void;
  65337. ampScale: number;
  65338. woodColor: BABYLON.Color3;
  65339. /**
  65340. * Serializes this wood procedural texture
  65341. * @returns a serialized wood procedural texture object
  65342. */
  65343. serialize(): any;
  65344. /**
  65345. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  65346. * @param parsedTexture defines parsed texture data
  65347. * @param scene defines the current scene
  65348. * @param rootUrl defines the root URL containing wood procedural texture information
  65349. * @returns a parsed Wood Procedural BABYLON.Texture
  65350. */
  65351. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  65352. }
  65353. }