babylon.d.txt 2.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module BABYLON {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module BABYLON {
  256. /**
  257. * Constant used to convert a value to gamma space
  258. * @ignorenaming
  259. */
  260. export const ToGammaSpace: number;
  261. /**
  262. * Constant used to convert a value to linear space
  263. * @ignorenaming
  264. */
  265. export const ToLinearSpace = 2.2;
  266. /**
  267. * Constant used to define the minimal number value in Babylon.js
  268. * @ignorenaming
  269. */
  270. export const Epsilon = 0.001;
  271. /**
  272. * Class used to hold a RBG color
  273. */
  274. export class Color3 {
  275. /**
  276. * Defines the red component (between 0 and 1, default is 0)
  277. */
  278. r: number;
  279. /**
  280. * Defines the green component (between 0 and 1, default is 0)
  281. */
  282. g: number;
  283. /**
  284. * Defines the blue component (between 0 and 1, default is 0)
  285. */
  286. b: number;
  287. /**
  288. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  289. * @param r defines the red component (between 0 and 1, default is 0)
  290. * @param g defines the green component (between 0 and 1, default is 0)
  291. * @param b defines the blue component (between 0 and 1, default is 0)
  292. */
  293. constructor(
  294. /**
  295. * Defines the red component (between 0 and 1, default is 0)
  296. */
  297. r?: number,
  298. /**
  299. * Defines the green component (between 0 and 1, default is 0)
  300. */
  301. g?: number,
  302. /**
  303. * Defines the blue component (between 0 and 1, default is 0)
  304. */
  305. b?: number);
  306. /**
  307. * Creates a string with the Color3 current values
  308. * @returns the string representation of the Color3 object
  309. */
  310. toString(): string;
  311. /**
  312. * Returns the string "Color3"
  313. * @returns "Color3"
  314. */
  315. getClassName(): string;
  316. /**
  317. * Compute the Color3 hash code
  318. * @returns an unique number that can be used to hash Color3 objects
  319. */
  320. getHashCode(): number;
  321. /**
  322. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  323. * @param array defines the array where to store the r,g,b components
  324. * @param index defines an optional index in the target array to define where to start storing values
  325. * @returns the current Color3 object
  326. */
  327. toArray(array: FloatArray, index?: number): Color3;
  328. /**
  329. * Returns a new Color4 object from the current Color3 and the given alpha
  330. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  331. * @returns a new Color4 object
  332. */
  333. toColor4(alpha?: number): Color4;
  334. /**
  335. * Returns a new array populated with 3 numeric elements : red, green and blue values
  336. * @returns the new array
  337. */
  338. asArray(): number[];
  339. /**
  340. * Returns the luminance value
  341. * @returns a float value
  342. */
  343. toLuminance(): number;
  344. /**
  345. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  346. * @param otherColor defines the second operand
  347. * @returns the new Color3 object
  348. */
  349. multiply(otherColor: DeepImmutable<Color3>): Color3;
  350. /**
  351. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  352. * @param otherColor defines the second operand
  353. * @param result defines the Color3 object where to store the result
  354. * @returns the current Color3
  355. */
  356. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  357. /**
  358. * Determines equality between Color3 objects
  359. * @param otherColor defines the second operand
  360. * @returns true if the rgb values are equal to the given ones
  361. */
  362. equals(otherColor: DeepImmutable<Color3>): boolean;
  363. /**
  364. * Determines equality between the current Color3 object and a set of r,b,g values
  365. * @param r defines the red component to check
  366. * @param g defines the green component to check
  367. * @param b defines the blue component to check
  368. * @returns true if the rgb values are equal to the given ones
  369. */
  370. equalsFloats(r: number, g: number, b: number): boolean;
  371. /**
  372. * Multiplies in place each rgb value by scale
  373. * @param scale defines the scaling factor
  374. * @returns the updated Color3
  375. */
  376. scale(scale: number): Color3;
  377. /**
  378. * Multiplies the rgb values by scale and stores the result into "result"
  379. * @param scale defines the scaling factor
  380. * @param result defines the Color3 object where to store the result
  381. * @returns the unmodified current Color3
  382. */
  383. scaleToRef(scale: number, result: Color3): Color3;
  384. /**
  385. * Scale the current Color3 values by a factor and add the result to a given Color3
  386. * @param scale defines the scale factor
  387. * @param result defines color to store the result into
  388. * @returns the unmodified current Color3
  389. */
  390. scaleAndAddToRef(scale: number, result: Color3): Color3;
  391. /**
  392. * Clamps the rgb values by the min and max values and stores the result into "result"
  393. * @param min defines minimum clamping value (default is 0)
  394. * @param max defines maximum clamping value (default is 1)
  395. * @param result defines color to store the result into
  396. * @returns the original Color3
  397. */
  398. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  399. /**
  400. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  401. * @param otherColor defines the second operand
  402. * @returns the new Color3
  403. */
  404. add(otherColor: DeepImmutable<Color3>): Color3;
  405. /**
  406. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  407. * @param otherColor defines the second operand
  408. * @param result defines Color3 object to store the result into
  409. * @returns the unmodified current Color3
  410. */
  411. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  412. /**
  413. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  414. * @param otherColor defines the second operand
  415. * @returns the new Color3
  416. */
  417. subtract(otherColor: DeepImmutable<Color3>): Color3;
  418. /**
  419. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  420. * @param otherColor defines the second operand
  421. * @param result defines Color3 object to store the result into
  422. * @returns the unmodified current Color3
  423. */
  424. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  425. /**
  426. * Copy the current object
  427. * @returns a new Color3 copied the current one
  428. */
  429. clone(): Color3;
  430. /**
  431. * Copies the rgb values from the source in the current Color3
  432. * @param source defines the source Color3 object
  433. * @returns the updated Color3 object
  434. */
  435. copyFrom(source: DeepImmutable<Color3>): Color3;
  436. /**
  437. * Updates the Color3 rgb values from the given floats
  438. * @param r defines the red component to read from
  439. * @param g defines the green component to read from
  440. * @param b defines the blue component to read from
  441. * @returns the current Color3 object
  442. */
  443. copyFromFloats(r: number, g: number, b: number): Color3;
  444. /**
  445. * Updates the Color3 rgb values from the given floats
  446. * @param r defines the red component to read from
  447. * @param g defines the green component to read from
  448. * @param b defines the blue component to read from
  449. * @returns the current Color3 object
  450. */
  451. set(r: number, g: number, b: number): Color3;
  452. /**
  453. * Compute the Color3 hexadecimal code as a string
  454. * @returns a string containing the hexadecimal representation of the Color3 object
  455. */
  456. toHexString(): string;
  457. /**
  458. * Computes a new Color3 converted from the current one to linear space
  459. * @returns a new Color3 object
  460. */
  461. toLinearSpace(): Color3;
  462. /**
  463. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  464. * @param convertedColor defines the Color3 object where to store the linear space version
  465. * @returns the unmodified Color3
  466. */
  467. toLinearSpaceToRef(convertedColor: Color3): Color3;
  468. /**
  469. * Computes a new Color3 converted from the current one to gamma space
  470. * @returns a new Color3 object
  471. */
  472. toGammaSpace(): Color3;
  473. /**
  474. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  475. * @param convertedColor defines the Color3 object where to store the gamma space version
  476. * @returns the unmodified Color3
  477. */
  478. toGammaSpaceToRef(convertedColor: Color3): Color3;
  479. private static _BlackReadOnly;
  480. /**
  481. * Creates a new Color3 from the string containing valid hexadecimal values
  482. * @param hex defines a string containing valid hexadecimal values
  483. * @returns a new Color3 object
  484. */
  485. static FromHexString(hex: string): Color3;
  486. /**
  487. * Creates a new Vector3 from the starting index of the given array
  488. * @param array defines the source array
  489. * @param offset defines an offset in the source array
  490. * @returns a new Color3 object
  491. */
  492. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  493. /**
  494. * Creates a new Color3 from integer values (< 256)
  495. * @param r defines the red component to read from (value between 0 and 255)
  496. * @param g defines the green component to read from (value between 0 and 255)
  497. * @param b defines the blue component to read from (value between 0 and 255)
  498. * @returns a new Color3 object
  499. */
  500. static FromInts(r: number, g: number, b: number): Color3;
  501. /**
  502. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  503. * @param start defines the start Color3 value
  504. * @param end defines the end Color3 value
  505. * @param amount defines the gradient value between start and end
  506. * @returns a new Color3 object
  507. */
  508. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  509. /**
  510. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  511. * @param left defines the start value
  512. * @param right defines the end value
  513. * @param amount defines the gradient factor
  514. * @param result defines the Color3 object where to store the result
  515. */
  516. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  517. /**
  518. * Returns a Color3 value containing a red color
  519. * @returns a new Color3 object
  520. */
  521. static Red(): Color3;
  522. /**
  523. * Returns a Color3 value containing a green color
  524. * @returns a new Color3 object
  525. */
  526. static Green(): Color3;
  527. /**
  528. * Returns a Color3 value containing a blue color
  529. * @returns a new Color3 object
  530. */
  531. static Blue(): Color3;
  532. /**
  533. * Returns a Color3 value containing a black color
  534. * @returns a new Color3 object
  535. */
  536. static Black(): Color3;
  537. /**
  538. * Gets a Color3 value containing a black color that must not be updated
  539. */
  540. static readonly BlackReadOnly: DeepImmutable<Color3>;
  541. /**
  542. * Returns a Color3 value containing a white color
  543. * @returns a new Color3 object
  544. */
  545. static White(): Color3;
  546. /**
  547. * Returns a Color3 value containing a purple color
  548. * @returns a new Color3 object
  549. */
  550. static Purple(): Color3;
  551. /**
  552. * Returns a Color3 value containing a magenta color
  553. * @returns a new Color3 object
  554. */
  555. static Magenta(): Color3;
  556. /**
  557. * Returns a Color3 value containing a yellow color
  558. * @returns a new Color3 object
  559. */
  560. static Yellow(): Color3;
  561. /**
  562. * Returns a Color3 value containing a gray color
  563. * @returns a new Color3 object
  564. */
  565. static Gray(): Color3;
  566. /**
  567. * Returns a Color3 value containing a teal color
  568. * @returns a new Color3 object
  569. */
  570. static Teal(): Color3;
  571. /**
  572. * Returns a Color3 value containing a random color
  573. * @returns a new Color3 object
  574. */
  575. static Random(): Color3;
  576. }
  577. /**
  578. * Class used to hold a RBGA color
  579. */
  580. export class Color4 {
  581. /**
  582. * Defines the red component (between 0 and 1, default is 0)
  583. */
  584. r: number;
  585. /**
  586. * Defines the green component (between 0 and 1, default is 0)
  587. */
  588. g: number;
  589. /**
  590. * Defines the blue component (between 0 and 1, default is 0)
  591. */
  592. b: number;
  593. /**
  594. * Defines the alpha component (between 0 and 1, default is 1)
  595. */
  596. a: number;
  597. /**
  598. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  599. * @param r defines the red component (between 0 and 1, default is 0)
  600. * @param g defines the green component (between 0 and 1, default is 0)
  601. * @param b defines the blue component (between 0 and 1, default is 0)
  602. * @param a defines the alpha component (between 0 and 1, default is 1)
  603. */
  604. constructor(
  605. /**
  606. * Defines the red component (between 0 and 1, default is 0)
  607. */
  608. r?: number,
  609. /**
  610. * Defines the green component (between 0 and 1, default is 0)
  611. */
  612. g?: number,
  613. /**
  614. * Defines the blue component (between 0 and 1, default is 0)
  615. */
  616. b?: number,
  617. /**
  618. * Defines the alpha component (between 0 and 1, default is 1)
  619. */
  620. a?: number);
  621. /**
  622. * Adds in place the given Color4 values to the current Color4 object
  623. * @param right defines the second operand
  624. * @returns the current updated Color4 object
  625. */
  626. addInPlace(right: DeepImmutable<Color4>): Color4;
  627. /**
  628. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  629. * @returns the new array
  630. */
  631. asArray(): number[];
  632. /**
  633. * Stores from the starting index in the given array the Color4 successive values
  634. * @param array defines the array where to store the r,g,b components
  635. * @param index defines an optional index in the target array to define where to start storing values
  636. * @returns the current Color4 object
  637. */
  638. toArray(array: number[], index?: number): Color4;
  639. /**
  640. * Determines equality between Color4 objects
  641. * @param otherColor defines the second operand
  642. * @returns true if the rgba values are equal to the given ones
  643. */
  644. equals(otherColor: DeepImmutable<Color4>): boolean;
  645. /**
  646. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  647. * @param right defines the second operand
  648. * @returns a new Color4 object
  649. */
  650. add(right: DeepImmutable<Color4>): Color4;
  651. /**
  652. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  653. * @param right defines the second operand
  654. * @returns a new Color4 object
  655. */
  656. subtract(right: DeepImmutable<Color4>): Color4;
  657. /**
  658. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  659. * @param right defines the second operand
  660. * @param result defines the Color4 object where to store the result
  661. * @returns the current Color4 object
  662. */
  663. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  664. /**
  665. * Creates a new Color4 with the current Color4 values multiplied by scale
  666. * @param scale defines the scaling factor to apply
  667. * @returns a new Color4 object
  668. */
  669. scale(scale: number): Color4;
  670. /**
  671. * Multiplies the current Color4 values by scale and stores the result in "result"
  672. * @param scale defines the scaling factor to apply
  673. * @param result defines the Color4 object where to store the result
  674. * @returns the current unmodified Color4
  675. */
  676. scaleToRef(scale: number, result: Color4): Color4;
  677. /**
  678. * Scale the current Color4 values by a factor and add the result to a given Color4
  679. * @param scale defines the scale factor
  680. * @param result defines the Color4 object where to store the result
  681. * @returns the unmodified current Color4
  682. */
  683. scaleAndAddToRef(scale: number, result: Color4): Color4;
  684. /**
  685. * Clamps the rgb values by the min and max values and stores the result into "result"
  686. * @param min defines minimum clamping value (default is 0)
  687. * @param max defines maximum clamping value (default is 1)
  688. * @param result defines color to store the result into.
  689. * @returns the cuurent Color4
  690. */
  691. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  692. /**
  693. * Multipy an Color4 value by another and return a new Color4 object
  694. * @param color defines the Color4 value to multiply by
  695. * @returns a new Color4 object
  696. */
  697. multiply(color: Color4): Color4;
  698. /**
  699. * Multipy a Color4 value by another and push the result in a reference value
  700. * @param color defines the Color4 value to multiply by
  701. * @param result defines the Color4 to fill the result in
  702. * @returns the result Color4
  703. */
  704. multiplyToRef(color: Color4, result: Color4): Color4;
  705. /**
  706. * Creates a string with the Color4 current values
  707. * @returns the string representation of the Color4 object
  708. */
  709. toString(): string;
  710. /**
  711. * Returns the string "Color4"
  712. * @returns "Color4"
  713. */
  714. getClassName(): string;
  715. /**
  716. * Compute the Color4 hash code
  717. * @returns an unique number that can be used to hash Color4 objects
  718. */
  719. getHashCode(): number;
  720. /**
  721. * Creates a new Color4 copied from the current one
  722. * @returns a new Color4 object
  723. */
  724. clone(): Color4;
  725. /**
  726. * Copies the given Color4 values into the current one
  727. * @param source defines the source Color4 object
  728. * @returns the current updated Color4 object
  729. */
  730. copyFrom(source: Color4): Color4;
  731. /**
  732. * Copies the given float values into the current one
  733. * @param r defines the red component to read from
  734. * @param g defines the green component to read from
  735. * @param b defines the blue component to read from
  736. * @param a defines the alpha component to read from
  737. * @returns the current updated Color4 object
  738. */
  739. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  740. /**
  741. * Copies the given float values into the current one
  742. * @param r defines the red component to read from
  743. * @param g defines the green component to read from
  744. * @param b defines the blue component to read from
  745. * @param a defines the alpha component to read from
  746. * @returns the current updated Color4 object
  747. */
  748. set(r: number, g: number, b: number, a: number): Color4;
  749. /**
  750. * Compute the Color4 hexadecimal code as a string
  751. * @returns a string containing the hexadecimal representation of the Color4 object
  752. */
  753. toHexString(): string;
  754. /**
  755. * Computes a new Color4 converted from the current one to linear space
  756. * @returns a new Color4 object
  757. */
  758. toLinearSpace(): Color4;
  759. /**
  760. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  761. * @param convertedColor defines the Color4 object where to store the linear space version
  762. * @returns the unmodified Color4
  763. */
  764. toLinearSpaceToRef(convertedColor: Color4): Color4;
  765. /**
  766. * Computes a new Color4 converted from the current one to gamma space
  767. * @returns a new Color4 object
  768. */
  769. toGammaSpace(): Color4;
  770. /**
  771. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  772. * @param convertedColor defines the Color4 object where to store the gamma space version
  773. * @returns the unmodified Color4
  774. */
  775. toGammaSpaceToRef(convertedColor: Color4): Color4;
  776. /**
  777. * Creates a new Color4 from the string containing valid hexadecimal values
  778. * @param hex defines a string containing valid hexadecimal values
  779. * @returns a new Color4 object
  780. */
  781. static FromHexString(hex: string): Color4;
  782. /**
  783. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  784. * @param left defines the start value
  785. * @param right defines the end value
  786. * @param amount defines the gradient factor
  787. * @returns a new Color4 object
  788. */
  789. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  790. /**
  791. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  792. * @param left defines the start value
  793. * @param right defines the end value
  794. * @param amount defines the gradient factor
  795. * @param result defines the Color4 object where to store data
  796. */
  797. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  798. /**
  799. * Creates a new Color4 from a Color3 and an alpha value
  800. * @param color3 defines the source Color3 to read from
  801. * @param alpha defines the alpha component (1.0 by default)
  802. * @returns a new Color4 object
  803. */
  804. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  805. /**
  806. * Creates a new Color4 from the starting index element of the given array
  807. * @param array defines the source array to read from
  808. * @param offset defines the offset in the source array
  809. * @returns a new Color4 object
  810. */
  811. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  812. /**
  813. * Creates a new Color3 from integer values (< 256)
  814. * @param r defines the red component to read from (value between 0 and 255)
  815. * @param g defines the green component to read from (value between 0 and 255)
  816. * @param b defines the blue component to read from (value between 0 and 255)
  817. * @param a defines the alpha component to read from (value between 0 and 255)
  818. * @returns a new Color3 object
  819. */
  820. static FromInts(r: number, g: number, b: number, a: number): Color4;
  821. /**
  822. * Check the content of a given array and convert it to an array containing RGBA data
  823. * If the original array was already containing count * 4 values then it is returned directly
  824. * @param colors defines the array to check
  825. * @param count defines the number of RGBA data to expect
  826. * @returns an array containing count * 4 values (RGBA)
  827. */
  828. static CheckColors4(colors: number[], count: number): number[];
  829. }
  830. /**
  831. * Class representing a vector containing 2 coordinates
  832. */
  833. export class Vector2 {
  834. /** defines the first coordinate */
  835. x: number;
  836. /** defines the second coordinate */
  837. y: number;
  838. /**
  839. * Creates a new Vector2 from the given x and y coordinates
  840. * @param x defines the first coordinate
  841. * @param y defines the second coordinate
  842. */
  843. constructor(
  844. /** defines the first coordinate */
  845. x?: number,
  846. /** defines the second coordinate */
  847. y?: number);
  848. /**
  849. * Gets a string with the Vector2 coordinates
  850. * @returns a string with the Vector2 coordinates
  851. */
  852. toString(): string;
  853. /**
  854. * Gets class name
  855. * @returns the string "Vector2"
  856. */
  857. getClassName(): string;
  858. /**
  859. * Gets current vector hash code
  860. * @returns the Vector2 hash code as a number
  861. */
  862. getHashCode(): number;
  863. /**
  864. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  865. * @param array defines the source array
  866. * @param index defines the offset in source array
  867. * @returns the current Vector2
  868. */
  869. toArray(array: FloatArray, index?: number): Vector2;
  870. /**
  871. * Copy the current vector to an array
  872. * @returns a new array with 2 elements: the Vector2 coordinates.
  873. */
  874. asArray(): number[];
  875. /**
  876. * Sets the Vector2 coordinates with the given Vector2 coordinates
  877. * @param source defines the source Vector2
  878. * @returns the current updated Vector2
  879. */
  880. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  881. /**
  882. * Sets the Vector2 coordinates with the given floats
  883. * @param x defines the first coordinate
  884. * @param y defines the second coordinate
  885. * @returns the current updated Vector2
  886. */
  887. copyFromFloats(x: number, y: number): Vector2;
  888. /**
  889. * Sets the Vector2 coordinates with the given floats
  890. * @param x defines the first coordinate
  891. * @param y defines the second coordinate
  892. * @returns the current updated Vector2
  893. */
  894. set(x: number, y: number): Vector2;
  895. /**
  896. * Add another vector with the current one
  897. * @param otherVector defines the other vector
  898. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  899. */
  900. add(otherVector: DeepImmutable<Vector2>): Vector2;
  901. /**
  902. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  903. * @param otherVector defines the other vector
  904. * @param result defines the target vector
  905. * @returns the unmodified current Vector2
  906. */
  907. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  908. /**
  909. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  910. * @param otherVector defines the other vector
  911. * @returns the current updated Vector2
  912. */
  913. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  916. * @param otherVector defines the other vector
  917. * @returns a new Vector2
  918. */
  919. addVector3(otherVector: Vector3): Vector2;
  920. /**
  921. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  922. * @param otherVector defines the other vector
  923. * @returns a new Vector2
  924. */
  925. subtract(otherVector: Vector2): Vector2;
  926. /**
  927. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  928. * @param otherVector defines the other vector
  929. * @param result defines the target vector
  930. * @returns the unmodified current Vector2
  931. */
  932. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  933. /**
  934. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  935. * @param otherVector defines the other vector
  936. * @returns the current updated Vector2
  937. */
  938. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  939. /**
  940. * Multiplies in place the current Vector2 coordinates by the given ones
  941. * @param otherVector defines the other vector
  942. * @returns the current updated Vector2
  943. */
  944. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  945. /**
  946. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  947. * @param otherVector defines the other vector
  948. * @returns a new Vector2
  949. */
  950. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  951. /**
  952. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @param result defines the target vector
  955. * @returns the unmodified current Vector2
  956. */
  957. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  958. /**
  959. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  960. * @param x defines the first coordinate
  961. * @param y defines the second coordinate
  962. * @returns a new Vector2
  963. */
  964. multiplyByFloats(x: number, y: number): Vector2;
  965. /**
  966. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  967. * @param otherVector defines the other vector
  968. * @returns a new Vector2
  969. */
  970. divide(otherVector: Vector2): Vector2;
  971. /**
  972. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  973. * @param otherVector defines the other vector
  974. * @param result defines the target vector
  975. * @returns the unmodified current Vector2
  976. */
  977. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  978. /**
  979. * Divides the current Vector2 coordinates by the given ones
  980. * @param otherVector defines the other vector
  981. * @returns the current updated Vector2
  982. */
  983. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Gets a new Vector2 with current Vector2 negated coordinates
  986. * @returns a new Vector2
  987. */
  988. negate(): Vector2;
  989. /**
  990. * Multiply the Vector2 coordinates by scale
  991. * @param scale defines the scaling factor
  992. * @returns the current updated Vector2
  993. */
  994. scaleInPlace(scale: number): Vector2;
  995. /**
  996. * Returns a new Vector2 scaled by "scale" from the current Vector2
  997. * @param scale defines the scaling factor
  998. * @returns a new Vector2
  999. */
  1000. scale(scale: number): Vector2;
  1001. /**
  1002. * Scale the current Vector2 values by a factor to a given Vector2
  1003. * @param scale defines the scale factor
  1004. * @param result defines the Vector2 object where to store the result
  1005. * @returns the unmodified current Vector2
  1006. */
  1007. scaleToRef(scale: number, result: Vector2): Vector2;
  1008. /**
  1009. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1010. * @param scale defines the scale factor
  1011. * @param result defines the Vector2 object where to store the result
  1012. * @returns the unmodified current Vector2
  1013. */
  1014. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1015. /**
  1016. * Gets a boolean if two vectors are equals
  1017. * @param otherVector defines the other vector
  1018. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1019. */
  1020. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1021. /**
  1022. * Gets a boolean if two vectors are equals (using an epsilon value)
  1023. * @param otherVector defines the other vector
  1024. * @param epsilon defines the minimal distance to consider equality
  1025. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1026. */
  1027. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1028. /**
  1029. * Gets a new Vector2 from current Vector2 floored values
  1030. * @returns a new Vector2
  1031. */
  1032. floor(): Vector2;
  1033. /**
  1034. * Gets a new Vector2 from current Vector2 floored values
  1035. * @returns a new Vector2
  1036. */
  1037. fract(): Vector2;
  1038. /**
  1039. * Gets the length of the vector
  1040. * @returns the vector length (float)
  1041. */
  1042. length(): number;
  1043. /**
  1044. * Gets the vector squared length
  1045. * @returns the vector squared length (float)
  1046. */
  1047. lengthSquared(): number;
  1048. /**
  1049. * Normalize the vector
  1050. * @returns the current updated Vector2
  1051. */
  1052. normalize(): Vector2;
  1053. /**
  1054. * Gets a new Vector2 copied from the Vector2
  1055. * @returns a new Vector2
  1056. */
  1057. clone(): Vector2;
  1058. /**
  1059. * Gets a new Vector2(0, 0)
  1060. * @returns a new Vector2
  1061. */
  1062. static Zero(): Vector2;
  1063. /**
  1064. * Gets a new Vector2(1, 1)
  1065. * @returns a new Vector2
  1066. */
  1067. static One(): Vector2;
  1068. /**
  1069. * Gets a new Vector2 set from the given index element of the given array
  1070. * @param array defines the data source
  1071. * @param offset defines the offset in the data source
  1072. * @returns a new Vector2
  1073. */
  1074. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1075. /**
  1076. * Sets "result" from the given index element of the given array
  1077. * @param array defines the data source
  1078. * @param offset defines the offset in the data source
  1079. * @param result defines the target vector
  1080. */
  1081. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1082. /**
  1083. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1084. * @param value1 defines 1st point of control
  1085. * @param value2 defines 2nd point of control
  1086. * @param value3 defines 3rd point of control
  1087. * @param value4 defines 4th point of control
  1088. * @param amount defines the interpolation factor
  1089. * @returns a new Vector2
  1090. */
  1091. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1092. /**
  1093. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1094. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1095. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1096. * @param value defines the value to clamp
  1097. * @param min defines the lower limit
  1098. * @param max defines the upper limit
  1099. * @returns a new Vector2
  1100. */
  1101. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1102. /**
  1103. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1104. * @param value1 defines the 1st control point
  1105. * @param tangent1 defines the outgoing tangent
  1106. * @param value2 defines the 2nd control point
  1107. * @param tangent2 defines the incoming tangent
  1108. * @param amount defines the interpolation factor
  1109. * @returns a new Vector2
  1110. */
  1111. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1112. /**
  1113. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1114. * @param start defines the start vector
  1115. * @param end defines the end vector
  1116. * @param amount defines the interpolation factor
  1117. * @returns a new Vector2
  1118. */
  1119. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1120. /**
  1121. * Gets the dot product of the vector "left" and the vector "right"
  1122. * @param left defines first vector
  1123. * @param right defines second vector
  1124. * @returns the dot product (float)
  1125. */
  1126. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1127. /**
  1128. * Returns a new Vector2 equal to the normalized given vector
  1129. * @param vector defines the vector to normalize
  1130. * @returns a new Vector2
  1131. */
  1132. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1133. /**
  1134. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1135. * @param left defines 1st vector
  1136. * @param right defines 2nd vector
  1137. * @returns a new Vector2
  1138. */
  1139. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1140. /**
  1141. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1142. * @param left defines 1st vector
  1143. * @param right defines 2nd vector
  1144. * @returns a new Vector2
  1145. */
  1146. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1147. /**
  1148. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1149. * @param vector defines the vector to transform
  1150. * @param transformation defines the matrix to apply
  1151. * @returns a new Vector2
  1152. */
  1153. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1154. /**
  1155. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1156. * @param vector defines the vector to transform
  1157. * @param transformation defines the matrix to apply
  1158. * @param result defines the target vector
  1159. */
  1160. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1161. /**
  1162. * Determines if a given vector is included in a triangle
  1163. * @param p defines the vector to test
  1164. * @param p0 defines 1st triangle point
  1165. * @param p1 defines 2nd triangle point
  1166. * @param p2 defines 3rd triangle point
  1167. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1168. */
  1169. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1170. /**
  1171. * Gets the distance between the vectors "value1" and "value2"
  1172. * @param value1 defines first vector
  1173. * @param value2 defines second vector
  1174. * @returns the distance between vectors
  1175. */
  1176. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1177. /**
  1178. * Returns the squared distance between the vectors "value1" and "value2"
  1179. * @param value1 defines first vector
  1180. * @param value2 defines second vector
  1181. * @returns the squared distance between vectors
  1182. */
  1183. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1184. /**
  1185. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1186. * @param value1 defines first vector
  1187. * @param value2 defines second vector
  1188. * @returns a new Vector2
  1189. */
  1190. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1191. /**
  1192. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1193. * @param p defines the middle point
  1194. * @param segA defines one point of the segment
  1195. * @param segB defines the other point of the segment
  1196. * @returns the shortest distance
  1197. */
  1198. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1199. }
  1200. /**
  1201. * Classed used to store (x,y,z) vector representation
  1202. * A Vector3 is the main object used in 3D geometry
  1203. * It can represent etiher the coordinates of a point the space, either a direction
  1204. * Reminder: js uses a left handed forward facing system
  1205. */
  1206. export class Vector3 {
  1207. /**
  1208. * Defines the first coordinates (on X axis)
  1209. */
  1210. x: number;
  1211. /**
  1212. * Defines the second coordinates (on Y axis)
  1213. */
  1214. y: number;
  1215. /**
  1216. * Defines the third coordinates (on Z axis)
  1217. */
  1218. z: number;
  1219. private static _UpReadOnly;
  1220. /**
  1221. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1222. * @param x defines the first coordinates (on X axis)
  1223. * @param y defines the second coordinates (on Y axis)
  1224. * @param z defines the third coordinates (on Z axis)
  1225. */
  1226. constructor(
  1227. /**
  1228. * Defines the first coordinates (on X axis)
  1229. */
  1230. x?: number,
  1231. /**
  1232. * Defines the second coordinates (on Y axis)
  1233. */
  1234. y?: number,
  1235. /**
  1236. * Defines the third coordinates (on Z axis)
  1237. */
  1238. z?: number);
  1239. /**
  1240. * Creates a string representation of the Vector3
  1241. * @returns a string with the Vector3 coordinates.
  1242. */
  1243. toString(): string;
  1244. /**
  1245. * Gets the class name
  1246. * @returns the string "Vector3"
  1247. */
  1248. getClassName(): string;
  1249. /**
  1250. * Creates the Vector3 hash code
  1251. * @returns a number which tends to be unique between Vector3 instances
  1252. */
  1253. getHashCode(): number;
  1254. /**
  1255. * Creates an array containing three elements : the coordinates of the Vector3
  1256. * @returns a new array of numbers
  1257. */
  1258. asArray(): number[];
  1259. /**
  1260. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1261. * @param array defines the destination array
  1262. * @param index defines the offset in the destination array
  1263. * @returns the current Vector3
  1264. */
  1265. toArray(array: FloatArray, index?: number): Vector3;
  1266. /**
  1267. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1268. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1269. */
  1270. toQuaternion(): Quaternion;
  1271. /**
  1272. * Adds the given vector to the current Vector3
  1273. * @param otherVector defines the second operand
  1274. * @returns the current updated Vector3
  1275. */
  1276. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1277. /**
  1278. * Adds the given coordinates to the current Vector3
  1279. * @param x defines the x coordinate of the operand
  1280. * @param y defines the y coordinate of the operand
  1281. * @param z defines the z coordinate of the operand
  1282. * @returns the current updated Vector3
  1283. */
  1284. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1285. /**
  1286. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1287. * @param otherVector defines the second operand
  1288. * @returns the resulting Vector3
  1289. */
  1290. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1291. /**
  1292. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1293. * @param otherVector defines the second operand
  1294. * @param result defines the Vector3 object where to store the result
  1295. * @returns the current Vector3
  1296. */
  1297. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1298. /**
  1299. * Subtract the given vector from the current Vector3
  1300. * @param otherVector defines the second operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1304. /**
  1305. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1312. * @param otherVector defines the second operand
  1313. * @param result defines the Vector3 object where to store the result
  1314. * @returns the current Vector3
  1315. */
  1316. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1319. * @param x defines the x coordinate of the operand
  1320. * @param y defines the y coordinate of the operand
  1321. * @param z defines the z coordinate of the operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1325. /**
  1326. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1327. * @param x defines the x coordinate of the operand
  1328. * @param y defines the y coordinate of the operand
  1329. * @param z defines the z coordinate of the operand
  1330. * @param result defines the Vector3 object where to store the result
  1331. * @returns the current Vector3
  1332. */
  1333. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1334. /**
  1335. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1336. * @returns a new Vector3
  1337. */
  1338. negate(): Vector3;
  1339. /**
  1340. * Multiplies the Vector3 coordinates by the float "scale"
  1341. * @param scale defines the multiplier factor
  1342. * @returns the current updated Vector3
  1343. */
  1344. scaleInPlace(scale: number): Vector3;
  1345. /**
  1346. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1347. * @param scale defines the multiplier factor
  1348. * @returns a new Vector3
  1349. */
  1350. scale(scale: number): Vector3;
  1351. /**
  1352. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1353. * @param scale defines the multiplier factor
  1354. * @param result defines the Vector3 object where to store the result
  1355. * @returns the current Vector3
  1356. */
  1357. scaleToRef(scale: number, result: Vector3): Vector3;
  1358. /**
  1359. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1360. * @param scale defines the scale factor
  1361. * @param result defines the Vector3 object where to store the result
  1362. * @returns the unmodified current Vector3
  1363. */
  1364. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1365. /**
  1366. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1367. * @param otherVector defines the second operand
  1368. * @returns true if both vectors are equals
  1369. */
  1370. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1371. /**
  1372. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1373. * @param otherVector defines the second operand
  1374. * @param epsilon defines the minimal distance to define values as equals
  1375. * @returns true if both vectors are distant less than epsilon
  1376. */
  1377. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1378. /**
  1379. * Returns true if the current Vector3 coordinates equals the given floats
  1380. * @param x defines the x coordinate of the operand
  1381. * @param y defines the y coordinate of the operand
  1382. * @param z defines the z coordinate of the operand
  1383. * @returns true if both vectors are equals
  1384. */
  1385. equalsToFloats(x: number, y: number, z: number): boolean;
  1386. /**
  1387. * Multiplies the current Vector3 coordinates by the given ones
  1388. * @param otherVector defines the second operand
  1389. * @returns the current updated Vector3
  1390. */
  1391. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1392. /**
  1393. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1394. * @param otherVector defines the second operand
  1395. * @returns the new Vector3
  1396. */
  1397. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1398. /**
  1399. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1400. * @param otherVector defines the second operand
  1401. * @param result defines the Vector3 object where to store the result
  1402. * @returns the current Vector3
  1403. */
  1404. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1405. /**
  1406. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1407. * @param x defines the x coordinate of the operand
  1408. * @param y defines the y coordinate of the operand
  1409. * @param z defines the z coordinate of the operand
  1410. * @returns the new Vector3
  1411. */
  1412. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1413. /**
  1414. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1415. * @param otherVector defines the second operand
  1416. * @returns the new Vector3
  1417. */
  1418. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1419. /**
  1420. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1421. * @param otherVector defines the second operand
  1422. * @param result defines the Vector3 object where to store the result
  1423. * @returns the current Vector3
  1424. */
  1425. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1426. /**
  1427. * Divides the current Vector3 coordinates by the given ones.
  1428. * @param otherVector defines the second operand
  1429. * @returns the current updated Vector3
  1430. */
  1431. divideInPlace(otherVector: Vector3): Vector3;
  1432. /**
  1433. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1434. * @param other defines the second operand
  1435. * @returns the current updated Vector3
  1436. */
  1437. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1440. * @param other defines the second operand
  1441. * @returns the current updated Vector3
  1442. */
  1443. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1444. /**
  1445. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1446. * @param x defines the x coordinate of the operand
  1447. * @param y defines the y coordinate of the operand
  1448. * @param z defines the z coordinate of the operand
  1449. * @returns the current updated Vector3
  1450. */
  1451. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1452. /**
  1453. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1454. * @param x defines the x coordinate of the operand
  1455. * @param y defines the y coordinate of the operand
  1456. * @param z defines the z coordinate of the operand
  1457. * @returns the current updated Vector3
  1458. */
  1459. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1460. /**
  1461. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1462. * Check if is non uniform within a certain amount of decimal places to account for this
  1463. * @param epsilon the amount the values can differ
  1464. * @returns if the the vector is non uniform to a certain number of decimal places
  1465. */
  1466. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1467. /**
  1468. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1469. */
  1470. readonly isNonUniform: boolean;
  1471. /**
  1472. * Gets a new Vector3 from current Vector3 floored values
  1473. * @returns a new Vector3
  1474. */
  1475. floor(): Vector3;
  1476. /**
  1477. * Gets a new Vector3 from current Vector3 floored values
  1478. * @returns a new Vector3
  1479. */
  1480. fract(): Vector3;
  1481. /**
  1482. * Gets the length of the Vector3
  1483. * @returns the length of the Vecto3
  1484. */
  1485. length(): number;
  1486. /**
  1487. * Gets the squared length of the Vector3
  1488. * @returns squared length of the Vector3
  1489. */
  1490. lengthSquared(): number;
  1491. /**
  1492. * Normalize the current Vector3.
  1493. * Please note that this is an in place operation.
  1494. * @returns the current updated Vector3
  1495. */
  1496. normalize(): Vector3;
  1497. /**
  1498. * Reorders the x y z properties of the vector in place
  1499. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1500. * @returns the current updated vector
  1501. */
  1502. reorderInPlace(order: string): this;
  1503. /**
  1504. * Rotates the vector around 0,0,0 by a quaternion
  1505. * @param quaternion the rotation quaternion
  1506. * @param result vector to store the result
  1507. * @returns the resulting vector
  1508. */
  1509. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1510. /**
  1511. * Rotates a vector around a given point
  1512. * @param quaternion the rotation quaternion
  1513. * @param point the point to rotate around
  1514. * @param result vector to store the result
  1515. * @returns the resulting vector
  1516. */
  1517. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1518. /**
  1519. * Normalize the current Vector3 with the given input length.
  1520. * Please note that this is an in place operation.
  1521. * @param len the length of the vector
  1522. * @returns the current updated Vector3
  1523. */
  1524. normalizeFromLength(len: number): Vector3;
  1525. /**
  1526. * Normalize the current Vector3 to a new vector
  1527. * @returns the new Vector3
  1528. */
  1529. normalizeToNew(): Vector3;
  1530. /**
  1531. * Normalize the current Vector3 to the reference
  1532. * @param reference define the Vector3 to update
  1533. * @returns the updated Vector3
  1534. */
  1535. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1536. /**
  1537. * Creates a new Vector3 copied from the current Vector3
  1538. * @returns the new Vector3
  1539. */
  1540. clone(): Vector3;
  1541. /**
  1542. * Copies the given vector coordinates to the current Vector3 ones
  1543. * @param source defines the source Vector3
  1544. * @returns the current updated Vector3
  1545. */
  1546. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1547. /**
  1548. * Copies the given floats to the current Vector3 coordinates
  1549. * @param x defines the x coordinate of the operand
  1550. * @param y defines the y coordinate of the operand
  1551. * @param z defines the z coordinate of the operand
  1552. * @returns the current updated Vector3
  1553. */
  1554. copyFromFloats(x: number, y: number, z: number): Vector3;
  1555. /**
  1556. * Copies the given floats to the current Vector3 coordinates
  1557. * @param x defines the x coordinate of the operand
  1558. * @param y defines the y coordinate of the operand
  1559. * @param z defines the z coordinate of the operand
  1560. * @returns the current updated Vector3
  1561. */
  1562. set(x: number, y: number, z: number): Vector3;
  1563. /**
  1564. * Copies the given float to the current Vector3 coordinates
  1565. * @param v defines the x, y and z coordinates of the operand
  1566. * @returns the current updated Vector3
  1567. */
  1568. setAll(v: number): Vector3;
  1569. /**
  1570. * Get the clip factor between two vectors
  1571. * @param vector0 defines the first operand
  1572. * @param vector1 defines the second operand
  1573. * @param axis defines the axis to use
  1574. * @param size defines the size along the axis
  1575. * @returns the clip factor
  1576. */
  1577. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1578. /**
  1579. * Get angle between two vectors
  1580. * @param vector0 angle between vector0 and vector1
  1581. * @param vector1 angle between vector0 and vector1
  1582. * @param normal direction of the normal
  1583. * @return the angle between vector0 and vector1
  1584. */
  1585. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1586. /**
  1587. * Returns a new Vector3 set from the index "offset" of the given array
  1588. * @param array defines the source array
  1589. * @param offset defines the offset in the source array
  1590. * @returns the new Vector3
  1591. */
  1592. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1593. /**
  1594. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1595. * This function is deprecated. Use FromArray instead
  1596. * @param array defines the source array
  1597. * @param offset defines the offset in the source array
  1598. * @returns the new Vector3
  1599. */
  1600. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1601. /**
  1602. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1603. * @param array defines the source array
  1604. * @param offset defines the offset in the source array
  1605. * @param result defines the Vector3 where to store the result
  1606. */
  1607. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1608. /**
  1609. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1610. * This function is deprecated. Use FromArrayToRef instead.
  1611. * @param array defines the source array
  1612. * @param offset defines the offset in the source array
  1613. * @param result defines the Vector3 where to store the result
  1614. */
  1615. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1616. /**
  1617. * Sets the given vector "result" with the given floats.
  1618. * @param x defines the x coordinate of the source
  1619. * @param y defines the y coordinate of the source
  1620. * @param z defines the z coordinate of the source
  1621. * @param result defines the Vector3 where to store the result
  1622. */
  1623. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1624. /**
  1625. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1626. * @returns a new empty Vector3
  1627. */
  1628. static Zero(): Vector3;
  1629. /**
  1630. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1631. * @returns a new unit Vector3
  1632. */
  1633. static One(): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1636. * @returns a new up Vector3
  1637. */
  1638. static Up(): Vector3;
  1639. /**
  1640. * Gets a up Vector3 that must not be updated
  1641. */
  1642. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1645. * @returns a new down Vector3
  1646. */
  1647. static Down(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1650. * @returns a new forward Vector3
  1651. */
  1652. static Forward(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1655. * @returns a new forward Vector3
  1656. */
  1657. static Backward(): Vector3;
  1658. /**
  1659. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1660. * @returns a new right Vector3
  1661. */
  1662. static Right(): Vector3;
  1663. /**
  1664. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1665. * @returns a new left Vector3
  1666. */
  1667. static Left(): Vector3;
  1668. /**
  1669. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1670. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1671. * @param vector defines the Vector3 to transform
  1672. * @param transformation defines the transformation matrix
  1673. * @returns the transformed Vector3
  1674. */
  1675. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1676. /**
  1677. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1678. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1679. * @param vector defines the Vector3 to transform
  1680. * @param transformation defines the transformation matrix
  1681. * @param result defines the Vector3 where to store the result
  1682. */
  1683. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1684. /**
  1685. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1686. * This method computes tranformed coordinates only, not transformed direction vectors
  1687. * @param x define the x coordinate of the source vector
  1688. * @param y define the y coordinate of the source vector
  1689. * @param z define the z coordinate of the source vector
  1690. * @param transformation defines the transformation matrix
  1691. * @param result defines the Vector3 where to store the result
  1692. */
  1693. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1694. /**
  1695. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1696. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1697. * @param vector defines the Vector3 to transform
  1698. * @param transformation defines the transformation matrix
  1699. * @returns the new Vector3
  1700. */
  1701. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1702. /**
  1703. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1704. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1705. * @param vector defines the Vector3 to transform
  1706. * @param transformation defines the transformation matrix
  1707. * @param result defines the Vector3 where to store the result
  1708. */
  1709. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1710. /**
  1711. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1712. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1713. * @param x define the x coordinate of the source vector
  1714. * @param y define the y coordinate of the source vector
  1715. * @param z define the z coordinate of the source vector
  1716. * @param transformation defines the transformation matrix
  1717. * @param result defines the Vector3 where to store the result
  1718. */
  1719. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1720. /**
  1721. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1722. * @param value1 defines the first control point
  1723. * @param value2 defines the second control point
  1724. * @param value3 defines the third control point
  1725. * @param value4 defines the fourth control point
  1726. * @param amount defines the amount on the spline to use
  1727. * @returns the new Vector3
  1728. */
  1729. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1730. /**
  1731. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1732. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1733. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1734. * @param value defines the current value
  1735. * @param min defines the lower range value
  1736. * @param max defines the upper range value
  1737. * @returns the new Vector3
  1738. */
  1739. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1740. /**
  1741. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1742. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1743. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1744. * @param value defines the current value
  1745. * @param min defines the lower range value
  1746. * @param max defines the upper range value
  1747. * @param result defines the Vector3 where to store the result
  1748. */
  1749. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1750. /**
  1751. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1752. * @param value1 defines the first control point
  1753. * @param tangent1 defines the first tangent vector
  1754. * @param value2 defines the second control point
  1755. * @param tangent2 defines the second tangent vector
  1756. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1757. * @returns the new Vector3
  1758. */
  1759. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1760. /**
  1761. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1762. * @param start defines the start value
  1763. * @param end defines the end value
  1764. * @param amount max defines amount between both (between 0 and 1)
  1765. * @returns the new Vector3
  1766. */
  1767. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1768. /**
  1769. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1770. * @param start defines the start value
  1771. * @param end defines the end value
  1772. * @param amount max defines amount between both (between 0 and 1)
  1773. * @param result defines the Vector3 where to store the result
  1774. */
  1775. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1776. /**
  1777. * Returns the dot product (float) between the vectors "left" and "right"
  1778. * @param left defines the left operand
  1779. * @param right defines the right operand
  1780. * @returns the dot product
  1781. */
  1782. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1785. * The cross product is then orthogonal to both "left" and "right"
  1786. * @param left defines the left operand
  1787. * @param right defines the right operand
  1788. * @returns the cross product
  1789. */
  1790. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the cross product of "left" and "right"
  1793. * The cross product is then orthogonal to both "left" and "right"
  1794. * @param left defines the left operand
  1795. * @param right defines the right operand
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1799. /**
  1800. * Returns a new Vector3 as the normalization of the given vector
  1801. * @param vector defines the Vector3 to normalize
  1802. * @returns the new Vector3
  1803. */
  1804. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Sets the given vector "result" with the normalization of the given first vector
  1807. * @param vector defines the Vector3 to normalize
  1808. * @param result defines the Vector3 where to store the result
  1809. */
  1810. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1811. /**
  1812. * Project a Vector3 onto screen space
  1813. * @param vector defines the Vector3 to project
  1814. * @param world defines the world matrix to use
  1815. * @param transform defines the transform (view x projection) matrix to use
  1816. * @param viewport defines the screen viewport to use
  1817. * @returns the new Vector3
  1818. */
  1819. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1820. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1821. /**
  1822. * Unproject from screen space to object space
  1823. * @param source defines the screen space Vector3 to use
  1824. * @param viewportWidth defines the current width of the viewport
  1825. * @param viewportHeight defines the current height of the viewport
  1826. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1827. * @param transform defines the transform (view x projection) matrix to use
  1828. * @returns the new Vector3
  1829. */
  1830. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1831. /**
  1832. * Unproject from screen space to object space
  1833. * @param source defines the screen space Vector3 to use
  1834. * @param viewportWidth defines the current width of the viewport
  1835. * @param viewportHeight defines the current height of the viewport
  1836. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1837. * @param view defines the view matrix to use
  1838. * @param projection defines the projection matrix to use
  1839. * @returns the new Vector3
  1840. */
  1841. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1842. /**
  1843. * Unproject from screen space to object space
  1844. * @param source defines the screen space Vector3 to use
  1845. * @param viewportWidth defines the current width of the viewport
  1846. * @param viewportHeight defines the current height of the viewport
  1847. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1848. * @param view defines the view matrix to use
  1849. * @param projection defines the projection matrix to use
  1850. * @param result defines the Vector3 where to store the result
  1851. */
  1852. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1853. /**
  1854. * Unproject from screen space to object space
  1855. * @param sourceX defines the screen space x coordinate to use
  1856. * @param sourceY defines the screen space y coordinate to use
  1857. * @param sourceZ defines the screen space z coordinate to use
  1858. * @param viewportWidth defines the current width of the viewport
  1859. * @param viewportHeight defines the current height of the viewport
  1860. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1861. * @param view defines the view matrix to use
  1862. * @param projection defines the projection matrix to use
  1863. * @param result defines the Vector3 where to store the result
  1864. */
  1865. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1866. /**
  1867. * Gets the minimal coordinate values between two Vector3
  1868. * @param left defines the first operand
  1869. * @param right defines the second operand
  1870. * @returns the new Vector3
  1871. */
  1872. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1873. /**
  1874. * Gets the maximal coordinate values between two Vector3
  1875. * @param left defines the first operand
  1876. * @param right defines the second operand
  1877. * @returns the new Vector3
  1878. */
  1879. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1880. /**
  1881. * Returns the distance between the vectors "value1" and "value2"
  1882. * @param value1 defines the first operand
  1883. * @param value2 defines the second operand
  1884. * @returns the distance
  1885. */
  1886. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1887. /**
  1888. * Returns the squared distance between the vectors "value1" and "value2"
  1889. * @param value1 defines the first operand
  1890. * @param value2 defines the second operand
  1891. * @returns the squared distance
  1892. */
  1893. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1894. /**
  1895. * Returns a new Vector3 located at the center between "value1" and "value2"
  1896. * @param value1 defines the first operand
  1897. * @param value2 defines the second operand
  1898. * @returns the new Vector3
  1899. */
  1900. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1901. /**
  1902. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1903. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1904. * to something in order to rotate it from its local system to the given target system
  1905. * Note: axis1, axis2 and axis3 are normalized during this operation
  1906. * @param axis1 defines the first axis
  1907. * @param axis2 defines the second axis
  1908. * @param axis3 defines the third axis
  1909. * @returns a new Vector3
  1910. */
  1911. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1912. /**
  1913. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1914. * @param axis1 defines the first axis
  1915. * @param axis2 defines the second axis
  1916. * @param axis3 defines the third axis
  1917. * @param ref defines the Vector3 where to store the result
  1918. */
  1919. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1920. }
  1921. /**
  1922. * Vector4 class created for EulerAngle class conversion to Quaternion
  1923. */
  1924. export class Vector4 {
  1925. /** x value of the vector */
  1926. x: number;
  1927. /** y value of the vector */
  1928. y: number;
  1929. /** z value of the vector */
  1930. z: number;
  1931. /** w value of the vector */
  1932. w: number;
  1933. /**
  1934. * Creates a Vector4 object from the given floats.
  1935. * @param x x value of the vector
  1936. * @param y y value of the vector
  1937. * @param z z value of the vector
  1938. * @param w w value of the vector
  1939. */
  1940. constructor(
  1941. /** x value of the vector */
  1942. x: number,
  1943. /** y value of the vector */
  1944. y: number,
  1945. /** z value of the vector */
  1946. z: number,
  1947. /** w value of the vector */
  1948. w: number);
  1949. /**
  1950. * Returns the string with the Vector4 coordinates.
  1951. * @returns a string containing all the vector values
  1952. */
  1953. toString(): string;
  1954. /**
  1955. * Returns the string "Vector4".
  1956. * @returns "Vector4"
  1957. */
  1958. getClassName(): string;
  1959. /**
  1960. * Returns the Vector4 hash code.
  1961. * @returns a unique hash code
  1962. */
  1963. getHashCode(): number;
  1964. /**
  1965. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1966. * @returns the resulting array
  1967. */
  1968. asArray(): number[];
  1969. /**
  1970. * Populates the given array from the given index with the Vector4 coordinates.
  1971. * @param array array to populate
  1972. * @param index index of the array to start at (default: 0)
  1973. * @returns the Vector4.
  1974. */
  1975. toArray(array: FloatArray, index?: number): Vector4;
  1976. /**
  1977. * Adds the given vector to the current Vector4.
  1978. * @param otherVector the vector to add
  1979. * @returns the updated Vector4.
  1980. */
  1981. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1982. /**
  1983. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1984. * @param otherVector the vector to add
  1985. * @returns the resulting vector
  1986. */
  1987. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1988. /**
  1989. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1990. * @param otherVector the vector to add
  1991. * @param result the vector to store the result
  1992. * @returns the current Vector4.
  1993. */
  1994. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1995. /**
  1996. * Subtract in place the given vector from the current Vector4.
  1997. * @param otherVector the vector to subtract
  1998. * @returns the updated Vector4.
  1999. */
  2000. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2001. /**
  2002. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2003. * @param otherVector the vector to add
  2004. * @returns the new vector with the result
  2005. */
  2006. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2007. /**
  2008. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2009. * @param otherVector the vector to subtract
  2010. * @param result the vector to store the result
  2011. * @returns the current Vector4.
  2012. */
  2013. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2014. /**
  2015. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2016. */
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. * @param x value to subtract
  2020. * @param y value to subtract
  2021. * @param z value to subtract
  2022. * @param w value to subtract
  2023. * @returns new vector containing the result
  2024. */
  2025. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2026. /**
  2027. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2028. * @param x value to subtract
  2029. * @param y value to subtract
  2030. * @param z value to subtract
  2031. * @param w value to subtract
  2032. * @param result the vector to store the result in
  2033. * @returns the current Vector4.
  2034. */
  2035. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2036. /**
  2037. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2038. * @returns a new vector with the negated values
  2039. */
  2040. negate(): Vector4;
  2041. /**
  2042. * Multiplies the current Vector4 coordinates by scale (float).
  2043. * @param scale the number to scale with
  2044. * @returns the updated Vector4.
  2045. */
  2046. scaleInPlace(scale: number): Vector4;
  2047. /**
  2048. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2049. * @param scale the number to scale with
  2050. * @returns a new vector with the result
  2051. */
  2052. scale(scale: number): Vector4;
  2053. /**
  2054. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2055. * @param scale the number to scale with
  2056. * @param result a vector to store the result in
  2057. * @returns the current Vector4.
  2058. */
  2059. scaleToRef(scale: number, result: Vector4): Vector4;
  2060. /**
  2061. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2062. * @param scale defines the scale factor
  2063. * @param result defines the Vector4 object where to store the result
  2064. * @returns the unmodified current Vector4
  2065. */
  2066. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2067. /**
  2068. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2069. * @param otherVector the vector to compare against
  2070. * @returns true if they are equal
  2071. */
  2072. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2073. /**
  2074. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2075. * @param otherVector vector to compare against
  2076. * @param epsilon (Default: very small number)
  2077. * @returns true if they are equal
  2078. */
  2079. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2080. /**
  2081. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2082. * @param x x value to compare against
  2083. * @param y y value to compare against
  2084. * @param z z value to compare against
  2085. * @param w w value to compare against
  2086. * @returns true if equal
  2087. */
  2088. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2089. /**
  2090. * Multiplies in place the current Vector4 by the given one.
  2091. * @param otherVector vector to multiple with
  2092. * @returns the updated Vector4.
  2093. */
  2094. multiplyInPlace(otherVector: Vector4): Vector4;
  2095. /**
  2096. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2097. * @param otherVector vector to multiple with
  2098. * @returns resulting new vector
  2099. */
  2100. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2101. /**
  2102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2103. * @param otherVector vector to multiple with
  2104. * @param result vector to store the result
  2105. * @returns the current Vector4.
  2106. */
  2107. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2108. /**
  2109. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2110. * @param x x value multiply with
  2111. * @param y y value multiply with
  2112. * @param z z value multiply with
  2113. * @param w w value multiply with
  2114. * @returns resulting new vector
  2115. */
  2116. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2117. /**
  2118. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2119. * @param otherVector vector to devide with
  2120. * @returns resulting new vector
  2121. */
  2122. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2123. /**
  2124. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2125. * @param otherVector vector to devide with
  2126. * @param result vector to store the result
  2127. * @returns the current Vector4.
  2128. */
  2129. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2130. /**
  2131. * Divides the current Vector3 coordinates by the given ones.
  2132. * @param otherVector vector to devide with
  2133. * @returns the updated Vector3.
  2134. */
  2135. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2136. /**
  2137. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2138. * @param other defines the second operand
  2139. * @returns the current updated Vector4
  2140. */
  2141. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2142. /**
  2143. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2144. * @param other defines the second operand
  2145. * @returns the current updated Vector4
  2146. */
  2147. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2148. /**
  2149. * Gets a new Vector4 from current Vector4 floored values
  2150. * @returns a new Vector4
  2151. */
  2152. floor(): Vector4;
  2153. /**
  2154. * Gets a new Vector4 from current Vector3 floored values
  2155. * @returns a new Vector4
  2156. */
  2157. fract(): Vector4;
  2158. /**
  2159. * Returns the Vector4 length (float).
  2160. * @returns the length
  2161. */
  2162. length(): number;
  2163. /**
  2164. * Returns the Vector4 squared length (float).
  2165. * @returns the length squared
  2166. */
  2167. lengthSquared(): number;
  2168. /**
  2169. * Normalizes in place the Vector4.
  2170. * @returns the updated Vector4.
  2171. */
  2172. normalize(): Vector4;
  2173. /**
  2174. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2175. * @returns this converted to a new vector3
  2176. */
  2177. toVector3(): Vector3;
  2178. /**
  2179. * Returns a new Vector4 copied from the current one.
  2180. * @returns the new cloned vector
  2181. */
  2182. clone(): Vector4;
  2183. /**
  2184. * Updates the current Vector4 with the given one coordinates.
  2185. * @param source the source vector to copy from
  2186. * @returns the updated Vector4.
  2187. */
  2188. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the current Vector4 coordinates with the given floats.
  2191. * @param x float to copy from
  2192. * @param y float to copy from
  2193. * @param z float to copy from
  2194. * @param w float to copy from
  2195. * @returns the updated Vector4.
  2196. */
  2197. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2198. /**
  2199. * Updates the current Vector4 coordinates with the given floats.
  2200. * @param x float to set from
  2201. * @param y float to set from
  2202. * @param z float to set from
  2203. * @param w float to set from
  2204. * @returns the updated Vector4.
  2205. */
  2206. set(x: number, y: number, z: number, w: number): Vector4;
  2207. /**
  2208. * Copies the given float to the current Vector3 coordinates
  2209. * @param v defines the x, y, z and w coordinates of the operand
  2210. * @returns the current updated Vector3
  2211. */
  2212. setAll(v: number): Vector4;
  2213. /**
  2214. * Returns a new Vector4 set from the starting index of the given array.
  2215. * @param array the array to pull values from
  2216. * @param offset the offset into the array to start at
  2217. * @returns the new vector
  2218. */
  2219. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2220. /**
  2221. * Updates the given vector "result" from the starting index of the given array.
  2222. * @param array the array to pull values from
  2223. * @param offset the offset into the array to start at
  2224. * @param result the vector to store the result in
  2225. */
  2226. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2227. /**
  2228. * Updates the given vector "result" from the starting index of the given Float32Array.
  2229. * @param array the array to pull values from
  2230. * @param offset the offset into the array to start at
  2231. * @param result the vector to store the result in
  2232. */
  2233. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2234. /**
  2235. * Updates the given vector "result" coordinates from the given floats.
  2236. * @param x float to set from
  2237. * @param y float to set from
  2238. * @param z float to set from
  2239. * @param w float to set from
  2240. * @param result the vector to the floats in
  2241. */
  2242. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2243. /**
  2244. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2245. * @returns the new vector
  2246. */
  2247. static Zero(): Vector4;
  2248. /**
  2249. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2250. * @returns the new vector
  2251. */
  2252. static One(): Vector4;
  2253. /**
  2254. * Returns a new normalized Vector4 from the given one.
  2255. * @param vector the vector to normalize
  2256. * @returns the vector
  2257. */
  2258. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2259. /**
  2260. * Updates the given vector "result" from the normalization of the given one.
  2261. * @param vector the vector to normalize
  2262. * @param result the vector to store the result in
  2263. */
  2264. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2265. /**
  2266. * Returns a vector with the minimum values from the left and right vectors
  2267. * @param left left vector to minimize
  2268. * @param right right vector to minimize
  2269. * @returns a new vector with the minimum of the left and right vector values
  2270. */
  2271. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2272. /**
  2273. * Returns a vector with the maximum values from the left and right vectors
  2274. * @param left left vector to maximize
  2275. * @param right right vector to maximize
  2276. * @returns a new vector with the maximum of the left and right vector values
  2277. */
  2278. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2279. /**
  2280. * Returns the distance (float) between the vectors "value1" and "value2".
  2281. * @param value1 value to calulate the distance between
  2282. * @param value2 value to calulate the distance between
  2283. * @return the distance between the two vectors
  2284. */
  2285. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2286. /**
  2287. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2288. * @param value1 value to calulate the distance between
  2289. * @param value2 value to calulate the distance between
  2290. * @return the distance between the two vectors squared
  2291. */
  2292. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2293. /**
  2294. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2295. * @param value1 value to calulate the center between
  2296. * @param value2 value to calulate the center between
  2297. * @return the center between the two vectors
  2298. */
  2299. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2300. /**
  2301. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2302. * This methods computes transformed normalized direction vectors only.
  2303. * @param vector the vector to transform
  2304. * @param transformation the transformation matrix to apply
  2305. * @returns the new vector
  2306. */
  2307. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2308. /**
  2309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2310. * This methods computes transformed normalized direction vectors only.
  2311. * @param vector the vector to transform
  2312. * @param transformation the transformation matrix to apply
  2313. * @param result the vector to store the result in
  2314. */
  2315. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2316. /**
  2317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2318. * This methods computes transformed normalized direction vectors only.
  2319. * @param x value to transform
  2320. * @param y value to transform
  2321. * @param z value to transform
  2322. * @param w value to transform
  2323. * @param transformation the transformation matrix to apply
  2324. * @param result the vector to store the results in
  2325. */
  2326. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2327. /**
  2328. * Creates a new Vector4 from a Vector3
  2329. * @param source defines the source data
  2330. * @param w defines the 4th component (default is 0)
  2331. * @returns a new Vector4
  2332. */
  2333. static FromVector3(source: Vector3, w?: number): Vector4;
  2334. }
  2335. /**
  2336. * Interface for the size containing width and height
  2337. */
  2338. export interface ISize {
  2339. /**
  2340. * Width
  2341. */
  2342. width: number;
  2343. /**
  2344. * Heighht
  2345. */
  2346. height: number;
  2347. }
  2348. /**
  2349. * Size containing widht and height
  2350. */
  2351. export class Size implements ISize {
  2352. /**
  2353. * Width
  2354. */
  2355. width: number;
  2356. /**
  2357. * Height
  2358. */
  2359. height: number;
  2360. /**
  2361. * Creates a Size object from the given width and height (floats).
  2362. * @param width width of the new size
  2363. * @param height height of the new size
  2364. */
  2365. constructor(width: number, height: number);
  2366. /**
  2367. * Returns a string with the Size width and height
  2368. * @returns a string with the Size width and height
  2369. */
  2370. toString(): string;
  2371. /**
  2372. * "Size"
  2373. * @returns the string "Size"
  2374. */
  2375. getClassName(): string;
  2376. /**
  2377. * Returns the Size hash code.
  2378. * @returns a hash code for a unique width and height
  2379. */
  2380. getHashCode(): number;
  2381. /**
  2382. * Updates the current size from the given one.
  2383. * @param src the given size
  2384. */
  2385. copyFrom(src: Size): void;
  2386. /**
  2387. * Updates in place the current Size from the given floats.
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. * @returns the updated Size.
  2391. */
  2392. copyFromFloats(width: number, height: number): Size;
  2393. /**
  2394. * Updates in place the current Size from the given floats.
  2395. * @param width width to set
  2396. * @param height height to set
  2397. * @returns the updated Size.
  2398. */
  2399. set(width: number, height: number): Size;
  2400. /**
  2401. * Multiplies the width and height by numbers
  2402. * @param w factor to multiple the width by
  2403. * @param h factor to multiple the height by
  2404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2405. */
  2406. multiplyByFloats(w: number, h: number): Size;
  2407. /**
  2408. * Clones the size
  2409. * @returns a new Size copied from the given one.
  2410. */
  2411. clone(): Size;
  2412. /**
  2413. * True if the current Size and the given one width and height are strictly equal.
  2414. * @param other the other size to compare against
  2415. * @returns True if the current Size and the given one width and height are strictly equal.
  2416. */
  2417. equals(other: Size): boolean;
  2418. /**
  2419. * The surface of the Size : width * height (float).
  2420. */
  2421. readonly surface: number;
  2422. /**
  2423. * Create a new size of zero
  2424. * @returns a new Size set to (0.0, 0.0)
  2425. */
  2426. static Zero(): Size;
  2427. /**
  2428. * Sums the width and height of two sizes
  2429. * @param otherSize size to add to this size
  2430. * @returns a new Size set as the addition result of the current Size and the given one.
  2431. */
  2432. add(otherSize: Size): Size;
  2433. /**
  2434. * Subtracts the width and height of two
  2435. * @param otherSize size to subtract to this size
  2436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2437. */
  2438. subtract(otherSize: Size): Size;
  2439. /**
  2440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2441. * @param start starting size to lerp between
  2442. * @param end end size to lerp between
  2443. * @param amount amount to lerp between the start and end values
  2444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2445. */
  2446. static Lerp(start: Size, end: Size, amount: number): Size;
  2447. }
  2448. /**
  2449. * Class used to store quaternion data
  2450. * @see https://en.wikipedia.org/wiki/Quaternion
  2451. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2452. */
  2453. export class Quaternion {
  2454. /** defines the first component (0 by default) */
  2455. x: number;
  2456. /** defines the second component (0 by default) */
  2457. y: number;
  2458. /** defines the third component (0 by default) */
  2459. z: number;
  2460. /** defines the fourth component (1.0 by default) */
  2461. w: number;
  2462. /**
  2463. * Creates a new Quaternion from the given floats
  2464. * @param x defines the first component (0 by default)
  2465. * @param y defines the second component (0 by default)
  2466. * @param z defines the third component (0 by default)
  2467. * @param w defines the fourth component (1.0 by default)
  2468. */
  2469. constructor(
  2470. /** defines the first component (0 by default) */
  2471. x?: number,
  2472. /** defines the second component (0 by default) */
  2473. y?: number,
  2474. /** defines the third component (0 by default) */
  2475. z?: number,
  2476. /** defines the fourth component (1.0 by default) */
  2477. w?: number);
  2478. /**
  2479. * Gets a string representation for the current quaternion
  2480. * @returns a string with the Quaternion coordinates
  2481. */
  2482. toString(): string;
  2483. /**
  2484. * Gets the class name of the quaternion
  2485. * @returns the string "Quaternion"
  2486. */
  2487. getClassName(): string;
  2488. /**
  2489. * Gets a hash code for this quaternion
  2490. * @returns the quaternion hash code
  2491. */
  2492. getHashCode(): number;
  2493. /**
  2494. * Copy the quaternion to an array
  2495. * @returns a new array populated with 4 elements from the quaternion coordinates
  2496. */
  2497. asArray(): number[];
  2498. /**
  2499. * Check if two quaternions are equals
  2500. * @param otherQuaternion defines the second operand
  2501. * @return true if the current quaternion and the given one coordinates are strictly equals
  2502. */
  2503. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2504. /**
  2505. * Clone the current quaternion
  2506. * @returns a new quaternion copied from the current one
  2507. */
  2508. clone(): Quaternion;
  2509. /**
  2510. * Copy a quaternion to the current one
  2511. * @param other defines the other quaternion
  2512. * @returns the updated current quaternion
  2513. */
  2514. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2515. /**
  2516. * Updates the current quaternion with the given float coordinates
  2517. * @param x defines the x coordinate
  2518. * @param y defines the y coordinate
  2519. * @param z defines the z coordinate
  2520. * @param w defines the w coordinate
  2521. * @returns the updated current quaternion
  2522. */
  2523. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2524. /**
  2525. * Updates the current quaternion from the given float coordinates
  2526. * @param x defines the x coordinate
  2527. * @param y defines the y coordinate
  2528. * @param z defines the z coordinate
  2529. * @param w defines the w coordinate
  2530. * @returns the updated current quaternion
  2531. */
  2532. set(x: number, y: number, z: number, w: number): Quaternion;
  2533. /**
  2534. * Adds two quaternions
  2535. * @param other defines the second operand
  2536. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2537. */
  2538. add(other: DeepImmutable<Quaternion>): Quaternion;
  2539. /**
  2540. * Add a quaternion to the current one
  2541. * @param other defines the quaternion to add
  2542. * @returns the current quaternion
  2543. */
  2544. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2545. /**
  2546. * Subtract two quaternions
  2547. * @param other defines the second operand
  2548. * @returns a new quaternion as the subtraction result of the given one from the current one
  2549. */
  2550. subtract(other: Quaternion): Quaternion;
  2551. /**
  2552. * Multiplies the current quaternion by a scale factor
  2553. * @param value defines the scale factor
  2554. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2555. */
  2556. scale(value: number): Quaternion;
  2557. /**
  2558. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2559. * @param scale defines the scale factor
  2560. * @param result defines the Quaternion object where to store the result
  2561. * @returns the unmodified current quaternion
  2562. */
  2563. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2564. /**
  2565. * Multiplies in place the current quaternion by a scale factor
  2566. * @param value defines the scale factor
  2567. * @returns the current modified quaternion
  2568. */
  2569. scaleInPlace(value: number): Quaternion;
  2570. /**
  2571. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2572. * @param scale defines the scale factor
  2573. * @param result defines the Quaternion object where to store the result
  2574. * @returns the unmodified current quaternion
  2575. */
  2576. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies two quaternions
  2579. * @param q1 defines the second operand
  2580. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2581. */
  2582. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2583. /**
  2584. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2585. * @param q1 defines the second operand
  2586. * @param result defines the target quaternion
  2587. * @returns the current quaternion
  2588. */
  2589. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2590. /**
  2591. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2592. * @param q1 defines the second operand
  2593. * @returns the currentupdated quaternion
  2594. */
  2595. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2596. /**
  2597. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2598. * @param ref defines the target quaternion
  2599. * @returns the current quaternion
  2600. */
  2601. conjugateToRef(ref: Quaternion): Quaternion;
  2602. /**
  2603. * Conjugates in place (1-q) the current quaternion
  2604. * @returns the current updated quaternion
  2605. */
  2606. conjugateInPlace(): Quaternion;
  2607. /**
  2608. * Conjugates in place (1-q) the current quaternion
  2609. * @returns a new quaternion
  2610. */
  2611. conjugate(): Quaternion;
  2612. /**
  2613. * Gets length of current quaternion
  2614. * @returns the quaternion length (float)
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Normalize in place the current quaternion
  2619. * @returns the current updated quaternion
  2620. */
  2621. normalize(): Quaternion;
  2622. /**
  2623. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2624. * @param order is a reserved parameter and is ignore for now
  2625. * @returns a new Vector3 containing the Euler angles
  2626. */
  2627. toEulerAngles(order?: string): Vector3;
  2628. /**
  2629. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2630. * @param result defines the vector which will be filled with the Euler angles
  2631. * @param order is a reserved parameter and is ignore for now
  2632. * @returns the current unchanged quaternion
  2633. */
  2634. toEulerAnglesToRef(result: Vector3): Quaternion;
  2635. /**
  2636. * Updates the given rotation matrix with the current quaternion values
  2637. * @param result defines the target matrix
  2638. * @returns the current unchanged quaternion
  2639. */
  2640. toRotationMatrix(result: Matrix): Quaternion;
  2641. /**
  2642. * Updates the current quaternion from the given rotation matrix values
  2643. * @param matrix defines the source matrix
  2644. * @returns the current updated quaternion
  2645. */
  2646. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2647. /**
  2648. * Creates a new quaternion from a rotation matrix
  2649. * @param matrix defines the source matrix
  2650. * @returns a new quaternion created from the given rotation matrix values
  2651. */
  2652. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2653. /**
  2654. * Updates the given quaternion with the given rotation matrix values
  2655. * @param matrix defines the source matrix
  2656. * @param result defines the target quaternion
  2657. */
  2658. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2659. /**
  2660. * Returns the dot product (float) between the quaternions "left" and "right"
  2661. * @param left defines the left operand
  2662. * @param right defines the right operand
  2663. * @returns the dot product
  2664. */
  2665. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2666. /**
  2667. * Checks if the two quaternions are close to each other
  2668. * @param quat0 defines the first quaternion to check
  2669. * @param quat1 defines the second quaternion to check
  2670. * @returns true if the two quaternions are close to each other
  2671. */
  2672. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2673. /**
  2674. * Creates an empty quaternion
  2675. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2676. */
  2677. static Zero(): Quaternion;
  2678. /**
  2679. * Inverse a given quaternion
  2680. * @param q defines the source quaternion
  2681. * @returns a new quaternion as the inverted current quaternion
  2682. */
  2683. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2684. /**
  2685. * Inverse a given quaternion
  2686. * @param q defines the source quaternion
  2687. * @param result the quaternion the result will be stored in
  2688. * @returns the result quaternion
  2689. */
  2690. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2691. /**
  2692. * Creates an identity quaternion
  2693. * @returns the identity quaternion
  2694. */
  2695. static Identity(): Quaternion;
  2696. /**
  2697. * Gets a boolean indicating if the given quaternion is identity
  2698. * @param quaternion defines the quaternion to check
  2699. * @returns true if the quaternion is identity
  2700. */
  2701. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2702. /**
  2703. * Creates a quaternion from a rotation around an axis
  2704. * @param axis defines the axis to use
  2705. * @param angle defines the angle to use
  2706. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2707. */
  2708. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2709. /**
  2710. * Creates a rotation around an axis and stores it into the given quaternion
  2711. * @param axis defines the axis to use
  2712. * @param angle defines the angle to use
  2713. * @param result defines the target quaternion
  2714. * @returns the target quaternion
  2715. */
  2716. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates a new quaternion from data stored into an array
  2719. * @param array defines the data source
  2720. * @param offset defines the offset in the source array where the data starts
  2721. * @returns a new quaternion
  2722. */
  2723. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2724. /**
  2725. * Create a quaternion from Euler rotation angles
  2726. * @param x Pitch
  2727. * @param y Yaw
  2728. * @param z Roll
  2729. * @returns the new Quaternion
  2730. */
  2731. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2732. /**
  2733. * Updates a quaternion from Euler rotation angles
  2734. * @param x Pitch
  2735. * @param y Yaw
  2736. * @param z Roll
  2737. * @param result the quaternion to store the result
  2738. * @returns the updated quaternion
  2739. */
  2740. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2741. /**
  2742. * Create a quaternion from Euler rotation vector
  2743. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2744. * @returns the new Quaternion
  2745. */
  2746. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2747. /**
  2748. * Updates a quaternion from Euler rotation vector
  2749. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2750. * @param result the quaternion to store the result
  2751. * @returns the updated quaternion
  2752. */
  2753. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2754. /**
  2755. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2756. * @param yaw defines the rotation around Y axis
  2757. * @param pitch defines the rotation around X axis
  2758. * @param roll defines the rotation around Z axis
  2759. * @returns the new quaternion
  2760. */
  2761. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2762. /**
  2763. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2764. * @param yaw defines the rotation around Y axis
  2765. * @param pitch defines the rotation around X axis
  2766. * @param roll defines the rotation around Z axis
  2767. * @param result defines the target quaternion
  2768. */
  2769. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2770. /**
  2771. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2772. * @param alpha defines the rotation around first axis
  2773. * @param beta defines the rotation around second axis
  2774. * @param gamma defines the rotation around third axis
  2775. * @returns the new quaternion
  2776. */
  2777. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2778. /**
  2779. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2780. * @param alpha defines the rotation around first axis
  2781. * @param beta defines the rotation around second axis
  2782. * @param gamma defines the rotation around third axis
  2783. * @param result defines the target quaternion
  2784. */
  2785. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2786. /**
  2787. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2788. * @param axis1 defines the first axis
  2789. * @param axis2 defines the second axis
  2790. * @param axis3 defines the third axis
  2791. * @returns the new quaternion
  2792. */
  2793. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2794. /**
  2795. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2796. * @param axis1 defines the first axis
  2797. * @param axis2 defines the second axis
  2798. * @param axis3 defines the third axis
  2799. * @param ref defines the target quaternion
  2800. */
  2801. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2802. /**
  2803. * Interpolates between two quaternions
  2804. * @param left defines first quaternion
  2805. * @param right defines second quaternion
  2806. * @param amount defines the gradient to use
  2807. * @returns the new interpolated quaternion
  2808. */
  2809. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2810. /**
  2811. * Interpolates between two quaternions and stores it into a target quaternion
  2812. * @param left defines first quaternion
  2813. * @param right defines second quaternion
  2814. * @param amount defines the gradient to use
  2815. * @param result defines the target quaternion
  2816. */
  2817. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2818. /**
  2819. * Interpolate between two quaternions using Hermite interpolation
  2820. * @param value1 defines first quaternion
  2821. * @param tangent1 defines the incoming tangent
  2822. * @param value2 defines second quaternion
  2823. * @param tangent2 defines the outgoing tangent
  2824. * @param amount defines the target quaternion
  2825. * @returns the new interpolated quaternion
  2826. */
  2827. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2828. }
  2829. /**
  2830. * Class used to store matrix data (4x4)
  2831. */
  2832. export class Matrix {
  2833. private static _updateFlagSeed;
  2834. private static _identityReadOnly;
  2835. private _isIdentity;
  2836. private _isIdentityDirty;
  2837. private _isIdentity3x2;
  2838. private _isIdentity3x2Dirty;
  2839. /**
  2840. * Gets the update flag of the matrix which is an unique number for the matrix.
  2841. * It will be incremented every time the matrix data change.
  2842. * You can use it to speed the comparison between two versions of the same matrix.
  2843. */
  2844. updateFlag: number;
  2845. private readonly _m;
  2846. /**
  2847. * Gets the internal data of the matrix
  2848. */
  2849. readonly m: DeepImmutable<Float32Array>;
  2850. /** @hidden */ markAsUpdated(): void;
  2851. /** @hidden */
  2852. private _updateIdentityStatus;
  2853. /**
  2854. * Creates an empty matrix (filled with zeros)
  2855. */
  2856. constructor();
  2857. /**
  2858. * Check if the current matrix is identity
  2859. * @returns true is the matrix is the identity matrix
  2860. */
  2861. isIdentity(): boolean;
  2862. /**
  2863. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2864. * @returns true is the matrix is the identity matrix
  2865. */
  2866. isIdentityAs3x2(): boolean;
  2867. /**
  2868. * Gets the determinant of the matrix
  2869. * @returns the matrix determinant
  2870. */
  2871. determinant(): number;
  2872. /**
  2873. * Returns the matrix as a Float32Array
  2874. * @returns the matrix underlying array
  2875. */
  2876. toArray(): DeepImmutable<Float32Array>;
  2877. /**
  2878. * Returns the matrix as a Float32Array
  2879. * @returns the matrix underlying array.
  2880. */
  2881. asArray(): DeepImmutable<Float32Array>;
  2882. /**
  2883. * Inverts the current matrix in place
  2884. * @returns the current inverted matrix
  2885. */
  2886. invert(): Matrix;
  2887. /**
  2888. * Sets all the matrix elements to zero
  2889. * @returns the current matrix
  2890. */
  2891. reset(): Matrix;
  2892. /**
  2893. * Adds the current matrix with a second one
  2894. * @param other defines the matrix to add
  2895. * @returns a new matrix as the addition of the current matrix and the given one
  2896. */
  2897. add(other: DeepImmutable<Matrix>): Matrix;
  2898. /**
  2899. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2900. * @param other defines the matrix to add
  2901. * @param result defines the target matrix
  2902. * @returns the current matrix
  2903. */
  2904. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2905. /**
  2906. * Adds in place the given matrix to the current matrix
  2907. * @param other defines the second operand
  2908. * @returns the current updated matrix
  2909. */
  2910. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2911. /**
  2912. * Sets the given matrix to the current inverted Matrix
  2913. * @param other defines the target matrix
  2914. * @returns the unmodified current matrix
  2915. */
  2916. invertToRef(other: Matrix): Matrix;
  2917. /**
  2918. * add a value at the specified position in the current Matrix
  2919. * @param index the index of the value within the matrix. between 0 and 15.
  2920. * @param value the value to be added
  2921. * @returns the current updated matrix
  2922. */
  2923. addAtIndex(index: number, value: number): Matrix;
  2924. /**
  2925. * mutiply the specified position in the current Matrix by a value
  2926. * @param index the index of the value within the matrix. between 0 and 15.
  2927. * @param value the value to be added
  2928. * @returns the current updated matrix
  2929. */
  2930. multiplyAtIndex(index: number, value: number): Matrix;
  2931. /**
  2932. * Inserts the translation vector (using 3 floats) in the current matrix
  2933. * @param x defines the 1st component of the translation
  2934. * @param y defines the 2nd component of the translation
  2935. * @param z defines the 3rd component of the translation
  2936. * @returns the current updated matrix
  2937. */
  2938. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2939. /**
  2940. * Inserts the translation vector in the current matrix
  2941. * @param vector3 defines the translation to insert
  2942. * @returns the current updated matrix
  2943. */
  2944. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2945. /**
  2946. * Gets the translation value of the current matrix
  2947. * @returns a new Vector3 as the extracted translation from the matrix
  2948. */
  2949. getTranslation(): Vector3;
  2950. /**
  2951. * Fill a Vector3 with the extracted translation from the matrix
  2952. * @param result defines the Vector3 where to store the translation
  2953. * @returns the current matrix
  2954. */
  2955. getTranslationToRef(result: Vector3): Matrix;
  2956. /**
  2957. * Remove rotation and scaling part from the matrix
  2958. * @returns the updated matrix
  2959. */
  2960. removeRotationAndScaling(): Matrix;
  2961. /**
  2962. * Multiply two matrices
  2963. * @param other defines the second operand
  2964. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2965. */
  2966. multiply(other: DeepImmutable<Matrix>): Matrix;
  2967. /**
  2968. * Copy the current matrix from the given one
  2969. * @param other defines the source matrix
  2970. * @returns the current updated matrix
  2971. */
  2972. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2973. /**
  2974. * Populates the given array from the starting index with the current matrix values
  2975. * @param array defines the target array
  2976. * @param offset defines the offset in the target array where to start storing values
  2977. * @returns the current matrix
  2978. */
  2979. copyToArray(array: Float32Array, offset?: number): Matrix;
  2980. /**
  2981. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2982. * @param other defines the second operand
  2983. * @param result defines the matrix where to store the multiplication
  2984. * @returns the current matrix
  2985. */
  2986. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2987. /**
  2988. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2989. * @param other defines the second operand
  2990. * @param result defines the array where to store the multiplication
  2991. * @param offset defines the offset in the target array where to start storing values
  2992. * @returns the current matrix
  2993. */
  2994. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2995. /**
  2996. * Check equality between this matrix and a second one
  2997. * @param value defines the second matrix to compare
  2998. * @returns true is the current matrix and the given one values are strictly equal
  2999. */
  3000. equals(value: DeepImmutable<Matrix>): boolean;
  3001. /**
  3002. * Clone the current matrix
  3003. * @returns a new matrix from the current matrix
  3004. */
  3005. clone(): Matrix;
  3006. /**
  3007. * Returns the name of the current matrix class
  3008. * @returns the string "Matrix"
  3009. */
  3010. getClassName(): string;
  3011. /**
  3012. * Gets the hash code of the current matrix
  3013. * @returns the hash code
  3014. */
  3015. getHashCode(): number;
  3016. /**
  3017. * Decomposes the current Matrix into a translation, rotation and scaling components
  3018. * @param scale defines the scale vector3 given as a reference to update
  3019. * @param rotation defines the rotation quaternion given as a reference to update
  3020. * @param translation defines the translation vector3 given as a reference to update
  3021. * @returns true if operation was successful
  3022. */
  3023. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3024. /**
  3025. * Gets specific row of the matrix
  3026. * @param index defines the number of the row to get
  3027. * @returns the index-th row of the current matrix as a new Vector4
  3028. */
  3029. getRow(index: number): Nullable<Vector4>;
  3030. /**
  3031. * Sets the index-th row of the current matrix to the vector4 values
  3032. * @param index defines the number of the row to set
  3033. * @param row defines the target vector4
  3034. * @returns the updated current matrix
  3035. */
  3036. setRow(index: number, row: Vector4): Matrix;
  3037. /**
  3038. * Compute the transpose of the matrix
  3039. * @returns the new transposed matrix
  3040. */
  3041. transpose(): Matrix;
  3042. /**
  3043. * Compute the transpose of the matrix and store it in a given matrix
  3044. * @param result defines the target matrix
  3045. * @returns the current matrix
  3046. */
  3047. transposeToRef(result: Matrix): Matrix;
  3048. /**
  3049. * Sets the index-th row of the current matrix with the given 4 x float values
  3050. * @param index defines the row index
  3051. * @param x defines the x component to set
  3052. * @param y defines the y component to set
  3053. * @param z defines the z component to set
  3054. * @param w defines the w component to set
  3055. * @returns the updated current matrix
  3056. */
  3057. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3058. /**
  3059. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3060. * @param scale defines the scale factor
  3061. * @returns a new matrix
  3062. */
  3063. scale(scale: number): Matrix;
  3064. /**
  3065. * Scale the current matrix values by a factor to a given result matrix
  3066. * @param scale defines the scale factor
  3067. * @param result defines the matrix to store the result
  3068. * @returns the current matrix
  3069. */
  3070. scaleToRef(scale: number, result: Matrix): Matrix;
  3071. /**
  3072. * Scale the current matrix values by a factor and add the result to a given matrix
  3073. * @param scale defines the scale factor
  3074. * @param result defines the Matrix to store the result
  3075. * @returns the current matrix
  3076. */
  3077. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3078. /**
  3079. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3080. * @param ref matrix to store the result
  3081. */
  3082. toNormalMatrix(ref: Matrix): void;
  3083. /**
  3084. * Gets only rotation part of the current matrix
  3085. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3086. */
  3087. getRotationMatrix(): Matrix;
  3088. /**
  3089. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3090. * @param result defines the target matrix to store data to
  3091. * @returns the current matrix
  3092. */
  3093. getRotationMatrixToRef(result: Matrix): Matrix;
  3094. /**
  3095. * Toggles model matrix from being right handed to left handed in place and vice versa
  3096. */
  3097. toggleModelMatrixHandInPlace(): void;
  3098. /**
  3099. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3100. */
  3101. toggleProjectionMatrixHandInPlace(): void;
  3102. /**
  3103. * Creates a matrix from an array
  3104. * @param array defines the source array
  3105. * @param offset defines an offset in the source array
  3106. * @returns a new Matrix set from the starting index of the given array
  3107. */
  3108. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3109. /**
  3110. * Copy the content of an array into a given matrix
  3111. * @param array defines the source array
  3112. * @param offset defines an offset in the source array
  3113. * @param result defines the target matrix
  3114. */
  3115. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3116. /**
  3117. * Stores an array into a matrix after having multiplied each component by a given factor
  3118. * @param array defines the source array
  3119. * @param offset defines the offset in the source array
  3120. * @param scale defines the scaling factor
  3121. * @param result defines the target matrix
  3122. */
  3123. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3124. /**
  3125. * Gets an identity matrix that must not be updated
  3126. */
  3127. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3128. /**
  3129. * Stores a list of values (16) inside a given matrix
  3130. * @param initialM11 defines 1st value of 1st row
  3131. * @param initialM12 defines 2nd value of 1st row
  3132. * @param initialM13 defines 3rd value of 1st row
  3133. * @param initialM14 defines 4th value of 1st row
  3134. * @param initialM21 defines 1st value of 2nd row
  3135. * @param initialM22 defines 2nd value of 2nd row
  3136. * @param initialM23 defines 3rd value of 2nd row
  3137. * @param initialM24 defines 4th value of 2nd row
  3138. * @param initialM31 defines 1st value of 3rd row
  3139. * @param initialM32 defines 2nd value of 3rd row
  3140. * @param initialM33 defines 3rd value of 3rd row
  3141. * @param initialM34 defines 4th value of 3rd row
  3142. * @param initialM41 defines 1st value of 4th row
  3143. * @param initialM42 defines 2nd value of 4th row
  3144. * @param initialM43 defines 3rd value of 4th row
  3145. * @param initialM44 defines 4th value of 4th row
  3146. * @param result defines the target matrix
  3147. */
  3148. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3149. /**
  3150. * Creates new matrix from a list of values (16)
  3151. * @param initialM11 defines 1st value of 1st row
  3152. * @param initialM12 defines 2nd value of 1st row
  3153. * @param initialM13 defines 3rd value of 1st row
  3154. * @param initialM14 defines 4th value of 1st row
  3155. * @param initialM21 defines 1st value of 2nd row
  3156. * @param initialM22 defines 2nd value of 2nd row
  3157. * @param initialM23 defines 3rd value of 2nd row
  3158. * @param initialM24 defines 4th value of 2nd row
  3159. * @param initialM31 defines 1st value of 3rd row
  3160. * @param initialM32 defines 2nd value of 3rd row
  3161. * @param initialM33 defines 3rd value of 3rd row
  3162. * @param initialM34 defines 4th value of 3rd row
  3163. * @param initialM41 defines 1st value of 4th row
  3164. * @param initialM42 defines 2nd value of 4th row
  3165. * @param initialM43 defines 3rd value of 4th row
  3166. * @param initialM44 defines 4th value of 4th row
  3167. * @returns the new matrix
  3168. */
  3169. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3170. /**
  3171. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3172. * @param scale defines the scale vector3
  3173. * @param rotation defines the rotation quaternion
  3174. * @param translation defines the translation vector3
  3175. * @returns a new matrix
  3176. */
  3177. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3178. /**
  3179. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3180. * @param scale defines the scale vector3
  3181. * @param rotation defines the rotation quaternion
  3182. * @param translation defines the translation vector3
  3183. * @param result defines the target matrix
  3184. */
  3185. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3186. /**
  3187. * Creates a new identity matrix
  3188. * @returns a new identity matrix
  3189. */
  3190. static Identity(): Matrix;
  3191. /**
  3192. * Creates a new identity matrix and stores the result in a given matrix
  3193. * @param result defines the target matrix
  3194. */
  3195. static IdentityToRef(result: Matrix): void;
  3196. /**
  3197. * Creates a new zero matrix
  3198. * @returns a new zero matrix
  3199. */
  3200. static Zero(): Matrix;
  3201. /**
  3202. * Creates a new rotation matrix for "angle" radians around the X axis
  3203. * @param angle defines the angle (in radians) to use
  3204. * @return the new matrix
  3205. */
  3206. static RotationX(angle: number): Matrix;
  3207. /**
  3208. * Creates a new matrix as the invert of a given matrix
  3209. * @param source defines the source matrix
  3210. * @returns the new matrix
  3211. */
  3212. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3215. * @param angle defines the angle (in radians) to use
  3216. * @param result defines the target matrix
  3217. */
  3218. static RotationXToRef(angle: number, result: Matrix): void;
  3219. /**
  3220. * Creates a new rotation matrix for "angle" radians around the Y axis
  3221. * @param angle defines the angle (in radians) to use
  3222. * @return the new matrix
  3223. */
  3224. static RotationY(angle: number): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationYToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Z axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationZ(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationZToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the given axis
  3245. * @param axis defines the axis to use
  3246. * @param angle defines the angle (in radians) to use
  3247. * @return the new matrix
  3248. */
  3249. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3252. * @param axis defines the axis to use
  3253. * @param angle defines the angle (in radians) to use
  3254. * @param result defines the target matrix
  3255. */
  3256. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3257. /**
  3258. * Creates a rotation matrix
  3259. * @param yaw defines the yaw angle in radians (Y axis)
  3260. * @param pitch defines the pitch angle in radians (X axis)
  3261. * @param roll defines the roll angle in radians (X axis)
  3262. * @returns the new rotation matrix
  3263. */
  3264. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3265. /**
  3266. * Creates a rotation matrix and stores it in a given matrix
  3267. * @param yaw defines the yaw angle in radians (Y axis)
  3268. * @param pitch defines the pitch angle in radians (X axis)
  3269. * @param roll defines the roll angle in radians (X axis)
  3270. * @param result defines the target matrix
  3271. */
  3272. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3273. /**
  3274. * Creates a scaling matrix
  3275. * @param x defines the scale factor on X axis
  3276. * @param y defines the scale factor on Y axis
  3277. * @param z defines the scale factor on Z axis
  3278. * @returns the new matrix
  3279. */
  3280. static Scaling(x: number, y: number, z: number): Matrix;
  3281. /**
  3282. * Creates a scaling matrix and stores it in a given matrix
  3283. * @param x defines the scale factor on X axis
  3284. * @param y defines the scale factor on Y axis
  3285. * @param z defines the scale factor on Z axis
  3286. * @param result defines the target matrix
  3287. */
  3288. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3289. /**
  3290. * Creates a translation matrix
  3291. * @param x defines the translation on X axis
  3292. * @param y defines the translation on Y axis
  3293. * @param z defines the translationon Z axis
  3294. * @returns the new matrix
  3295. */
  3296. static Translation(x: number, y: number, z: number): Matrix;
  3297. /**
  3298. * Creates a translation matrix and stores it in a given matrix
  3299. * @param x defines the translation on X axis
  3300. * @param y defines the translation on Y axis
  3301. * @param z defines the translationon Z axis
  3302. * @param result defines the target matrix
  3303. */
  3304. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3305. /**
  3306. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3307. * @param startValue defines the start value
  3308. * @param endValue defines the end value
  3309. * @param gradient defines the gradient factor
  3310. * @returns the new matrix
  3311. */
  3312. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3313. /**
  3314. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3315. * @param startValue defines the start value
  3316. * @param endValue defines the end value
  3317. * @param gradient defines the gradient factor
  3318. * @param result defines the Matrix object where to store data
  3319. */
  3320. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3321. /**
  3322. * Builds a new matrix whose values are computed by:
  3323. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3324. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3325. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3326. * @param startValue defines the first matrix
  3327. * @param endValue defines the second matrix
  3328. * @param gradient defines the gradient between the two matrices
  3329. * @returns the new matrix
  3330. */
  3331. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3332. /**
  3333. * Update a matrix to values which are computed by:
  3334. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3335. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3336. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3337. * @param startValue defines the first matrix
  3338. * @param endValue defines the second matrix
  3339. * @param gradient defines the gradient between the two matrices
  3340. * @param result defines the target matrix
  3341. */
  3342. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3343. /**
  3344. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3345. * This function works in left handed mode
  3346. * @param eye defines the final position of the entity
  3347. * @param target defines where the entity should look at
  3348. * @param up defines the up vector for the entity
  3349. * @returns the new matrix
  3350. */
  3351. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3352. /**
  3353. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3354. * This function works in left handed mode
  3355. * @param eye defines the final position of the entity
  3356. * @param target defines where the entity should look at
  3357. * @param up defines the up vector for the entity
  3358. * @param result defines the target matrix
  3359. */
  3360. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3361. /**
  3362. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3363. * This function works in right handed mode
  3364. * @param eye defines the final position of the entity
  3365. * @param target defines where the entity should look at
  3366. * @param up defines the up vector for the entity
  3367. * @returns the new matrix
  3368. */
  3369. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3370. /**
  3371. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3372. * This function works in right handed mode
  3373. * @param eye defines the final position of the entity
  3374. * @param target defines where the entity should look at
  3375. * @param up defines the up vector for the entity
  3376. * @param result defines the target matrix
  3377. */
  3378. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3379. /**
  3380. * Create a left-handed orthographic projection matrix
  3381. * @param width defines the viewport width
  3382. * @param height defines the viewport height
  3383. * @param znear defines the near clip plane
  3384. * @param zfar defines the far clip plane
  3385. * @returns a new matrix as a left-handed orthographic projection matrix
  3386. */
  3387. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3388. /**
  3389. * Store a left-handed orthographic projection to a given matrix
  3390. * @param width defines the viewport width
  3391. * @param height defines the viewport height
  3392. * @param znear defines the near clip plane
  3393. * @param zfar defines the far clip plane
  3394. * @param result defines the target matrix
  3395. */
  3396. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3397. /**
  3398. * Create a left-handed orthographic projection matrix
  3399. * @param left defines the viewport left coordinate
  3400. * @param right defines the viewport right coordinate
  3401. * @param bottom defines the viewport bottom coordinate
  3402. * @param top defines the viewport top coordinate
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Stores a left-handed orthographic projection into a given matrix
  3410. * @param left defines the viewport left coordinate
  3411. * @param right defines the viewport right coordinate
  3412. * @param bottom defines the viewport bottom coordinate
  3413. * @param top defines the viewport top coordinate
  3414. * @param znear defines the near clip plane
  3415. * @param zfar defines the far clip plane
  3416. * @param result defines the target matrix
  3417. */
  3418. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3419. /**
  3420. * Creates a right-handed orthographic projection matrix
  3421. * @param left defines the viewport left coordinate
  3422. * @param right defines the viewport right coordinate
  3423. * @param bottom defines the viewport bottom coordinate
  3424. * @param top defines the viewport top coordinate
  3425. * @param znear defines the near clip plane
  3426. * @param zfar defines the far clip plane
  3427. * @returns a new matrix as a right-handed orthographic projection matrix
  3428. */
  3429. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3430. /**
  3431. * Stores a right-handed orthographic projection into a given matrix
  3432. * @param left defines the viewport left coordinate
  3433. * @param right defines the viewport right coordinate
  3434. * @param bottom defines the viewport bottom coordinate
  3435. * @param top defines the viewport top coordinate
  3436. * @param znear defines the near clip plane
  3437. * @param zfar defines the far clip plane
  3438. * @param result defines the target matrix
  3439. */
  3440. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3441. /**
  3442. * Creates a left-handed perspective projection matrix
  3443. * @param width defines the viewport width
  3444. * @param height defines the viewport height
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a left-handed perspective projection matrix
  3448. */
  3449. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Creates a left-handed perspective projection matrix
  3452. * @param fov defines the horizontal field of view
  3453. * @param aspect defines the aspect ratio
  3454. * @param znear defines the near clip plane
  3455. * @param zfar defines the far clip plane
  3456. * @returns a new matrix as a left-handed perspective projection matrix
  3457. */
  3458. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3459. /**
  3460. * Stores a left-handed perspective projection into a given matrix
  3461. * @param fov defines the horizontal field of view
  3462. * @param aspect defines the aspect ratio
  3463. * @param znear defines the near clip plane
  3464. * @param zfar defines the far clip plane
  3465. * @param result defines the target matrix
  3466. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3467. */
  3468. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3469. /**
  3470. * Creates a right-handed perspective projection matrix
  3471. * @param fov defines the horizontal field of view
  3472. * @param aspect defines the aspect ratio
  3473. * @param znear defines the near clip plane
  3474. * @param zfar defines the far clip plane
  3475. * @returns a new matrix as a right-handed perspective projection matrix
  3476. */
  3477. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3478. /**
  3479. * Stores a right-handed perspective projection into a given matrix
  3480. * @param fov defines the horizontal field of view
  3481. * @param aspect defines the aspect ratio
  3482. * @param znear defines the near clip plane
  3483. * @param zfar defines the far clip plane
  3484. * @param result defines the target matrix
  3485. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3486. */
  3487. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3488. /**
  3489. * Stores a perspective projection for WebVR info a given matrix
  3490. * @param fov defines the field of view
  3491. * @param znear defines the near clip plane
  3492. * @param zfar defines the far clip plane
  3493. * @param result defines the target matrix
  3494. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3495. */
  3496. static PerspectiveFovWebVRToRef(fov: {
  3497. upDegrees: number;
  3498. downDegrees: number;
  3499. leftDegrees: number;
  3500. rightDegrees: number;
  3501. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3502. /**
  3503. * Computes a complete transformation matrix
  3504. * @param viewport defines the viewport to use
  3505. * @param world defines the world matrix
  3506. * @param view defines the view matrix
  3507. * @param projection defines the projection matrix
  3508. * @param zmin defines the near clip plane
  3509. * @param zmax defines the far clip plane
  3510. * @returns the transformation matrix
  3511. */
  3512. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3513. /**
  3514. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3515. * @param matrix defines the matrix to use
  3516. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3517. */
  3518. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3519. /**
  3520. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3521. * @param matrix defines the matrix to use
  3522. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3523. */
  3524. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3525. /**
  3526. * Compute the transpose of a given matrix
  3527. * @param matrix defines the matrix to transpose
  3528. * @returns the new matrix
  3529. */
  3530. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3531. /**
  3532. * Compute the transpose of a matrix and store it in a target matrix
  3533. * @param matrix defines the matrix to transpose
  3534. * @param result defines the target matrix
  3535. */
  3536. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3537. /**
  3538. * Computes a reflection matrix from a plane
  3539. * @param plane defines the reflection plane
  3540. * @returns a new matrix
  3541. */
  3542. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3543. /**
  3544. * Computes a reflection matrix from a plane
  3545. * @param plane defines the reflection plane
  3546. * @param result defines the target matrix
  3547. */
  3548. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3549. /**
  3550. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3551. * @param xaxis defines the value of the 1st axis
  3552. * @param yaxis defines the value of the 2nd axis
  3553. * @param zaxis defines the value of the 3rd axis
  3554. * @param result defines the target matrix
  3555. */
  3556. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3557. /**
  3558. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3559. * @param quat defines the quaternion to use
  3560. * @param result defines the target matrix
  3561. */
  3562. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3563. }
  3564. /**
  3565. * Represens a plane by the equation ax + by + cz + d = 0
  3566. */
  3567. export class Plane {
  3568. /**
  3569. * Normal of the plane (a,b,c)
  3570. */
  3571. normal: Vector3;
  3572. /**
  3573. * d component of the plane
  3574. */
  3575. d: number;
  3576. /**
  3577. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3578. * @param a a component of the plane
  3579. * @param b b component of the plane
  3580. * @param c c component of the plane
  3581. * @param d d component of the plane
  3582. */
  3583. constructor(a: number, b: number, c: number, d: number);
  3584. /**
  3585. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3586. */
  3587. asArray(): number[];
  3588. /**
  3589. * @returns a new plane copied from the current Plane.
  3590. */
  3591. clone(): Plane;
  3592. /**
  3593. * @returns the string "Plane".
  3594. */
  3595. getClassName(): string;
  3596. /**
  3597. * @returns the Plane hash code.
  3598. */
  3599. getHashCode(): number;
  3600. /**
  3601. * Normalize the current Plane in place.
  3602. * @returns the updated Plane.
  3603. */
  3604. normalize(): Plane;
  3605. /**
  3606. * Applies a transformation the plane and returns the result
  3607. * @param transformation the transformation matrix to be applied to the plane
  3608. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3609. */
  3610. transform(transformation: DeepImmutable<Matrix>): Plane;
  3611. /**
  3612. * Calcualtte the dot product between the point and the plane normal
  3613. * @param point point to calculate the dot product with
  3614. * @returns the dot product (float) of the point coordinates and the plane normal.
  3615. */
  3616. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3617. /**
  3618. * Updates the current Plane from the plane defined by the three given points.
  3619. * @param point1 one of the points used to contruct the plane
  3620. * @param point2 one of the points used to contruct the plane
  3621. * @param point3 one of the points used to contruct the plane
  3622. * @returns the updated Plane.
  3623. */
  3624. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3625. /**
  3626. * Checks if the plane is facing a given direction
  3627. * @param direction the direction to check if the plane is facing
  3628. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3629. * @returns True is the vector "direction" is the same side than the plane normal.
  3630. */
  3631. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3632. /**
  3633. * Calculates the distance to a point
  3634. * @param point point to calculate distance to
  3635. * @returns the signed distance (float) from the given point to the Plane.
  3636. */
  3637. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3638. /**
  3639. * Creates a plane from an array
  3640. * @param array the array to create a plane from
  3641. * @returns a new Plane from the given array.
  3642. */
  3643. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3644. /**
  3645. * Creates a plane from three points
  3646. * @param point1 point used to create the plane
  3647. * @param point2 point used to create the plane
  3648. * @param point3 point used to create the plane
  3649. * @returns a new Plane defined by the three given points.
  3650. */
  3651. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3652. /**
  3653. * Creates a plane from an origin point and a normal
  3654. * @param origin origin of the plane to be constructed
  3655. * @param normal normal of the plane to be constructed
  3656. * @returns a new Plane the normal vector to this plane at the given origin point.
  3657. * Note : the vector "normal" is updated because normalized.
  3658. */
  3659. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3660. /**
  3661. * Calculates the distance from a plane and a point
  3662. * @param origin origin of the plane to be constructed
  3663. * @param normal normal of the plane to be constructed
  3664. * @param point point to calculate distance to
  3665. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3666. */
  3667. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3668. }
  3669. /**
  3670. * Class used to represent a viewport on screen
  3671. */
  3672. export class Viewport {
  3673. /** viewport left coordinate */
  3674. x: number;
  3675. /** viewport top coordinate */
  3676. y: number;
  3677. /**viewport width */
  3678. width: number;
  3679. /** viewport height */
  3680. height: number;
  3681. /**
  3682. * Creates a Viewport object located at (x, y) and sized (width, height)
  3683. * @param x defines viewport left coordinate
  3684. * @param y defines viewport top coordinate
  3685. * @param width defines the viewport width
  3686. * @param height defines the viewport height
  3687. */
  3688. constructor(
  3689. /** viewport left coordinate */
  3690. x: number,
  3691. /** viewport top coordinate */
  3692. y: number,
  3693. /**viewport width */
  3694. width: number,
  3695. /** viewport height */
  3696. height: number);
  3697. /**
  3698. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3699. * @param renderWidth defines the rendering width
  3700. * @param renderHeight defines the rendering height
  3701. * @returns a new Viewport
  3702. */
  3703. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3704. /**
  3705. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3706. * @param renderWidth defines the rendering width
  3707. * @param renderHeight defines the rendering height
  3708. * @param ref defines the target viewport
  3709. * @returns the current viewport
  3710. */
  3711. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3712. /**
  3713. * Returns a new Viewport copied from the current one
  3714. * @returns a new Viewport
  3715. */
  3716. clone(): Viewport;
  3717. }
  3718. /**
  3719. * Reprasents a camera frustum
  3720. */
  3721. export class Frustum {
  3722. /**
  3723. * Gets the planes representing the frustum
  3724. * @param transform matrix to be applied to the returned planes
  3725. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3726. */
  3727. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3728. /**
  3729. * Gets the near frustum plane transformed by the transform matrix
  3730. * @param transform transformation matrix to be applied to the resulting frustum plane
  3731. * @param frustumPlane the resuling frustum plane
  3732. */
  3733. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3734. /**
  3735. * Gets the far frustum plane transformed by the transform matrix
  3736. * @param transform transformation matrix to be applied to the resulting frustum plane
  3737. * @param frustumPlane the resuling frustum plane
  3738. */
  3739. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3740. /**
  3741. * Gets the left frustum plane transformed by the transform matrix
  3742. * @param transform transformation matrix to be applied to the resulting frustum plane
  3743. * @param frustumPlane the resuling frustum plane
  3744. */
  3745. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3746. /**
  3747. * Gets the right frustum plane transformed by the transform matrix
  3748. * @param transform transformation matrix to be applied to the resulting frustum plane
  3749. * @param frustumPlane the resuling frustum plane
  3750. */
  3751. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3752. /**
  3753. * Gets the top frustum plane transformed by the transform matrix
  3754. * @param transform transformation matrix to be applied to the resulting frustum plane
  3755. * @param frustumPlane the resuling frustum plane
  3756. */
  3757. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3758. /**
  3759. * Gets the bottom frustum plane transformed by the transform matrix
  3760. * @param transform transformation matrix to be applied to the resulting frustum plane
  3761. * @param frustumPlane the resuling frustum plane
  3762. */
  3763. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3764. /**
  3765. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3766. * @param transform transformation matrix to be applied to the resulting frustum planes
  3767. * @param frustumPlanes the resuling frustum planes
  3768. */
  3769. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3770. }
  3771. /** Defines supported spaces */
  3772. export enum Space {
  3773. /** Local (object) space */
  3774. LOCAL = 0,
  3775. /** World space */
  3776. WORLD = 1,
  3777. /** Bone space */
  3778. BONE = 2
  3779. }
  3780. /** Defines the 3 main axes */
  3781. export class Axis {
  3782. /** X axis */
  3783. static X: Vector3;
  3784. /** Y axis */
  3785. static Y: Vector3;
  3786. /** Z axis */
  3787. static Z: Vector3;
  3788. }
  3789. /** Class used to represent a Bezier curve */
  3790. export class BezierCurve {
  3791. /**
  3792. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3793. * @param t defines the time
  3794. * @param x1 defines the left coordinate on X axis
  3795. * @param y1 defines the left coordinate on Y axis
  3796. * @param x2 defines the right coordinate on X axis
  3797. * @param y2 defines the right coordinate on Y axis
  3798. * @returns the interpolated value
  3799. */
  3800. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3801. }
  3802. /**
  3803. * Defines potential orientation for back face culling
  3804. */
  3805. export enum Orientation {
  3806. /**
  3807. * Clockwise
  3808. */
  3809. CW = 0,
  3810. /** Counter clockwise */
  3811. CCW = 1
  3812. }
  3813. /**
  3814. * Defines angle representation
  3815. */
  3816. export class Angle {
  3817. private _radians;
  3818. /**
  3819. * Creates an Angle object of "radians" radians (float).
  3820. * @param radians the angle in radians
  3821. */
  3822. constructor(radians: number);
  3823. /**
  3824. * Get value in degrees
  3825. * @returns the Angle value in degrees (float)
  3826. */
  3827. degrees(): number;
  3828. /**
  3829. * Get value in radians
  3830. * @returns the Angle value in radians (float)
  3831. */
  3832. radians(): number;
  3833. /**
  3834. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3835. * @param a defines first vector
  3836. * @param b defines second vector
  3837. * @returns a new Angle
  3838. */
  3839. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3840. /**
  3841. * Gets a new Angle object from the given float in radians
  3842. * @param radians defines the angle value in radians
  3843. * @returns a new Angle
  3844. */
  3845. static FromRadians(radians: number): Angle;
  3846. /**
  3847. * Gets a new Angle object from the given float in degrees
  3848. * @param degrees defines the angle value in degrees
  3849. * @returns a new Angle
  3850. */
  3851. static FromDegrees(degrees: number): Angle;
  3852. }
  3853. /**
  3854. * This represents an arc in a 2d space.
  3855. */
  3856. export class Arc2 {
  3857. /** Defines the start point of the arc */
  3858. startPoint: Vector2;
  3859. /** Defines the mid point of the arc */
  3860. midPoint: Vector2;
  3861. /** Defines the end point of the arc */
  3862. endPoint: Vector2;
  3863. /**
  3864. * Defines the center point of the arc.
  3865. */
  3866. centerPoint: Vector2;
  3867. /**
  3868. * Defines the radius of the arc.
  3869. */
  3870. radius: number;
  3871. /**
  3872. * Defines the angle of the arc (from mid point to end point).
  3873. */
  3874. angle: Angle;
  3875. /**
  3876. * Defines the start angle of the arc (from start point to middle point).
  3877. */
  3878. startAngle: Angle;
  3879. /**
  3880. * Defines the orientation of the arc (clock wise/counter clock wise).
  3881. */
  3882. orientation: Orientation;
  3883. /**
  3884. * Creates an Arc object from the three given points : start, middle and end.
  3885. * @param startPoint Defines the start point of the arc
  3886. * @param midPoint Defines the midlle point of the arc
  3887. * @param endPoint Defines the end point of the arc
  3888. */
  3889. constructor(
  3890. /** Defines the start point of the arc */
  3891. startPoint: Vector2,
  3892. /** Defines the mid point of the arc */
  3893. midPoint: Vector2,
  3894. /** Defines the end point of the arc */
  3895. endPoint: Vector2);
  3896. }
  3897. /**
  3898. * Represents a 2D path made up of multiple 2D points
  3899. */
  3900. export class Path2 {
  3901. private _points;
  3902. private _length;
  3903. /**
  3904. * If the path start and end point are the same
  3905. */
  3906. closed: boolean;
  3907. /**
  3908. * Creates a Path2 object from the starting 2D coordinates x and y.
  3909. * @param x the starting points x value
  3910. * @param y the starting points y value
  3911. */
  3912. constructor(x: number, y: number);
  3913. /**
  3914. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3915. * @param x the added points x value
  3916. * @param y the added points y value
  3917. * @returns the updated Path2.
  3918. */
  3919. addLineTo(x: number, y: number): Path2;
  3920. /**
  3921. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3922. * @param midX middle point x value
  3923. * @param midY middle point y value
  3924. * @param endX end point x value
  3925. * @param endY end point y value
  3926. * @param numberOfSegments (default: 36)
  3927. * @returns the updated Path2.
  3928. */
  3929. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3930. /**
  3931. * Closes the Path2.
  3932. * @returns the Path2.
  3933. */
  3934. close(): Path2;
  3935. /**
  3936. * Gets the sum of the distance between each sequential point in the path
  3937. * @returns the Path2 total length (float).
  3938. */
  3939. length(): number;
  3940. /**
  3941. * Gets the points which construct the path
  3942. * @returns the Path2 internal array of points.
  3943. */
  3944. getPoints(): Vector2[];
  3945. /**
  3946. * Retreives the point at the distance aways from the starting point
  3947. * @param normalizedLengthPosition the length along the path to retreive the point from
  3948. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3949. */
  3950. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3951. /**
  3952. * Creates a new path starting from an x and y position
  3953. * @param x starting x value
  3954. * @param y starting y value
  3955. * @returns a new Path2 starting at the coordinates (x, y).
  3956. */
  3957. static StartingAt(x: number, y: number): Path2;
  3958. }
  3959. /**
  3960. * Represents a 3D path made up of multiple 3D points
  3961. */
  3962. export class Path3D {
  3963. /**
  3964. * an array of Vector3, the curve axis of the Path3D
  3965. */
  3966. path: Vector3[];
  3967. private _curve;
  3968. private _distances;
  3969. private _tangents;
  3970. private _normals;
  3971. private _binormals;
  3972. private _raw;
  3973. /**
  3974. * new Path3D(path, normal, raw)
  3975. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3976. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3977. * @param path an array of Vector3, the curve axis of the Path3D
  3978. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3979. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  3980. */
  3981. constructor(
  3982. /**
  3983. * an array of Vector3, the curve axis of the Path3D
  3984. */
  3985. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  3986. /**
  3987. * Returns the Path3D array of successive Vector3 designing its curve.
  3988. * @returns the Path3D array of successive Vector3 designing its curve.
  3989. */
  3990. getCurve(): Vector3[];
  3991. /**
  3992. * Returns an array populated with tangent vectors on each Path3D curve point.
  3993. * @returns an array populated with tangent vectors on each Path3D curve point.
  3994. */
  3995. getTangents(): Vector3[];
  3996. /**
  3997. * Returns an array populated with normal vectors on each Path3D curve point.
  3998. * @returns an array populated with normal vectors on each Path3D curve point.
  3999. */
  4000. getNormals(): Vector3[];
  4001. /**
  4002. * Returns an array populated with binormal vectors on each Path3D curve point.
  4003. * @returns an array populated with binormal vectors on each Path3D curve point.
  4004. */
  4005. getBinormals(): Vector3[];
  4006. /**
  4007. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4008. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4009. */
  4010. getDistances(): number[];
  4011. /**
  4012. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4013. * @param path path which all values are copied into the curves points
  4014. * @param firstNormal which should be projected onto the curve
  4015. * @returns the same object updated.
  4016. */
  4017. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4018. private _compute;
  4019. private _getFirstNonNullVector;
  4020. private _getLastNonNullVector;
  4021. private _normalVector;
  4022. }
  4023. /**
  4024. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4025. * A Curve3 is designed from a series of successive Vector3.
  4026. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4027. */
  4028. export class Curve3 {
  4029. private _points;
  4030. private _length;
  4031. /**
  4032. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4033. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4034. * @param v1 (Vector3) the control point
  4035. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4036. * @param nbPoints (integer) the wanted number of points in the curve
  4037. * @returns the created Curve3
  4038. */
  4039. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4040. /**
  4041. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4042. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4043. * @param v1 (Vector3) the first control point
  4044. * @param v2 (Vector3) the second control point
  4045. * @param v3 (Vector3) the end point of the Cubic Bezier
  4046. * @param nbPoints (integer) the wanted number of points in the curve
  4047. * @returns the created Curve3
  4048. */
  4049. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4050. /**
  4051. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4052. * @param p1 (Vector3) the origin point of the Hermite Spline
  4053. * @param t1 (Vector3) the tangent vector at the origin point
  4054. * @param p2 (Vector3) the end point of the Hermite Spline
  4055. * @param t2 (Vector3) the tangent vector at the end point
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a CatmullRom Spline curve :
  4062. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4063. * @param nbPoints (integer) the wanted number of points between each curve control points
  4064. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4065. * @returns the created Curve3
  4066. */
  4067. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4068. /**
  4069. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4070. * A Curve3 is designed from a series of successive Vector3.
  4071. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4072. * @param points points which make up the curve
  4073. */
  4074. constructor(points: Vector3[]);
  4075. /**
  4076. * @returns the Curve3 stored array of successive Vector3
  4077. */
  4078. getPoints(): Vector3[];
  4079. /**
  4080. * @returns the computed length (float) of the curve.
  4081. */
  4082. length(): number;
  4083. /**
  4084. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4085. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4086. * curveA and curveB keep unchanged.
  4087. * @param curve the curve to continue from this curve
  4088. * @returns the newly constructed curve
  4089. */
  4090. continue(curve: DeepImmutable<Curve3>): Curve3;
  4091. private _computeLength;
  4092. }
  4093. /**
  4094. * Contains position and normal vectors for a vertex
  4095. */
  4096. export class PositionNormalVertex {
  4097. /** the position of the vertex (defaut: 0,0,0) */
  4098. position: Vector3;
  4099. /** the normal of the vertex (defaut: 0,1,0) */
  4100. normal: Vector3;
  4101. /**
  4102. * Creates a PositionNormalVertex
  4103. * @param position the position of the vertex (defaut: 0,0,0)
  4104. * @param normal the normal of the vertex (defaut: 0,1,0)
  4105. */
  4106. constructor(
  4107. /** the position of the vertex (defaut: 0,0,0) */
  4108. position?: Vector3,
  4109. /** the normal of the vertex (defaut: 0,1,0) */
  4110. normal?: Vector3);
  4111. /**
  4112. * Clones the PositionNormalVertex
  4113. * @returns the cloned PositionNormalVertex
  4114. */
  4115. clone(): PositionNormalVertex;
  4116. }
  4117. /**
  4118. * Contains position, normal and uv vectors for a vertex
  4119. */
  4120. export class PositionNormalTextureVertex {
  4121. /** the position of the vertex (defaut: 0,0,0) */
  4122. position: Vector3;
  4123. /** the normal of the vertex (defaut: 0,1,0) */
  4124. normal: Vector3;
  4125. /** the uv of the vertex (default: 0,0) */
  4126. uv: Vector2;
  4127. /**
  4128. * Creates a PositionNormalTextureVertex
  4129. * @param position the position of the vertex (defaut: 0,0,0)
  4130. * @param normal the normal of the vertex (defaut: 0,1,0)
  4131. * @param uv the uv of the vertex (default: 0,0)
  4132. */
  4133. constructor(
  4134. /** the position of the vertex (defaut: 0,0,0) */
  4135. position?: Vector3,
  4136. /** the normal of the vertex (defaut: 0,1,0) */
  4137. normal?: Vector3,
  4138. /** the uv of the vertex (default: 0,0) */
  4139. uv?: Vector2);
  4140. /**
  4141. * Clones the PositionNormalTextureVertex
  4142. * @returns the cloned PositionNormalTextureVertex
  4143. */
  4144. clone(): PositionNormalTextureVertex;
  4145. }
  4146. /**
  4147. * @hidden
  4148. */
  4149. export class Tmp {
  4150. static Color3: Color3[];
  4151. static Color4: Color4[];
  4152. static Vector2: Vector2[];
  4153. static Vector3: Vector3[];
  4154. static Vector4: Vector4[];
  4155. static Quaternion: Quaternion[];
  4156. static Matrix: Matrix[];
  4157. }
  4158. }
  4159. declare module BABYLON {
  4160. /**
  4161. * Class used to enable access to offline support
  4162. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4163. */
  4164. export interface IOfflineProvider {
  4165. /**
  4166. * Gets a boolean indicating if scene must be saved in the database
  4167. */
  4168. enableSceneOffline: boolean;
  4169. /**
  4170. * Gets a boolean indicating if textures must be saved in the database
  4171. */
  4172. enableTexturesOffline: boolean;
  4173. /**
  4174. * Open the offline support and make it available
  4175. * @param successCallback defines the callback to call on success
  4176. * @param errorCallback defines the callback to call on error
  4177. */
  4178. open(successCallback: () => void, errorCallback: () => void): void;
  4179. /**
  4180. * Loads an image from the offline support
  4181. * @param url defines the url to load from
  4182. * @param image defines the target DOM image
  4183. */
  4184. loadImage(url: string, image: HTMLImageElement): void;
  4185. /**
  4186. * Loads a file from offline support
  4187. * @param url defines the URL to load from
  4188. * @param sceneLoaded defines a callback to call on success
  4189. * @param progressCallBack defines a callback to call when progress changed
  4190. * @param errorCallback defines a callback to call on error
  4191. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4192. */
  4193. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4194. }
  4195. }
  4196. declare module BABYLON {
  4197. /**
  4198. * A class serves as a medium between the observable and its observers
  4199. */
  4200. export class EventState {
  4201. /**
  4202. * Create a new EventState
  4203. * @param mask defines the mask associated with this state
  4204. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4205. * @param target defines the original target of the state
  4206. * @param currentTarget defines the current target of the state
  4207. */
  4208. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4209. /**
  4210. * Initialize the current event state
  4211. * @param mask defines the mask associated with this state
  4212. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4213. * @param target defines the original target of the state
  4214. * @param currentTarget defines the current target of the state
  4215. * @returns the current event state
  4216. */
  4217. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4218. /**
  4219. * An Observer can set this property to true to prevent subsequent observers of being notified
  4220. */
  4221. skipNextObservers: boolean;
  4222. /**
  4223. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4224. */
  4225. mask: number;
  4226. /**
  4227. * The object that originally notified the event
  4228. */
  4229. target?: any;
  4230. /**
  4231. * The current object in the bubbling phase
  4232. */
  4233. currentTarget?: any;
  4234. /**
  4235. * This will be populated with the return value of the last function that was executed.
  4236. * If it is the first function in the callback chain it will be the event data.
  4237. */
  4238. lastReturnValue?: any;
  4239. }
  4240. /**
  4241. * Represent an Observer registered to a given Observable object.
  4242. */
  4243. export class Observer<T> {
  4244. /**
  4245. * Defines the callback to call when the observer is notified
  4246. */
  4247. callback: (eventData: T, eventState: EventState) => void;
  4248. /**
  4249. * Defines the mask of the observer (used to filter notifications)
  4250. */
  4251. mask: number;
  4252. /**
  4253. * Defines the current scope used to restore the JS context
  4254. */
  4255. scope: any;
  4256. /** @hidden */ willBeUnregistered: boolean;
  4257. /**
  4258. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4259. */
  4260. unregisterOnNextCall: boolean;
  4261. /**
  4262. * Creates a new observer
  4263. * @param callback defines the callback to call when the observer is notified
  4264. * @param mask defines the mask of the observer (used to filter notifications)
  4265. * @param scope defines the current scope used to restore the JS context
  4266. */
  4267. constructor(
  4268. /**
  4269. * Defines the callback to call when the observer is notified
  4270. */
  4271. callback: (eventData: T, eventState: EventState) => void,
  4272. /**
  4273. * Defines the mask of the observer (used to filter notifications)
  4274. */
  4275. mask: number,
  4276. /**
  4277. * Defines the current scope used to restore the JS context
  4278. */
  4279. scope?: any);
  4280. }
  4281. /**
  4282. * Represent a list of observers registered to multiple Observables object.
  4283. */
  4284. export class MultiObserver<T> {
  4285. private _observers;
  4286. private _observables;
  4287. /**
  4288. * Release associated resources
  4289. */
  4290. dispose(): void;
  4291. /**
  4292. * Raise a callback when one of the observable will notify
  4293. * @param observables defines a list of observables to watch
  4294. * @param callback defines the callback to call on notification
  4295. * @param mask defines the mask used to filter notifications
  4296. * @param scope defines the current scope used to restore the JS context
  4297. * @returns the new MultiObserver
  4298. */
  4299. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4300. }
  4301. /**
  4302. * The Observable class is a simple implementation of the Observable pattern.
  4303. *
  4304. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4305. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4306. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4307. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4308. */
  4309. export class Observable<T> {
  4310. private _observers;
  4311. private _eventState;
  4312. private _onObserverAdded;
  4313. /**
  4314. * Creates a new observable
  4315. * @param onObserverAdded defines a callback to call when a new observer is added
  4316. */
  4317. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4318. /**
  4319. * Create a new Observer with the specified callback
  4320. * @param callback the callback that will be executed for that Observer
  4321. * @param mask the mask used to filter observers
  4322. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4323. * @param scope optional scope for the callback to be called from
  4324. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4325. * @returns the new observer created for the callback
  4326. */
  4327. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4328. /**
  4329. * Create a new Observer with the specified callback and unregisters after the next notification
  4330. * @param callback the callback that will be executed for that Observer
  4331. * @returns the new observer created for the callback
  4332. */
  4333. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4334. /**
  4335. * Remove an Observer from the Observable object
  4336. * @param observer the instance of the Observer to remove
  4337. * @returns false if it doesn't belong to this Observable
  4338. */
  4339. remove(observer: Nullable<Observer<T>>): boolean;
  4340. /**
  4341. * Remove a callback from the Observable object
  4342. * @param callback the callback to remove
  4343. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4344. * @returns false if it doesn't belong to this Observable
  4345. */
  4346. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4347. private _deferUnregister;
  4348. private _remove;
  4349. /**
  4350. * Moves the observable to the top of the observer list making it get called first when notified
  4351. * @param observer the observer to move
  4352. */
  4353. makeObserverTopPriority(observer: Observer<T>): void;
  4354. /**
  4355. * Moves the observable to the bottom of the observer list making it get called last when notified
  4356. * @param observer the observer to move
  4357. */
  4358. makeObserverBottomPriority(observer: Observer<T>): void;
  4359. /**
  4360. * Notify all Observers by calling their respective callback with the given data
  4361. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4362. * @param eventData defines the data to send to all observers
  4363. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4364. * @param target defines the original target of the state
  4365. * @param currentTarget defines the current target of the state
  4366. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4367. */
  4368. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4369. /**
  4370. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4371. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4372. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4373. * and it is crucial that all callbacks will be executed.
  4374. * The order of the callbacks is kept, callbacks are not executed parallel.
  4375. *
  4376. * @param eventData The data to be sent to each callback
  4377. * @param mask is used to filter observers defaults to -1
  4378. * @param target defines the callback target (see EventState)
  4379. * @param currentTarget defines he current object in the bubbling phase
  4380. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4381. */
  4382. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4383. /**
  4384. * Notify a specific observer
  4385. * @param observer defines the observer to notify
  4386. * @param eventData defines the data to be sent to each callback
  4387. * @param mask is used to filter observers defaults to -1
  4388. */
  4389. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4390. /**
  4391. * Gets a boolean indicating if the observable has at least one observer
  4392. * @returns true is the Observable has at least one Observer registered
  4393. */
  4394. hasObservers(): boolean;
  4395. /**
  4396. * Clear the list of observers
  4397. */
  4398. clear(): void;
  4399. /**
  4400. * Clone the current observable
  4401. * @returns a new observable
  4402. */
  4403. clone(): Observable<T>;
  4404. /**
  4405. * Does this observable handles observer registered with a given mask
  4406. * @param mask defines the mask to be tested
  4407. * @return whether or not one observer registered with the given mask is handeled
  4408. **/
  4409. hasSpecificMask(mask?: number): boolean;
  4410. }
  4411. }
  4412. declare module BABYLON {
  4413. /**
  4414. * Class used to help managing file picking and drag'n'drop
  4415. * File Storage
  4416. */
  4417. export class FilesInputStore {
  4418. /**
  4419. * List of files ready to be loaded
  4420. */
  4421. static FilesToLoad: {
  4422. [key: string]: File;
  4423. };
  4424. }
  4425. }
  4426. declare module BABYLON {
  4427. /** Defines the cross module used constants to avoid circular dependncies */
  4428. export class Constants {
  4429. /** Defines that alpha blending is disabled */
  4430. static readonly ALPHA_DISABLE: number;
  4431. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4432. static readonly ALPHA_ADD: number;
  4433. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4434. static readonly ALPHA_COMBINE: number;
  4435. /** Defines that alpha blending to DEST - SRC * DEST */
  4436. static readonly ALPHA_SUBTRACT: number;
  4437. /** Defines that alpha blending to SRC * DEST */
  4438. static readonly ALPHA_MULTIPLY: number;
  4439. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4440. static readonly ALPHA_MAXIMIZED: number;
  4441. /** Defines that alpha blending to SRC + DEST */
  4442. static readonly ALPHA_ONEONE: number;
  4443. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4444. static readonly ALPHA_PREMULTIPLIED: number;
  4445. /**
  4446. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4447. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4448. */
  4449. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4450. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4451. static readonly ALPHA_INTERPOLATE: number;
  4452. /**
  4453. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4454. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4455. */
  4456. static readonly ALPHA_SCREENMODE: number;
  4457. /** Defines that the ressource is not delayed*/
  4458. static readonly DELAYLOADSTATE_NONE: number;
  4459. /** Defines that the ressource was successfully delay loaded */
  4460. static readonly DELAYLOADSTATE_LOADED: number;
  4461. /** Defines that the ressource is currently delay loading */
  4462. static readonly DELAYLOADSTATE_LOADING: number;
  4463. /** Defines that the ressource is delayed and has not started loading */
  4464. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4465. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4466. static readonly NEVER: number;
  4467. /** 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 */
  4468. static readonly ALWAYS: number;
  4469. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4470. static readonly LESS: number;
  4471. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4472. static readonly EQUAL: number;
  4473. /** 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 */
  4474. static readonly LEQUAL: number;
  4475. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4476. static readonly GREATER: number;
  4477. /** 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 */
  4478. static readonly GEQUAL: number;
  4479. /** 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 */
  4480. static readonly NOTEQUAL: number;
  4481. /** Passed to stencilOperation to specify that stencil value must be kept */
  4482. static readonly KEEP: number;
  4483. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4484. static readonly REPLACE: number;
  4485. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4486. static readonly INCR: number;
  4487. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4488. static readonly DECR: number;
  4489. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4490. static readonly INVERT: number;
  4491. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4492. static readonly INCR_WRAP: number;
  4493. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4494. static readonly DECR_WRAP: number;
  4495. /** Texture is not repeating outside of 0..1 UVs */
  4496. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4497. /** Texture is repeating outside of 0..1 UVs */
  4498. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4499. /** Texture is repeating and mirrored */
  4500. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4501. /** ALPHA */
  4502. static readonly TEXTUREFORMAT_ALPHA: number;
  4503. /** LUMINANCE */
  4504. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4505. /** LUMINANCE_ALPHA */
  4506. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4507. /** RGB */
  4508. static readonly TEXTUREFORMAT_RGB: number;
  4509. /** RGBA */
  4510. static readonly TEXTUREFORMAT_RGBA: number;
  4511. /** RED */
  4512. static readonly TEXTUREFORMAT_RED: number;
  4513. /** RED (2nd reference) */
  4514. static readonly TEXTUREFORMAT_R: number;
  4515. /** RG */
  4516. static readonly TEXTUREFORMAT_RG: number;
  4517. /** RED_INTEGER */
  4518. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4519. /** RED_INTEGER (2nd reference) */
  4520. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4521. /** RG_INTEGER */
  4522. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4523. /** RGB_INTEGER */
  4524. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4525. /** RGBA_INTEGER */
  4526. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4527. /** UNSIGNED_BYTE */
  4528. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4529. /** UNSIGNED_BYTE (2nd reference) */
  4530. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4531. /** FLOAT */
  4532. static readonly TEXTURETYPE_FLOAT: number;
  4533. /** HALF_FLOAT */
  4534. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4535. /** BYTE */
  4536. static readonly TEXTURETYPE_BYTE: number;
  4537. /** SHORT */
  4538. static readonly TEXTURETYPE_SHORT: number;
  4539. /** UNSIGNED_SHORT */
  4540. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4541. /** INT */
  4542. static readonly TEXTURETYPE_INT: number;
  4543. /** UNSIGNED_INT */
  4544. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4545. /** UNSIGNED_SHORT_4_4_4_4 */
  4546. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4547. /** UNSIGNED_SHORT_5_5_5_1 */
  4548. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4549. /** UNSIGNED_SHORT_5_6_5 */
  4550. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4551. /** UNSIGNED_INT_2_10_10_10_REV */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4553. /** UNSIGNED_INT_24_8 */
  4554. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4555. /** UNSIGNED_INT_10F_11F_11F_REV */
  4556. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4557. /** UNSIGNED_INT_5_9_9_9_REV */
  4558. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4559. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4560. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4561. /** nearest is mag = nearest and min = nearest and mip = linear */
  4562. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4563. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4564. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4565. /** Trilinear is mag = linear and min = linear and mip = linear */
  4566. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4567. /** nearest is mag = nearest and min = nearest and mip = linear */
  4568. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4569. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4570. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4571. /** Trilinear is mag = linear and min = linear and mip = linear */
  4572. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4573. /** mag = nearest and min = nearest and mip = nearest */
  4574. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4575. /** mag = nearest and min = linear and mip = nearest */
  4576. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4577. /** mag = nearest and min = linear and mip = linear */
  4578. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4579. /** mag = nearest and min = linear and mip = none */
  4580. static readonly TEXTURE_NEAREST_LINEAR: number;
  4581. /** mag = nearest and min = nearest and mip = none */
  4582. static readonly TEXTURE_NEAREST_NEAREST: number;
  4583. /** mag = linear and min = nearest and mip = nearest */
  4584. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4585. /** mag = linear and min = nearest and mip = linear */
  4586. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4587. /** mag = linear and min = linear and mip = none */
  4588. static readonly TEXTURE_LINEAR_LINEAR: number;
  4589. /** mag = linear and min = nearest and mip = none */
  4590. static readonly TEXTURE_LINEAR_NEAREST: number;
  4591. /** Explicit coordinates mode */
  4592. static readonly TEXTURE_EXPLICIT_MODE: number;
  4593. /** Spherical coordinates mode */
  4594. static readonly TEXTURE_SPHERICAL_MODE: number;
  4595. /** Planar coordinates mode */
  4596. static readonly TEXTURE_PLANAR_MODE: number;
  4597. /** Cubic coordinates mode */
  4598. static readonly TEXTURE_CUBIC_MODE: number;
  4599. /** Projection coordinates mode */
  4600. static readonly TEXTURE_PROJECTION_MODE: number;
  4601. /** Skybox coordinates mode */
  4602. static readonly TEXTURE_SKYBOX_MODE: number;
  4603. /** Inverse Cubic coordinates mode */
  4604. static readonly TEXTURE_INVCUBIC_MODE: number;
  4605. /** Equirectangular coordinates mode */
  4606. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4607. /** Equirectangular Fixed coordinates mode */
  4608. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4609. /** Equirectangular Fixed Mirrored coordinates mode */
  4610. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4611. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4612. static readonly SCALEMODE_FLOOR: number;
  4613. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4614. static readonly SCALEMODE_NEAREST: number;
  4615. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4616. static readonly SCALEMODE_CEILING: number;
  4617. /**
  4618. * The dirty texture flag value
  4619. */
  4620. static readonly MATERIAL_TextureDirtyFlag: number;
  4621. /**
  4622. * The dirty light flag value
  4623. */
  4624. static readonly MATERIAL_LightDirtyFlag: number;
  4625. /**
  4626. * The dirty fresnel flag value
  4627. */
  4628. static readonly MATERIAL_FresnelDirtyFlag: number;
  4629. /**
  4630. * The dirty attribute flag value
  4631. */
  4632. static readonly MATERIAL_AttributesDirtyFlag: number;
  4633. /**
  4634. * The dirty misc flag value
  4635. */
  4636. static readonly MATERIAL_MiscDirtyFlag: number;
  4637. /**
  4638. * The all dirty flag value
  4639. */
  4640. static readonly MATERIAL_AllDirtyFlag: number;
  4641. /**
  4642. * Returns the triangle fill mode
  4643. */
  4644. static readonly MATERIAL_TriangleFillMode: number;
  4645. /**
  4646. * Returns the wireframe mode
  4647. */
  4648. static readonly MATERIAL_WireFrameFillMode: number;
  4649. /**
  4650. * Returns the point fill mode
  4651. */
  4652. static readonly MATERIAL_PointFillMode: number;
  4653. /**
  4654. * Returns the point list draw mode
  4655. */
  4656. static readonly MATERIAL_PointListDrawMode: number;
  4657. /**
  4658. * Returns the line list draw mode
  4659. */
  4660. static readonly MATERIAL_LineListDrawMode: number;
  4661. /**
  4662. * Returns the line loop draw mode
  4663. */
  4664. static readonly MATERIAL_LineLoopDrawMode: number;
  4665. /**
  4666. * Returns the line strip draw mode
  4667. */
  4668. static readonly MATERIAL_LineStripDrawMode: number;
  4669. /**
  4670. * Returns the triangle strip draw mode
  4671. */
  4672. static readonly MATERIAL_TriangleStripDrawMode: number;
  4673. /**
  4674. * Returns the triangle fan draw mode
  4675. */
  4676. static readonly MATERIAL_TriangleFanDrawMode: number;
  4677. /**
  4678. * Stores the clock-wise side orientation
  4679. */
  4680. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4681. /**
  4682. * Stores the counter clock-wise side orientation
  4683. */
  4684. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4685. /**
  4686. * Nothing
  4687. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4688. */
  4689. static readonly ACTION_NothingTrigger: number;
  4690. /**
  4691. * On pick
  4692. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4693. */
  4694. static readonly ACTION_OnPickTrigger: number;
  4695. /**
  4696. * On left pick
  4697. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4698. */
  4699. static readonly ACTION_OnLeftPickTrigger: number;
  4700. /**
  4701. * On right pick
  4702. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4703. */
  4704. static readonly ACTION_OnRightPickTrigger: number;
  4705. /**
  4706. * On center pick
  4707. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4708. */
  4709. static readonly ACTION_OnCenterPickTrigger: number;
  4710. /**
  4711. * On pick down
  4712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4713. */
  4714. static readonly ACTION_OnPickDownTrigger: number;
  4715. /**
  4716. * On double pick
  4717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4718. */
  4719. static readonly ACTION_OnDoublePickTrigger: number;
  4720. /**
  4721. * On pick up
  4722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4723. */
  4724. static readonly ACTION_OnPickUpTrigger: number;
  4725. /**
  4726. * On pick out.
  4727. * This trigger will only be raised if you also declared a OnPickDown
  4728. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4729. */
  4730. static readonly ACTION_OnPickOutTrigger: number;
  4731. /**
  4732. * On long press
  4733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4734. */
  4735. static readonly ACTION_OnLongPressTrigger: number;
  4736. /**
  4737. * On pointer over
  4738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4739. */
  4740. static readonly ACTION_OnPointerOverTrigger: number;
  4741. /**
  4742. * On pointer out
  4743. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4744. */
  4745. static readonly ACTION_OnPointerOutTrigger: number;
  4746. /**
  4747. * On every frame
  4748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4749. */
  4750. static readonly ACTION_OnEveryFrameTrigger: number;
  4751. /**
  4752. * On intersection enter
  4753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4754. */
  4755. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4756. /**
  4757. * On intersection exit
  4758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4759. */
  4760. static readonly ACTION_OnIntersectionExitTrigger: number;
  4761. /**
  4762. * On key down
  4763. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4764. */
  4765. static readonly ACTION_OnKeyDownTrigger: number;
  4766. /**
  4767. * On key up
  4768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4769. */
  4770. static readonly ACTION_OnKeyUpTrigger: number;
  4771. /**
  4772. * Billboard mode will only apply to Y axis
  4773. */
  4774. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4775. /**
  4776. * Billboard mode will apply to all axes
  4777. */
  4778. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4779. /**
  4780. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4781. */
  4782. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4783. /**
  4784. * Gets or sets base Assets URL
  4785. */
  4786. static readonly PARTICLES_BaseAssetsUrl: string;
  4787. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4788. * Test order :
  4789. * Is the bounding sphere outside the frustum ?
  4790. * If not, are the bounding box vertices outside the frustum ?
  4791. * It not, then the cullable object is in the frustum.
  4792. */
  4793. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4794. /** Culling strategy : Bounding Sphere Only.
  4795. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4796. * It's also less accurate than the standard because some not visible objects can still be selected.
  4797. * Test : is the bounding sphere outside the frustum ?
  4798. * If not, then the cullable object is in the frustum.
  4799. */
  4800. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4801. /** Culling strategy : Optimistic Inclusion.
  4802. * This in an inclusion test first, then the standard exclusion test.
  4803. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4804. * 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.
  4805. * Anyway, it's as accurate as the standard strategy.
  4806. * Test :
  4807. * Is the cullable object bounding sphere center in the frustum ?
  4808. * If not, apply the default culling strategy.
  4809. */
  4810. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4811. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4812. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4813. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4814. * 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.
  4815. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4816. * Test :
  4817. * Is the cullable object bounding sphere center in the frustum ?
  4818. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4819. */
  4820. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4821. /**
  4822. * No logging while loading
  4823. */
  4824. static readonly SCENELOADER_NO_LOGGING: number;
  4825. /**
  4826. * Minimal logging while loading
  4827. */
  4828. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4829. /**
  4830. * Summary logging while loading
  4831. */
  4832. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4833. /**
  4834. * Detailled logging while loading
  4835. */
  4836. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4837. }
  4838. }
  4839. declare module BABYLON {
  4840. /**
  4841. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4842. * Babylon.js
  4843. */
  4844. export class DomManagement {
  4845. /**
  4846. * Checks if the window object exists
  4847. * @returns true if the window object exists
  4848. */
  4849. static IsWindowObjectExist(): boolean;
  4850. /**
  4851. * Extracts text content from a DOM element hierarchy
  4852. * @param element defines the root element
  4853. * @returns a string
  4854. */
  4855. static GetDOMTextContent(element: HTMLElement): string;
  4856. }
  4857. }
  4858. declare module BABYLON {
  4859. /**
  4860. * Logger used througouht the application to allow configuration of
  4861. * the log level required for the messages.
  4862. */
  4863. export class Logger {
  4864. /**
  4865. * No log
  4866. */
  4867. static readonly NoneLogLevel: number;
  4868. /**
  4869. * Only message logs
  4870. */
  4871. static readonly MessageLogLevel: number;
  4872. /**
  4873. * Only warning logs
  4874. */
  4875. static readonly WarningLogLevel: number;
  4876. /**
  4877. * Only error logs
  4878. */
  4879. static readonly ErrorLogLevel: number;
  4880. /**
  4881. * All logs
  4882. */
  4883. static readonly AllLogLevel: number;
  4884. private static _LogCache;
  4885. /**
  4886. * Gets a value indicating the number of loading errors
  4887. * @ignorenaming
  4888. */
  4889. static errorsCount: number;
  4890. /**
  4891. * Callback called when a new log is added
  4892. */
  4893. static OnNewCacheEntry: (entry: string) => void;
  4894. private static _AddLogEntry;
  4895. private static _FormatMessage;
  4896. private static _LogDisabled;
  4897. private static _LogEnabled;
  4898. private static _WarnDisabled;
  4899. private static _WarnEnabled;
  4900. private static _ErrorDisabled;
  4901. private static _ErrorEnabled;
  4902. /**
  4903. * Log a message to the console
  4904. */
  4905. static Log: (message: string) => void;
  4906. /**
  4907. * Write a warning message to the console
  4908. */
  4909. static Warn: (message: string) => void;
  4910. /**
  4911. * Write an error message to the console
  4912. */
  4913. static Error: (message: string) => void;
  4914. /**
  4915. * Gets current log cache (list of logs)
  4916. */
  4917. static readonly LogCache: string;
  4918. /**
  4919. * Clears the log cache
  4920. */
  4921. static ClearLogCache(): void;
  4922. /**
  4923. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4924. */
  4925. static LogLevels: number;
  4926. }
  4927. }
  4928. declare module BABYLON {
  4929. /** @hidden */
  4930. export class _TypeStore {
  4931. /** @hidden */
  4932. static RegisteredTypes: {
  4933. [key: string]: Object;
  4934. };
  4935. /** @hidden */
  4936. static GetClass(fqdn: string): any;
  4937. }
  4938. }
  4939. declare module BABYLON {
  4940. /**
  4941. * Class containing a set of static utilities functions for deep copy.
  4942. */
  4943. export class DeepCopier {
  4944. /**
  4945. * Tries to copy an object by duplicating every property
  4946. * @param source defines the source object
  4947. * @param destination defines the target object
  4948. * @param doNotCopyList defines a list of properties to avoid
  4949. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4950. */
  4951. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4952. }
  4953. }
  4954. declare module BABYLON {
  4955. /**
  4956. * Class containing a set of static utilities functions for precision date
  4957. */
  4958. export class PrecisionDate {
  4959. /**
  4960. * Gets either window.performance.now() if supported or Date.now() else
  4961. */
  4962. static readonly Now: number;
  4963. }
  4964. }
  4965. declare module BABYLON {
  4966. /** @hidden */
  4967. export class _DevTools {
  4968. static WarnImport(name: string): string;
  4969. }
  4970. }
  4971. declare module BABYLON {
  4972. /**
  4973. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4974. */
  4975. export class WebRequest {
  4976. private _xhr;
  4977. /**
  4978. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  4979. * i.e. when loading files, where the server/service expects an Authorization header
  4980. */
  4981. static CustomRequestHeaders: {
  4982. [key: string]: string;
  4983. };
  4984. /**
  4985. * Add callback functions in this array to update all the requests before they get sent to the network
  4986. */
  4987. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  4988. private _injectCustomRequestHeaders;
  4989. /**
  4990. * Gets or sets a function to be called when loading progress changes
  4991. */
  4992. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  4993. /**
  4994. * Returns client's state
  4995. */
  4996. readonly readyState: number;
  4997. /**
  4998. * Returns client's status
  4999. */
  5000. readonly status: number;
  5001. /**
  5002. * Returns client's status as a text
  5003. */
  5004. readonly statusText: string;
  5005. /**
  5006. * Returns client's response
  5007. */
  5008. readonly response: any;
  5009. /**
  5010. * Returns client's response url
  5011. */
  5012. readonly responseURL: string;
  5013. /**
  5014. * Returns client's response as text
  5015. */
  5016. readonly responseText: string;
  5017. /**
  5018. * Gets or sets the expected response type
  5019. */
  5020. responseType: XMLHttpRequestResponseType;
  5021. /** @hidden */
  5022. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5023. /** @hidden */
  5024. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5025. /**
  5026. * Cancels any network activity
  5027. */
  5028. abort(): void;
  5029. /**
  5030. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5031. * @param body defines an optional request body
  5032. */
  5033. send(body?: Document | BodyInit | null): void;
  5034. /**
  5035. * Sets the request method, request URL
  5036. * @param method defines the method to use (GET, POST, etc..)
  5037. * @param url defines the url to connect with
  5038. */
  5039. open(method: string, url: string): void;
  5040. }
  5041. }
  5042. declare module BABYLON {
  5043. /**
  5044. * Class used to evalaute queries containing `and` and `or` operators
  5045. */
  5046. export class AndOrNotEvaluator {
  5047. /**
  5048. * Evaluate a query
  5049. * @param query defines the query to evaluate
  5050. * @param evaluateCallback defines the callback used to filter result
  5051. * @returns true if the query matches
  5052. */
  5053. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5054. private static _HandleParenthesisContent;
  5055. private static _SimplifyNegation;
  5056. }
  5057. }
  5058. declare module BABYLON {
  5059. /**
  5060. * Class used to store custom tags
  5061. */
  5062. export class Tags {
  5063. /**
  5064. * Adds support for tags on the given object
  5065. * @param obj defines the object to use
  5066. */
  5067. static EnableFor(obj: any): void;
  5068. /**
  5069. * Removes tags support
  5070. * @param obj defines the object to use
  5071. */
  5072. static DisableFor(obj: any): void;
  5073. /**
  5074. * Gets a boolean indicating if the given object has tags
  5075. * @param obj defines the object to use
  5076. * @returns a boolean
  5077. */
  5078. static HasTags(obj: any): boolean;
  5079. /**
  5080. * Gets the tags available on a given object
  5081. * @param obj defines the object to use
  5082. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5083. * @returns the tags
  5084. */
  5085. static GetTags(obj: any, asString?: boolean): any;
  5086. /**
  5087. * Adds tags to an object
  5088. * @param obj defines the object to use
  5089. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5090. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5091. */
  5092. static AddTagsTo(obj: any, tagsString: string): void;
  5093. /**
  5094. * @hidden
  5095. */ private static _AddTagTo(obj: any, tag: string): void;
  5096. /**
  5097. * Removes specific tags from a specific object
  5098. * @param obj defines the object to use
  5099. * @param tagsString defines the tags to remove
  5100. */
  5101. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5102. /**
  5103. * @hidden
  5104. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5105. /**
  5106. * Defines if tags hosted on an object match a given query
  5107. * @param obj defines the object to use
  5108. * @param tagsQuery defines the tag query
  5109. * @returns a boolean
  5110. */
  5111. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5112. }
  5113. }
  5114. declare module BABYLON {
  5115. /**
  5116. * Manages the defines for the Material
  5117. */
  5118. export class MaterialDefines {
  5119. private _keys;
  5120. private _isDirty;
  5121. /** @hidden */ renderId: number;
  5122. /** @hidden */ areLightsDirty: boolean;
  5123. /** @hidden */ areAttributesDirty: boolean;
  5124. /** @hidden */ areTexturesDirty: boolean;
  5125. /** @hidden */ areFresnelDirty: boolean;
  5126. /** @hidden */ areMiscDirty: boolean;
  5127. /** @hidden */ areImageProcessingDirty: boolean;
  5128. /** @hidden */ normals: boolean;
  5129. /** @hidden */ uvs: boolean;
  5130. /** @hidden */ needNormals: boolean;
  5131. /** @hidden */ needUVs: boolean;
  5132. /**
  5133. * Specifies if the material needs to be re-calculated
  5134. */
  5135. readonly isDirty: boolean;
  5136. /**
  5137. * Marks the material to indicate that it has been re-calculated
  5138. */
  5139. markAsProcessed(): void;
  5140. /**
  5141. * Marks the material to indicate that it needs to be re-calculated
  5142. */
  5143. markAsUnprocessed(): void;
  5144. /**
  5145. * Marks the material to indicate all of its defines need to be re-calculated
  5146. */
  5147. markAllAsDirty(): void;
  5148. /**
  5149. * Marks the material to indicate that image processing needs to be re-calculated
  5150. */
  5151. markAsImageProcessingDirty(): void;
  5152. /**
  5153. * Marks the material to indicate the lights need to be re-calculated
  5154. */
  5155. markAsLightDirty(): void;
  5156. /**
  5157. * Marks the attribute state as changed
  5158. */
  5159. markAsAttributesDirty(): void;
  5160. /**
  5161. * Marks the texture state as changed
  5162. */
  5163. markAsTexturesDirty(): void;
  5164. /**
  5165. * Marks the fresnel state as changed
  5166. */
  5167. markAsFresnelDirty(): void;
  5168. /**
  5169. * Marks the misc state as changed
  5170. */
  5171. markAsMiscDirty(): void;
  5172. /**
  5173. * Rebuilds the material defines
  5174. */
  5175. rebuild(): void;
  5176. /**
  5177. * Specifies if two material defines are equal
  5178. * @param other - A material define instance to compare to
  5179. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5180. */
  5181. isEqual(other: MaterialDefines): boolean;
  5182. /**
  5183. * Clones this instance's defines to another instance
  5184. * @param other - material defines to clone values to
  5185. */
  5186. cloneTo(other: MaterialDefines): void;
  5187. /**
  5188. * Resets the material define values
  5189. */
  5190. reset(): void;
  5191. /**
  5192. * Converts the material define values to a string
  5193. * @returns - String of material define information
  5194. */
  5195. toString(): string;
  5196. }
  5197. }
  5198. declare module BABYLON {
  5199. /**
  5200. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5201. */
  5202. export class PerformanceMonitor {
  5203. private _enabled;
  5204. private _rollingFrameTime;
  5205. private _lastFrameTimeMs;
  5206. /**
  5207. * constructor
  5208. * @param frameSampleSize The number of samples required to saturate the sliding window
  5209. */
  5210. constructor(frameSampleSize?: number);
  5211. /**
  5212. * Samples current frame
  5213. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5214. */
  5215. sampleFrame(timeMs?: number): void;
  5216. /**
  5217. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5218. */
  5219. readonly averageFrameTime: number;
  5220. /**
  5221. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5222. */
  5223. readonly averageFrameTimeVariance: number;
  5224. /**
  5225. * Returns the frame time of the most recent frame
  5226. */
  5227. readonly instantaneousFrameTime: number;
  5228. /**
  5229. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5230. */
  5231. readonly averageFPS: number;
  5232. /**
  5233. * Returns the average framerate in frames per second using the most recent frame time
  5234. */
  5235. readonly instantaneousFPS: number;
  5236. /**
  5237. * Returns true if enough samples have been taken to completely fill the sliding window
  5238. */
  5239. readonly isSaturated: boolean;
  5240. /**
  5241. * Enables contributions to the sliding window sample set
  5242. */
  5243. enable(): void;
  5244. /**
  5245. * Disables contributions to the sliding window sample set
  5246. * Samples will not be interpolated over the disabled period
  5247. */
  5248. disable(): void;
  5249. /**
  5250. * Returns true if sampling is enabled
  5251. */
  5252. readonly isEnabled: boolean;
  5253. /**
  5254. * Resets performance monitor
  5255. */
  5256. reset(): void;
  5257. }
  5258. /**
  5259. * RollingAverage
  5260. *
  5261. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5262. */
  5263. export class RollingAverage {
  5264. /**
  5265. * Current average
  5266. */
  5267. average: number;
  5268. /**
  5269. * Current variance
  5270. */
  5271. variance: number;
  5272. protected _samples: Array<number>;
  5273. protected _sampleCount: number;
  5274. protected _pos: number;
  5275. protected _m2: number;
  5276. /**
  5277. * constructor
  5278. * @param length The number of samples required to saturate the sliding window
  5279. */
  5280. constructor(length: number);
  5281. /**
  5282. * Adds a sample to the sample set
  5283. * @param v The sample value
  5284. */
  5285. add(v: number): void;
  5286. /**
  5287. * Returns previously added values or null if outside of history or outside the sliding window domain
  5288. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5289. * @return Value previously recorded with add() or null if outside of range
  5290. */
  5291. history(i: number): number;
  5292. /**
  5293. * Returns true if enough samples have been taken to completely fill the sliding window
  5294. * @return true if sample-set saturated
  5295. */
  5296. isSaturated(): boolean;
  5297. /**
  5298. * Resets the rolling average (equivalent to 0 samples taken so far)
  5299. */
  5300. reset(): void;
  5301. /**
  5302. * Wraps a value around the sample range boundaries
  5303. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5304. * @return Wrapped position in sample range
  5305. */
  5306. protected _wrapPosition(i: number): number;
  5307. }
  5308. }
  5309. declare module BABYLON {
  5310. /**
  5311. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5312. * The underlying implementation relies on an associative array to ensure the best performances.
  5313. * The value can be anything including 'null' but except 'undefined'
  5314. */
  5315. export class StringDictionary<T> {
  5316. /**
  5317. * This will clear this dictionary and copy the content from the 'source' one.
  5318. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5319. * @param source the dictionary to take the content from and copy to this dictionary
  5320. */
  5321. copyFrom(source: StringDictionary<T>): void;
  5322. /**
  5323. * Get a value based from its key
  5324. * @param key the given key to get the matching value from
  5325. * @return the value if found, otherwise undefined is returned
  5326. */
  5327. get(key: string): T | undefined;
  5328. /**
  5329. * Get a value from its key or add it if it doesn't exist.
  5330. * This method will ensure you that a given key/data will be present in the dictionary.
  5331. * @param key the given key to get the matching value from
  5332. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5333. * The factory will only be invoked if there's no data for the given key.
  5334. * @return the value corresponding to the key.
  5335. */
  5336. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5337. /**
  5338. * Get a value from its key if present in the dictionary otherwise add it
  5339. * @param key the key to get the value from
  5340. * @param val if there's no such key/value pair in the dictionary add it with this value
  5341. * @return the value corresponding to the key
  5342. */
  5343. getOrAdd(key: string, val: T): T;
  5344. /**
  5345. * Check if there's a given key in the dictionary
  5346. * @param key the key to check for
  5347. * @return true if the key is present, false otherwise
  5348. */
  5349. contains(key: string): boolean;
  5350. /**
  5351. * Add a new key and its corresponding value
  5352. * @param key the key to add
  5353. * @param value the value corresponding to the key
  5354. * @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
  5355. */
  5356. add(key: string, value: T): boolean;
  5357. /**
  5358. * Update a specific value associated to a key
  5359. * @param key defines the key to use
  5360. * @param value defines the value to store
  5361. * @returns true if the value was updated (or false if the key was not found)
  5362. */
  5363. set(key: string, value: T): boolean;
  5364. /**
  5365. * Get the element of the given key and remove it from the dictionary
  5366. * @param key defines the key to search
  5367. * @returns the value associated with the key or null if not found
  5368. */
  5369. getAndRemove(key: string): Nullable<T>;
  5370. /**
  5371. * Remove a key/value from the dictionary.
  5372. * @param key the key to remove
  5373. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5374. */
  5375. remove(key: string): boolean;
  5376. /**
  5377. * Clear the whole content of the dictionary
  5378. */
  5379. clear(): void;
  5380. /**
  5381. * Gets the current count
  5382. */
  5383. readonly count: number;
  5384. /**
  5385. * Execute a callback on each key/val of the dictionary.
  5386. * Note that you can remove any element in this dictionary in the callback implementation
  5387. * @param callback the callback to execute on a given key/value pair
  5388. */
  5389. forEach(callback: (key: string, val: T) => void): void;
  5390. /**
  5391. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5392. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5393. * Note that you can remove any element in this dictionary in the callback implementation
  5394. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5395. * @returns the first item
  5396. */
  5397. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5398. private _count;
  5399. private _data;
  5400. }
  5401. }
  5402. declare module BABYLON {
  5403. /**
  5404. * Helper class that provides a small promise polyfill
  5405. */
  5406. export class PromisePolyfill {
  5407. /**
  5408. * Static function used to check if the polyfill is required
  5409. * If this is the case then the function will inject the polyfill to window.Promise
  5410. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5411. */
  5412. static Apply(force?: boolean): void;
  5413. }
  5414. }
  5415. declare module BABYLON {
  5416. /**
  5417. * Class used to store data that will be store in GPU memory
  5418. */
  5419. export class Buffer {
  5420. private _engine;
  5421. private _buffer;
  5422. /** @hidden */ data: Nullable<DataArray>;
  5423. private _updatable;
  5424. private _instanced;
  5425. /**
  5426. * Gets the byte stride.
  5427. */
  5428. readonly byteStride: number;
  5429. /**
  5430. * Constructor
  5431. * @param engine the engine
  5432. * @param data the data to use for this buffer
  5433. * @param updatable whether the data is updatable
  5434. * @param stride the stride (optional)
  5435. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5436. * @param instanced whether the buffer is instanced (optional)
  5437. * @param useBytes set to true if the stride in in bytes (optional)
  5438. */
  5439. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5440. /**
  5441. * Create a new VertexBuffer based on the current buffer
  5442. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5443. * @param offset defines offset in the buffer (0 by default)
  5444. * @param size defines the size in floats of attributes (position is 3 for instance)
  5445. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5446. * @param instanced defines if the vertex buffer contains indexed data
  5447. * @param useBytes defines if the offset and stride are in bytes
  5448. * @returns the new vertex buffer
  5449. */
  5450. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5451. /**
  5452. * Gets a boolean indicating if the Buffer is updatable?
  5453. * @returns true if the buffer is updatable
  5454. */
  5455. isUpdatable(): boolean;
  5456. /**
  5457. * Gets current buffer's data
  5458. * @returns a DataArray or null
  5459. */
  5460. getData(): Nullable<DataArray>;
  5461. /**
  5462. * Gets underlying native buffer
  5463. * @returns underlying native buffer
  5464. */
  5465. getBuffer(): Nullable<WebGLBuffer>;
  5466. /**
  5467. * Gets the stride in float32 units (i.e. byte stride / 4).
  5468. * May not be an integer if the byte stride is not divisible by 4.
  5469. * DEPRECATED. Use byteStride instead.
  5470. * @returns the stride in float32 units
  5471. */
  5472. getStrideSize(): number;
  5473. /**
  5474. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5475. * @param data defines the data to store
  5476. */
  5477. create(data?: Nullable<DataArray>): void;
  5478. /** @hidden */ rebuild(): void;
  5479. /**
  5480. * Update current buffer data
  5481. * @param data defines the data to store
  5482. */
  5483. update(data: DataArray): void;
  5484. /**
  5485. * Updates the data directly.
  5486. * @param data the new data
  5487. * @param offset the new offset
  5488. * @param vertexCount the vertex count (optional)
  5489. * @param useBytes set to true if the offset is in bytes
  5490. */
  5491. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5492. /**
  5493. * Release all resources
  5494. */
  5495. dispose(): void;
  5496. }
  5497. /**
  5498. * Specialized buffer used to store vertex data
  5499. */
  5500. export class VertexBuffer {
  5501. /** @hidden */ buffer: Buffer;
  5502. private _kind;
  5503. private _size;
  5504. private _ownsBuffer;
  5505. private _instanced;
  5506. private _instanceDivisor;
  5507. /**
  5508. * The byte type.
  5509. */
  5510. static readonly BYTE: number;
  5511. /**
  5512. * The unsigned byte type.
  5513. */
  5514. static readonly UNSIGNED_BYTE: number;
  5515. /**
  5516. * The short type.
  5517. */
  5518. static readonly SHORT: number;
  5519. /**
  5520. * The unsigned short type.
  5521. */
  5522. static readonly UNSIGNED_SHORT: number;
  5523. /**
  5524. * The integer type.
  5525. */
  5526. static readonly INT: number;
  5527. /**
  5528. * The unsigned integer type.
  5529. */
  5530. static readonly UNSIGNED_INT: number;
  5531. /**
  5532. * The float type.
  5533. */
  5534. static readonly FLOAT: number;
  5535. /**
  5536. * Gets or sets the instance divisor when in instanced mode
  5537. */
  5538. instanceDivisor: number;
  5539. /**
  5540. * Gets the byte stride.
  5541. */
  5542. readonly byteStride: number;
  5543. /**
  5544. * Gets the byte offset.
  5545. */
  5546. readonly byteOffset: number;
  5547. /**
  5548. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5549. */
  5550. readonly normalized: boolean;
  5551. /**
  5552. * Gets the data type of each component in the array.
  5553. */
  5554. readonly type: number;
  5555. /**
  5556. * Constructor
  5557. * @param engine the engine
  5558. * @param data the data to use for this vertex buffer
  5559. * @param kind the vertex buffer kind
  5560. * @param updatable whether the data is updatable
  5561. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5562. * @param stride the stride (optional)
  5563. * @param instanced whether the buffer is instanced (optional)
  5564. * @param offset the offset of the data (optional)
  5565. * @param size the number of components (optional)
  5566. * @param type the type of the component (optional)
  5567. * @param normalized whether the data contains normalized data (optional)
  5568. * @param useBytes set to true if stride and offset are in bytes (optional)
  5569. */
  5570. 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);
  5571. /** @hidden */ rebuild(): void;
  5572. /**
  5573. * Returns the kind of the VertexBuffer (string)
  5574. * @returns a string
  5575. */
  5576. getKind(): string;
  5577. /**
  5578. * Gets a boolean indicating if the VertexBuffer is updatable?
  5579. * @returns true if the buffer is updatable
  5580. */
  5581. isUpdatable(): boolean;
  5582. /**
  5583. * Gets current buffer's data
  5584. * @returns a DataArray or null
  5585. */
  5586. getData(): Nullable<DataArray>;
  5587. /**
  5588. * Gets underlying native buffer
  5589. * @returns underlying native buffer
  5590. */
  5591. getBuffer(): Nullable<WebGLBuffer>;
  5592. /**
  5593. * Gets the stride in float32 units (i.e. byte stride / 4).
  5594. * May not be an integer if the byte stride is not divisible by 4.
  5595. * DEPRECATED. Use byteStride instead.
  5596. * @returns the stride in float32 units
  5597. */
  5598. getStrideSize(): number;
  5599. /**
  5600. * Returns the offset as a multiple of the type byte length.
  5601. * DEPRECATED. Use byteOffset instead.
  5602. * @returns the offset in bytes
  5603. */
  5604. getOffset(): number;
  5605. /**
  5606. * Returns the number of components per vertex attribute (integer)
  5607. * @returns the size in float
  5608. */
  5609. getSize(): number;
  5610. /**
  5611. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5612. * @returns true if this buffer is instanced
  5613. */
  5614. getIsInstanced(): boolean;
  5615. /**
  5616. * Returns the instancing divisor, zero for non-instanced (integer).
  5617. * @returns a number
  5618. */
  5619. getInstanceDivisor(): number;
  5620. /**
  5621. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5622. * @param data defines the data to store
  5623. */
  5624. create(data?: DataArray): void;
  5625. /**
  5626. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5627. * This function will create a new buffer if the current one is not updatable
  5628. * @param data defines the data to store
  5629. */
  5630. update(data: DataArray): void;
  5631. /**
  5632. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5633. * Returns the directly updated WebGLBuffer.
  5634. * @param data the new data
  5635. * @param offset the new offset
  5636. * @param useBytes set to true if the offset is in bytes
  5637. */
  5638. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5639. /**
  5640. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5641. */
  5642. dispose(): void;
  5643. /**
  5644. * Enumerates each value of this vertex buffer as numbers.
  5645. * @param count the number of values to enumerate
  5646. * @param callback the callback function called for each value
  5647. */
  5648. forEach(count: number, callback: (value: number, index: number) => void): void;
  5649. /**
  5650. * Positions
  5651. */
  5652. static readonly PositionKind: string;
  5653. /**
  5654. * Normals
  5655. */
  5656. static readonly NormalKind: string;
  5657. /**
  5658. * Tangents
  5659. */
  5660. static readonly TangentKind: string;
  5661. /**
  5662. * Texture coordinates
  5663. */
  5664. static readonly UVKind: string;
  5665. /**
  5666. * Texture coordinates 2
  5667. */
  5668. static readonly UV2Kind: string;
  5669. /**
  5670. * Texture coordinates 3
  5671. */
  5672. static readonly UV3Kind: string;
  5673. /**
  5674. * Texture coordinates 4
  5675. */
  5676. static readonly UV4Kind: string;
  5677. /**
  5678. * Texture coordinates 5
  5679. */
  5680. static readonly UV5Kind: string;
  5681. /**
  5682. * Texture coordinates 6
  5683. */
  5684. static readonly UV6Kind: string;
  5685. /**
  5686. * Colors
  5687. */
  5688. static readonly ColorKind: string;
  5689. /**
  5690. * Matrix indices (for bones)
  5691. */
  5692. static readonly MatricesIndicesKind: string;
  5693. /**
  5694. * Matrix weights (for bones)
  5695. */
  5696. static readonly MatricesWeightsKind: string;
  5697. /**
  5698. * Additional matrix indices (for bones)
  5699. */
  5700. static readonly MatricesIndicesExtraKind: string;
  5701. /**
  5702. * Additional matrix weights (for bones)
  5703. */
  5704. static readonly MatricesWeightsExtraKind: string;
  5705. /**
  5706. * Deduces the stride given a kind.
  5707. * @param kind The kind string to deduce
  5708. * @returns The deduced stride
  5709. */
  5710. static DeduceStride(kind: string): number;
  5711. /**
  5712. * Gets the byte length of the given type.
  5713. * @param type the type
  5714. * @returns the number of bytes
  5715. */
  5716. static GetTypeByteLength(type: number): number;
  5717. /**
  5718. * Enumerates each value of the given parameters as numbers.
  5719. * @param data the data to enumerate
  5720. * @param byteOffset the byte offset of the data
  5721. * @param byteStride the byte stride of the data
  5722. * @param componentCount the number of components per element
  5723. * @param componentType the type of the component
  5724. * @param count the total number of components
  5725. * @param normalized whether the data is normalized
  5726. * @param callback the callback function called for each value
  5727. */
  5728. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5729. private static _GetFloatValue;
  5730. }
  5731. }
  5732. declare module BABYLON {
  5733. /**
  5734. * Class representing spherical polynomial coefficients to the 3rd degree
  5735. */
  5736. export class SphericalPolynomial {
  5737. /**
  5738. * The x coefficients of the spherical polynomial
  5739. */
  5740. x: Vector3;
  5741. /**
  5742. * The y coefficients of the spherical polynomial
  5743. */
  5744. y: Vector3;
  5745. /**
  5746. * The z coefficients of the spherical polynomial
  5747. */
  5748. z: Vector3;
  5749. /**
  5750. * The xx coefficients of the spherical polynomial
  5751. */
  5752. xx: Vector3;
  5753. /**
  5754. * The yy coefficients of the spherical polynomial
  5755. */
  5756. yy: Vector3;
  5757. /**
  5758. * The zz coefficients of the spherical polynomial
  5759. */
  5760. zz: Vector3;
  5761. /**
  5762. * The xy coefficients of the spherical polynomial
  5763. */
  5764. xy: Vector3;
  5765. /**
  5766. * The yz coefficients of the spherical polynomial
  5767. */
  5768. yz: Vector3;
  5769. /**
  5770. * The zx coefficients of the spherical polynomial
  5771. */
  5772. zx: Vector3;
  5773. /**
  5774. * Adds an ambient color to the spherical polynomial
  5775. * @param color the color to add
  5776. */
  5777. addAmbient(color: Color3): void;
  5778. /**
  5779. * Scales the spherical polynomial by the given amount
  5780. * @param scale the amount to scale
  5781. */
  5782. scale(scale: number): void;
  5783. /**
  5784. * Gets the spherical polynomial from harmonics
  5785. * @param harmonics the spherical harmonics
  5786. * @returns the spherical polynomial
  5787. */
  5788. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5789. /**
  5790. * Constructs a spherical polynomial from an array.
  5791. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5792. * @returns the spherical polynomial
  5793. */
  5794. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5795. }
  5796. /**
  5797. * Class representing spherical harmonics coefficients to the 3rd degree
  5798. */
  5799. export class SphericalHarmonics {
  5800. /**
  5801. * The l0,0 coefficients of the spherical harmonics
  5802. */
  5803. l00: Vector3;
  5804. /**
  5805. * The l1,-1 coefficients of the spherical harmonics
  5806. */
  5807. l1_1: Vector3;
  5808. /**
  5809. * The l1,0 coefficients of the spherical harmonics
  5810. */
  5811. l10: Vector3;
  5812. /**
  5813. * The l1,1 coefficients of the spherical harmonics
  5814. */
  5815. l11: Vector3;
  5816. /**
  5817. * The l2,-2 coefficients of the spherical harmonics
  5818. */
  5819. l2_2: Vector3;
  5820. /**
  5821. * The l2,-1 coefficients of the spherical harmonics
  5822. */
  5823. l2_1: Vector3;
  5824. /**
  5825. * The l2,0 coefficients of the spherical harmonics
  5826. */
  5827. l20: Vector3;
  5828. /**
  5829. * The l2,1 coefficients of the spherical harmonics
  5830. */
  5831. l21: Vector3;
  5832. /**
  5833. * The l2,2 coefficients of the spherical harmonics
  5834. */
  5835. lL22: Vector3;
  5836. /**
  5837. * Adds a light to the spherical harmonics
  5838. * @param direction the direction of the light
  5839. * @param color the color of the light
  5840. * @param deltaSolidAngle the delta solid angle of the light
  5841. */
  5842. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5843. /**
  5844. * Scales the spherical harmonics by the given amount
  5845. * @param scale the amount to scale
  5846. */
  5847. scale(scale: number): void;
  5848. /**
  5849. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5850. *
  5851. * ```
  5852. * E_lm = A_l * L_lm
  5853. * ```
  5854. *
  5855. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5856. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5857. * the scaling factors are given in equation 9.
  5858. */
  5859. convertIncidentRadianceToIrradiance(): void;
  5860. /**
  5861. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5862. *
  5863. * ```
  5864. * L = (1/pi) * E * rho
  5865. * ```
  5866. *
  5867. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5868. */
  5869. convertIrradianceToLambertianRadiance(): void;
  5870. /**
  5871. * Gets the spherical harmonics from polynomial
  5872. * @param polynomial the spherical polynomial
  5873. * @returns the spherical harmonics
  5874. */
  5875. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5876. /**
  5877. * Constructs a spherical harmonics from an array.
  5878. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5879. * @returns the spherical harmonics
  5880. */
  5881. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5882. }
  5883. }
  5884. declare module BABYLON {
  5885. /**
  5886. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5887. */
  5888. export interface CubeMapInfo {
  5889. /**
  5890. * The pixel array for the front face.
  5891. * This is stored in format, left to right, up to down format.
  5892. */
  5893. front: Nullable<ArrayBufferView>;
  5894. /**
  5895. * The pixel array for the back face.
  5896. * This is stored in format, left to right, up to down format.
  5897. */
  5898. back: Nullable<ArrayBufferView>;
  5899. /**
  5900. * The pixel array for the left face.
  5901. * This is stored in format, left to right, up to down format.
  5902. */
  5903. left: Nullable<ArrayBufferView>;
  5904. /**
  5905. * The pixel array for the right face.
  5906. * This is stored in format, left to right, up to down format.
  5907. */
  5908. right: Nullable<ArrayBufferView>;
  5909. /**
  5910. * The pixel array for the up face.
  5911. * This is stored in format, left to right, up to down format.
  5912. */
  5913. up: Nullable<ArrayBufferView>;
  5914. /**
  5915. * The pixel array for the down face.
  5916. * This is stored in format, left to right, up to down format.
  5917. */
  5918. down: Nullable<ArrayBufferView>;
  5919. /**
  5920. * The size of the cubemap stored.
  5921. *
  5922. * Each faces will be size * size pixels.
  5923. */
  5924. size: number;
  5925. /**
  5926. * The format of the texture.
  5927. *
  5928. * RGBA, RGB.
  5929. */
  5930. format: number;
  5931. /**
  5932. * The type of the texture data.
  5933. *
  5934. * UNSIGNED_INT, FLOAT.
  5935. */
  5936. type: number;
  5937. /**
  5938. * Specifies whether the texture is in gamma space.
  5939. */
  5940. gammaSpace: boolean;
  5941. }
  5942. /**
  5943. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5944. */
  5945. export class PanoramaToCubeMapTools {
  5946. private static FACE_FRONT;
  5947. private static FACE_BACK;
  5948. private static FACE_RIGHT;
  5949. private static FACE_LEFT;
  5950. private static FACE_DOWN;
  5951. private static FACE_UP;
  5952. /**
  5953. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5954. *
  5955. * @param float32Array The source data.
  5956. * @param inputWidth The width of the input panorama.
  5957. * @param inputHeight The height of the input panorama.
  5958. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  5959. * @return The cubemap data
  5960. */
  5961. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  5962. private static CreateCubemapTexture;
  5963. private static CalcProjectionSpherical;
  5964. }
  5965. }
  5966. declare module BABYLON {
  5967. /**
  5968. * Helper class dealing with the extraction of spherical polynomial dataArray
  5969. * from a cube map.
  5970. */
  5971. export class CubeMapToSphericalPolynomialTools {
  5972. private static FileFaces;
  5973. /**
  5974. * Converts a texture to the according Spherical Polynomial data.
  5975. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5976. *
  5977. * @param texture The texture to extract the information from.
  5978. * @return The Spherical Polynomial data.
  5979. */
  5980. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  5981. /**
  5982. * Converts a cubemap to the according Spherical Polynomial data.
  5983. * This extracts the first 3 orders only as they are the only one used in the lighting.
  5984. *
  5985. * @param cubeInfo The Cube map to extract the information from.
  5986. * @return The Spherical Polynomial data.
  5987. */
  5988. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  5989. }
  5990. }
  5991. declare module BABYLON {
  5992. /**
  5993. * The engine store class is responsible to hold all the instances of Engine and Scene created
  5994. * during the life time of the application.
  5995. */
  5996. export class EngineStore {
  5997. /** Gets the list of created engines */
  5998. static Instances: Engine[];
  5999. /**
  6000. * Gets the latest created engine
  6001. */
  6002. static readonly LastCreatedEngine: Nullable<Engine>;
  6003. /**
  6004. * Gets the latest created scene
  6005. */
  6006. static readonly LastCreatedScene: Nullable<Scene>;
  6007. }
  6008. }
  6009. declare module BABYLON {
  6010. /**
  6011. * Define options used to create a render target texture
  6012. */
  6013. export class RenderTargetCreationOptions {
  6014. /**
  6015. * Specifies is mipmaps must be generated
  6016. */
  6017. generateMipMaps?: boolean;
  6018. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6019. generateDepthBuffer?: boolean;
  6020. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6021. generateStencilBuffer?: boolean;
  6022. /** Defines texture type (int by default) */
  6023. type?: number;
  6024. /** Defines sampling mode (trilinear by default) */
  6025. samplingMode?: number;
  6026. /** Defines format (RGBA by default) */
  6027. format?: number;
  6028. }
  6029. }
  6030. declare module BABYLON {
  6031. /**
  6032. * @hidden
  6033. **/
  6034. export class _AlphaState {
  6035. private _isAlphaBlendDirty;
  6036. private _isBlendFunctionParametersDirty;
  6037. private _isBlendEquationParametersDirty;
  6038. private _isBlendConstantsDirty;
  6039. private _alphaBlend;
  6040. private _blendFunctionParameters;
  6041. private _blendEquationParameters;
  6042. private _blendConstants;
  6043. /**
  6044. * Initializes the state.
  6045. */
  6046. constructor();
  6047. readonly isDirty: boolean;
  6048. alphaBlend: boolean;
  6049. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6050. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6051. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6052. reset(): void;
  6053. apply(gl: WebGLRenderingContext): void;
  6054. }
  6055. }
  6056. declare module BABYLON {
  6057. /**
  6058. * @hidden
  6059. **/
  6060. export class _DepthCullingState {
  6061. private _isDepthTestDirty;
  6062. private _isDepthMaskDirty;
  6063. private _isDepthFuncDirty;
  6064. private _isCullFaceDirty;
  6065. private _isCullDirty;
  6066. private _isZOffsetDirty;
  6067. private _isFrontFaceDirty;
  6068. private _depthTest;
  6069. private _depthMask;
  6070. private _depthFunc;
  6071. private _cull;
  6072. private _cullFace;
  6073. private _zOffset;
  6074. private _frontFace;
  6075. /**
  6076. * Initializes the state.
  6077. */
  6078. constructor();
  6079. readonly isDirty: boolean;
  6080. zOffset: number;
  6081. cullFace: Nullable<number>;
  6082. cull: Nullable<boolean>;
  6083. depthFunc: Nullable<number>;
  6084. depthMask: boolean;
  6085. depthTest: boolean;
  6086. frontFace: Nullable<number>;
  6087. reset(): void;
  6088. apply(gl: WebGLRenderingContext): void;
  6089. }
  6090. }
  6091. declare module BABYLON {
  6092. /**
  6093. * @hidden
  6094. **/
  6095. export class _StencilState {
  6096. /** 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 */
  6097. static readonly ALWAYS: number;
  6098. /** Passed to stencilOperation to specify that stencil value must be kept */
  6099. static readonly KEEP: number;
  6100. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6101. static readonly REPLACE: number;
  6102. private _isStencilTestDirty;
  6103. private _isStencilMaskDirty;
  6104. private _isStencilFuncDirty;
  6105. private _isStencilOpDirty;
  6106. private _stencilTest;
  6107. private _stencilMask;
  6108. private _stencilFunc;
  6109. private _stencilFuncRef;
  6110. private _stencilFuncMask;
  6111. private _stencilOpStencilFail;
  6112. private _stencilOpDepthFail;
  6113. private _stencilOpStencilDepthPass;
  6114. readonly isDirty: boolean;
  6115. stencilFunc: number;
  6116. stencilFuncRef: number;
  6117. stencilFuncMask: number;
  6118. stencilOpStencilFail: number;
  6119. stencilOpDepthFail: number;
  6120. stencilOpStencilDepthPass: number;
  6121. stencilMask: number;
  6122. stencilTest: boolean;
  6123. constructor();
  6124. reset(): void;
  6125. apply(gl: WebGLRenderingContext): void;
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * @hidden
  6131. **/
  6132. export class _TimeToken { startTimeQuery: Nullable<WebGLQuery>; endTimeQuery: Nullable<WebGLQuery>; timeElapsedQuery: Nullable<WebGLQuery>; timeElapsedQueryEnded: boolean;
  6133. }
  6134. }
  6135. declare module BABYLON {
  6136. /**
  6137. * Internal interface used to track InternalTexture already bound to the GL context
  6138. */
  6139. export interface IInternalTextureTracker {
  6140. /**
  6141. * Gets or set the previous tracker in the list
  6142. */
  6143. previous: Nullable<IInternalTextureTracker>;
  6144. /**
  6145. * Gets or set the next tracker in the list
  6146. */
  6147. next: Nullable<IInternalTextureTracker>;
  6148. }
  6149. /**
  6150. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  6151. */
  6152. export class DummyInternalTextureTracker {
  6153. /**
  6154. * Gets or set the previous tracker in the list
  6155. */
  6156. previous: Nullable<IInternalTextureTracker>;
  6157. /**
  6158. * Gets or set the next tracker in the list
  6159. */
  6160. next: Nullable<IInternalTextureTracker>;
  6161. }
  6162. }
  6163. declare module BABYLON {
  6164. /**
  6165. * Class used to store data associated with WebGL texture data for the engine
  6166. * This class should not be used directly
  6167. */
  6168. export class InternalTexture implements IInternalTextureTracker {
  6169. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6170. /**
  6171. * The source of the texture data is unknown
  6172. */
  6173. static DATASOURCE_UNKNOWN: number;
  6174. /**
  6175. * Texture data comes from an URL
  6176. */
  6177. static DATASOURCE_URL: number;
  6178. /**
  6179. * Texture data is only used for temporary storage
  6180. */
  6181. static DATASOURCE_TEMP: number;
  6182. /**
  6183. * Texture data comes from raw data (ArrayBuffer)
  6184. */
  6185. static DATASOURCE_RAW: number;
  6186. /**
  6187. * Texture content is dynamic (video or dynamic texture)
  6188. */
  6189. static DATASOURCE_DYNAMIC: number;
  6190. /**
  6191. * Texture content is generated by rendering to it
  6192. */
  6193. static DATASOURCE_RENDERTARGET: number;
  6194. /**
  6195. * Texture content is part of a multi render target process
  6196. */
  6197. static DATASOURCE_MULTIRENDERTARGET: number;
  6198. /**
  6199. * Texture data comes from a cube data file
  6200. */
  6201. static DATASOURCE_CUBE: number;
  6202. /**
  6203. * Texture data comes from a raw cube data
  6204. */
  6205. static DATASOURCE_CUBERAW: number;
  6206. /**
  6207. * Texture data come from a prefiltered cube data file
  6208. */
  6209. static DATASOURCE_CUBEPREFILTERED: number;
  6210. /**
  6211. * Texture content is raw 3D data
  6212. */
  6213. static DATASOURCE_RAW3D: number;
  6214. /**
  6215. * Texture content is a depth texture
  6216. */
  6217. static DATASOURCE_DEPTHTEXTURE: number;
  6218. /**
  6219. * Texture data comes from a raw cube data encoded with RGBD
  6220. */
  6221. static DATASOURCE_CUBERAW_RGBD: number;
  6222. /**
  6223. * Defines if the texture is ready
  6224. */
  6225. isReady: boolean;
  6226. /**
  6227. * Defines if the texture is a cube texture
  6228. */
  6229. isCube: boolean;
  6230. /**
  6231. * Defines if the texture contains 3D data
  6232. */
  6233. is3D: boolean;
  6234. /**
  6235. * Defines if the texture contains multiview data
  6236. */
  6237. isMultiview: boolean;
  6238. /**
  6239. * Gets the URL used to load this texture
  6240. */
  6241. url: string;
  6242. /**
  6243. * Gets the sampling mode of the texture
  6244. */
  6245. samplingMode: number;
  6246. /**
  6247. * Gets a boolean indicating if the texture needs mipmaps generation
  6248. */
  6249. generateMipMaps: boolean;
  6250. /**
  6251. * Gets the number of samples used by the texture (WebGL2+ only)
  6252. */
  6253. samples: number;
  6254. /**
  6255. * Gets the type of the texture (int, float...)
  6256. */
  6257. type: number;
  6258. /**
  6259. * Gets the format of the texture (RGB, RGBA...)
  6260. */
  6261. format: number;
  6262. /**
  6263. * Observable called when the texture is loaded
  6264. */
  6265. onLoadedObservable: Observable<InternalTexture>;
  6266. /**
  6267. * Gets the width of the texture
  6268. */
  6269. width: number;
  6270. /**
  6271. * Gets the height of the texture
  6272. */
  6273. height: number;
  6274. /**
  6275. * Gets the depth of the texture
  6276. */
  6277. depth: number;
  6278. /**
  6279. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6280. */
  6281. baseWidth: number;
  6282. /**
  6283. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6284. */
  6285. baseHeight: number;
  6286. /**
  6287. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6288. */
  6289. baseDepth: number;
  6290. /**
  6291. * Gets a boolean indicating if the texture is inverted on Y axis
  6292. */
  6293. invertY: boolean;
  6294. /**
  6295. * Gets or set the previous tracker in the list
  6296. */
  6297. previous: Nullable<IInternalTextureTracker>;
  6298. /**
  6299. * Gets or set the next tracker in the list
  6300. */
  6301. next: Nullable<IInternalTextureTracker>;
  6302. /** @hidden */ invertVScale: boolean;
  6303. /** @hidden */ initialSlot: number;
  6304. /** @hidden */ designatedSlot: number;
  6305. /** @hidden */ dataSource: number;
  6306. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6307. /** @hidden */ bufferView: Nullable<ArrayBufferView>;
  6308. /** @hidden */ bufferViewArray: Nullable<ArrayBufferView[]>;
  6309. /** @hidden */ bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6310. /** @hidden */ size: number;
  6311. /** @hidden */ extension: string;
  6312. /** @hidden */ files: Nullable<string[]>;
  6313. /** @hidden */ workingCanvas: HTMLCanvasElement;
  6314. /** @hidden */ workingContext: CanvasRenderingContext2D;
  6315. /** @hidden */ framebuffer: Nullable<WebGLFramebuffer>;
  6316. /** @hidden */ depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6317. /** @hidden */ MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6318. /** @hidden */ MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6319. /** @hidden */ attachments: Nullable<number[]>;
  6320. /** @hidden */ cachedCoordinatesMode: Nullable<number>;
  6321. /** @hidden */ cachedWrapU: Nullable<number>;
  6322. /** @hidden */ cachedWrapV: Nullable<number>;
  6323. /** @hidden */ cachedWrapR: Nullable<number>;
  6324. /** @hidden */ cachedAnisotropicFilteringLevel: Nullable<number>;
  6325. /** @hidden */ isDisabled: boolean;
  6326. /** @hidden */ compression: Nullable<string>;
  6327. /** @hidden */ generateStencilBuffer: boolean;
  6328. /** @hidden */ generateDepthBuffer: boolean;
  6329. /** @hidden */ comparisonFunction: number;
  6330. /** @hidden */ sphericalPolynomial: Nullable<SphericalPolynomial>;
  6331. /** @hidden */ lodGenerationScale: number;
  6332. /** @hidden */ lodGenerationOffset: number;
  6333. /** @hidden */ colorTextureArray: Nullable<WebGLTexture>;
  6334. /** @hidden */ depthStencilTextureArray: Nullable<WebGLTexture>;
  6335. /** @hidden */ lodTextureHigh: BaseTexture;
  6336. /** @hidden */ lodTextureMid: BaseTexture;
  6337. /** @hidden */ lodTextureLow: BaseTexture;
  6338. /** @hidden */ isRGBD: boolean;
  6339. /** @hidden */ webGLTexture: Nullable<WebGLTexture>;
  6340. /** @hidden */ references: number;
  6341. private _engine;
  6342. /**
  6343. * Gets the Engine the texture belongs to.
  6344. * @returns The babylon engine
  6345. */
  6346. getEngine(): Engine;
  6347. /**
  6348. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6349. */
  6350. readonly dataSource: number;
  6351. /**
  6352. * Creates a new InternalTexture
  6353. * @param engine defines the engine to use
  6354. * @param dataSource defines the type of data that will be used
  6355. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6356. */
  6357. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6358. /**
  6359. * Increments the number of references (ie. the number of Texture that point to it)
  6360. */
  6361. incrementReferences(): void;
  6362. /**
  6363. * Change the size of the texture (not the size of the content)
  6364. * @param width defines the new width
  6365. * @param height defines the new height
  6366. * @param depth defines the new depth (1 by default)
  6367. */
  6368. updateSize(width: int, height: int, depth?: int): void;
  6369. /** @hidden */ rebuild(): void;
  6370. /** @hidden */ swapAndDie(target: InternalTexture): void;
  6371. /**
  6372. * Dispose the current allocated resources
  6373. */
  6374. dispose(): void;
  6375. }
  6376. }
  6377. declare module BABYLON {
  6378. /**
  6379. * This represents the main contract an easing function should follow.
  6380. * Easing functions are used throughout the animation system.
  6381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6382. */
  6383. export interface IEasingFunction {
  6384. /**
  6385. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6386. * of the easing function.
  6387. * The link below provides some of the most common examples of easing functions.
  6388. * @see https://easings.net/
  6389. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6390. * @returns the corresponding value on the curve defined by the easing function
  6391. */
  6392. ease(gradient: number): number;
  6393. }
  6394. /**
  6395. * Base class used for every default easing function.
  6396. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6397. */
  6398. export class EasingFunction implements IEasingFunction {
  6399. /**
  6400. * Interpolation follows the mathematical formula associated with the easing function.
  6401. */
  6402. static readonly EASINGMODE_EASEIN: number;
  6403. /**
  6404. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6405. */
  6406. static readonly EASINGMODE_EASEOUT: number;
  6407. /**
  6408. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6409. */
  6410. static readonly EASINGMODE_EASEINOUT: number;
  6411. private _easingMode;
  6412. /**
  6413. * Sets the easing mode of the current function.
  6414. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6415. */
  6416. setEasingMode(easingMode: number): void;
  6417. /**
  6418. * Gets the current easing mode.
  6419. * @returns the easing mode
  6420. */
  6421. getEasingMode(): number;
  6422. /**
  6423. * @hidden
  6424. */
  6425. easeInCore(gradient: number): number;
  6426. /**
  6427. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6428. * of the easing function.
  6429. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6430. * @returns the corresponding value on the curve defined by the easing function
  6431. */
  6432. ease(gradient: number): number;
  6433. }
  6434. /**
  6435. * Easing function with a circle shape (see link below).
  6436. * @see https://easings.net/#easeInCirc
  6437. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6438. */
  6439. export class CircleEase extends EasingFunction implements IEasingFunction {
  6440. /** @hidden */
  6441. easeInCore(gradient: number): number;
  6442. }
  6443. /**
  6444. * Easing function with a ease back shape (see link below).
  6445. * @see https://easings.net/#easeInBack
  6446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6447. */
  6448. export class BackEase extends EasingFunction implements IEasingFunction {
  6449. /** Defines the amplitude of the function */
  6450. amplitude: number;
  6451. /**
  6452. * Instantiates a back ease easing
  6453. * @see https://easings.net/#easeInBack
  6454. * @param amplitude Defines the amplitude of the function
  6455. */
  6456. constructor(
  6457. /** Defines the amplitude of the function */
  6458. amplitude?: number);
  6459. /** @hidden */
  6460. easeInCore(gradient: number): number;
  6461. }
  6462. /**
  6463. * Easing function with a bouncing shape (see link below).
  6464. * @see https://easings.net/#easeInBounce
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export class BounceEase extends EasingFunction implements IEasingFunction {
  6468. /** Defines the number of bounces */
  6469. bounces: number;
  6470. /** Defines the amplitude of the bounce */
  6471. bounciness: number;
  6472. /**
  6473. * Instantiates a bounce easing
  6474. * @see https://easings.net/#easeInBounce
  6475. * @param bounces Defines the number of bounces
  6476. * @param bounciness Defines the amplitude of the bounce
  6477. */
  6478. constructor(
  6479. /** Defines the number of bounces */
  6480. bounces?: number,
  6481. /** Defines the amplitude of the bounce */
  6482. bounciness?: number);
  6483. /** @hidden */
  6484. easeInCore(gradient: number): number;
  6485. }
  6486. /**
  6487. * Easing function with a power of 3 shape (see link below).
  6488. * @see https://easings.net/#easeInCubic
  6489. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6490. */
  6491. export class CubicEase extends EasingFunction implements IEasingFunction {
  6492. /** @hidden */
  6493. easeInCore(gradient: number): number;
  6494. }
  6495. /**
  6496. * Easing function with an elastic shape (see link below).
  6497. * @see https://easings.net/#easeInElastic
  6498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6499. */
  6500. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6501. /** Defines the number of oscillations*/
  6502. oscillations: number;
  6503. /** Defines the amplitude of the oscillations*/
  6504. springiness: number;
  6505. /**
  6506. * Instantiates an elastic easing function
  6507. * @see https://easings.net/#easeInElastic
  6508. * @param oscillations Defines the number of oscillations
  6509. * @param springiness Defines the amplitude of the oscillations
  6510. */
  6511. constructor(
  6512. /** Defines the number of oscillations*/
  6513. oscillations?: number,
  6514. /** Defines the amplitude of the oscillations*/
  6515. springiness?: number);
  6516. /** @hidden */
  6517. easeInCore(gradient: number): number;
  6518. }
  6519. /**
  6520. * Easing function with an exponential shape (see link below).
  6521. * @see https://easings.net/#easeInExpo
  6522. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6523. */
  6524. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6525. /** Defines the exponent of the function */
  6526. exponent: number;
  6527. /**
  6528. * Instantiates an exponential easing function
  6529. * @see https://easings.net/#easeInExpo
  6530. * @param exponent Defines the exponent of the function
  6531. */
  6532. constructor(
  6533. /** Defines the exponent of the function */
  6534. exponent?: number);
  6535. /** @hidden */
  6536. easeInCore(gradient: number): number;
  6537. }
  6538. /**
  6539. * Easing function with a power shape (see link below).
  6540. * @see https://easings.net/#easeInQuad
  6541. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6542. */
  6543. export class PowerEase extends EasingFunction implements IEasingFunction {
  6544. /** Defines the power of the function */
  6545. power: number;
  6546. /**
  6547. * Instantiates an power base easing function
  6548. * @see https://easings.net/#easeInQuad
  6549. * @param power Defines the power of the function
  6550. */
  6551. constructor(
  6552. /** Defines the power of the function */
  6553. power?: number);
  6554. /** @hidden */
  6555. easeInCore(gradient: number): number;
  6556. }
  6557. /**
  6558. * Easing function with a power of 2 shape (see link below).
  6559. * @see https://easings.net/#easeInQuad
  6560. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6561. */
  6562. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6563. /** @hidden */
  6564. easeInCore(gradient: number): number;
  6565. }
  6566. /**
  6567. * Easing function with a power of 4 shape (see link below).
  6568. * @see https://easings.net/#easeInQuart
  6569. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6570. */
  6571. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6572. /** @hidden */
  6573. easeInCore(gradient: number): number;
  6574. }
  6575. /**
  6576. * Easing function with a power of 5 shape (see link below).
  6577. * @see https://easings.net/#easeInQuint
  6578. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6579. */
  6580. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6581. /** @hidden */
  6582. easeInCore(gradient: number): number;
  6583. }
  6584. /**
  6585. * Easing function with a sin shape (see link below).
  6586. * @see https://easings.net/#easeInSine
  6587. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6588. */
  6589. export class SineEase extends EasingFunction implements IEasingFunction {
  6590. /** @hidden */
  6591. easeInCore(gradient: number): number;
  6592. }
  6593. /**
  6594. * Easing function with a bezier shape (see link below).
  6595. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6596. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6597. */
  6598. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6599. /** Defines the x component of the start tangent in the bezier curve */
  6600. x1: number;
  6601. /** Defines the y component of the start tangent in the bezier curve */
  6602. y1: number;
  6603. /** Defines the x component of the end tangent in the bezier curve */
  6604. x2: number;
  6605. /** Defines the y component of the end tangent in the bezier curve */
  6606. y2: number;
  6607. /**
  6608. * Instantiates a bezier function
  6609. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6610. * @param x1 Defines the x component of the start tangent in the bezier curve
  6611. * @param y1 Defines the y component of the start tangent in the bezier curve
  6612. * @param x2 Defines the x component of the end tangent in the bezier curve
  6613. * @param y2 Defines the y component of the end tangent in the bezier curve
  6614. */
  6615. constructor(
  6616. /** Defines the x component of the start tangent in the bezier curve */
  6617. x1?: number,
  6618. /** Defines the y component of the start tangent in the bezier curve */
  6619. y1?: number,
  6620. /** Defines the x component of the end tangent in the bezier curve */
  6621. x2?: number,
  6622. /** Defines the y component of the end tangent in the bezier curve */
  6623. y2?: number);
  6624. /** @hidden */
  6625. easeInCore(gradient: number): number;
  6626. }
  6627. }
  6628. declare module BABYLON {
  6629. /**
  6630. * Defines an interface which represents an animation key frame
  6631. */
  6632. export interface IAnimationKey {
  6633. /**
  6634. * Frame of the key frame
  6635. */
  6636. frame: number;
  6637. /**
  6638. * Value at the specifies key frame
  6639. */
  6640. value: any;
  6641. /**
  6642. * The input tangent for the cubic hermite spline
  6643. */
  6644. inTangent?: any;
  6645. /**
  6646. * The output tangent for the cubic hermite spline
  6647. */
  6648. outTangent?: any;
  6649. /**
  6650. * The animation interpolation type
  6651. */
  6652. interpolation?: AnimationKeyInterpolation;
  6653. }
  6654. /**
  6655. * Enum for the animation key frame interpolation type
  6656. */
  6657. export enum AnimationKeyInterpolation {
  6658. /**
  6659. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6660. */
  6661. STEP = 1
  6662. }
  6663. }
  6664. declare module BABYLON {
  6665. /**
  6666. * Represents the range of an animation
  6667. */
  6668. export class AnimationRange {
  6669. /**The name of the animation range**/
  6670. name: string;
  6671. /**The starting frame of the animation */
  6672. from: number;
  6673. /**The ending frame of the animation*/
  6674. to: number;
  6675. /**
  6676. * Initializes the range of an animation
  6677. * @param name The name of the animation range
  6678. * @param from The starting frame of the animation
  6679. * @param to The ending frame of the animation
  6680. */
  6681. constructor(
  6682. /**The name of the animation range**/
  6683. name: string,
  6684. /**The starting frame of the animation */
  6685. from: number,
  6686. /**The ending frame of the animation*/
  6687. to: number);
  6688. /**
  6689. * Makes a copy of the animation range
  6690. * @returns A copy of the animation range
  6691. */
  6692. clone(): AnimationRange;
  6693. }
  6694. }
  6695. declare module BABYLON {
  6696. /**
  6697. * Composed of a frame, and an action function
  6698. */
  6699. export class AnimationEvent {
  6700. /** The frame for which the event is triggered **/
  6701. frame: number;
  6702. /** The event to perform when triggered **/
  6703. action: (currentFrame: number) => void;
  6704. /** Specifies if the event should be triggered only once**/
  6705. onlyOnce?: boolean | undefined;
  6706. /**
  6707. * Specifies if the animation event is done
  6708. */
  6709. isDone: boolean;
  6710. /**
  6711. * Initializes the animation event
  6712. * @param frame The frame for which the event is triggered
  6713. * @param action The event to perform when triggered
  6714. * @param onlyOnce Specifies if the event should be triggered only once
  6715. */
  6716. constructor(
  6717. /** The frame for which the event is triggered **/
  6718. frame: number,
  6719. /** The event to perform when triggered **/
  6720. action: (currentFrame: number) => void,
  6721. /** Specifies if the event should be triggered only once**/
  6722. onlyOnce?: boolean | undefined);
  6723. /** @hidden */ clone(): AnimationEvent;
  6724. }
  6725. }
  6726. declare module BABYLON {
  6727. /**
  6728. * Interface used to define a behavior
  6729. */
  6730. export interface Behavior<T> {
  6731. /** gets or sets behavior's name */
  6732. name: string;
  6733. /**
  6734. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6735. */
  6736. init(): void;
  6737. /**
  6738. * Called when the behavior is attached to a target
  6739. * @param target defines the target where the behavior is attached to
  6740. */
  6741. attach(target: T): void;
  6742. /**
  6743. * Called when the behavior is detached from its target
  6744. */
  6745. detach(): void;
  6746. }
  6747. /**
  6748. * Interface implemented by classes supporting behaviors
  6749. */
  6750. export interface IBehaviorAware<T> {
  6751. /**
  6752. * Attach a behavior
  6753. * @param behavior defines the behavior to attach
  6754. * @returns the current host
  6755. */
  6756. addBehavior(behavior: Behavior<T>): T;
  6757. /**
  6758. * Remove a behavior from the current object
  6759. * @param behavior defines the behavior to detach
  6760. * @returns the current host
  6761. */
  6762. removeBehavior(behavior: Behavior<T>): T;
  6763. /**
  6764. * Gets a behavior using its name to search
  6765. * @param name defines the name to search
  6766. * @returns the behavior or null if not found
  6767. */
  6768. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6769. }
  6770. }
  6771. declare module BABYLON {
  6772. /**
  6773. * @hidden
  6774. */
  6775. export class IntersectionInfo {
  6776. bu: Nullable<number>;
  6777. bv: Nullable<number>;
  6778. distance: number;
  6779. faceId: number;
  6780. subMeshId: number;
  6781. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6782. }
  6783. }
  6784. declare module BABYLON {
  6785. /**
  6786. * Class used to store bounding sphere information
  6787. */
  6788. export class BoundingSphere {
  6789. /**
  6790. * Gets the center of the bounding sphere in local space
  6791. */
  6792. readonly center: Vector3;
  6793. /**
  6794. * Radius of the bounding sphere in local space
  6795. */
  6796. radius: number;
  6797. /**
  6798. * Gets the center of the bounding sphere in world space
  6799. */
  6800. readonly centerWorld: Vector3;
  6801. /**
  6802. * Radius of the bounding sphere in world space
  6803. */
  6804. radiusWorld: number;
  6805. /**
  6806. * Gets the minimum vector in local space
  6807. */
  6808. readonly minimum: Vector3;
  6809. /**
  6810. * Gets the maximum vector in local space
  6811. */
  6812. readonly maximum: Vector3;
  6813. private _worldMatrix;
  6814. private static readonly TmpVector3;
  6815. /**
  6816. * Creates a new bounding sphere
  6817. * @param min defines the minimum vector (in local space)
  6818. * @param max defines the maximum vector (in local space)
  6819. * @param worldMatrix defines the new world matrix
  6820. */
  6821. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6822. /**
  6823. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6824. * @param min defines the new minimum vector (in local space)
  6825. * @param max defines the new maximum vector (in local space)
  6826. * @param worldMatrix defines the new world matrix
  6827. */
  6828. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6829. /**
  6830. * Scale the current bounding sphere by applying a scale factor
  6831. * @param factor defines the scale factor to apply
  6832. * @returns the current bounding box
  6833. */
  6834. scale(factor: number): BoundingSphere;
  6835. /**
  6836. * Gets the world matrix of the bounding box
  6837. * @returns a matrix
  6838. */
  6839. getWorldMatrix(): DeepImmutable<Matrix>;
  6840. /** @hidden */ update(worldMatrix: DeepImmutable<Matrix>): void;
  6841. /**
  6842. * Tests if the bounding sphere is intersecting the frustum planes
  6843. * @param frustumPlanes defines the frustum planes to test
  6844. * @returns true if there is an intersection
  6845. */
  6846. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6847. /**
  6848. * Tests if the bounding sphere center is in between the frustum planes.
  6849. * Used for optimistic fast inclusion.
  6850. * @param frustumPlanes defines the frustum planes to test
  6851. * @returns true if the sphere center is in between the frustum planes
  6852. */
  6853. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6854. /**
  6855. * Tests if a point is inside the bounding sphere
  6856. * @param point defines the point to test
  6857. * @returns true if the point is inside the bounding sphere
  6858. */
  6859. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6860. /**
  6861. * Checks if two sphere intersct
  6862. * @param sphere0 sphere 0
  6863. * @param sphere1 sphere 1
  6864. * @returns true if the speres intersect
  6865. */
  6866. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6867. }
  6868. }
  6869. declare module BABYLON {
  6870. /**
  6871. * Class used to store bounding box information
  6872. */
  6873. export class BoundingBox implements ICullable {
  6874. /**
  6875. * Gets the 8 vectors representing the bounding box in local space
  6876. */
  6877. readonly vectors: Vector3[];
  6878. /**
  6879. * Gets the center of the bounding box in local space
  6880. */
  6881. readonly center: Vector3;
  6882. /**
  6883. * Gets the center of the bounding box in world space
  6884. */
  6885. readonly centerWorld: Vector3;
  6886. /**
  6887. * Gets the extend size in local space
  6888. */
  6889. readonly extendSize: Vector3;
  6890. /**
  6891. * Gets the extend size in world space
  6892. */
  6893. readonly extendSizeWorld: Vector3;
  6894. /**
  6895. * Gets the OBB (object bounding box) directions
  6896. */
  6897. readonly directions: Vector3[];
  6898. /**
  6899. * Gets the 8 vectors representing the bounding box in world space
  6900. */
  6901. readonly vectorsWorld: Vector3[];
  6902. /**
  6903. * Gets the minimum vector in world space
  6904. */
  6905. readonly minimumWorld: Vector3;
  6906. /**
  6907. * Gets the maximum vector in world space
  6908. */
  6909. readonly maximumWorld: Vector3;
  6910. /**
  6911. * Gets the minimum vector in local space
  6912. */
  6913. readonly minimum: Vector3;
  6914. /**
  6915. * Gets the maximum vector in local space
  6916. */
  6917. readonly maximum: Vector3;
  6918. private _worldMatrix;
  6919. private static readonly TmpVector3;
  6920. /**
  6921. * @hidden
  6922. */ tag: number;
  6923. /**
  6924. * Creates a new bounding box
  6925. * @param min defines the minimum vector (in local space)
  6926. * @param max defines the maximum vector (in local space)
  6927. * @param worldMatrix defines the new world matrix
  6928. */
  6929. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6930. /**
  6931. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6932. * @param min defines the new minimum vector (in local space)
  6933. * @param max defines the new maximum vector (in local space)
  6934. * @param worldMatrix defines the new world matrix
  6935. */
  6936. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6937. /**
  6938. * Scale the current bounding box by applying a scale factor
  6939. * @param factor defines the scale factor to apply
  6940. * @returns the current bounding box
  6941. */
  6942. scale(factor: number): BoundingBox;
  6943. /**
  6944. * Gets the world matrix of the bounding box
  6945. * @returns a matrix
  6946. */
  6947. getWorldMatrix(): DeepImmutable<Matrix>;
  6948. /** @hidden */ update(world: DeepImmutable<Matrix>): void;
  6949. /**
  6950. * Tests if the bounding box is intersecting the frustum planes
  6951. * @param frustumPlanes defines the frustum planes to test
  6952. * @returns true if there is an intersection
  6953. */
  6954. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6955. /**
  6956. * Tests if the bounding box is entirely inside the frustum planes
  6957. * @param frustumPlanes defines the frustum planes to test
  6958. * @returns true if there is an inclusion
  6959. */
  6960. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6961. /**
  6962. * Tests if a point is inside the bounding box
  6963. * @param point defines the point to test
  6964. * @returns true if the point is inside the bounding box
  6965. */
  6966. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6967. /**
  6968. * Tests if the bounding box intersects with a bounding sphere
  6969. * @param sphere defines the sphere to test
  6970. * @returns true if there is an intersection
  6971. */
  6972. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6973. /**
  6974. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6975. * @param min defines the min vector to use
  6976. * @param max defines the max vector to use
  6977. * @returns true if there is an intersection
  6978. */
  6979. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6980. /**
  6981. * Tests if two bounding boxes are intersections
  6982. * @param box0 defines the first box to test
  6983. * @param box1 defines the second box to test
  6984. * @returns true if there is an intersection
  6985. */
  6986. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6987. /**
  6988. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6989. * @param minPoint defines the minimum vector of the bounding box
  6990. * @param maxPoint defines the maximum vector of the bounding box
  6991. * @param sphereCenter defines the sphere center
  6992. * @param sphereRadius defines the sphere radius
  6993. * @returns true if there is an intersection
  6994. */
  6995. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6996. /**
  6997. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6998. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @return true if there is an inclusion
  7001. */
  7002. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7005. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @return true if there is an intersection
  7008. */
  7009. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. }
  7011. }
  7012. declare module BABYLON {
  7013. /** @hidden */
  7014. export class Collider {
  7015. /** Define if a collision was found */
  7016. collisionFound: boolean;
  7017. /**
  7018. * Define last intersection point in local space
  7019. */
  7020. intersectionPoint: Vector3;
  7021. /**
  7022. * Define last collided mesh
  7023. */
  7024. collidedMesh: Nullable<AbstractMesh>;
  7025. private _collisionPoint;
  7026. private _planeIntersectionPoint;
  7027. private _tempVector;
  7028. private _tempVector2;
  7029. private _tempVector3;
  7030. private _tempVector4;
  7031. private _edge;
  7032. private _baseToVertex;
  7033. private _destinationPoint;
  7034. private _slidePlaneNormal;
  7035. private _displacementVector;
  7036. /** @hidden */ radius: Vector3;
  7037. /** @hidden */ retry: number;
  7038. private _velocity;
  7039. private _basePoint;
  7040. private _epsilon;
  7041. /** @hidden */ velocityWorldLength: number;
  7042. /** @hidden */ basePointWorld: Vector3;
  7043. private _velocityWorld;
  7044. private _normalizedVelocity;
  7045. /** @hidden */ initialVelocity: Vector3;
  7046. /** @hidden */ initialPosition: Vector3;
  7047. private _nearestDistance;
  7048. private _collisionMask;
  7049. collisionMask: number;
  7050. /**
  7051. * Gets the plane normal used to compute the sliding response (in local space)
  7052. */
  7053. readonly slidePlaneNormal: Vector3;
  7054. /** @hidden */ initialize(source: Vector3, dir: Vector3, e: number): void;
  7055. /** @hidden */ checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7056. /** @hidden */ canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7057. /** @hidden */ testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7058. /** @hidden */ collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7059. /** @hidden */ getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module BABYLON {
  7063. /**
  7064. * Interface for cullable objects
  7065. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7066. */
  7067. export interface ICullable {
  7068. /**
  7069. * Checks if the object or part of the object is in the frustum
  7070. * @param frustumPlanes Camera near/planes
  7071. * @returns true if the object is in frustum otherwise false
  7072. */
  7073. isInFrustum(frustumPlanes: Plane[]): boolean;
  7074. /**
  7075. * Checks if a cullable object (mesh...) is in the camera frustum
  7076. * Unlike isInFrustum this cheks the full bounding box
  7077. * @param frustumPlanes Camera near/planes
  7078. * @returns true if the object is in frustum otherwise false
  7079. */
  7080. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7081. }
  7082. /**
  7083. * Info for a bounding data of a mesh
  7084. */
  7085. export class BoundingInfo implements ICullable {
  7086. /**
  7087. * Bounding box for the mesh
  7088. */
  7089. readonly boundingBox: BoundingBox;
  7090. /**
  7091. * Bounding sphere for the mesh
  7092. */
  7093. readonly boundingSphere: BoundingSphere;
  7094. private _isLocked;
  7095. private static readonly TmpVector3;
  7096. /**
  7097. * Constructs bounding info
  7098. * @param minimum min vector of the bounding box/sphere
  7099. * @param maximum max vector of the bounding box/sphere
  7100. * @param worldMatrix defines the new world matrix
  7101. */
  7102. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7103. /**
  7104. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7105. * @param min defines the new minimum vector (in local space)
  7106. * @param max defines the new maximum vector (in local space)
  7107. * @param worldMatrix defines the new world matrix
  7108. */
  7109. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7110. /**
  7111. * min vector of the bounding box/sphere
  7112. */
  7113. readonly minimum: Vector3;
  7114. /**
  7115. * max vector of the bounding box/sphere
  7116. */
  7117. readonly maximum: Vector3;
  7118. /**
  7119. * If the info is locked and won't be updated to avoid perf overhead
  7120. */
  7121. isLocked: boolean;
  7122. /**
  7123. * Updates the bounding sphere and box
  7124. * @param world world matrix to be used to update
  7125. */
  7126. update(world: DeepImmutable<Matrix>): void;
  7127. /**
  7128. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7129. * @param center New center of the bounding info
  7130. * @param extend New extend of the bounding info
  7131. * @returns the current bounding info
  7132. */
  7133. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7134. /**
  7135. * Scale the current bounding info by applying a scale factor
  7136. * @param factor defines the scale factor to apply
  7137. * @returns the current bounding info
  7138. */
  7139. scale(factor: number): BoundingInfo;
  7140. /**
  7141. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7142. * @param frustumPlanes defines the frustum to test
  7143. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7144. * @returns true if the bounding info is in the frustum planes
  7145. */
  7146. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7147. /**
  7148. * Gets the world distance between the min and max points of the bounding box
  7149. */
  7150. readonly diagonalLength: number;
  7151. /**
  7152. * Checks if a cullable object (mesh...) is in the camera frustum
  7153. * Unlike isInFrustum this cheks the full bounding box
  7154. * @param frustumPlanes Camera near/planes
  7155. * @returns true if the object is in frustum otherwise false
  7156. */
  7157. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7158. /** @hidden */ checkCollision(collider: Collider): boolean;
  7159. /**
  7160. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7161. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7162. * @param point the point to check intersection with
  7163. * @returns if the point intersects
  7164. */
  7165. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7166. /**
  7167. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7168. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7169. * @param boundingInfo the bounding info to check intersection with
  7170. * @param precise if the intersection should be done using OBB
  7171. * @returns if the bounding info intersects
  7172. */
  7173. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7174. }
  7175. }
  7176. declare module BABYLON {
  7177. /**
  7178. * Defines an array and its length.
  7179. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7180. */
  7181. export interface ISmartArrayLike<T> {
  7182. /**
  7183. * The data of the array.
  7184. */
  7185. data: Array<T>;
  7186. /**
  7187. * The active length of the array.
  7188. */
  7189. length: number;
  7190. }
  7191. /**
  7192. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7193. */
  7194. export class SmartArray<T> implements ISmartArrayLike<T> {
  7195. /**
  7196. * The full set of data from the array.
  7197. */
  7198. data: Array<T>;
  7199. /**
  7200. * The active length of the array.
  7201. */
  7202. length: number;
  7203. protected _id: number;
  7204. /**
  7205. * Instantiates a Smart Array.
  7206. * @param capacity defines the default capacity of the array.
  7207. */
  7208. constructor(capacity: number);
  7209. /**
  7210. * Pushes a value at the end of the active data.
  7211. * @param value defines the object to push in the array.
  7212. */
  7213. push(value: T): void;
  7214. /**
  7215. * Iterates over the active data and apply the lambda to them.
  7216. * @param func defines the action to apply on each value.
  7217. */
  7218. forEach(func: (content: T) => void): void;
  7219. /**
  7220. * Sorts the full sets of data.
  7221. * @param compareFn defines the comparison function to apply.
  7222. */
  7223. sort(compareFn: (a: T, b: T) => number): void;
  7224. /**
  7225. * Resets the active data to an empty array.
  7226. */
  7227. reset(): void;
  7228. /**
  7229. * Releases all the data from the array as well as the array.
  7230. */
  7231. dispose(): void;
  7232. /**
  7233. * Concats the active data with a given array.
  7234. * @param array defines the data to concatenate with.
  7235. */
  7236. concat(array: any): void;
  7237. /**
  7238. * Returns the position of a value in the active data.
  7239. * @param value defines the value to find the index for
  7240. * @returns the index if found in the active data otherwise -1
  7241. */
  7242. indexOf(value: T): number;
  7243. /**
  7244. * Returns whether an element is part of the active data.
  7245. * @param value defines the value to look for
  7246. * @returns true if found in the active data otherwise false
  7247. */
  7248. contains(value: T): boolean;
  7249. private static _GlobalId;
  7250. }
  7251. /**
  7252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7253. * The data in this array can only be present once
  7254. */
  7255. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7256. private _duplicateId;
  7257. /**
  7258. * Pushes a value at the end of the active data.
  7259. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7260. * @param value defines the object to push in the array.
  7261. */
  7262. push(value: T): void;
  7263. /**
  7264. * Pushes a value at the end of the active data.
  7265. * If the data is already present, it won t be added again
  7266. * @param value defines the object to push in the array.
  7267. * @returns true if added false if it was already present
  7268. */
  7269. pushNoDuplicate(value: T): boolean;
  7270. /**
  7271. * Resets the active data to an empty array.
  7272. */
  7273. reset(): void;
  7274. /**
  7275. * Concats the active data with a given array.
  7276. * This ensures no dupplicate will be present in the result.
  7277. * @param array defines the data to concatenate with.
  7278. */
  7279. concatWithNoDuplicate(array: any): void;
  7280. }
  7281. }
  7282. declare module BABYLON {
  7283. /**
  7284. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7285. * separate meshes. This can be use to improve performances.
  7286. * @see http://doc.babylonjs.com/how_to/multi_materials
  7287. */
  7288. export class MultiMaterial extends Material {
  7289. private _subMaterials;
  7290. /**
  7291. * Gets or Sets the list of Materials used within the multi material.
  7292. * They need to be ordered according to the submeshes order in the associated mesh
  7293. */
  7294. subMaterials: Nullable<Material>[];
  7295. /**
  7296. * Function used to align with Node.getChildren()
  7297. * @returns the list of Materials used within the multi material
  7298. */
  7299. getChildren(): Nullable<Material>[];
  7300. /**
  7301. * Instantiates a new Multi Material
  7302. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7303. * separate meshes. This can be use to improve performances.
  7304. * @see http://doc.babylonjs.com/how_to/multi_materials
  7305. * @param name Define the name in the scene
  7306. * @param scene Define the scene the material belongs to
  7307. */
  7308. constructor(name: string, scene: Scene);
  7309. private _hookArray;
  7310. /**
  7311. * Get one of the submaterial by its index in the submaterials array
  7312. * @param index The index to look the sub material at
  7313. * @returns The Material if the index has been defined
  7314. */
  7315. getSubMaterial(index: number): Nullable<Material>;
  7316. /**
  7317. * Get the list of active textures for the whole sub materials list.
  7318. * @returns All the textures that will be used during the rendering
  7319. */
  7320. getActiveTextures(): BaseTexture[];
  7321. /**
  7322. * Gets the current class name of the material e.g. "MultiMaterial"
  7323. * Mainly use in serialization.
  7324. * @returns the class name
  7325. */
  7326. getClassName(): string;
  7327. /**
  7328. * Checks if the material is ready to render the requested sub mesh
  7329. * @param mesh Define the mesh the submesh belongs to
  7330. * @param subMesh Define the sub mesh to look readyness for
  7331. * @param useInstances Define whether or not the material is used with instances
  7332. * @returns true if ready, otherwise false
  7333. */
  7334. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7335. /**
  7336. * Clones the current material and its related sub materials
  7337. * @param name Define the name of the newly cloned material
  7338. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7339. * @returns the cloned material
  7340. */
  7341. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7342. /**
  7343. * Serializes the materials into a JSON representation.
  7344. * @returns the JSON representation
  7345. */
  7346. serialize(): any;
  7347. /**
  7348. * Dispose the material and release its associated resources
  7349. * @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)
  7350. * @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)
  7351. * @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)
  7352. */
  7353. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7354. /**
  7355. * Creates a MultiMaterial from parsed MultiMaterial data.
  7356. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7357. * @param scene defines the hosting scene
  7358. * @returns a new MultiMaterial
  7359. */
  7360. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7361. }
  7362. }
  7363. declare module BABYLON {
  7364. /**
  7365. * Class used to represent data loading progression
  7366. */
  7367. export class SceneLoaderFlags {
  7368. private static _ForceFullSceneLoadingForIncremental;
  7369. private static _ShowLoadingScreen;
  7370. private static _CleanBoneMatrixWeights;
  7371. private static _loggingLevel;
  7372. /**
  7373. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7374. */
  7375. static ForceFullSceneLoadingForIncremental: boolean;
  7376. /**
  7377. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7378. */
  7379. static ShowLoadingScreen: boolean;
  7380. /**
  7381. * Defines the current logging level (while loading the scene)
  7382. * @ignorenaming
  7383. */
  7384. static loggingLevel: number;
  7385. /**
  7386. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7387. */
  7388. static CleanBoneMatrixWeights: boolean;
  7389. }
  7390. }
  7391. declare module BABYLON {
  7392. /**
  7393. * 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.
  7394. * @see https://doc.babylonjs.com/how_to/transformnode
  7395. */
  7396. export class TransformNode extends Node {
  7397. /**
  7398. * Object will not rotate to face the camera
  7399. */
  7400. static BILLBOARDMODE_NONE: number;
  7401. /**
  7402. * Object will rotate to face the camera but only on the x axis
  7403. */
  7404. static BILLBOARDMODE_X: number;
  7405. /**
  7406. * Object will rotate to face the camera but only on the y axis
  7407. */
  7408. static BILLBOARDMODE_Y: number;
  7409. /**
  7410. * Object will rotate to face the camera but only on the z axis
  7411. */
  7412. static BILLBOARDMODE_Z: number;
  7413. /**
  7414. * Object will rotate to face the camera
  7415. */
  7416. static BILLBOARDMODE_ALL: number;
  7417. private _forward;
  7418. private _forwardInverted;
  7419. private _up;
  7420. private _right;
  7421. private _rightInverted;
  7422. private _position;
  7423. private _rotation;
  7424. private _rotationQuaternion;
  7425. protected _scaling: Vector3;
  7426. protected _isDirty: boolean;
  7427. private _transformToBoneReferal;
  7428. /**
  7429. * Set the billboard mode. Default is 0.
  7430. *
  7431. * | Value | Type | Description |
  7432. * | --- | --- | --- |
  7433. * | 0 | BILLBOARDMODE_NONE | |
  7434. * | 1 | BILLBOARDMODE_X | |
  7435. * | 2 | BILLBOARDMODE_Y | |
  7436. * | 4 | BILLBOARDMODE_Z | |
  7437. * | 7 | BILLBOARDMODE_ALL | |
  7438. *
  7439. */
  7440. billboardMode: number;
  7441. /**
  7442. * 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
  7443. */
  7444. scalingDeterminant: number;
  7445. /**
  7446. * Sets the distance of the object to max, often used by skybox
  7447. */
  7448. infiniteDistance: boolean;
  7449. /**
  7450. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7451. * By default the system will update normals to compensate
  7452. */
  7453. ignoreNonUniformScaling: boolean;
  7454. /** @hidden */ poseMatrix: Matrix;
  7455. /** @hidden */ localMatrix: Matrix;
  7456. private _absolutePosition;
  7457. private _pivotMatrix;
  7458. private _pivotMatrixInverse;
  7459. protected _postMultiplyPivotMatrix: boolean;
  7460. private _tempMatrix;
  7461. private _tempMatrix2;
  7462. protected _isWorldMatrixFrozen: boolean;
  7463. /** @hidden */ indexInSceneTransformNodesArray: number;
  7464. /**
  7465. * An event triggered after the world matrix is updated
  7466. */
  7467. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7468. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7469. /**
  7470. * Gets a string identifying the name of the class
  7471. * @returns "TransformNode" string
  7472. */
  7473. getClassName(): string;
  7474. /**
  7475. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7476. */
  7477. position: Vector3;
  7478. /**
  7479. * 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)).
  7480. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7481. */
  7482. rotation: Vector3;
  7483. /**
  7484. * 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)).
  7485. */
  7486. scaling: Vector3;
  7487. /**
  7488. * 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).
  7489. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7490. */
  7491. rotationQuaternion: Nullable<Quaternion>;
  7492. /**
  7493. * The forward direction of that transform in world space.
  7494. */
  7495. readonly forward: Vector3;
  7496. /**
  7497. * The up direction of that transform in world space.
  7498. */
  7499. readonly up: Vector3;
  7500. /**
  7501. * The right direction of that transform in world space.
  7502. */
  7503. readonly right: Vector3;
  7504. /**
  7505. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7506. * @param matrix the matrix to copy the pose from
  7507. * @returns this TransformNode.
  7508. */
  7509. updatePoseMatrix(matrix: Matrix): TransformNode;
  7510. /**
  7511. * Returns the mesh Pose matrix.
  7512. * @returns the pose matrix
  7513. */
  7514. getPoseMatrix(): Matrix;
  7515. /** @hidden */ isSynchronized(): boolean;
  7516. /** @hidden */ initCache(): void;
  7517. /**
  7518. * Flag the transform node as dirty (Forcing it to update everything)
  7519. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7520. * @returns this transform node
  7521. */
  7522. markAsDirty(property: string): TransformNode;
  7523. /**
  7524. * Returns the current mesh absolute position.
  7525. * Returns a Vector3.
  7526. */
  7527. readonly absolutePosition: Vector3;
  7528. /**
  7529. * Sets a new matrix to apply before all other transformation
  7530. * @param matrix defines the transform matrix
  7531. * @returns the current TransformNode
  7532. */
  7533. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7534. /**
  7535. * Sets a new pivot matrix to the current node
  7536. * @param matrix defines the new pivot matrix to use
  7537. * @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
  7538. * @returns the current TransformNode
  7539. */
  7540. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7541. /**
  7542. * Returns the mesh pivot matrix.
  7543. * Default : Identity.
  7544. * @returns the matrix
  7545. */
  7546. getPivotMatrix(): Matrix;
  7547. /**
  7548. * Prevents the World matrix to be computed any longer.
  7549. * @returns the TransformNode.
  7550. */
  7551. freezeWorldMatrix(): TransformNode;
  7552. /**
  7553. * Allows back the World matrix computation.
  7554. * @returns the TransformNode.
  7555. */
  7556. unfreezeWorldMatrix(): this;
  7557. /**
  7558. * True if the World matrix has been frozen.
  7559. */
  7560. readonly isWorldMatrixFrozen: boolean;
  7561. /**
  7562. * Retuns the mesh absolute position in the World.
  7563. * @returns a Vector3.
  7564. */
  7565. getAbsolutePosition(): Vector3;
  7566. /**
  7567. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7568. * @param absolutePosition the absolute position to set
  7569. * @returns the TransformNode.
  7570. */
  7571. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7572. /**
  7573. * Sets the mesh position in its local space.
  7574. * @param vector3 the position to set in localspace
  7575. * @returns the TransformNode.
  7576. */
  7577. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7578. /**
  7579. * Returns the mesh position in the local space from the current World matrix values.
  7580. * @returns a new Vector3.
  7581. */
  7582. getPositionExpressedInLocalSpace(): Vector3;
  7583. /**
  7584. * Translates the mesh along the passed Vector3 in its local space.
  7585. * @param vector3 the distance to translate in localspace
  7586. * @returns the TransformNode.
  7587. */
  7588. locallyTranslate(vector3: Vector3): TransformNode;
  7589. private static _lookAtVectorCache;
  7590. /**
  7591. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7592. * @param targetPoint the position (must be in same space as current mesh) to look at
  7593. * @param yawCor optional yaw (y-axis) correction in radians
  7594. * @param pitchCor optional pitch (x-axis) correction in radians
  7595. * @param rollCor optional roll (z-axis) correction in radians
  7596. * @param space the choosen space of the target
  7597. * @returns the TransformNode.
  7598. */
  7599. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7600. /**
  7601. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7602. * This Vector3 is expressed in the World space.
  7603. * @param localAxis axis to rotate
  7604. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7605. */
  7606. getDirection(localAxis: Vector3): Vector3;
  7607. /**
  7608. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7609. * localAxis is expressed in the mesh local space.
  7610. * result is computed in the Wordl space from the mesh World matrix.
  7611. * @param localAxis axis to rotate
  7612. * @param result the resulting transformnode
  7613. * @returns this TransformNode.
  7614. */
  7615. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7616. /**
  7617. * Sets this transform node rotation to the given local axis.
  7618. * @param localAxis the axis in local space
  7619. * @param yawCor optional yaw (y-axis) correction in radians
  7620. * @param pitchCor optional pitch (x-axis) correction in radians
  7621. * @param rollCor optional roll (z-axis) correction in radians
  7622. * @returns this TransformNode
  7623. */
  7624. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7625. /**
  7626. * Sets a new pivot point to the current node
  7627. * @param point defines the new pivot point to use
  7628. * @param space defines if the point is in world or local space (local by default)
  7629. * @returns the current TransformNode
  7630. */
  7631. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7632. /**
  7633. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7634. * @returns the pivot point
  7635. */
  7636. getPivotPoint(): Vector3;
  7637. /**
  7638. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7639. * @param result the vector3 to store the result
  7640. * @returns this TransformNode.
  7641. */
  7642. getPivotPointToRef(result: Vector3): TransformNode;
  7643. /**
  7644. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7645. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7646. */
  7647. getAbsolutePivotPoint(): Vector3;
  7648. /**
  7649. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7650. * @param result vector3 to store the result
  7651. * @returns this TransformNode.
  7652. */
  7653. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7654. /**
  7655. * Defines the passed node as the parent of the current node.
  7656. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7657. * @see https://doc.babylonjs.com/how_to/parenting
  7658. * @param node the node ot set as the parent
  7659. * @returns this TransformNode.
  7660. */
  7661. setParent(node: Nullable<Node>): TransformNode;
  7662. private _nonUniformScaling;
  7663. /**
  7664. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7665. */
  7666. readonly nonUniformScaling: boolean;
  7667. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  7668. /**
  7669. * Attach the current TransformNode to another TransformNode associated with a bone
  7670. * @param bone Bone affecting the TransformNode
  7671. * @param affectedTransformNode TransformNode associated with the bone
  7672. * @returns this object
  7673. */
  7674. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7675. /**
  7676. * Detach the transform node if its associated with a bone
  7677. * @returns this object
  7678. */
  7679. detachFromBone(): TransformNode;
  7680. private static _rotationAxisCache;
  7681. /**
  7682. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7683. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7684. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7685. * The passed axis is also normalized.
  7686. * @param axis the axis to rotate around
  7687. * @param amount the amount to rotate in radians
  7688. * @param space Space to rotate in (Default: local)
  7689. * @returns the TransformNode.
  7690. */
  7691. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7692. /**
  7693. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7694. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7695. * The passed axis is also normalized. .
  7696. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7697. * @param point the point to rotate around
  7698. * @param axis the axis to rotate around
  7699. * @param amount the amount to rotate in radians
  7700. * @returns the TransformNode
  7701. */
  7702. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7703. /**
  7704. * Translates the mesh along the axis vector for the passed distance in the given space.
  7705. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7706. * @param axis the axis to translate in
  7707. * @param distance the distance to translate
  7708. * @param space Space to rotate in (Default: local)
  7709. * @returns the TransformNode.
  7710. */
  7711. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7712. /**
  7713. * Adds a rotation step to the mesh current rotation.
  7714. * x, y, z are Euler angles expressed in radians.
  7715. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7716. * This means this rotation is made in the mesh local space only.
  7717. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7718. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7719. * ```javascript
  7720. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7721. * ```
  7722. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7723. * 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.
  7724. * @param x Rotation to add
  7725. * @param y Rotation to add
  7726. * @param z Rotation to add
  7727. * @returns the TransformNode.
  7728. */
  7729. addRotation(x: number, y: number, z: number): TransformNode;
  7730. /**
  7731. * Computes the world matrix of the node
  7732. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7733. * @returns the world matrix
  7734. */
  7735. computeWorldMatrix(force?: boolean): Matrix;
  7736. protected _afterComputeWorldMatrix(): void;
  7737. /**
  7738. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7739. * @param func callback function to add
  7740. *
  7741. * @returns the TransformNode.
  7742. */
  7743. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7744. /**
  7745. * Removes a registered callback function.
  7746. * @param func callback function to remove
  7747. * @returns the TransformNode.
  7748. */
  7749. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7750. /**
  7751. * Gets the position of the current mesh in camera space
  7752. * @param camera defines the camera to use
  7753. * @returns a position
  7754. */
  7755. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7756. /**
  7757. * Returns the distance from the mesh to the active camera
  7758. * @param camera defines the camera to use
  7759. * @returns the distance
  7760. */
  7761. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7762. /**
  7763. * Clone the current transform node
  7764. * @param name Name of the new clone
  7765. * @param newParent New parent for the clone
  7766. * @param doNotCloneChildren Do not clone children hierarchy
  7767. * @returns the new transform node
  7768. */
  7769. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7770. /**
  7771. * Serializes the objects information.
  7772. * @param currentSerializationObject defines the object to serialize in
  7773. * @returns the serialized object
  7774. */
  7775. serialize(currentSerializationObject?: any): any;
  7776. /**
  7777. * Returns a new TransformNode object parsed from the source provided.
  7778. * @param parsedTransformNode is the source.
  7779. * @param scene the scne the object belongs to
  7780. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7781. * @returns a new TransformNode object parsed from the source provided.
  7782. */
  7783. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7784. /**
  7785. * Get all child-transformNodes of this node
  7786. * @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
  7787. * @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
  7788. * @returns an array of TransformNode
  7789. */
  7790. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7791. /**
  7792. * Releases resources associated with this transform node.
  7793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7795. */
  7796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7797. }
  7798. }
  7799. declare module BABYLON {
  7800. /**
  7801. * Class used to override all child animations of a given target
  7802. */
  7803. export class AnimationPropertiesOverride {
  7804. /**
  7805. * Gets or sets a value indicating if animation blending must be used
  7806. */
  7807. enableBlending: boolean;
  7808. /**
  7809. * Gets or sets the blending speed to use when enableBlending is true
  7810. */
  7811. blendingSpeed: number;
  7812. /**
  7813. * Gets or sets the default loop mode to use
  7814. */
  7815. loopMode: number;
  7816. }
  7817. }
  7818. declare module BABYLON {
  7819. /**
  7820. * Class used to store bone information
  7821. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7822. */
  7823. export class Bone extends Node {
  7824. /**
  7825. * defines the bone name
  7826. */
  7827. name: string;
  7828. private static _tmpVecs;
  7829. private static _tmpQuat;
  7830. private static _tmpMats;
  7831. /**
  7832. * Gets the list of child bones
  7833. */
  7834. children: Bone[];
  7835. /** Gets the animations associated with this bone */
  7836. animations: Animation[];
  7837. /**
  7838. * Gets or sets bone length
  7839. */
  7840. length: number;
  7841. /**
  7842. * @hidden Internal only
  7843. * Set this value to map this bone to a different index in the transform matrices
  7844. * Set this value to -1 to exclude the bone from the transform matrices
  7845. */ index: Nullable<number>;
  7846. private _skeleton;
  7847. private _localMatrix;
  7848. private _restPose;
  7849. private _baseMatrix;
  7850. private _absoluteTransform;
  7851. private _invertedAbsoluteTransform;
  7852. private _parent;
  7853. private _scalingDeterminant;
  7854. private _worldTransform;
  7855. private _localScaling;
  7856. private _localRotation;
  7857. private _localPosition;
  7858. private _needToDecompose;
  7859. private _needToCompose;
  7860. /** @hidden */ linkedTransformNode: Nullable<TransformNode>;
  7861. /** @hidden */
  7862. /** @hidden */ matrix: Matrix;
  7863. /**
  7864. * Create a new bone
  7865. * @param name defines the bone name
  7866. * @param skeleton defines the parent skeleton
  7867. * @param parentBone defines the parent (can be null if the bone is the root)
  7868. * @param localMatrix defines the local matrix
  7869. * @param restPose defines the rest pose matrix
  7870. * @param baseMatrix defines the base matrix
  7871. * @param index defines index of the bone in the hiearchy
  7872. */
  7873. constructor(
  7874. /**
  7875. * defines the bone name
  7876. */
  7877. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7878. /**
  7879. * Gets the current object class name.
  7880. * @return the class name
  7881. */
  7882. getClassName(): string;
  7883. /**
  7884. * Gets the parent skeleton
  7885. * @returns a skeleton
  7886. */
  7887. getSkeleton(): Skeleton;
  7888. /**
  7889. * Gets parent bone
  7890. * @returns a bone or null if the bone is the root of the bone hierarchy
  7891. */
  7892. getParent(): Nullable<Bone>;
  7893. /**
  7894. * Returns an array containing the root bones
  7895. * @returns an array containing the root bones
  7896. */
  7897. getChildren(): Array<Bone>;
  7898. /**
  7899. * Sets the parent bone
  7900. * @param parent defines the parent (can be null if the bone is the root)
  7901. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7902. */
  7903. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7904. /**
  7905. * Gets the local matrix
  7906. * @returns a matrix
  7907. */
  7908. getLocalMatrix(): Matrix;
  7909. /**
  7910. * Gets the base matrix (initial matrix which remains unchanged)
  7911. * @returns a matrix
  7912. */
  7913. getBaseMatrix(): Matrix;
  7914. /**
  7915. * Gets the rest pose matrix
  7916. * @returns a matrix
  7917. */
  7918. getRestPose(): Matrix;
  7919. /**
  7920. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7921. */
  7922. getWorldMatrix(): Matrix;
  7923. /**
  7924. * Sets the local matrix to rest pose matrix
  7925. */
  7926. returnToRest(): void;
  7927. /**
  7928. * Gets the inverse of the absolute transform matrix.
  7929. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  7930. * @returns a matrix
  7931. */
  7932. getInvertedAbsoluteTransform(): Matrix;
  7933. /**
  7934. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  7935. * @returns a matrix
  7936. */
  7937. getAbsoluteTransform(): Matrix;
  7938. /**
  7939. * Links with the given transform node.
  7940. * The local matrix of this bone is copied from the transform node every frame.
  7941. * @param transformNode defines the transform node to link to
  7942. */
  7943. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  7944. /** Gets or sets current position (in local space) */
  7945. position: Vector3;
  7946. /** Gets or sets current rotation (in local space) */
  7947. rotation: Vector3;
  7948. /** Gets or sets current rotation quaternion (in local space) */
  7949. rotationQuaternion: Quaternion;
  7950. /** Gets or sets current scaling (in local space) */
  7951. scaling: Vector3;
  7952. /**
  7953. * Gets the animation properties override
  7954. */
  7955. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  7956. private _decompose;
  7957. private _compose;
  7958. /**
  7959. * Update the base and local matrices
  7960. * @param matrix defines the new base or local matrix
  7961. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7962. * @param updateLocalMatrix defines if the local matrix should be updated
  7963. */
  7964. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  7965. /** @hidden */ updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  7966. /**
  7967. * Flag the bone as dirty (Forcing it to update everything)
  7968. */
  7969. markAsDirty(): void;
  7970. private _markAsDirtyAndCompose;
  7971. private _markAsDirtyAndDecompose;
  7972. /**
  7973. * Translate the bone in local or world space
  7974. * @param vec The amount to translate the bone
  7975. * @param space The space that the translation is in
  7976. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7977. */
  7978. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7979. /**
  7980. * Set the postion of the bone in local or world space
  7981. * @param position The position to set the bone
  7982. * @param space The space that the position is in
  7983. * @param mesh The mesh that this bone is attached to. This is only used in world space
  7984. */
  7985. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  7986. /**
  7987. * Set the absolute position of the bone (world space)
  7988. * @param position The position to set the bone
  7989. * @param mesh The mesh that this bone is attached to
  7990. */
  7991. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  7992. /**
  7993. * Scale the bone on the x, y and z axes (in local space)
  7994. * @param x The amount to scale the bone on the x axis
  7995. * @param y The amount to scale the bone on the y axis
  7996. * @param z The amount to scale the bone on the z axis
  7997. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  7998. */
  7999. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8000. /**
  8001. * Set the bone scaling in local space
  8002. * @param scale defines the scaling vector
  8003. */
  8004. setScale(scale: Vector3): void;
  8005. /**
  8006. * Gets the current scaling in local space
  8007. * @returns the current scaling vector
  8008. */
  8009. getScale(): Vector3;
  8010. /**
  8011. * Gets the current scaling in local space and stores it in a target vector
  8012. * @param result defines the target vector
  8013. */
  8014. getScaleToRef(result: Vector3): void;
  8015. /**
  8016. * Set the yaw, pitch, and roll of the bone in local or world space
  8017. * @param yaw The rotation of the bone on the y axis
  8018. * @param pitch The rotation of the bone on the x axis
  8019. * @param roll The rotation of the bone on the z axis
  8020. * @param space The space that the axes of rotation are in
  8021. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8022. */
  8023. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8024. /**
  8025. * Add a rotation to the bone on an axis in local or world space
  8026. * @param axis The axis to rotate the bone on
  8027. * @param amount The amount to rotate the bone
  8028. * @param space The space that the axis is in
  8029. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8030. */
  8031. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8032. /**
  8033. * Set the rotation of the bone to a particular axis angle in local or world space
  8034. * @param axis The axis to rotate the bone on
  8035. * @param angle The angle that the bone should be rotated to
  8036. * @param space The space that the axis is in
  8037. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8038. */
  8039. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8040. /**
  8041. * Set the euler rotation of the bone in local of world space
  8042. * @param rotation The euler rotation that the bone should be set to
  8043. * @param space The space that the rotation is in
  8044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8045. */
  8046. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8047. /**
  8048. * Set the quaternion rotation of the bone in local of world space
  8049. * @param quat The quaternion rotation that the bone should be set to
  8050. * @param space The space that the rotation is in
  8051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8052. */
  8053. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8054. /**
  8055. * Set the rotation matrix of the bone in local of world space
  8056. * @param rotMat The rotation matrix that the bone should be set to
  8057. * @param space The space that the rotation is in
  8058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8059. */
  8060. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8061. private _rotateWithMatrix;
  8062. private _getNegativeRotationToRef;
  8063. /**
  8064. * Get the position of the bone in local or world space
  8065. * @param space The space that the returned position is in
  8066. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8067. * @returns The position of the bone
  8068. */
  8069. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8070. /**
  8071. * Copy the position of the bone to a vector3 in local or world space
  8072. * @param space The space that the returned position is in
  8073. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8074. * @param result The vector3 to copy the position to
  8075. */
  8076. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8077. /**
  8078. * Get the absolute position of the bone (world space)
  8079. * @param mesh The mesh that this bone is attached to
  8080. * @returns The absolute position of the bone
  8081. */
  8082. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8083. /**
  8084. * Copy the absolute position of the bone (world space) to the result param
  8085. * @param mesh The mesh that this bone is attached to
  8086. * @param result The vector3 to copy the absolute position to
  8087. */
  8088. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8089. /**
  8090. * Compute the absolute transforms of this bone and its children
  8091. */
  8092. computeAbsoluteTransforms(): void;
  8093. /**
  8094. * Get the world direction from an axis that is in the local space of the bone
  8095. * @param localAxis The local direction that is used to compute the world direction
  8096. * @param mesh The mesh that this bone is attached to
  8097. * @returns The world direction
  8098. */
  8099. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8100. /**
  8101. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8102. * @param localAxis The local direction that is used to compute the world direction
  8103. * @param mesh The mesh that this bone is attached to
  8104. * @param result The vector3 that the world direction will be copied to
  8105. */
  8106. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8107. /**
  8108. * Get the euler rotation of the bone in local or world space
  8109. * @param space The space that the rotation should be in
  8110. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8111. * @returns The euler rotation
  8112. */
  8113. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8114. /**
  8115. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8116. * @param space The space that the rotation should be in
  8117. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8118. * @param result The vector3 that the rotation should be copied to
  8119. */
  8120. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8121. /**
  8122. * Get the quaternion rotation of the bone in either local or world space
  8123. * @param space The space that the rotation should be in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. * @returns The quaternion rotation
  8126. */
  8127. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8128. /**
  8129. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8130. * @param space The space that the rotation should be in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. * @param result The quaternion that the rotation should be copied to
  8133. */
  8134. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8135. /**
  8136. * Get the rotation matrix of the bone in local or world space
  8137. * @param space The space that the rotation should be in
  8138. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8139. * @returns The rotation matrix
  8140. */
  8141. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8142. /**
  8143. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8144. * @param space The space that the rotation should be in
  8145. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8146. * @param result The quaternion that the rotation should be copied to
  8147. */
  8148. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8149. /**
  8150. * Get the world position of a point that is in the local space of the bone
  8151. * @param position The local position
  8152. * @param mesh The mesh that this bone is attached to
  8153. * @returns The world position
  8154. */
  8155. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8156. /**
  8157. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8158. * @param position The local position
  8159. * @param mesh The mesh that this bone is attached to
  8160. * @param result The vector3 that the world position should be copied to
  8161. */
  8162. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8163. /**
  8164. * Get the local position of a point that is in world space
  8165. * @param position The world position
  8166. * @param mesh The mesh that this bone is attached to
  8167. * @returns The local position
  8168. */
  8169. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8170. /**
  8171. * Get the local position of a point that is in world space and copy it to the result param
  8172. * @param position The world position
  8173. * @param mesh The mesh that this bone is attached to
  8174. * @param result The vector3 that the local position should be copied to
  8175. */
  8176. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8177. }
  8178. }
  8179. declare module BABYLON {
  8180. /**
  8181. * Enum that determines the text-wrapping mode to use.
  8182. */
  8183. export enum InspectableType {
  8184. /**
  8185. * Checkbox for booleans
  8186. */
  8187. Checkbox = 0,
  8188. /**
  8189. * Sliders for numbers
  8190. */
  8191. Slider = 1,
  8192. /**
  8193. * Vector3
  8194. */
  8195. Vector3 = 2,
  8196. /**
  8197. * Quaternions
  8198. */
  8199. Quaternion = 3,
  8200. /**
  8201. * Color3
  8202. */
  8203. Color3 = 4
  8204. }
  8205. /**
  8206. * Interface used to define custom inspectable properties.
  8207. * This interface is used by the inspector to display custom property grids
  8208. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8209. */
  8210. export interface IInspectable {
  8211. /**
  8212. * Gets the label to display
  8213. */
  8214. label: string;
  8215. /**
  8216. * Gets the name of the property to edit
  8217. */
  8218. propertyName: string;
  8219. /**
  8220. * Gets the type of the editor to use
  8221. */
  8222. type: InspectableType;
  8223. /**
  8224. * Gets the minimum value of the property when using in "slider" mode
  8225. */
  8226. min?: number;
  8227. /**
  8228. * Gets the maximum value of the property when using in "slider" mode
  8229. */
  8230. max?: number;
  8231. /**
  8232. * Gets the setp to use when using in "slider" mode
  8233. */
  8234. step?: number;
  8235. }
  8236. }
  8237. declare module BABYLON {
  8238. /**
  8239. * Class for creating a cube texture
  8240. */
  8241. export class CubeTexture extends BaseTexture {
  8242. private _delayedOnLoad;
  8243. /**
  8244. * The url of the texture
  8245. */
  8246. url: string;
  8247. /**
  8248. * Gets or sets the center of the bounding box associated with the cube texture.
  8249. * It must define where the camera used to render the texture was set
  8250. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8251. */
  8252. boundingBoxPosition: Vector3;
  8253. private _boundingBoxSize;
  8254. /**
  8255. * Gets or sets the size of the bounding box associated with the cube texture
  8256. * When defined, the cubemap will switch to local mode
  8257. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8258. * @example https://www.babylonjs-playground.com/#RNASML
  8259. */
  8260. /**
  8261. * Returns the bounding box size
  8262. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8263. */
  8264. boundingBoxSize: Vector3;
  8265. protected _rotationY: number;
  8266. /**
  8267. * Sets texture matrix rotation angle around Y axis in radians.
  8268. */
  8269. /**
  8270. * Gets texture matrix rotation angle around Y axis radians.
  8271. */
  8272. rotationY: number;
  8273. /**
  8274. * Are mip maps generated for this texture or not.
  8275. */
  8276. readonly noMipmap: boolean;
  8277. private _noMipmap;
  8278. private _files;
  8279. private _extensions;
  8280. private _textureMatrix;
  8281. private _format;
  8282. private _createPolynomials;
  8283. /** @hidden */ prefiltered: boolean;
  8284. /**
  8285. * Creates a cube texture from an array of image urls
  8286. * @param files defines an array of image urls
  8287. * @param scene defines the hosting scene
  8288. * @param noMipmap specifies if mip maps are not used
  8289. * @returns a cube texture
  8290. */
  8291. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8292. /**
  8293. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8294. * @param url defines the url of the prefiltered texture
  8295. * @param scene defines the scene the texture is attached to
  8296. * @param forcedExtension defines the extension of the file if different from the url
  8297. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8298. * @return the prefiltered texture
  8299. */
  8300. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8301. /**
  8302. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8303. * as prefiltered data.
  8304. * @param rootUrl defines the url of the texture or the root name of the six images
  8305. * @param scene defines the scene the texture is attached to
  8306. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8307. * @param noMipmap defines if mipmaps should be created or not
  8308. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8309. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8310. * @param onError defines a callback triggered in case of error during load
  8311. * @param format defines the internal format to use for the texture once loaded
  8312. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8313. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8314. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8315. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8316. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8317. * @return the cube texture
  8318. */
  8319. 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);
  8320. /**
  8321. * Get the current class name of the texture useful for serialization or dynamic coding.
  8322. * @returns "CubeTexture"
  8323. */
  8324. getClassName(): string;
  8325. /**
  8326. * Update the url (and optional buffer) of this texture if url was null during construction.
  8327. * @param url the url of the texture
  8328. * @param forcedExtension defines the extension to use
  8329. * @param onLoad callback called when the texture is loaded (defaults to null)
  8330. */
  8331. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8332. /**
  8333. * Delays loading of the cube texture
  8334. * @param forcedExtension defines the extension to use
  8335. */
  8336. delayLoad(forcedExtension?: string): void;
  8337. /**
  8338. * Returns the reflection texture matrix
  8339. * @returns the reflection texture matrix
  8340. */
  8341. getReflectionTextureMatrix(): Matrix;
  8342. /**
  8343. * Sets the reflection texture matrix
  8344. * @param value Reflection texture matrix
  8345. */
  8346. setReflectionTextureMatrix(value: Matrix): void;
  8347. /**
  8348. * Parses text to create a cube texture
  8349. * @param parsedTexture define the serialized text to read from
  8350. * @param scene defines the hosting scene
  8351. * @param rootUrl defines the root url of the cube texture
  8352. * @returns a cube texture
  8353. */
  8354. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8355. /**
  8356. * Makes a clone, or deep copy, of the cube texture
  8357. * @returns a new cube texture
  8358. */
  8359. clone(): CubeTexture;
  8360. }
  8361. }
  8362. declare module BABYLON {
  8363. /** @hidden */
  8364. export var postprocessVertexShader: {
  8365. name: string;
  8366. shader: string;
  8367. };
  8368. }
  8369. declare module BABYLON {
  8370. /**
  8371. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8372. * This is the base of the follow, arc rotate cameras and Free camera
  8373. * @see http://doc.babylonjs.com/features/cameras
  8374. */
  8375. export class TargetCamera extends Camera {
  8376. private static _RigCamTransformMatrix;
  8377. private static _TargetTransformMatrix;
  8378. private static _TargetFocalPoint;
  8379. /**
  8380. * Define the current direction the camera is moving to
  8381. */
  8382. cameraDirection: Vector3;
  8383. /**
  8384. * Define the current rotation the camera is rotating to
  8385. */
  8386. cameraRotation: Vector2;
  8387. /**
  8388. * When set, the up vector of the camera will be updated by the rotation of the camera
  8389. */
  8390. updateUpVectorFromRotation: boolean;
  8391. private _tmpQuaternion;
  8392. /**
  8393. * Define the current rotation of the camera
  8394. */
  8395. rotation: Vector3;
  8396. /**
  8397. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8398. */
  8399. rotationQuaternion: Quaternion;
  8400. /**
  8401. * Define the current speed of the camera
  8402. */
  8403. speed: number;
  8404. /**
  8405. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8406. * around all axis.
  8407. */
  8408. noRotationConstraint: boolean;
  8409. /**
  8410. * Define the current target of the camera as an object or a position.
  8411. */
  8412. lockedTarget: any;
  8413. /** @hidden */ currentTarget: Vector3;
  8414. /** @hidden */ initialFocalDistance: number;
  8415. /** @hidden */ viewMatrix: Matrix;
  8416. /** @hidden */ camMatrix: Matrix;
  8417. /** @hidden */ cameraTransformMatrix: Matrix;
  8418. /** @hidden */ cameraRotationMatrix: Matrix;
  8419. /** @hidden */ referencePoint: Vector3;
  8420. /** @hidden */ transformedReferencePoint: Vector3;
  8421. protected _globalCurrentTarget: Vector3;
  8422. protected _globalCurrentUpVector: Vector3;
  8423. /** @hidden */ reset: () => void;
  8424. private _defaultUp;
  8425. /**
  8426. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8427. * This is the base of the follow, arc rotate cameras and Free camera
  8428. * @see http://doc.babylonjs.com/features/cameras
  8429. * @param name Defines the name of the camera in the scene
  8430. * @param position Defines the start position of the camera in the scene
  8431. * @param scene Defines the scene the camera belongs to
  8432. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8433. */
  8434. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8435. /**
  8436. * Gets the position in front of the camera at a given distance.
  8437. * @param distance The distance from the camera we want the position to be
  8438. * @returns the position
  8439. */
  8440. getFrontPosition(distance: number): Vector3;
  8441. /** @hidden */ getLockedTargetPosition(): Nullable<Vector3>;
  8442. private _storedPosition;
  8443. private _storedRotation;
  8444. private _storedRotationQuaternion;
  8445. /**
  8446. * Store current camera state of the camera (fov, position, rotation, etc..)
  8447. * @returns the camera
  8448. */
  8449. storeState(): Camera;
  8450. /**
  8451. * Restored camera state. You must call storeState() first
  8452. * @returns whether it was successful or not
  8453. * @hidden
  8454. */ restoreStateValues(): boolean;
  8455. /** @hidden */ initCache(): void;
  8456. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  8457. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  8458. /** @hidden */ computeLocalCameraSpeed(): number;
  8459. /**
  8460. * Defines the target the camera should look at.
  8461. * This will automatically adapt alpha beta and radius to fit within the new target.
  8462. * @param target Defines the new target as a Vector or a mesh
  8463. */
  8464. setTarget(target: Vector3): void;
  8465. /**
  8466. * Return the current target position of the camera. This value is expressed in local space.
  8467. * @returns the target position
  8468. */
  8469. getTarget(): Vector3;
  8470. /** @hidden */ decideIfNeedsToMove(): boolean;
  8471. /** @hidden */ updatePosition(): void;
  8472. /** @hidden */ checkInputs(): void;
  8473. protected _updateCameraRotationMatrix(): void;
  8474. /**
  8475. * 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)
  8476. * @returns the current camera
  8477. */
  8478. private _rotateUpVectorWithCameraRotationMatrix;
  8479. private _cachedRotationZ;
  8480. private _cachedQuaternionRotationZ;
  8481. /** @hidden */ getViewMatrix(): Matrix;
  8482. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8483. /**
  8484. * @hidden
  8485. */
  8486. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8487. /**
  8488. * @hidden
  8489. */ updateRigCameras(): void;
  8490. private _getRigCamPositionAndTarget;
  8491. /**
  8492. * Gets the current object class name.
  8493. * @return the class name
  8494. */
  8495. getClassName(): string;
  8496. }
  8497. }
  8498. declare module BABYLON {
  8499. /**
  8500. * @ignore
  8501. * This is a list of all the different input types that are available in the application.
  8502. * Fo instance: ArcRotateCameraGamepadInput...
  8503. */
  8504. export var CameraInputTypes: {};
  8505. /**
  8506. * This is the contract to implement in order to create a new input class.
  8507. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8508. */
  8509. export interface ICameraInput<TCamera extends Camera> {
  8510. /**
  8511. * Defines the camera the input is attached to.
  8512. */
  8513. camera: Nullable<TCamera>;
  8514. /**
  8515. * Gets the class name of the current intput.
  8516. * @returns the class name
  8517. */
  8518. getClassName(): string;
  8519. /**
  8520. * Get the friendly name associated with the input class.
  8521. * @returns the input friendly name
  8522. */
  8523. getSimpleName(): string;
  8524. /**
  8525. * Attach the input controls to a specific dom element to get the input from.
  8526. * @param element Defines the element the controls should be listened from
  8527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8528. */
  8529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8530. /**
  8531. * Detach the current controls from the specified dom element.
  8532. * @param element Defines the element to stop listening the inputs from
  8533. */
  8534. detachControl(element: Nullable<HTMLElement>): void;
  8535. /**
  8536. * Update the current camera state depending on the inputs that have been used this frame.
  8537. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8538. */
  8539. checkInputs?: () => void;
  8540. }
  8541. /**
  8542. * Represents a map of input types to input instance or input index to input instance.
  8543. */
  8544. export interface CameraInputsMap<TCamera extends Camera> {
  8545. /**
  8546. * Accessor to the input by input type.
  8547. */
  8548. [name: string]: ICameraInput<TCamera>;
  8549. /**
  8550. * Accessor to the input by input index.
  8551. */
  8552. [idx: number]: ICameraInput<TCamera>;
  8553. }
  8554. /**
  8555. * This represents the input manager used within a camera.
  8556. * It helps dealing with all the different kind of input attached to a camera.
  8557. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8558. */
  8559. export class CameraInputsManager<TCamera extends Camera> {
  8560. /**
  8561. * Defines the list of inputs attahed to the camera.
  8562. */
  8563. attached: CameraInputsMap<TCamera>;
  8564. /**
  8565. * Defines the dom element the camera is collecting inputs from.
  8566. * This is null if the controls have not been attached.
  8567. */
  8568. attachedElement: Nullable<HTMLElement>;
  8569. /**
  8570. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8571. */
  8572. noPreventDefault: boolean;
  8573. /**
  8574. * Defined the camera the input manager belongs to.
  8575. */
  8576. camera: TCamera;
  8577. /**
  8578. * Update the current camera state depending on the inputs that have been used this frame.
  8579. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8580. */
  8581. checkInputs: () => void;
  8582. /**
  8583. * Instantiate a new Camera Input Manager.
  8584. * @param camera Defines the camera the input manager blongs to
  8585. */
  8586. constructor(camera: TCamera);
  8587. /**
  8588. * Add an input method to a camera
  8589. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8590. * @param input camera input method
  8591. */
  8592. add(input: ICameraInput<TCamera>): void;
  8593. /**
  8594. * Remove a specific input method from a camera
  8595. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8596. * @param inputToRemove camera input method
  8597. */
  8598. remove(inputToRemove: ICameraInput<TCamera>): void;
  8599. /**
  8600. * Remove a specific input type from a camera
  8601. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8602. * @param inputType the type of the input to remove
  8603. */
  8604. removeByType(inputType: string): void;
  8605. private _addCheckInputs;
  8606. /**
  8607. * Attach the input controls to the currently attached dom element to listen the events from.
  8608. * @param input Defines the input to attach
  8609. */
  8610. attachInput(input: ICameraInput<TCamera>): void;
  8611. /**
  8612. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8613. * @param element Defines the dom element to collect the events from
  8614. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8615. */
  8616. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8617. /**
  8618. * Detach the current manager inputs controls from a specific dom element.
  8619. * @param element Defines the dom element to collect the events from
  8620. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8621. */
  8622. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8623. /**
  8624. * Rebuild the dynamic inputCheck function from the current list of
  8625. * defined inputs in the manager.
  8626. */
  8627. rebuildInputCheck(): void;
  8628. /**
  8629. * Remove all attached input methods from a camera
  8630. */
  8631. clear(): void;
  8632. /**
  8633. * Serialize the current input manager attached to a camera.
  8634. * This ensures than once parsed,
  8635. * the input associated to the camera will be identical to the current ones
  8636. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8637. */
  8638. serialize(serializedCamera: any): void;
  8639. /**
  8640. * Parses an input manager serialized JSON to restore the previous list of inputs
  8641. * and states associated to a camera.
  8642. * @param parsedCamera Defines the JSON to parse
  8643. */
  8644. parse(parsedCamera: any): void;
  8645. }
  8646. }
  8647. declare module BABYLON {
  8648. /**
  8649. * Gather the list of keyboard event types as constants.
  8650. */
  8651. export class KeyboardEventTypes {
  8652. /**
  8653. * The keydown event is fired when a key becomes active (pressed).
  8654. */
  8655. static readonly KEYDOWN: number;
  8656. /**
  8657. * The keyup event is fired when a key has been released.
  8658. */
  8659. static readonly KEYUP: number;
  8660. }
  8661. /**
  8662. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8663. */
  8664. export class KeyboardInfo {
  8665. /**
  8666. * Defines the type of event (KeyboardEventTypes)
  8667. */
  8668. type: number;
  8669. /**
  8670. * Defines the related dom event
  8671. */
  8672. event: KeyboardEvent;
  8673. /**
  8674. * Instantiates a new keyboard info.
  8675. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8676. * @param type Defines the type of event (KeyboardEventTypes)
  8677. * @param event Defines the related dom event
  8678. */
  8679. constructor(
  8680. /**
  8681. * Defines the type of event (KeyboardEventTypes)
  8682. */
  8683. type: number,
  8684. /**
  8685. * Defines the related dom event
  8686. */
  8687. event: KeyboardEvent);
  8688. }
  8689. /**
  8690. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8691. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8692. */
  8693. export class KeyboardInfoPre extends KeyboardInfo {
  8694. /**
  8695. * Defines the type of event (KeyboardEventTypes)
  8696. */
  8697. type: number;
  8698. /**
  8699. * Defines the related dom event
  8700. */
  8701. event: KeyboardEvent;
  8702. /**
  8703. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8704. */
  8705. skipOnPointerObservable: boolean;
  8706. /**
  8707. * Instantiates a new keyboard pre info.
  8708. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8709. * @param type Defines the type of event (KeyboardEventTypes)
  8710. * @param event Defines the related dom event
  8711. */
  8712. constructor(
  8713. /**
  8714. * Defines the type of event (KeyboardEventTypes)
  8715. */
  8716. type: number,
  8717. /**
  8718. * Defines the related dom event
  8719. */
  8720. event: KeyboardEvent);
  8721. }
  8722. }
  8723. declare module BABYLON {
  8724. /**
  8725. * Manage the keyboard inputs to control the movement of a free camera.
  8726. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8727. */
  8728. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8729. /**
  8730. * Defines the camera the input is attached to.
  8731. */
  8732. camera: FreeCamera;
  8733. /**
  8734. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8735. */
  8736. keysUp: number[];
  8737. /**
  8738. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8739. */
  8740. keysDown: number[];
  8741. /**
  8742. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8743. */
  8744. keysLeft: number[];
  8745. /**
  8746. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8747. */
  8748. keysRight: number[];
  8749. private _keys;
  8750. private _onCanvasBlurObserver;
  8751. private _onKeyboardObserver;
  8752. private _engine;
  8753. private _scene;
  8754. /**
  8755. * Attach the input controls to a specific dom element to get the input from.
  8756. * @param element Defines the element the controls should be listened from
  8757. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8758. */
  8759. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8760. /**
  8761. * Detach the current controls from the specified dom element.
  8762. * @param element Defines the element to stop listening the inputs from
  8763. */
  8764. detachControl(element: Nullable<HTMLElement>): void;
  8765. /**
  8766. * Update the current camera state depending on the inputs that have been used this frame.
  8767. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8768. */
  8769. checkInputs(): void;
  8770. /**
  8771. * Gets the class name of the current intput.
  8772. * @returns the class name
  8773. */
  8774. getClassName(): string;
  8775. /** @hidden */ onLostFocus(): void;
  8776. /**
  8777. * Get the friendly name associated with the input class.
  8778. * @returns the input friendly name
  8779. */
  8780. getSimpleName(): string;
  8781. }
  8782. }
  8783. declare module BABYLON {
  8784. /**
  8785. * Interface describing all the common properties and methods a shadow light needs to implement.
  8786. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8787. * as well as binding the different shadow properties to the effects.
  8788. */
  8789. export interface IShadowLight extends Light {
  8790. /**
  8791. * The light id in the scene (used in scene.findLighById for instance)
  8792. */
  8793. id: string;
  8794. /**
  8795. * The position the shdow will be casted from.
  8796. */
  8797. position: Vector3;
  8798. /**
  8799. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8800. */
  8801. direction: Vector3;
  8802. /**
  8803. * The transformed position. Position of the light in world space taking parenting in account.
  8804. */
  8805. transformedPosition: Vector3;
  8806. /**
  8807. * The transformed direction. Direction of the light in world space taking parenting in account.
  8808. */
  8809. transformedDirection: Vector3;
  8810. /**
  8811. * The friendly name of the light in the scene.
  8812. */
  8813. name: string;
  8814. /**
  8815. * Defines the shadow projection clipping minimum z value.
  8816. */
  8817. shadowMinZ: number;
  8818. /**
  8819. * Defines the shadow projection clipping maximum z value.
  8820. */
  8821. shadowMaxZ: number;
  8822. /**
  8823. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8824. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8825. */
  8826. computeTransformedInformation(): boolean;
  8827. /**
  8828. * Gets the scene the light belongs to.
  8829. * @returns The scene
  8830. */
  8831. getScene(): Scene;
  8832. /**
  8833. * Callback defining a custom Projection Matrix Builder.
  8834. * This can be used to override the default projection matrix computation.
  8835. */
  8836. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8837. /**
  8838. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8839. * @param matrix The materix to updated with the projection information
  8840. * @param viewMatrix The transform matrix of the light
  8841. * @param renderList The list of mesh to render in the map
  8842. * @returns The current light
  8843. */
  8844. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8845. /**
  8846. * Gets the current depth scale used in ESM.
  8847. * @returns The scale
  8848. */
  8849. getDepthScale(): number;
  8850. /**
  8851. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8852. * @returns true if a cube texture needs to be use
  8853. */
  8854. needCube(): boolean;
  8855. /**
  8856. * Detects if the projection matrix requires to be recomputed this frame.
  8857. * @returns true if it requires to be recomputed otherwise, false.
  8858. */
  8859. needProjectionMatrixCompute(): boolean;
  8860. /**
  8861. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8862. */
  8863. forceProjectionMatrixCompute(): void;
  8864. /**
  8865. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8866. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8867. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8868. */
  8869. getShadowDirection(faceIndex?: number): Vector3;
  8870. /**
  8871. * Gets the minZ used for shadow according to both the scene and the light.
  8872. * @param activeCamera The camera we are returning the min for
  8873. * @returns the depth min z
  8874. */
  8875. getDepthMinZ(activeCamera: Camera): number;
  8876. /**
  8877. * Gets the maxZ used for shadow according to both the scene and the light.
  8878. * @param activeCamera The camera we are returning the max for
  8879. * @returns the depth max z
  8880. */
  8881. getDepthMaxZ(activeCamera: Camera): number;
  8882. }
  8883. /**
  8884. * Base implementation IShadowLight
  8885. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8886. */
  8887. export abstract class ShadowLight extends Light implements IShadowLight {
  8888. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8889. protected _position: Vector3;
  8890. protected _setPosition(value: Vector3): void;
  8891. /**
  8892. * Sets the position the shadow will be casted from. Also use as the light position for both
  8893. * point and spot lights.
  8894. */
  8895. /**
  8896. * Sets the position the shadow will be casted from. Also use as the light position for both
  8897. * point and spot lights.
  8898. */
  8899. position: Vector3;
  8900. protected _direction: Vector3;
  8901. protected _setDirection(value: Vector3): void;
  8902. /**
  8903. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8904. * Also use as the light direction on spot and directional lights.
  8905. */
  8906. /**
  8907. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8908. * Also use as the light direction on spot and directional lights.
  8909. */
  8910. direction: Vector3;
  8911. private _shadowMinZ;
  8912. /**
  8913. * Gets the shadow projection clipping minimum z value.
  8914. */
  8915. /**
  8916. * Sets the shadow projection clipping minimum z value.
  8917. */
  8918. shadowMinZ: number;
  8919. private _shadowMaxZ;
  8920. /**
  8921. * Sets the shadow projection clipping maximum z value.
  8922. */
  8923. /**
  8924. * Gets the shadow projection clipping maximum z value.
  8925. */
  8926. shadowMaxZ: number;
  8927. /**
  8928. * Callback defining a custom Projection Matrix Builder.
  8929. * This can be used to override the default projection matrix computation.
  8930. */
  8931. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8932. /**
  8933. * The transformed position. Position of the light in world space taking parenting in account.
  8934. */
  8935. transformedPosition: Vector3;
  8936. /**
  8937. * The transformed direction. Direction of the light in world space taking parenting in account.
  8938. */
  8939. transformedDirection: Vector3;
  8940. private _needProjectionMatrixCompute;
  8941. /**
  8942. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8943. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8944. */
  8945. computeTransformedInformation(): boolean;
  8946. /**
  8947. * Return the depth scale used for the shadow map.
  8948. * @returns the depth scale.
  8949. */
  8950. getDepthScale(): number;
  8951. /**
  8952. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8953. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8954. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8955. */
  8956. getShadowDirection(faceIndex?: number): Vector3;
  8957. /**
  8958. * Returns the ShadowLight absolute position in the World.
  8959. * @returns the position vector in world space
  8960. */
  8961. getAbsolutePosition(): Vector3;
  8962. /**
  8963. * Sets the ShadowLight direction toward the passed target.
  8964. * @param target The point to target in local space
  8965. * @returns the updated ShadowLight direction
  8966. */
  8967. setDirectionToTarget(target: Vector3): Vector3;
  8968. /**
  8969. * Returns the light rotation in euler definition.
  8970. * @returns the x y z rotation in local space.
  8971. */
  8972. getRotation(): Vector3;
  8973. /**
  8974. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8975. * @returns true if a cube texture needs to be use
  8976. */
  8977. needCube(): boolean;
  8978. /**
  8979. * Detects if the projection matrix requires to be recomputed this frame.
  8980. * @returns true if it requires to be recomputed otherwise, false.
  8981. */
  8982. needProjectionMatrixCompute(): boolean;
  8983. /**
  8984. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8985. */
  8986. forceProjectionMatrixCompute(): void;
  8987. /** @hidden */ initCache(): void;
  8988. /** @hidden */ isSynchronized(): boolean;
  8989. /**
  8990. * Computes the world matrix of the node
  8991. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8992. * @returns the world matrix
  8993. */
  8994. computeWorldMatrix(force?: boolean): Matrix;
  8995. /**
  8996. * Gets the minZ used for shadow according to both the scene and the light.
  8997. * @param activeCamera The camera we are returning the min for
  8998. * @returns the depth min z
  8999. */
  9000. getDepthMinZ(activeCamera: Camera): number;
  9001. /**
  9002. * Gets the maxZ used for shadow according to both the scene and the light.
  9003. * @param activeCamera The camera we are returning the max for
  9004. * @returns the depth max z
  9005. */
  9006. getDepthMaxZ(activeCamera: Camera): number;
  9007. /**
  9008. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9009. * @param matrix The materix to updated with the projection information
  9010. * @param viewMatrix The transform matrix of the light
  9011. * @param renderList The list of mesh to render in the map
  9012. * @returns The current light
  9013. */
  9014. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9015. }
  9016. }
  9017. declare module BABYLON {
  9018. /**
  9019. * "Static Class" containing the most commonly used helper while dealing with material for
  9020. * rendering purpose.
  9021. *
  9022. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9023. *
  9024. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9025. */
  9026. export class MaterialHelper {
  9027. /**
  9028. * Bind the current view position to an effect.
  9029. * @param effect The effect to be bound
  9030. * @param scene The scene the eyes position is used from
  9031. */
  9032. static BindEyePosition(effect: Effect, scene: Scene): void;
  9033. /**
  9034. * Helps preparing the defines values about the UVs in used in the effect.
  9035. * UVs are shared as much as we can accross channels in the shaders.
  9036. * @param texture The texture we are preparing the UVs for
  9037. * @param defines The defines to update
  9038. * @param key The channel key "diffuse", "specular"... used in the shader
  9039. */
  9040. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9041. /**
  9042. * Binds a texture matrix value to its corrsponding uniform
  9043. * @param texture The texture to bind the matrix for
  9044. * @param uniformBuffer The uniform buffer receivin the data
  9045. * @param key The channel key "diffuse", "specular"... used in the shader
  9046. */
  9047. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9048. /**
  9049. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9050. * @param mesh defines the current mesh
  9051. * @param scene defines the current scene
  9052. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9053. * @param pointsCloud defines if point cloud rendering has to be turned on
  9054. * @param fogEnabled defines if fog has to be turned on
  9055. * @param alphaTest defines if alpha testing has to be turned on
  9056. * @param defines defines the current list of defines
  9057. */
  9058. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9059. /**
  9060. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9061. * @param scene defines the current scene
  9062. * @param engine defines the current engine
  9063. * @param defines specifies the list of active defines
  9064. * @param useInstances defines if instances have to be turned on
  9065. * @param useClipPlane defines if clip plane have to be turned on
  9066. */
  9067. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9068. /**
  9069. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9070. * @param mesh The mesh containing the geometry data we will draw
  9071. * @param defines The defines to update
  9072. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9073. * @param useBones Precise whether bones should be used or not (override mesh info)
  9074. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9075. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9076. * @returns false if defines are considered not dirty and have not been checked
  9077. */
  9078. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9079. /**
  9080. * Prepares the defines related to multiview
  9081. * @param scene The scene we are intending to draw
  9082. * @param defines The defines to update
  9083. */
  9084. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9085. /**
  9086. * Prepares the defines related to the light information passed in parameter
  9087. * @param scene The scene we are intending to draw
  9088. * @param mesh The mesh the effect is compiling for
  9089. * @param defines The defines to update
  9090. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9091. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9092. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9093. * @returns true if normals will be required for the rest of the effect
  9094. */
  9095. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9096. /**
  9097. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9098. * that won t be acctive due to defines being turned off.
  9099. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9100. * @param samplersList The samplers list
  9101. * @param defines The defines helping in the list generation
  9102. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9103. */
  9104. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9105. /**
  9106. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9107. * @param defines The defines to update while falling back
  9108. * @param fallbacks The authorized effect fallbacks
  9109. * @param maxSimultaneousLights The maximum number of lights allowed
  9110. * @param rank the current rank of the Effect
  9111. * @returns The newly affected rank
  9112. */
  9113. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9114. /**
  9115. * Prepares the list of attributes required for morph targets according to the effect defines.
  9116. * @param attribs The current list of supported attribs
  9117. * @param mesh The mesh to prepare the morph targets attributes for
  9118. * @param defines The current Defines of the effect
  9119. */
  9120. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9121. /**
  9122. * Prepares the list of attributes required for bones according to the effect defines.
  9123. * @param attribs The current list of supported attribs
  9124. * @param mesh The mesh to prepare the bones attributes for
  9125. * @param defines The current Defines of the effect
  9126. * @param fallbacks The current efffect fallback strategy
  9127. */
  9128. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9129. /**
  9130. * Prepares the list of attributes required for instances according to the effect defines.
  9131. * @param attribs The current list of supported attribs
  9132. * @param defines The current Defines of the effect
  9133. */
  9134. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9135. /**
  9136. * Binds the light shadow information to the effect for the given mesh.
  9137. * @param light The light containing the generator
  9138. * @param scene The scene the lights belongs to
  9139. * @param mesh The mesh we are binding the information to render
  9140. * @param lightIndex The light index in the effect used to render the mesh
  9141. * @param effect The effect we are binding the data to
  9142. */
  9143. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9144. /**
  9145. * Binds the light information to the effect.
  9146. * @param light The light containing the generator
  9147. * @param effect The effect we are binding the data to
  9148. * @param lightIndex The light index in the effect used to render
  9149. */
  9150. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9151. /**
  9152. * Binds the lights information from the scene to the effect for the given mesh.
  9153. * @param scene The scene the lights belongs to
  9154. * @param mesh The mesh we are binding the information to render
  9155. * @param effect The effect we are binding the data to
  9156. * @param defines The generated defines for the effect
  9157. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9158. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9159. */
  9160. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9161. private static _tempFogColor;
  9162. /**
  9163. * Binds the fog information from the scene to the effect for the given mesh.
  9164. * @param scene The scene the lights belongs to
  9165. * @param mesh The mesh we are binding the information to render
  9166. * @param effect The effect we are binding the data to
  9167. * @param linearSpace Defines if the fog effect is applied in linear space
  9168. */
  9169. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9170. /**
  9171. * Binds the bones information from the mesh to the effect.
  9172. * @param mesh The mesh we are binding the information to render
  9173. * @param effect The effect we are binding the data to
  9174. */
  9175. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9176. /**
  9177. * Binds the morph targets information from the mesh to the effect.
  9178. * @param abstractMesh The mesh we are binding the information to render
  9179. * @param effect The effect we are binding the data to
  9180. */
  9181. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9182. /**
  9183. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9184. * @param defines The generated defines used in the effect
  9185. * @param effect The effect we are binding the data to
  9186. * @param scene The scene we are willing to render with logarithmic scale for
  9187. */
  9188. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9189. /**
  9190. * Binds the clip plane information from the scene to the effect.
  9191. * @param scene The scene the clip plane information are extracted from
  9192. * @param effect The effect we are binding the data to
  9193. */
  9194. static BindClipPlane(effect: Effect, scene: Scene): void;
  9195. }
  9196. }
  9197. declare module BABYLON {
  9198. /** @hidden */
  9199. export var kernelBlurVaryingDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module BABYLON {
  9205. /** @hidden */
  9206. export var kernelBlurFragment: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module BABYLON {
  9212. /** @hidden */
  9213. export var kernelBlurFragment2: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module BABYLON {
  9219. /** @hidden */
  9220. export var kernelBlurPixelShader: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module BABYLON {
  9226. /** @hidden */
  9227. export var kernelBlurVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module BABYLON {
  9233. /** @hidden */
  9234. export var kernelBlurVertexShader: {
  9235. name: string;
  9236. shader: string;
  9237. };
  9238. }
  9239. declare module BABYLON {
  9240. /**
  9241. * The Blur Post Process which blurs an image based on a kernel and direction.
  9242. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9243. */
  9244. export class BlurPostProcess extends PostProcess {
  9245. /** The direction in which to blur the image. */
  9246. direction: Vector2;
  9247. private blockCompilation;
  9248. protected _kernel: number;
  9249. protected _idealKernel: number;
  9250. protected _packedFloat: boolean;
  9251. private _staticDefines;
  9252. /**
  9253. * Sets the length in pixels of the blur sample region
  9254. */
  9255. /**
  9256. * Gets the length in pixels of the blur sample region
  9257. */
  9258. kernel: number;
  9259. /**
  9260. * Sets wether or not the blur needs to unpack/repack floats
  9261. */
  9262. /**
  9263. * Gets wether or not the blur is unpacking/repacking floats
  9264. */
  9265. packedFloat: boolean;
  9266. /**
  9267. * Creates a new instance BlurPostProcess
  9268. * @param name The name of the effect.
  9269. * @param direction The direction in which to blur the image.
  9270. * @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.
  9271. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9272. * @param camera The camera to apply the render pass to.
  9273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9274. * @param engine The engine which the post process will be applied. (default: current engine)
  9275. * @param reusable If the post process can be reused on the same frame. (default: false)
  9276. * @param textureType Type of textures used when performing the post process. (default: 0)
  9277. * @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)
  9278. */
  9279. constructor(name: string,
  9280. /** The direction in which to blur the image. */
  9281. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9282. /**
  9283. * Updates the effect with the current post process compile time values and recompiles the shader.
  9284. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9285. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9286. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9287. * @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
  9288. * @param onCompiled Called when the shader has been compiled.
  9289. * @param onError Called if there is an error when compiling a shader.
  9290. */
  9291. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9292. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9293. /**
  9294. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9295. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9296. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9297. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9298. * The gaps between physical kernels are compensated for in the weighting of the samples
  9299. * @param idealKernel Ideal blur kernel.
  9300. * @return Nearest best kernel.
  9301. */
  9302. protected _nearestBestKernel(idealKernel: number): number;
  9303. /**
  9304. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9305. * @param x The point on the Gaussian distribution to sample.
  9306. * @return the value of the Gaussian function at x.
  9307. */
  9308. protected _gaussianWeight(x: number): number;
  9309. /**
  9310. * Generates a string that can be used as a floating point number in GLSL.
  9311. * @param x Value to print.
  9312. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9313. * @return GLSL float string.
  9314. */
  9315. protected _glslFloat(x: number, decimalFigures?: number): string;
  9316. }
  9317. }
  9318. declare module BABYLON {
  9319. /** @hidden */
  9320. export var shadowMapPixelShader: {
  9321. name: string;
  9322. shader: string;
  9323. };
  9324. }
  9325. declare module BABYLON {
  9326. /** @hidden */
  9327. export var bonesDeclaration: {
  9328. name: string;
  9329. shader: string;
  9330. };
  9331. }
  9332. declare module BABYLON {
  9333. /** @hidden */
  9334. export var morphTargetsVertexGlobalDeclaration: {
  9335. name: string;
  9336. shader: string;
  9337. };
  9338. }
  9339. declare module BABYLON {
  9340. /** @hidden */
  9341. export var morphTargetsVertexDeclaration: {
  9342. name: string;
  9343. shader: string;
  9344. };
  9345. }
  9346. declare module BABYLON {
  9347. /** @hidden */
  9348. export var instancesDeclaration: {
  9349. name: string;
  9350. shader: string;
  9351. };
  9352. }
  9353. declare module BABYLON {
  9354. /** @hidden */
  9355. export var helperFunctions: {
  9356. name: string;
  9357. shader: string;
  9358. };
  9359. }
  9360. declare module BABYLON {
  9361. /** @hidden */
  9362. export var morphTargetsVertex: {
  9363. name: string;
  9364. shader: string;
  9365. };
  9366. }
  9367. declare module BABYLON {
  9368. /** @hidden */
  9369. export var instancesVertex: {
  9370. name: string;
  9371. shader: string;
  9372. };
  9373. }
  9374. declare module BABYLON {
  9375. /** @hidden */
  9376. export var bonesVertex: {
  9377. name: string;
  9378. shader: string;
  9379. };
  9380. }
  9381. declare module BABYLON {
  9382. /** @hidden */
  9383. export var shadowMapVertexShader: {
  9384. name: string;
  9385. shader: string;
  9386. };
  9387. }
  9388. declare module BABYLON {
  9389. /** @hidden */
  9390. export var depthBoxBlurPixelShader: {
  9391. name: string;
  9392. shader: string;
  9393. };
  9394. }
  9395. declare module BABYLON {
  9396. /**
  9397. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9398. */
  9399. export interface ICustomShaderOptions {
  9400. /**
  9401. * Gets or sets the custom shader name to use
  9402. */
  9403. shaderName: string;
  9404. /**
  9405. * The list of attribute names used in the shader
  9406. */
  9407. attributes?: string[];
  9408. /**
  9409. * The list of unifrom names used in the shader
  9410. */
  9411. uniforms?: string[];
  9412. /**
  9413. * The list of sampler names used in the shader
  9414. */
  9415. samplers?: string[];
  9416. /**
  9417. * The list of defines used in the shader
  9418. */
  9419. defines?: string[];
  9420. }
  9421. /**
  9422. * Interface to implement to create a shadow generator compatible with BJS.
  9423. */
  9424. export interface IShadowGenerator {
  9425. /**
  9426. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9427. * @returns The render target texture if present otherwise, null
  9428. */
  9429. getShadowMap(): Nullable<RenderTargetTexture>;
  9430. /**
  9431. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9432. * @returns The render target texture if the shadow map is present otherwise, null
  9433. */
  9434. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9435. /**
  9436. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9437. * @param subMesh The submesh we want to render in the shadow map
  9438. * @param useInstances Defines wether will draw in the map using instances
  9439. * @returns true if ready otherwise, false
  9440. */
  9441. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9442. /**
  9443. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9444. * @param defines Defines of the material we want to update
  9445. * @param lightIndex Index of the light in the enabled light list of the material
  9446. */
  9447. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9448. /**
  9449. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9450. * defined in the generator but impacting the effect).
  9451. * It implies the unifroms available on the materials are the standard BJS ones.
  9452. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9453. * @param effect The effect we are binfing the information for
  9454. */
  9455. bindShadowLight(lightIndex: string, effect: Effect): void;
  9456. /**
  9457. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9458. * (eq to shadow prjection matrix * light transform matrix)
  9459. * @returns The transform matrix used to create the shadow map
  9460. */
  9461. getTransformMatrix(): Matrix;
  9462. /**
  9463. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9464. * Cube and 2D textures for instance.
  9465. */
  9466. recreateShadowMap(): void;
  9467. /**
  9468. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9469. * @param onCompiled Callback triggered at the and of the effects compilation
  9470. * @param options Sets of optional options forcing the compilation with different modes
  9471. */
  9472. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9473. useInstances: boolean;
  9474. }>): void;
  9475. /**
  9476. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9477. * @param options Sets of optional options forcing the compilation with different modes
  9478. * @returns A promise that resolves when the compilation completes
  9479. */
  9480. forceCompilationAsync(options?: Partial<{
  9481. useInstances: boolean;
  9482. }>): Promise<void>;
  9483. /**
  9484. * Serializes the shadow generator setup to a json object.
  9485. * @returns The serialized JSON object
  9486. */
  9487. serialize(): any;
  9488. /**
  9489. * Disposes the Shadow map and related Textures and effects.
  9490. */
  9491. dispose(): void;
  9492. }
  9493. /**
  9494. * Default implementation IShadowGenerator.
  9495. * This is the main object responsible of generating shadows in the framework.
  9496. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9497. */
  9498. export class ShadowGenerator implements IShadowGenerator {
  9499. /**
  9500. * Shadow generator mode None: no filtering applied.
  9501. */
  9502. static readonly FILTER_NONE: number;
  9503. /**
  9504. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9505. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9506. */
  9507. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9508. /**
  9509. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9510. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9511. */
  9512. static readonly FILTER_POISSONSAMPLING: number;
  9513. /**
  9514. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9515. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9516. */
  9517. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9518. /**
  9519. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9520. * edge artifacts on steep falloff.
  9521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9522. */
  9523. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9524. /**
  9525. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9526. * edge artifacts on steep falloff.
  9527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9528. */
  9529. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9530. /**
  9531. * Shadow generator mode PCF: Percentage Closer Filtering
  9532. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9533. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9534. */
  9535. static readonly FILTER_PCF: number;
  9536. /**
  9537. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9538. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9539. * Contact Hardening
  9540. */
  9541. static readonly FILTER_PCSS: number;
  9542. /**
  9543. * Reserved for PCF and PCSS
  9544. * Highest Quality.
  9545. *
  9546. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9547. *
  9548. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9549. */
  9550. static readonly QUALITY_HIGH: number;
  9551. /**
  9552. * Reserved for PCF and PCSS
  9553. * Good tradeoff for quality/perf cross devices
  9554. *
  9555. * Execute PCF on a 3*3 kernel.
  9556. *
  9557. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9558. */
  9559. static readonly QUALITY_MEDIUM: number;
  9560. /**
  9561. * Reserved for PCF and PCSS
  9562. * The lowest quality but the fastest.
  9563. *
  9564. * Execute PCF on a 1*1 kernel.
  9565. *
  9566. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9567. */
  9568. static readonly QUALITY_LOW: number;
  9569. /** Gets or sets the custom shader name to use */
  9570. customShaderOptions: ICustomShaderOptions;
  9571. /**
  9572. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9573. */
  9574. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9575. /**
  9576. * Observable triggered before a mesh is rendered in the shadow map.
  9577. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9578. */
  9579. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9580. private _bias;
  9581. /**
  9582. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9583. */
  9584. /**
  9585. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9586. */
  9587. bias: number;
  9588. private _normalBias;
  9589. /**
  9590. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9591. */
  9592. /**
  9593. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9594. */
  9595. normalBias: number;
  9596. private _blurBoxOffset;
  9597. /**
  9598. * Gets the blur box offset: offset applied during the blur pass.
  9599. * Only useful if useKernelBlur = false
  9600. */
  9601. /**
  9602. * Sets the blur box offset: offset applied during the blur pass.
  9603. * Only useful if useKernelBlur = false
  9604. */
  9605. blurBoxOffset: number;
  9606. private _blurScale;
  9607. /**
  9608. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9609. * 2 means half of the size.
  9610. */
  9611. /**
  9612. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9613. * 2 means half of the size.
  9614. */
  9615. blurScale: number;
  9616. private _blurKernel;
  9617. /**
  9618. * Gets the blur kernel: kernel size of the blur pass.
  9619. * Only useful if useKernelBlur = true
  9620. */
  9621. /**
  9622. * Sets the blur kernel: kernel size of the blur pass.
  9623. * Only useful if useKernelBlur = true
  9624. */
  9625. blurKernel: number;
  9626. private _useKernelBlur;
  9627. /**
  9628. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9629. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9630. */
  9631. /**
  9632. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9633. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9634. */
  9635. useKernelBlur: boolean;
  9636. private _depthScale;
  9637. /**
  9638. * Gets the depth scale used in ESM mode.
  9639. */
  9640. /**
  9641. * Sets the depth scale used in ESM mode.
  9642. * This can override the scale stored on the light.
  9643. */
  9644. depthScale: number;
  9645. private _filter;
  9646. /**
  9647. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9648. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9649. */
  9650. /**
  9651. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9652. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9653. */
  9654. filter: number;
  9655. /**
  9656. * Gets if the current filter is set to Poisson Sampling.
  9657. */
  9658. /**
  9659. * Sets the current filter to Poisson Sampling.
  9660. */
  9661. usePoissonSampling: boolean;
  9662. /**
  9663. * Gets if the current filter is set to ESM.
  9664. */
  9665. /**
  9666. * Sets the current filter is to ESM.
  9667. */
  9668. useExponentialShadowMap: boolean;
  9669. /**
  9670. * Gets if the current filter is set to filtered ESM.
  9671. */
  9672. /**
  9673. * Gets if the current filter is set to filtered ESM.
  9674. */
  9675. useBlurExponentialShadowMap: boolean;
  9676. /**
  9677. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9678. * exponential to prevent steep falloff artifacts).
  9679. */
  9680. /**
  9681. * Sets the current filter to "close ESM" (using the inverse of the
  9682. * exponential to prevent steep falloff artifacts).
  9683. */
  9684. useCloseExponentialShadowMap: boolean;
  9685. /**
  9686. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9687. * exponential to prevent steep falloff artifacts).
  9688. */
  9689. /**
  9690. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9691. * exponential to prevent steep falloff artifacts).
  9692. */
  9693. useBlurCloseExponentialShadowMap: boolean;
  9694. /**
  9695. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9696. */
  9697. /**
  9698. * Sets the current filter to "PCF" (percentage closer filtering).
  9699. */
  9700. usePercentageCloserFiltering: boolean;
  9701. private _filteringQuality;
  9702. /**
  9703. * Gets the PCF or PCSS Quality.
  9704. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9705. */
  9706. /**
  9707. * Sets the PCF or PCSS Quality.
  9708. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9709. */
  9710. filteringQuality: number;
  9711. /**
  9712. * Gets if the current filter is set to "PCSS" (contact hardening).
  9713. */
  9714. /**
  9715. * Sets the current filter to "PCSS" (contact hardening).
  9716. */
  9717. useContactHardeningShadow: boolean;
  9718. private _contactHardeningLightSizeUVRatio;
  9719. /**
  9720. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9721. * Using a ratio helps keeping shape stability independently of the map size.
  9722. *
  9723. * It does not account for the light projection as it was having too much
  9724. * instability during the light setup or during light position changes.
  9725. *
  9726. * Only valid if useContactHardeningShadow is true.
  9727. */
  9728. /**
  9729. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9730. * Using a ratio helps keeping shape stability independently of the map size.
  9731. *
  9732. * It does not account for the light projection as it was having too much
  9733. * instability during the light setup or during light position changes.
  9734. *
  9735. * Only valid if useContactHardeningShadow is true.
  9736. */
  9737. contactHardeningLightSizeUVRatio: number;
  9738. private _darkness;
  9739. /**
  9740. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9741. * 0 means strongest and 1 would means no shadow.
  9742. * @returns the darkness.
  9743. */
  9744. getDarkness(): number;
  9745. /**
  9746. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9747. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9748. * @returns the shadow generator allowing fluent coding.
  9749. */
  9750. setDarkness(darkness: number): ShadowGenerator;
  9751. private _transparencyShadow;
  9752. /**
  9753. * Sets the ability to have transparent shadow (boolean).
  9754. * @param transparent True if transparent else False
  9755. * @returns the shadow generator allowing fluent coding
  9756. */
  9757. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9758. private _shadowMap;
  9759. private _shadowMap2;
  9760. /**
  9761. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9762. * @returns The render target texture if present otherwise, null
  9763. */
  9764. getShadowMap(): Nullable<RenderTargetTexture>;
  9765. /**
  9766. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9767. * @returns The render target texture if the shadow map is present otherwise, null
  9768. */
  9769. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9770. /**
  9771. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9772. * @param mesh Mesh to add
  9773. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9774. * @returns the Shadow Generator itself
  9775. */
  9776. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9777. /**
  9778. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9779. * @param mesh Mesh to remove
  9780. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9781. * @returns the Shadow Generator itself
  9782. */
  9783. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9784. /**
  9785. * Controls the extent to which the shadows fade out at the edge of the frustum
  9786. * Used only by directionals and spots
  9787. */
  9788. frustumEdgeFalloff: number;
  9789. private _light;
  9790. /**
  9791. * Returns the associated light object.
  9792. * @returns the light generating the shadow
  9793. */
  9794. getLight(): IShadowLight;
  9795. /**
  9796. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9797. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9798. * It might on the other hand introduce peter panning.
  9799. */
  9800. forceBackFacesOnly: boolean;
  9801. private _scene;
  9802. private _lightDirection;
  9803. private _effect;
  9804. private _viewMatrix;
  9805. private _projectionMatrix;
  9806. private _transformMatrix;
  9807. private _cachedPosition;
  9808. private _cachedDirection;
  9809. private _cachedDefines;
  9810. private _currentRenderID;
  9811. private _boxBlurPostprocess;
  9812. private _kernelBlurXPostprocess;
  9813. private _kernelBlurYPostprocess;
  9814. private _blurPostProcesses;
  9815. private _mapSize;
  9816. private _currentFaceIndex;
  9817. private _currentFaceIndexCache;
  9818. private _textureType;
  9819. private _defaultTextureMatrix;
  9820. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9821. /**
  9822. * Creates a ShadowGenerator object.
  9823. * A ShadowGenerator is the required tool to use the shadows.
  9824. * Each light casting shadows needs to use its own ShadowGenerator.
  9825. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9826. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9827. * @param light The light object generating the shadows.
  9828. * @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.
  9829. */
  9830. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9831. private _initializeGenerator;
  9832. private _initializeShadowMap;
  9833. private _initializeBlurRTTAndPostProcesses;
  9834. private _renderForShadowMap;
  9835. private _renderSubMeshForShadowMap;
  9836. private _applyFilterValues;
  9837. /**
  9838. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9839. * @param onCompiled Callback triggered at the and of the effects compilation
  9840. * @param options Sets of optional options forcing the compilation with different modes
  9841. */
  9842. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9843. useInstances: boolean;
  9844. }>): void;
  9845. /**
  9846. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9847. * @param options Sets of optional options forcing the compilation with different modes
  9848. * @returns A promise that resolves when the compilation completes
  9849. */
  9850. forceCompilationAsync(options?: Partial<{
  9851. useInstances: boolean;
  9852. }>): Promise<void>;
  9853. /**
  9854. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9855. * @param subMesh The submesh we want to render in the shadow map
  9856. * @param useInstances Defines wether will draw in the map using instances
  9857. * @returns true if ready otherwise, false
  9858. */
  9859. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9860. /**
  9861. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9862. * @param defines Defines of the material we want to update
  9863. * @param lightIndex Index of the light in the enabled light list of the material
  9864. */
  9865. prepareDefines(defines: any, lightIndex: number): void;
  9866. /**
  9867. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9868. * defined in the generator but impacting the effect).
  9869. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9870. * @param effect The effect we are binfing the information for
  9871. */
  9872. bindShadowLight(lightIndex: string, effect: Effect): void;
  9873. /**
  9874. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9875. * (eq to shadow prjection matrix * light transform matrix)
  9876. * @returns The transform matrix used to create the shadow map
  9877. */
  9878. getTransformMatrix(): Matrix;
  9879. /**
  9880. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9881. * Cube and 2D textures for instance.
  9882. */
  9883. recreateShadowMap(): void;
  9884. private _disposeBlurPostProcesses;
  9885. private _disposeRTTandPostProcesses;
  9886. /**
  9887. * Disposes the ShadowGenerator.
  9888. * Returns nothing.
  9889. */
  9890. dispose(): void;
  9891. /**
  9892. * Serializes the shadow generator setup to a json object.
  9893. * @returns The serialized JSON object
  9894. */
  9895. serialize(): any;
  9896. /**
  9897. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9898. * @param parsedShadowGenerator The JSON object to parse
  9899. * @param scene The scene to create the shadow map for
  9900. * @returns The parsed shadow generator
  9901. */
  9902. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9903. }
  9904. }
  9905. declare module BABYLON {
  9906. /**
  9907. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9908. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9909. * 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.
  9910. */
  9911. export abstract class Light extends Node {
  9912. /**
  9913. * Falloff Default: light is falling off following the material specification:
  9914. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9915. */
  9916. static readonly FALLOFF_DEFAULT: number;
  9917. /**
  9918. * Falloff Physical: light is falling off following the inverse squared distance law.
  9919. */
  9920. static readonly FALLOFF_PHYSICAL: number;
  9921. /**
  9922. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9923. * to enhance interoperability with other engines.
  9924. */
  9925. static readonly FALLOFF_GLTF: number;
  9926. /**
  9927. * Falloff Standard: light is falling off like in the standard material
  9928. * to enhance interoperability with other materials.
  9929. */
  9930. static readonly FALLOFF_STANDARD: number;
  9931. /**
  9932. * If every light affecting the material is in this lightmapMode,
  9933. * material.lightmapTexture adds or multiplies
  9934. * (depends on material.useLightmapAsShadowmap)
  9935. * after every other light calculations.
  9936. */
  9937. static readonly LIGHTMAP_DEFAULT: number;
  9938. /**
  9939. * material.lightmapTexture as only diffuse lighting from this light
  9940. * adds only specular lighting from this light
  9941. * adds dynamic shadows
  9942. */
  9943. static readonly LIGHTMAP_SPECULAR: number;
  9944. /**
  9945. * material.lightmapTexture as only lighting
  9946. * no light calculation from this light
  9947. * only adds dynamic shadows from this light
  9948. */
  9949. static readonly LIGHTMAP_SHADOWSONLY: number;
  9950. /**
  9951. * Each light type uses the default quantity according to its type:
  9952. * point/spot lights use luminous intensity
  9953. * directional lights use illuminance
  9954. */
  9955. static readonly INTENSITYMODE_AUTOMATIC: number;
  9956. /**
  9957. * lumen (lm)
  9958. */
  9959. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9960. /**
  9961. * candela (lm/sr)
  9962. */
  9963. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9964. /**
  9965. * lux (lm/m^2)
  9966. */
  9967. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9968. /**
  9969. * nit (cd/m^2)
  9970. */
  9971. static readonly INTENSITYMODE_LUMINANCE: number;
  9972. /**
  9973. * Light type const id of the point light.
  9974. */
  9975. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9976. /**
  9977. * Light type const id of the directional light.
  9978. */
  9979. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9980. /**
  9981. * Light type const id of the spot light.
  9982. */
  9983. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9984. /**
  9985. * Light type const id of the hemispheric light.
  9986. */
  9987. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9988. /**
  9989. * Diffuse gives the basic color to an object.
  9990. */
  9991. diffuse: Color3;
  9992. /**
  9993. * Specular produces a highlight color on an object.
  9994. * Note: This is note affecting PBR materials.
  9995. */
  9996. specular: Color3;
  9997. /**
  9998. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9999. * falling off base on range or angle.
  10000. * This can be set to any values in Light.FALLOFF_x.
  10001. *
  10002. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10003. * other types of materials.
  10004. */
  10005. falloffType: number;
  10006. /**
  10007. * Strength of the light.
  10008. * Note: By default it is define in the framework own unit.
  10009. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10010. */
  10011. intensity: number;
  10012. private _range;
  10013. protected _inverseSquaredRange: number;
  10014. /**
  10015. * Defines how far from the source the light is impacting in scene units.
  10016. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10017. */
  10018. /**
  10019. * Defines how far from the source the light is impacting in scene units.
  10020. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10021. */
  10022. range: number;
  10023. /**
  10024. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10025. * of light.
  10026. */
  10027. private _photometricScale;
  10028. private _intensityMode;
  10029. /**
  10030. * Gets the photometric scale used to interpret the intensity.
  10031. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10032. */
  10033. /**
  10034. * Sets the photometric scale used to interpret the intensity.
  10035. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10036. */
  10037. intensityMode: number;
  10038. private _radius;
  10039. /**
  10040. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10041. */
  10042. /**
  10043. * sets the light radius used by PBR Materials to simulate soft area lights.
  10044. */
  10045. radius: number;
  10046. private _renderPriority;
  10047. /**
  10048. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10049. * exceeding the number allowed of the materials.
  10050. */
  10051. renderPriority: number;
  10052. private _shadowEnabled;
  10053. /**
  10054. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10055. * the current shadow generator.
  10056. */
  10057. /**
  10058. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10059. * the current shadow generator.
  10060. */
  10061. shadowEnabled: boolean;
  10062. private _includedOnlyMeshes;
  10063. /**
  10064. * Gets the only meshes impacted by this light.
  10065. */
  10066. /**
  10067. * Sets the only meshes impacted by this light.
  10068. */
  10069. includedOnlyMeshes: AbstractMesh[];
  10070. private _excludedMeshes;
  10071. /**
  10072. * Gets the meshes not impacted by this light.
  10073. */
  10074. /**
  10075. * Sets the meshes not impacted by this light.
  10076. */
  10077. excludedMeshes: AbstractMesh[];
  10078. private _excludeWithLayerMask;
  10079. /**
  10080. * Gets the layer id use to find what meshes are not impacted by the light.
  10081. * Inactive if 0
  10082. */
  10083. /**
  10084. * Sets the layer id use to find what meshes are not impacted by the light.
  10085. * Inactive if 0
  10086. */
  10087. excludeWithLayerMask: number;
  10088. private _includeOnlyWithLayerMask;
  10089. /**
  10090. * Gets the layer id use to find what meshes are impacted by the light.
  10091. * Inactive if 0
  10092. */
  10093. /**
  10094. * Sets the layer id use to find what meshes are impacted by the light.
  10095. * Inactive if 0
  10096. */
  10097. includeOnlyWithLayerMask: number;
  10098. private _lightmapMode;
  10099. /**
  10100. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10101. */
  10102. /**
  10103. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10104. */
  10105. lightmapMode: number;
  10106. /**
  10107. * Shadow generator associted to the light.
  10108. * @hidden Internal use only.
  10109. */ shadowGenerator: Nullable<IShadowGenerator>;
  10110. /**
  10111. * @hidden Internal use only.
  10112. */ excludedMeshesIds: string[];
  10113. /**
  10114. * @hidden Internal use only.
  10115. */ includedOnlyMeshesIds: string[];
  10116. /**
  10117. * The current light unifom buffer.
  10118. * @hidden Internal use only.
  10119. */ uniformBuffer: UniformBuffer;
  10120. /**
  10121. * Creates a Light object in the scene.
  10122. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10123. * @param name The firendly name of the light
  10124. * @param scene The scene the light belongs too
  10125. */
  10126. constructor(name: string, scene: Scene);
  10127. protected abstract _buildUniformLayout(): void;
  10128. /**
  10129. * Sets the passed Effect "effect" with the Light information.
  10130. * @param effect The effect to update
  10131. * @param lightIndex The index of the light in the effect to update
  10132. * @returns The light
  10133. */
  10134. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10135. /**
  10136. * Returns the string "Light".
  10137. * @returns the class name
  10138. */
  10139. getClassName(): string;
  10140. /** @hidden */ protected readonly _isLight: boolean;
  10141. /**
  10142. * Converts the light information to a readable string for debug purpose.
  10143. * @param fullDetails Supports for multiple levels of logging within scene loading
  10144. * @returns the human readable light info
  10145. */
  10146. toString(fullDetails?: boolean): string;
  10147. /** @hidden */
  10148. protected _syncParentEnabledState(): void;
  10149. /**
  10150. * Set the enabled state of this node.
  10151. * @param value - the new enabled state
  10152. */
  10153. setEnabled(value: boolean): void;
  10154. /**
  10155. * Returns the Light associated shadow generator if any.
  10156. * @return the associated shadow generator.
  10157. */
  10158. getShadowGenerator(): Nullable<IShadowGenerator>;
  10159. /**
  10160. * Returns a Vector3, the absolute light position in the World.
  10161. * @returns the world space position of the light
  10162. */
  10163. getAbsolutePosition(): Vector3;
  10164. /**
  10165. * Specifies if the light will affect the passed mesh.
  10166. * @param mesh The mesh to test against the light
  10167. * @return true the mesh is affected otherwise, false.
  10168. */
  10169. canAffectMesh(mesh: AbstractMesh): boolean;
  10170. /**
  10171. * Sort function to order lights for rendering.
  10172. * @param a First Light object to compare to second.
  10173. * @param b Second Light object to compare first.
  10174. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10175. */
  10176. static CompareLightsPriority(a: Light, b: Light): number;
  10177. /**
  10178. * Releases resources associated with this node.
  10179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10181. */
  10182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10183. /**
  10184. * Returns the light type ID (integer).
  10185. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10186. */
  10187. getTypeID(): number;
  10188. /**
  10189. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10190. * @returns the scaled intensity in intensity mode unit
  10191. */
  10192. getScaledIntensity(): number;
  10193. /**
  10194. * Returns a new Light object, named "name", from the current one.
  10195. * @param name The name of the cloned light
  10196. * @returns the new created light
  10197. */
  10198. clone(name: string): Nullable<Light>;
  10199. /**
  10200. * Serializes the current light into a Serialization object.
  10201. * @returns the serialized object.
  10202. */
  10203. serialize(): any;
  10204. /**
  10205. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10206. * This new light is named "name" and added to the passed scene.
  10207. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10208. * @param name The friendly name of the light
  10209. * @param scene The scene the new light will belong to
  10210. * @returns the constructor function
  10211. */
  10212. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10213. /**
  10214. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10215. * @param parsedLight The JSON representation of the light
  10216. * @param scene The scene to create the parsed light in
  10217. * @returns the created light after parsing
  10218. */
  10219. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10220. private _hookArrayForExcluded;
  10221. private _hookArrayForIncludedOnly;
  10222. private _resyncMeshes;
  10223. /**
  10224. * Forces the meshes to update their light related information in their rendering used effects
  10225. * @hidden Internal Use Only
  10226. */ markMeshesAsLightDirty(): void;
  10227. /**
  10228. * Recomputes the cached photometric scale if needed.
  10229. */
  10230. private _computePhotometricScale;
  10231. /**
  10232. * Returns the Photometric Scale according to the light type and intensity mode.
  10233. */
  10234. private _getPhotometricScale;
  10235. /**
  10236. * Reorder the light in the scene according to their defined priority.
  10237. * @hidden Internal Use Only
  10238. */ reorderLightsInScene(): void;
  10239. /**
  10240. * Prepares the list of defines specific to the light type.
  10241. * @param defines the list of defines
  10242. * @param lightIndex defines the index of the light for the effect
  10243. */
  10244. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10245. }
  10246. }
  10247. declare module BABYLON {
  10248. /**
  10249. * Interface used to define Action
  10250. */
  10251. export interface IAction {
  10252. /**
  10253. * Trigger for the action
  10254. */
  10255. trigger: number;
  10256. /** Options of the trigger */
  10257. triggerOptions: any;
  10258. /**
  10259. * Gets the trigger parameters
  10260. * @returns the trigger parameters
  10261. */
  10262. getTriggerParameter(): any;
  10263. /**
  10264. * Internal only - executes current action event
  10265. * @hidden
  10266. */ executeCurrent(evt?: ActionEvent): void;
  10267. /**
  10268. * Serialize placeholder for child classes
  10269. * @param parent of child
  10270. * @returns the serialized object
  10271. */
  10272. serialize(parent: any): any;
  10273. /**
  10274. * Internal only
  10275. * @hidden
  10276. */ prepare(): void;
  10277. /**
  10278. * Internal only - manager for action
  10279. * @hidden
  10280. */ actionManager: AbstractActionManager;
  10281. }
  10282. /**
  10283. * The action to be carried out following a trigger
  10284. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10285. */
  10286. export class Action implements IAction {
  10287. /** the trigger, with or without parameters, for the action */
  10288. triggerOptions: any;
  10289. /**
  10290. * Trigger for the action
  10291. */
  10292. trigger: number;
  10293. /**
  10294. * Internal only - manager for action
  10295. * @hidden
  10296. */ actionManager: ActionManager;
  10297. private _nextActiveAction;
  10298. private _child;
  10299. private _condition?;
  10300. private _triggerParameter;
  10301. /**
  10302. * An event triggered prior to action being executed.
  10303. */
  10304. onBeforeExecuteObservable: Observable<Action>;
  10305. /**
  10306. * Creates a new Action
  10307. * @param triggerOptions the trigger, with or without parameters, for the action
  10308. * @param condition an optional determinant of action
  10309. */
  10310. constructor(
  10311. /** the trigger, with or without parameters, for the action */
  10312. triggerOptions: any, condition?: Condition);
  10313. /**
  10314. * Internal only
  10315. * @hidden
  10316. */ prepare(): void;
  10317. /**
  10318. * Gets the trigger parameters
  10319. * @returns the trigger parameters
  10320. */
  10321. getTriggerParameter(): any;
  10322. /**
  10323. * Internal only - executes current action event
  10324. * @hidden
  10325. */ executeCurrent(evt?: ActionEvent): void;
  10326. /**
  10327. * Execute placeholder for child classes
  10328. * @param evt optional action event
  10329. */
  10330. execute(evt?: ActionEvent): void;
  10331. /**
  10332. * Skips to next active action
  10333. */
  10334. skipToNextActiveAction(): void;
  10335. /**
  10336. * Adds action to chain of actions, may be a DoNothingAction
  10337. * @param action defines the next action to execute
  10338. * @returns The action passed in
  10339. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10340. */
  10341. then(action: Action): Action;
  10342. /**
  10343. * Internal only
  10344. * @hidden
  10345. */ getProperty(propertyPath: string): string;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10350. /**
  10351. * Serialize placeholder for child classes
  10352. * @param parent of child
  10353. * @returns the serialized object
  10354. */
  10355. serialize(parent: any): any;
  10356. /**
  10357. * Internal only called by serialize
  10358. * @hidden
  10359. */
  10360. protected _serialize(serializedAction: any, parent?: any): any;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */ private static _SerializeValueAsString: (value: any) => string;
  10365. /**
  10366. * Internal only
  10367. * @hidden
  10368. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10369. name: string;
  10370. targetType: string;
  10371. value: string;
  10372. };
  10373. }
  10374. }
  10375. declare module BABYLON {
  10376. /**
  10377. * A Condition applied to an Action
  10378. */
  10379. export class Condition {
  10380. /**
  10381. * Internal only - manager for action
  10382. * @hidden
  10383. */ actionManager: ActionManager;
  10384. /**
  10385. * Internal only
  10386. * @hidden
  10387. */ evaluationId: number;
  10388. /**
  10389. * Internal only
  10390. * @hidden
  10391. */ currentResult: boolean;
  10392. /**
  10393. * Creates a new Condition
  10394. * @param actionManager the manager of the action the condition is applied to
  10395. */
  10396. constructor(actionManager: ActionManager);
  10397. /**
  10398. * Check if the current condition is valid
  10399. * @returns a boolean
  10400. */
  10401. isValid(): boolean;
  10402. /**
  10403. * Internal only
  10404. * @hidden
  10405. */ getProperty(propertyPath: string): string;
  10406. /**
  10407. * Internal only
  10408. * @hidden
  10409. */ getEffectiveTarget(target: any, propertyPath: string): any;
  10410. /**
  10411. * Serialize placeholder for child classes
  10412. * @returns the serialized object
  10413. */
  10414. serialize(): any;
  10415. /**
  10416. * Internal only
  10417. * @hidden
  10418. */
  10419. protected _serialize(serializedCondition: any): any;
  10420. }
  10421. /**
  10422. * Defines specific conditional operators as extensions of Condition
  10423. */
  10424. export class ValueCondition extends Condition {
  10425. /** path to specify the property of the target the conditional operator uses */
  10426. propertyPath: string;
  10427. /** the value compared by the conditional operator against the current value of the property */
  10428. value: any;
  10429. /** the conditional operator, default ValueCondition.IsEqual */
  10430. operator: number;
  10431. /**
  10432. * Internal only
  10433. * @hidden
  10434. */
  10435. private static _IsEqual;
  10436. /**
  10437. * Internal only
  10438. * @hidden
  10439. */
  10440. private static _IsDifferent;
  10441. /**
  10442. * Internal only
  10443. * @hidden
  10444. */
  10445. private static _IsGreater;
  10446. /**
  10447. * Internal only
  10448. * @hidden
  10449. */
  10450. private static _IsLesser;
  10451. /**
  10452. * returns the number for IsEqual
  10453. */
  10454. static readonly IsEqual: number;
  10455. /**
  10456. * Returns the number for IsDifferent
  10457. */
  10458. static readonly IsDifferent: number;
  10459. /**
  10460. * Returns the number for IsGreater
  10461. */
  10462. static readonly IsGreater: number;
  10463. /**
  10464. * Returns the number for IsLesser
  10465. */
  10466. static readonly IsLesser: number;
  10467. /**
  10468. * Internal only The action manager for the condition
  10469. * @hidden
  10470. */ actionManager: ActionManager;
  10471. /**
  10472. * Internal only
  10473. * @hidden
  10474. */
  10475. private _target;
  10476. /**
  10477. * Internal only
  10478. * @hidden
  10479. */
  10480. private _effectiveTarget;
  10481. /**
  10482. * Internal only
  10483. * @hidden
  10484. */
  10485. private _property;
  10486. /**
  10487. * Creates a new ValueCondition
  10488. * @param actionManager manager for the action the condition applies to
  10489. * @param target for the action
  10490. * @param propertyPath path to specify the property of the target the conditional operator uses
  10491. * @param value the value compared by the conditional operator against the current value of the property
  10492. * @param operator the conditional operator, default ValueCondition.IsEqual
  10493. */
  10494. constructor(actionManager: ActionManager, target: any,
  10495. /** path to specify the property of the target the conditional operator uses */
  10496. propertyPath: string,
  10497. /** the value compared by the conditional operator against the current value of the property */
  10498. value: any,
  10499. /** the conditional operator, default ValueCondition.IsEqual */
  10500. operator?: number);
  10501. /**
  10502. * Compares the given value with the property value for the specified conditional operator
  10503. * @returns the result of the comparison
  10504. */
  10505. isValid(): boolean;
  10506. /**
  10507. * Serialize the ValueCondition into a JSON compatible object
  10508. * @returns serialization object
  10509. */
  10510. serialize(): any;
  10511. /**
  10512. * Gets the name of the conditional operator for the ValueCondition
  10513. * @param operator the conditional operator
  10514. * @returns the name
  10515. */
  10516. static GetOperatorName(operator: number): string;
  10517. }
  10518. /**
  10519. * Defines a predicate condition as an extension of Condition
  10520. */
  10521. export class PredicateCondition extends Condition {
  10522. /** defines the predicate function used to validate the condition */
  10523. predicate: () => boolean;
  10524. /**
  10525. * Internal only - manager for action
  10526. * @hidden
  10527. */ actionManager: ActionManager;
  10528. /**
  10529. * Creates a new PredicateCondition
  10530. * @param actionManager manager for the action the condition applies to
  10531. * @param predicate defines the predicate function used to validate the condition
  10532. */
  10533. constructor(actionManager: ActionManager,
  10534. /** defines the predicate function used to validate the condition */
  10535. predicate: () => boolean);
  10536. /**
  10537. * @returns the validity of the predicate condition
  10538. */
  10539. isValid(): boolean;
  10540. }
  10541. /**
  10542. * Defines a state condition as an extension of Condition
  10543. */
  10544. export class StateCondition extends Condition {
  10545. /** Value to compare with target state */
  10546. value: string;
  10547. /**
  10548. * Internal only - manager for action
  10549. * @hidden
  10550. */ actionManager: ActionManager;
  10551. /**
  10552. * Internal only
  10553. * @hidden
  10554. */
  10555. private _target;
  10556. /**
  10557. * Creates a new StateCondition
  10558. * @param actionManager manager for the action the condition applies to
  10559. * @param target of the condition
  10560. * @param value to compare with target state
  10561. */
  10562. constructor(actionManager: ActionManager, target: any,
  10563. /** Value to compare with target state */
  10564. value: string);
  10565. /**
  10566. * Gets a boolean indicating if the current condition is met
  10567. * @returns the validity of the state
  10568. */
  10569. isValid(): boolean;
  10570. /**
  10571. * Serialize the StateCondition into a JSON compatible object
  10572. * @returns serialization object
  10573. */
  10574. serialize(): any;
  10575. }
  10576. }
  10577. declare module BABYLON {
  10578. /**
  10579. * This defines an action responsible to toggle a boolean once triggered.
  10580. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10581. */
  10582. export class SwitchBooleanAction extends Action {
  10583. /**
  10584. * The path to the boolean property in the target object
  10585. */
  10586. propertyPath: string;
  10587. private _target;
  10588. private _effectiveTarget;
  10589. private _property;
  10590. /**
  10591. * Instantiate the action
  10592. * @param triggerOptions defines the trigger options
  10593. * @param target defines the object containing the boolean
  10594. * @param propertyPath defines the path to the boolean property in the target object
  10595. * @param condition defines the trigger related conditions
  10596. */
  10597. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10598. /** @hidden */ prepare(): void;
  10599. /**
  10600. * Execute the action toggle the boolean value.
  10601. */
  10602. execute(): void;
  10603. /**
  10604. * Serializes the actions and its related information.
  10605. * @param parent defines the object to serialize in
  10606. * @returns the serialized object
  10607. */
  10608. serialize(parent: any): any;
  10609. }
  10610. /**
  10611. * This defines an action responsible to set a the state field of the target
  10612. * to a desired value once triggered.
  10613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10614. */
  10615. export class SetStateAction extends Action {
  10616. /**
  10617. * The value to store in the state field.
  10618. */
  10619. value: string;
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the object containing the state property
  10625. * @param value defines the value to store in the state field
  10626. * @param condition defines the trigger related conditions
  10627. */
  10628. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10629. /**
  10630. * Execute the action and store the value on the target state property.
  10631. */
  10632. execute(): void;
  10633. /**
  10634. * Serializes the actions and its related information.
  10635. * @param parent defines the object to serialize in
  10636. * @returns the serialized object
  10637. */
  10638. serialize(parent: any): any;
  10639. }
  10640. /**
  10641. * This defines an action responsible to set a property of the target
  10642. * to a desired value once triggered.
  10643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10644. */
  10645. export class SetValueAction extends Action {
  10646. /**
  10647. * The path of the property to set in the target.
  10648. */
  10649. propertyPath: string;
  10650. /**
  10651. * The value to set in the property
  10652. */
  10653. value: any;
  10654. private _target;
  10655. private _effectiveTarget;
  10656. private _property;
  10657. /**
  10658. * Instantiate the action
  10659. * @param triggerOptions defines the trigger options
  10660. * @param target defines the object containing the property
  10661. * @param propertyPath defines the path of the property to set in the target
  10662. * @param value defines the value to set in the property
  10663. * @param condition defines the trigger related conditions
  10664. */
  10665. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10666. /** @hidden */ prepare(): void;
  10667. /**
  10668. * Execute the action and set the targetted property to the desired value.
  10669. */
  10670. execute(): void;
  10671. /**
  10672. * Serializes the actions and its related information.
  10673. * @param parent defines the object to serialize in
  10674. * @returns the serialized object
  10675. */
  10676. serialize(parent: any): any;
  10677. }
  10678. /**
  10679. * This defines an action responsible to increment the target value
  10680. * to a desired value once triggered.
  10681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10682. */
  10683. export class IncrementValueAction extends Action {
  10684. /**
  10685. * The path of the property to increment in the target.
  10686. */
  10687. propertyPath: string;
  10688. /**
  10689. * The value we should increment the property by.
  10690. */
  10691. value: any;
  10692. private _target;
  10693. private _effectiveTarget;
  10694. private _property;
  10695. /**
  10696. * Instantiate the action
  10697. * @param triggerOptions defines the trigger options
  10698. * @param target defines the object containing the property
  10699. * @param propertyPath defines the path of the property to increment in the target
  10700. * @param value defines the value value we should increment the property by
  10701. * @param condition defines the trigger related conditions
  10702. */
  10703. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10704. /** @hidden */ prepare(): void;
  10705. /**
  10706. * Execute the action and increment the target of the value amount.
  10707. */
  10708. execute(): void;
  10709. /**
  10710. * Serializes the actions and its related information.
  10711. * @param parent defines the object to serialize in
  10712. * @returns the serialized object
  10713. */
  10714. serialize(parent: any): any;
  10715. }
  10716. /**
  10717. * This defines an action responsible to start an animation once triggered.
  10718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10719. */
  10720. export class PlayAnimationAction extends Action {
  10721. /**
  10722. * Where the animation should start (animation frame)
  10723. */
  10724. from: number;
  10725. /**
  10726. * Where the animation should stop (animation frame)
  10727. */
  10728. to: number;
  10729. /**
  10730. * Define if the animation should loop or stop after the first play.
  10731. */
  10732. loop?: boolean;
  10733. private _target;
  10734. /**
  10735. * Instantiate the action
  10736. * @param triggerOptions defines the trigger options
  10737. * @param target defines the target animation or animation name
  10738. * @param from defines from where the animation should start (animation frame)
  10739. * @param end defines where the animation should stop (animation frame)
  10740. * @param loop defines if the animation should loop or stop after the first play
  10741. * @param condition defines the trigger related conditions
  10742. */
  10743. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10744. /** @hidden */ prepare(): void;
  10745. /**
  10746. * Execute the action and play the animation.
  10747. */
  10748. execute(): void;
  10749. /**
  10750. * Serializes the actions and its related information.
  10751. * @param parent defines the object to serialize in
  10752. * @returns the serialized object
  10753. */
  10754. serialize(parent: any): any;
  10755. }
  10756. /**
  10757. * This defines an action responsible to stop an animation once triggered.
  10758. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10759. */
  10760. export class StopAnimationAction extends Action {
  10761. private _target;
  10762. /**
  10763. * Instantiate the action
  10764. * @param triggerOptions defines the trigger options
  10765. * @param target defines the target animation or animation name
  10766. * @param condition defines the trigger related conditions
  10767. */
  10768. constructor(triggerOptions: any, target: any, condition?: Condition);
  10769. /** @hidden */ prepare(): void;
  10770. /**
  10771. * Execute the action and stop the animation.
  10772. */
  10773. execute(): void;
  10774. /**
  10775. * Serializes the actions and its related information.
  10776. * @param parent defines the object to serialize in
  10777. * @returns the serialized object
  10778. */
  10779. serialize(parent: any): any;
  10780. }
  10781. /**
  10782. * This defines an action responsible that does nothing once triggered.
  10783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10784. */
  10785. export class DoNothingAction extends Action {
  10786. /**
  10787. * Instantiate the action
  10788. * @param triggerOptions defines the trigger options
  10789. * @param condition defines the trigger related conditions
  10790. */
  10791. constructor(triggerOptions?: any, condition?: Condition);
  10792. /**
  10793. * Execute the action and do nothing.
  10794. */
  10795. execute(): void;
  10796. /**
  10797. * Serializes the actions and its related information.
  10798. * @param parent defines the object to serialize in
  10799. * @returns the serialized object
  10800. */
  10801. serialize(parent: any): any;
  10802. }
  10803. /**
  10804. * This defines an action responsible to trigger several actions once triggered.
  10805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10806. */
  10807. export class CombineAction extends Action {
  10808. /**
  10809. * The list of aggregated animations to run.
  10810. */
  10811. children: Action[];
  10812. /**
  10813. * Instantiate the action
  10814. * @param triggerOptions defines the trigger options
  10815. * @param children defines the list of aggregated animations to run
  10816. * @param condition defines the trigger related conditions
  10817. */
  10818. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10819. /** @hidden */ prepare(): void;
  10820. /**
  10821. * Execute the action and executes all the aggregated actions.
  10822. */
  10823. execute(evt: ActionEvent): void;
  10824. /**
  10825. * Serializes the actions and its related information.
  10826. * @param parent defines the object to serialize in
  10827. * @returns the serialized object
  10828. */
  10829. serialize(parent: any): any;
  10830. }
  10831. /**
  10832. * This defines an action responsible to run code (external event) once triggered.
  10833. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10834. */
  10835. export class ExecuteCodeAction extends Action {
  10836. /**
  10837. * The callback function to run.
  10838. */
  10839. func: (evt: ActionEvent) => void;
  10840. /**
  10841. * Instantiate the action
  10842. * @param triggerOptions defines the trigger options
  10843. * @param func defines the callback function to run
  10844. * @param condition defines the trigger related conditions
  10845. */
  10846. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10847. /**
  10848. * Execute the action and run the attached code.
  10849. */
  10850. execute(evt: ActionEvent): void;
  10851. }
  10852. /**
  10853. * This defines an action responsible to set the parent property of the target once triggered.
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10855. */
  10856. export class SetParentAction extends Action {
  10857. private _parent;
  10858. private _target;
  10859. /**
  10860. * Instantiate the action
  10861. * @param triggerOptions defines the trigger options
  10862. * @param target defines the target containing the parent property
  10863. * @param parent defines from where the animation should start (animation frame)
  10864. * @param condition defines the trigger related conditions
  10865. */
  10866. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10867. /** @hidden */ prepare(): void;
  10868. /**
  10869. * Execute the action and set the parent property.
  10870. */
  10871. execute(): void;
  10872. /**
  10873. * Serializes the actions and its related information.
  10874. * @param parent defines the object to serialize in
  10875. * @returns the serialized object
  10876. */
  10877. serialize(parent: any): any;
  10878. }
  10879. }
  10880. declare module BABYLON {
  10881. /**
  10882. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10883. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10885. */
  10886. export class ActionManager extends AbstractActionManager {
  10887. /**
  10888. * Nothing
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly NothingTrigger: number;
  10892. /**
  10893. * On pick
  10894. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10895. */
  10896. static readonly OnPickTrigger: number;
  10897. /**
  10898. * On left pick
  10899. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10900. */
  10901. static readonly OnLeftPickTrigger: number;
  10902. /**
  10903. * On right pick
  10904. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10905. */
  10906. static readonly OnRightPickTrigger: number;
  10907. /**
  10908. * On center pick
  10909. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10910. */
  10911. static readonly OnCenterPickTrigger: number;
  10912. /**
  10913. * On pick down
  10914. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10915. */
  10916. static readonly OnPickDownTrigger: number;
  10917. /**
  10918. * On double pick
  10919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10920. */
  10921. static readonly OnDoublePickTrigger: number;
  10922. /**
  10923. * On pick up
  10924. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10925. */
  10926. static readonly OnPickUpTrigger: number;
  10927. /**
  10928. * On pick out.
  10929. * This trigger will only be raised if you also declared a OnPickDown
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10931. */
  10932. static readonly OnPickOutTrigger: number;
  10933. /**
  10934. * On long press
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnLongPressTrigger: number;
  10938. /**
  10939. * On pointer over
  10940. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10941. */
  10942. static readonly OnPointerOverTrigger: number;
  10943. /**
  10944. * On pointer out
  10945. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10946. */
  10947. static readonly OnPointerOutTrigger: number;
  10948. /**
  10949. * On every frame
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10951. */
  10952. static readonly OnEveryFrameTrigger: number;
  10953. /**
  10954. * On intersection enter
  10955. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10956. */
  10957. static readonly OnIntersectionEnterTrigger: number;
  10958. /**
  10959. * On intersection exit
  10960. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10961. */
  10962. static readonly OnIntersectionExitTrigger: number;
  10963. /**
  10964. * On key down
  10965. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10966. */
  10967. static readonly OnKeyDownTrigger: number;
  10968. /**
  10969. * On key up
  10970. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10971. */
  10972. static readonly OnKeyUpTrigger: number;
  10973. private _scene;
  10974. /**
  10975. * Creates a new action manager
  10976. * @param scene defines the hosting scene
  10977. */
  10978. constructor(scene: Scene);
  10979. /**
  10980. * Releases all associated resources
  10981. */
  10982. dispose(): void;
  10983. /**
  10984. * Gets hosting scene
  10985. * @returns the hosting scene
  10986. */
  10987. getScene(): Scene;
  10988. /**
  10989. * Does this action manager handles actions of any of the given triggers
  10990. * @param triggers defines the triggers to be tested
  10991. * @return a boolean indicating whether one (or more) of the triggers is handled
  10992. */
  10993. hasSpecificTriggers(triggers: number[]): boolean;
  10994. /**
  10995. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10996. * speed.
  10997. * @param triggerA defines the trigger to be tested
  10998. * @param triggerB defines the trigger to be tested
  10999. * @return a boolean indicating whether one (or more) of the triggers is handled
  11000. */
  11001. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11002. /**
  11003. * Does this action manager handles actions of a given trigger
  11004. * @param trigger defines the trigger to be tested
  11005. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11006. * @return whether the trigger is handled
  11007. */
  11008. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11009. /**
  11010. * Does this action manager has pointer triggers
  11011. */
  11012. readonly hasPointerTriggers: boolean;
  11013. /**
  11014. * Does this action manager has pick triggers
  11015. */
  11016. readonly hasPickTriggers: boolean;
  11017. /**
  11018. * Registers an action to this action manager
  11019. * @param action defines the action to be registered
  11020. * @return the action amended (prepared) after registration
  11021. */
  11022. registerAction(action: IAction): Nullable<IAction>;
  11023. /**
  11024. * Unregisters an action to this action manager
  11025. * @param action defines the action to be unregistered
  11026. * @return a boolean indicating whether the action has been unregistered
  11027. */
  11028. unregisterAction(action: IAction): Boolean;
  11029. /**
  11030. * Process a specific trigger
  11031. * @param trigger defines the trigger to process
  11032. * @param evt defines the event details to be processed
  11033. */
  11034. processTrigger(trigger: number, evt?: IActionEvent): void;
  11035. /** @hidden */ getEffectiveTarget(target: any, propertyPath: string): any;
  11036. /** @hidden */ getProperty(propertyPath: string): string;
  11037. /**
  11038. * Serialize this manager to a JSON object
  11039. * @param name defines the property name to store this manager
  11040. * @returns a JSON representation of this manager
  11041. */
  11042. serialize(name: string): any;
  11043. /**
  11044. * Creates a new ActionManager from a JSON data
  11045. * @param parsedActions defines the JSON data to read from
  11046. * @param object defines the hosting mesh
  11047. * @param scene defines the hosting scene
  11048. */
  11049. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11050. /**
  11051. * Get a trigger name by index
  11052. * @param trigger defines the trigger index
  11053. * @returns a trigger name
  11054. */
  11055. static GetTriggerName(trigger: number): string;
  11056. }
  11057. }
  11058. declare module BABYLON {
  11059. /**
  11060. * Class representing a ray with position and direction
  11061. */
  11062. export class Ray {
  11063. /** origin point */
  11064. origin: Vector3;
  11065. /** direction */
  11066. direction: Vector3;
  11067. /** length of the ray */
  11068. length: number;
  11069. private static readonly TmpVector3;
  11070. private _tmpRay;
  11071. /**
  11072. * Creates a new ray
  11073. * @param origin origin point
  11074. * @param direction direction
  11075. * @param length length of the ray
  11076. */
  11077. constructor(
  11078. /** origin point */
  11079. origin: Vector3,
  11080. /** direction */
  11081. direction: Vector3,
  11082. /** length of the ray */
  11083. length?: number);
  11084. /**
  11085. * Checks if the ray intersects a box
  11086. * @param minimum bound of the box
  11087. * @param maximum bound of the box
  11088. * @param intersectionTreshold extra extend to be added to the box in all direction
  11089. * @returns if the box was hit
  11090. */
  11091. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11092. /**
  11093. * Checks if the ray intersects a box
  11094. * @param box the bounding box to check
  11095. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11096. * @returns if the box was hit
  11097. */
  11098. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11099. /**
  11100. * If the ray hits a sphere
  11101. * @param sphere the bounding sphere to check
  11102. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11103. * @returns true if it hits the sphere
  11104. */
  11105. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11106. /**
  11107. * If the ray hits a triange
  11108. * @param vertex0 triangle vertex
  11109. * @param vertex1 triangle vertex
  11110. * @param vertex2 triangle vertex
  11111. * @returns intersection information if hit
  11112. */
  11113. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11114. /**
  11115. * Checks if ray intersects a plane
  11116. * @param plane the plane to check
  11117. * @returns the distance away it was hit
  11118. */
  11119. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11120. /**
  11121. * Checks if ray intersects a mesh
  11122. * @param mesh the mesh to check
  11123. * @param fastCheck if only the bounding box should checked
  11124. * @returns picking info of the intersecton
  11125. */
  11126. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11127. /**
  11128. * Checks if ray intersects a mesh
  11129. * @param meshes the meshes to check
  11130. * @param fastCheck if only the bounding box should checked
  11131. * @param results array to store result in
  11132. * @returns Array of picking infos
  11133. */
  11134. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11135. private _comparePickingInfo;
  11136. private static smallnum;
  11137. private static rayl;
  11138. /**
  11139. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11140. * @param sega the first point of the segment to test the intersection against
  11141. * @param segb the second point of the segment to test the intersection against
  11142. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11143. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11144. */
  11145. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11146. /**
  11147. * Update the ray from viewport position
  11148. * @param x position
  11149. * @param y y position
  11150. * @param viewportWidth viewport width
  11151. * @param viewportHeight viewport height
  11152. * @param world world matrix
  11153. * @param view view matrix
  11154. * @param projection projection matrix
  11155. * @returns this ray updated
  11156. */
  11157. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11158. /**
  11159. * Creates a ray with origin and direction of 0,0,0
  11160. * @returns the new ray
  11161. */
  11162. static Zero(): Ray;
  11163. /**
  11164. * Creates a new ray from screen space and viewport
  11165. * @param x position
  11166. * @param y y position
  11167. * @param viewportWidth viewport width
  11168. * @param viewportHeight viewport height
  11169. * @param world world matrix
  11170. * @param view view matrix
  11171. * @param projection projection matrix
  11172. * @returns new ray
  11173. */
  11174. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11175. /**
  11176. * 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
  11177. * transformed to the given world matrix.
  11178. * @param origin The origin point
  11179. * @param end The end point
  11180. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11181. * @returns the new ray
  11182. */
  11183. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11184. /**
  11185. * Transforms a ray by a matrix
  11186. * @param ray ray to transform
  11187. * @param matrix matrix to apply
  11188. * @returns the resulting new ray
  11189. */
  11190. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11191. /**
  11192. * Transforms a ray by a matrix
  11193. * @param ray ray to transform
  11194. * @param matrix matrix to apply
  11195. * @param result ray to store result in
  11196. */
  11197. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11198. /**
  11199. * Unproject a ray from screen space to object space
  11200. * @param sourceX defines the screen space x coordinate to use
  11201. * @param sourceY defines the screen space y coordinate to use
  11202. * @param viewportWidth defines the current width of the viewport
  11203. * @param viewportHeight defines the current height of the viewport
  11204. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11205. * @param view defines the view matrix to use
  11206. * @param projection defines the projection matrix to use
  11207. */
  11208. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11209. }
  11210. /**
  11211. * Type used to define predicate used to select faces when a mesh intersection is detected
  11212. */
  11213. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11214. interface Scene {
  11215. /** @hidden */ tempPickingRay: Nullable<Ray>;
  11216. /** @hidden */ cachedRayForTransform: Ray;
  11217. /** @hidden */ pickWithRayInverseMatrix: Matrix;
  11218. /** @hidden */ internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11219. /** @hidden */ internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11220. }
  11221. }
  11222. declare module BABYLON {
  11223. /**
  11224. * Groups all the scene component constants in one place to ease maintenance.
  11225. * @hidden
  11226. */
  11227. export class SceneComponentConstants {
  11228. static readonly NAME_EFFECTLAYER: string;
  11229. static readonly NAME_LAYER: string;
  11230. static readonly NAME_LENSFLARESYSTEM: string;
  11231. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11232. static readonly NAME_PARTICLESYSTEM: string;
  11233. static readonly NAME_GAMEPAD: string;
  11234. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11235. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11236. static readonly NAME_DEPTHRENDERER: string;
  11237. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11238. static readonly NAME_SPRITE: string;
  11239. static readonly NAME_OUTLINERENDERER: string;
  11240. static readonly NAME_PROCEDURALTEXTURE: string;
  11241. static readonly NAME_SHADOWGENERATOR: string;
  11242. static readonly NAME_OCTREE: string;
  11243. static readonly NAME_PHYSICSENGINE: string;
  11244. static readonly NAME_AUDIO: string;
  11245. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11246. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11247. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11248. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11249. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11250. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11251. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11252. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11253. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11254. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11255. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11256. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11257. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11258. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11259. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11260. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11261. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11262. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11263. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11264. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11265. static readonly STEP_AFTERRENDER_AUDIO: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11267. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11268. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11269. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11270. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11271. static readonly STEP_POINTERMOVE_SPRITE: number;
  11272. static readonly STEP_POINTERDOWN_SPRITE: number;
  11273. static readonly STEP_POINTERUP_SPRITE: number;
  11274. }
  11275. /**
  11276. * This represents a scene component.
  11277. *
  11278. * This is used to decouple the dependency the scene is having on the different workloads like
  11279. * layers, post processes...
  11280. */
  11281. export interface ISceneComponent {
  11282. /**
  11283. * The name of the component. Each component must have a unique name.
  11284. */
  11285. name: string;
  11286. /**
  11287. * The scene the component belongs to.
  11288. */
  11289. scene: Scene;
  11290. /**
  11291. * Register the component to one instance of a scene.
  11292. */
  11293. register(): void;
  11294. /**
  11295. * Rebuilds the elements related to this component in case of
  11296. * context lost for instance.
  11297. */
  11298. rebuild(): void;
  11299. /**
  11300. * Disposes the component and the associated ressources.
  11301. */
  11302. dispose(): void;
  11303. }
  11304. /**
  11305. * This represents a SERIALIZABLE scene component.
  11306. *
  11307. * This extends Scene Component to add Serialization methods on top.
  11308. */
  11309. export interface ISceneSerializableComponent extends ISceneComponent {
  11310. /**
  11311. * Adds all the element from the container to the scene
  11312. * @param container the container holding the elements
  11313. */
  11314. addFromContainer(container: AbstractScene): void;
  11315. /**
  11316. * Removes all the elements in the container from the scene
  11317. * @param container contains the elements to remove
  11318. * @param dispose if the removed element should be disposed (default: false)
  11319. */
  11320. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11321. /**
  11322. * Serializes the component data to the specified json object
  11323. * @param serializationObject The object to serialize to
  11324. */
  11325. serialize(serializationObject: any): void;
  11326. }
  11327. /**
  11328. * Strong typing of a Mesh related stage step action
  11329. */
  11330. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11331. /**
  11332. * Strong typing of a Evaluate Sub Mesh related stage step action
  11333. */
  11334. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11335. /**
  11336. * Strong typing of a Active Mesh related stage step action
  11337. */
  11338. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11339. /**
  11340. * Strong typing of a Camera related stage step action
  11341. */
  11342. export type CameraStageAction = (camera: Camera) => void;
  11343. /**
  11344. * Strong typing of a Render Target related stage step action
  11345. */
  11346. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11347. /**
  11348. * Strong typing of a RenderingGroup related stage step action
  11349. */
  11350. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11351. /**
  11352. * Strong typing of a Mesh Render related stage step action
  11353. */
  11354. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11355. /**
  11356. * Strong typing of a simple stage step action
  11357. */
  11358. export type SimpleStageAction = () => void;
  11359. /**
  11360. * Strong typing of a render target action.
  11361. */
  11362. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11363. /**
  11364. * Strong typing of a pointer move action.
  11365. */
  11366. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11367. /**
  11368. * Strong typing of a pointer up/down action.
  11369. */
  11370. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11371. /**
  11372. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11373. * @hidden
  11374. */
  11375. export class Stage<T extends Function> extends Array<{
  11376. index: number;
  11377. component: ISceneComponent;
  11378. action: T;
  11379. }> {
  11380. /**
  11381. * Hide ctor from the rest of the world.
  11382. * @param items The items to add.
  11383. */
  11384. private constructor();
  11385. /**
  11386. * Creates a new Stage.
  11387. * @returns A new instance of a Stage
  11388. */
  11389. static Create<T extends Function>(): Stage<T>;
  11390. /**
  11391. * Registers a step in an ordered way in the targeted stage.
  11392. * @param index Defines the position to register the step in
  11393. * @param component Defines the component attached to the step
  11394. * @param action Defines the action to launch during the step
  11395. */
  11396. registerStep(index: number, component: ISceneComponent, action: T): void;
  11397. /**
  11398. * Clears all the steps from the stage.
  11399. */
  11400. clear(): void;
  11401. }
  11402. }
  11403. declare module BABYLON {
  11404. interface Scene {
  11405. /** @hidden */ pointerOverSprite: Nullable<Sprite>;
  11406. /** @hidden */ pickedDownSprite: Nullable<Sprite>;
  11407. /** @hidden */ tempSpritePickingRay: Nullable<Ray>;
  11408. /**
  11409. * All of the sprite managers added to this scene
  11410. * @see http://doc.babylonjs.com/babylon101/sprites
  11411. */
  11412. spriteManagers: Array<ISpriteManager>;
  11413. /**
  11414. * An event triggered when sprites rendering is about to start
  11415. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11416. */
  11417. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11418. /**
  11419. * An event triggered when sprites rendering is done
  11420. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11421. */
  11422. onAfterSpritesRenderingObservable: Observable<Scene>;
  11423. /** @hidden */ internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11424. /** Launch a ray to try to pick a sprite in the scene
  11425. * @param x position on screen
  11426. * @param y position on screen
  11427. * @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
  11428. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11429. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11430. * @returns a PickingInfo
  11431. */
  11432. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11433. /** Use the given ray to pick a sprite in the scene
  11434. * @param ray The ray (in world space) to use to pick meshes
  11435. * @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
  11436. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11437. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11438. * @returns a PickingInfo
  11439. */
  11440. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11441. /**
  11442. * Force the sprite under the pointer
  11443. * @param sprite defines the sprite to use
  11444. */
  11445. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11446. /**
  11447. * Gets the sprite under the pointer
  11448. * @returns a Sprite or null if no sprite is under the pointer
  11449. */
  11450. getPointerOverSprite(): Nullable<Sprite>;
  11451. }
  11452. /**
  11453. * Defines the sprite scene component responsible to manage sprites
  11454. * in a given scene.
  11455. */
  11456. export class SpriteSceneComponent implements ISceneComponent {
  11457. /**
  11458. * The component name helpfull to identify the component in the list of scene components.
  11459. */
  11460. readonly name: string;
  11461. /**
  11462. * The scene the component belongs to.
  11463. */
  11464. scene: Scene;
  11465. /** @hidden */
  11466. private _spritePredicate;
  11467. /**
  11468. * Creates a new instance of the component for the given scene
  11469. * @param scene Defines the scene to register the component in
  11470. */
  11471. constructor(scene: Scene);
  11472. /**
  11473. * Registers the component in a given scene
  11474. */
  11475. register(): void;
  11476. /**
  11477. * Rebuilds the elements related to this component in case of
  11478. * context lost for instance.
  11479. */
  11480. rebuild(): void;
  11481. /**
  11482. * Disposes the component and the associated ressources.
  11483. */
  11484. dispose(): void;
  11485. private _pickSpriteButKeepRay;
  11486. private _pointerMove;
  11487. private _pointerDown;
  11488. private _pointerUp;
  11489. }
  11490. }
  11491. declare module BABYLON {
  11492. /** @hidden */
  11493. export var fogFragmentDeclaration: {
  11494. name: string;
  11495. shader: string;
  11496. };
  11497. }
  11498. declare module BABYLON {
  11499. /** @hidden */
  11500. export var fogFragment: {
  11501. name: string;
  11502. shader: string;
  11503. };
  11504. }
  11505. declare module BABYLON {
  11506. /** @hidden */
  11507. export var spritesPixelShader: {
  11508. name: string;
  11509. shader: string;
  11510. };
  11511. }
  11512. declare module BABYLON {
  11513. /** @hidden */
  11514. export var fogVertexDeclaration: {
  11515. name: string;
  11516. shader: string;
  11517. };
  11518. }
  11519. declare module BABYLON {
  11520. /** @hidden */
  11521. export var spritesVertexShader: {
  11522. name: string;
  11523. shader: string;
  11524. };
  11525. }
  11526. declare module BABYLON {
  11527. /**
  11528. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11529. */
  11530. export interface ISpriteManager extends IDisposable {
  11531. /**
  11532. * Restricts the camera to viewing objects with the same layerMask.
  11533. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11534. */
  11535. layerMask: number;
  11536. /**
  11537. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11538. */
  11539. isPickable: boolean;
  11540. /**
  11541. * Specifies the rendering group id for this mesh (0 by default)
  11542. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11543. */
  11544. renderingGroupId: number;
  11545. /**
  11546. * Defines the list of sprites managed by the manager.
  11547. */
  11548. sprites: Array<Sprite>;
  11549. /**
  11550. * Tests the intersection of a sprite with a specific ray.
  11551. * @param ray The ray we are sending to test the collision
  11552. * @param camera The camera space we are sending rays in
  11553. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11554. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11555. * @returns picking info or null.
  11556. */
  11557. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11558. /**
  11559. * Renders the list of sprites on screen.
  11560. */
  11561. render(): void;
  11562. }
  11563. /**
  11564. * Class used to manage multiple sprites on the same spritesheet
  11565. * @see http://doc.babylonjs.com/babylon101/sprites
  11566. */
  11567. export class SpriteManager implements ISpriteManager {
  11568. /** defines the manager's name */
  11569. name: string;
  11570. /** Gets the list of sprites */
  11571. sprites: Sprite[];
  11572. /** Gets or sets the rendering group id (0 by default) */
  11573. renderingGroupId: number;
  11574. /** Gets or sets camera layer mask */
  11575. layerMask: number;
  11576. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11577. fogEnabled: boolean;
  11578. /** Gets or sets a boolean indicating if the sprites are pickable */
  11579. isPickable: boolean;
  11580. /** Defines the default width of a cell in the spritesheet */
  11581. cellWidth: number;
  11582. /** Defines the default height of a cell in the spritesheet */
  11583. cellHeight: number;
  11584. /**
  11585. * An event triggered when the manager is disposed.
  11586. */
  11587. onDisposeObservable: Observable<SpriteManager>;
  11588. private _onDisposeObserver;
  11589. /**
  11590. * Callback called when the manager is disposed
  11591. */
  11592. onDispose: () => void;
  11593. private _capacity;
  11594. private _spriteTexture;
  11595. private _epsilon;
  11596. private _scene;
  11597. private _vertexData;
  11598. private _buffer;
  11599. private _vertexBuffers;
  11600. private _indexBuffer;
  11601. private _effectBase;
  11602. private _effectFog;
  11603. /**
  11604. * Gets or sets the spritesheet texture
  11605. */
  11606. texture: Texture;
  11607. /**
  11608. * Creates a new sprite manager
  11609. * @param name defines the manager's name
  11610. * @param imgUrl defines the sprite sheet url
  11611. * @param capacity defines the maximum allowed number of sprites
  11612. * @param cellSize defines the size of a sprite cell
  11613. * @param scene defines the hosting scene
  11614. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11615. * @param samplingMode defines the smapling mode to use with spritesheet
  11616. */
  11617. constructor(
  11618. /** defines the manager's name */
  11619. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11620. private _appendSpriteVertex;
  11621. /**
  11622. * Intersects the sprites with a ray
  11623. * @param ray defines the ray to intersect with
  11624. * @param camera defines the current active camera
  11625. * @param predicate defines a predicate used to select candidate sprites
  11626. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11627. * @returns null if no hit or a PickingInfo
  11628. */
  11629. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11630. /**
  11631. * Render all child sprites
  11632. */
  11633. render(): void;
  11634. /**
  11635. * Release associated resources
  11636. */
  11637. dispose(): void;
  11638. }
  11639. }
  11640. declare module BABYLON {
  11641. /**
  11642. * Class used to represent a sprite
  11643. * @see http://doc.babylonjs.com/babylon101/sprites
  11644. */
  11645. export class Sprite {
  11646. /** defines the name */
  11647. name: string;
  11648. /** Gets or sets the current world position */
  11649. position: Vector3;
  11650. /** Gets or sets the main color */
  11651. color: Color4;
  11652. /** Gets or sets the width */
  11653. width: number;
  11654. /** Gets or sets the height */
  11655. height: number;
  11656. /** Gets or sets rotation angle */
  11657. angle: number;
  11658. /** Gets or sets the cell index in the sprite sheet */
  11659. cellIndex: number;
  11660. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11661. invertU: number;
  11662. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11663. invertV: number;
  11664. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11665. disposeWhenFinishedAnimating: boolean;
  11666. /** Gets the list of attached animations */
  11667. animations: Animation[];
  11668. /** Gets or sets a boolean indicating if the sprite can be picked */
  11669. isPickable: boolean;
  11670. /**
  11671. * Gets or sets the associated action manager
  11672. */
  11673. actionManager: Nullable<ActionManager>;
  11674. private _animationStarted;
  11675. private _loopAnimation;
  11676. private _fromIndex;
  11677. private _toIndex;
  11678. private _delay;
  11679. private _direction;
  11680. private _manager;
  11681. private _time;
  11682. private _onAnimationEnd;
  11683. /**
  11684. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11685. */
  11686. isVisible: boolean;
  11687. /**
  11688. * Gets or sets the sprite size
  11689. */
  11690. size: number;
  11691. /**
  11692. * Creates a new Sprite
  11693. * @param name defines the name
  11694. * @param manager defines the manager
  11695. */
  11696. constructor(
  11697. /** defines the name */
  11698. name: string, manager: ISpriteManager);
  11699. /**
  11700. * Starts an animation
  11701. * @param from defines the initial key
  11702. * @param to defines the end key
  11703. * @param loop defines if the animation must loop
  11704. * @param delay defines the start delay (in ms)
  11705. * @param onAnimationEnd defines a callback to call when animation ends
  11706. */
  11707. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11708. /** Stops current animation (if any) */
  11709. stopAnimation(): void;
  11710. /** @hidden */ animate(deltaTime: number): void;
  11711. /** Release associated resources */
  11712. dispose(): void;
  11713. }
  11714. }
  11715. declare module BABYLON {
  11716. /**
  11717. * Information about the result of picking within a scene
  11718. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11719. */
  11720. export class PickingInfo {
  11721. /** @hidden */ pickingUnavailable: boolean;
  11722. /**
  11723. * If the pick collided with an object
  11724. */
  11725. hit: boolean;
  11726. /**
  11727. * Distance away where the pick collided
  11728. */
  11729. distance: number;
  11730. /**
  11731. * The location of pick collision
  11732. */
  11733. pickedPoint: Nullable<Vector3>;
  11734. /**
  11735. * The mesh corresponding the the pick collision
  11736. */
  11737. pickedMesh: Nullable<AbstractMesh>;
  11738. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11739. bu: number;
  11740. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11741. bv: number;
  11742. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11743. faceId: number;
  11744. /** Id of the the submesh that was picked */
  11745. subMeshId: number;
  11746. /** If a sprite was picked, this will be the sprite the pick collided with */
  11747. pickedSprite: Nullable<Sprite>;
  11748. /**
  11749. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11750. */
  11751. originMesh: Nullable<AbstractMesh>;
  11752. /**
  11753. * The ray that was used to perform the picking.
  11754. */
  11755. ray: Nullable<Ray>;
  11756. /**
  11757. * Gets the normal correspodning to the face the pick collided with
  11758. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11759. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11760. * @returns The normal correspodning to the face the pick collided with
  11761. */
  11762. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11763. /**
  11764. * Gets the texture coordinates of where the pick occured
  11765. * @returns the vector containing the coordnates of the texture
  11766. */
  11767. getTextureCoordinates(): Nullable<Vector2>;
  11768. }
  11769. }
  11770. declare module BABYLON {
  11771. /**
  11772. * Gather the list of pointer event types as constants.
  11773. */
  11774. export class PointerEventTypes {
  11775. /**
  11776. * 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.
  11777. */
  11778. static readonly POINTERDOWN: number;
  11779. /**
  11780. * The pointerup event is fired when a pointer is no longer active.
  11781. */
  11782. static readonly POINTERUP: number;
  11783. /**
  11784. * The pointermove event is fired when a pointer changes coordinates.
  11785. */
  11786. static readonly POINTERMOVE: number;
  11787. /**
  11788. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11789. */
  11790. static readonly POINTERWHEEL: number;
  11791. /**
  11792. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11793. */
  11794. static readonly POINTERPICK: number;
  11795. /**
  11796. * The pointertap event is fired when a the object has been touched and released without drag.
  11797. */
  11798. static readonly POINTERTAP: number;
  11799. /**
  11800. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11801. */
  11802. static readonly POINTERDOUBLETAP: number;
  11803. }
  11804. /**
  11805. * Base class of pointer info types.
  11806. */
  11807. export class PointerInfoBase {
  11808. /**
  11809. * Defines the type of event (PointerEventTypes)
  11810. */
  11811. type: number;
  11812. /**
  11813. * Defines the related dom event
  11814. */
  11815. event: PointerEvent | MouseWheelEvent;
  11816. /**
  11817. * Instantiates the base class of pointers info.
  11818. * @param type Defines the type of event (PointerEventTypes)
  11819. * @param event Defines the related dom event
  11820. */
  11821. constructor(
  11822. /**
  11823. * Defines the type of event (PointerEventTypes)
  11824. */
  11825. type: number,
  11826. /**
  11827. * Defines the related dom event
  11828. */
  11829. event: PointerEvent | MouseWheelEvent);
  11830. }
  11831. /**
  11832. * This class is used to store pointer related info for the onPrePointerObservable event.
  11833. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11834. */
  11835. export class PointerInfoPre extends PointerInfoBase {
  11836. /**
  11837. * Ray from a pointer if availible (eg. 6dof controller)
  11838. */
  11839. ray: Nullable<Ray>;
  11840. /**
  11841. * Defines the local position of the pointer on the canvas.
  11842. */
  11843. localPosition: Vector2;
  11844. /**
  11845. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11846. */
  11847. skipOnPointerObservable: boolean;
  11848. /**
  11849. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11850. * @param type Defines the type of event (PointerEventTypes)
  11851. * @param event Defines the related dom event
  11852. * @param localX Defines the local x coordinates of the pointer when the event occured
  11853. * @param localY Defines the local y coordinates of the pointer when the event occured
  11854. */
  11855. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11856. }
  11857. /**
  11858. * This type contains all the data related to a pointer event in Babylon.js.
  11859. * 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.
  11860. */
  11861. export class PointerInfo extends PointerInfoBase {
  11862. /**
  11863. * Defines the picking info associated to the info (if any)\
  11864. */
  11865. pickInfo: Nullable<PickingInfo>;
  11866. /**
  11867. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11868. * @param type Defines the type of event (PointerEventTypes)
  11869. * @param event Defines the related dom event
  11870. * @param pickInfo Defines the picking info associated to the info (if any)\
  11871. */
  11872. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11873. /**
  11874. * Defines the picking info associated to the info (if any)\
  11875. */
  11876. pickInfo: Nullable<PickingInfo>);
  11877. }
  11878. /**
  11879. * Data relating to a touch event on the screen.
  11880. */
  11881. export interface PointerTouch {
  11882. /**
  11883. * X coordinate of touch.
  11884. */
  11885. x: number;
  11886. /**
  11887. * Y coordinate of touch.
  11888. */
  11889. y: number;
  11890. /**
  11891. * Id of touch. Unique for each finger.
  11892. */
  11893. pointerId: number;
  11894. /**
  11895. * Event type passed from DOM.
  11896. */
  11897. type: any;
  11898. }
  11899. }
  11900. declare module BABYLON {
  11901. /**
  11902. * Manage the mouse inputs to control the movement of a free camera.
  11903. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11904. */
  11905. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11906. /**
  11907. * Define if touch is enabled in the mouse input
  11908. */
  11909. touchEnabled: boolean;
  11910. /**
  11911. * Defines the camera the input is attached to.
  11912. */
  11913. camera: FreeCamera;
  11914. /**
  11915. * Defines the buttons associated with the input to handle camera move.
  11916. */
  11917. buttons: number[];
  11918. /**
  11919. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11920. */
  11921. angularSensibility: number;
  11922. private _pointerInput;
  11923. private _onMouseMove;
  11924. private _observer;
  11925. private previousPosition;
  11926. /**
  11927. * Observable for when a pointer move event occurs containing the move offset
  11928. */
  11929. onPointerMovedObservable: Observable<{
  11930. offsetX: number;
  11931. offsetY: number;
  11932. }>;
  11933. /**
  11934. * @hidden
  11935. * If the camera should be rotated automatically based on pointer movement
  11936. */ allowCameraRotation: boolean;
  11937. /**
  11938. * Manage the mouse inputs to control the movement of a free camera.
  11939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11940. * @param touchEnabled Defines if touch is enabled or not
  11941. */
  11942. constructor(
  11943. /**
  11944. * Define if touch is enabled in the mouse input
  11945. */
  11946. touchEnabled?: boolean);
  11947. /**
  11948. * Attach the input controls to a specific dom element to get the input from.
  11949. * @param element Defines the element the controls should be listened from
  11950. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11951. */
  11952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11953. /**
  11954. * Called on JS contextmenu event.
  11955. * Override this method to provide functionality.
  11956. */
  11957. protected onContextMenu(evt: PointerEvent): void;
  11958. /**
  11959. * Detach the current controls from the specified dom element.
  11960. * @param element Defines the element to stop listening the inputs from
  11961. */
  11962. detachControl(element: Nullable<HTMLElement>): void;
  11963. /**
  11964. * Gets the class name of the current intput.
  11965. * @returns the class name
  11966. */
  11967. getClassName(): string;
  11968. /**
  11969. * Get the friendly name associated with the input class.
  11970. * @returns the input friendly name
  11971. */
  11972. getSimpleName(): string;
  11973. }
  11974. }
  11975. declare module BABYLON {
  11976. /**
  11977. * Manage the touch inputs to control the movement of a free camera.
  11978. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11979. */
  11980. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11981. /**
  11982. * Defines the camera the input is attached to.
  11983. */
  11984. camera: FreeCamera;
  11985. /**
  11986. * Defines the touch sensibility for rotation.
  11987. * The higher the faster.
  11988. */
  11989. touchAngularSensibility: number;
  11990. /**
  11991. * Defines the touch sensibility for move.
  11992. * The higher the faster.
  11993. */
  11994. touchMoveSensibility: number;
  11995. private _offsetX;
  11996. private _offsetY;
  11997. private _pointerPressed;
  11998. private _pointerInput;
  11999. private _observer;
  12000. private _onLostFocus;
  12001. /**
  12002. * Attach the input controls to a specific dom element to get the input from.
  12003. * @param element Defines the element the controls should be listened from
  12004. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12005. */
  12006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12007. /**
  12008. * Detach the current controls from the specified dom element.
  12009. * @param element Defines the element to stop listening the inputs from
  12010. */
  12011. detachControl(element: Nullable<HTMLElement>): void;
  12012. /**
  12013. * Update the current camera state depending on the inputs that have been used this frame.
  12014. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12015. */
  12016. checkInputs(): void;
  12017. /**
  12018. * Gets the class name of the current intput.
  12019. * @returns the class name
  12020. */
  12021. getClassName(): string;
  12022. /**
  12023. * Get the friendly name associated with the input class.
  12024. * @returns the input friendly name
  12025. */
  12026. getSimpleName(): string;
  12027. }
  12028. }
  12029. declare module BABYLON {
  12030. /**
  12031. * Default Inputs manager for the FreeCamera.
  12032. * It groups all the default supported inputs for ease of use.
  12033. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12034. */
  12035. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12036. /**
  12037. * @hidden
  12038. */ keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12039. /**
  12040. * @hidden
  12041. */ mouseInput: Nullable<FreeCameraMouseInput>;
  12042. /**
  12043. * Instantiates a new FreeCameraInputsManager.
  12044. * @param camera Defines the camera the inputs belong to
  12045. */
  12046. constructor(camera: FreeCamera);
  12047. /**
  12048. * Add keyboard input support to the input manager.
  12049. * @returns the current input manager
  12050. */
  12051. addKeyboard(): FreeCameraInputsManager;
  12052. /**
  12053. * Add mouse input support to the input manager.
  12054. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12055. * @returns the current input manager
  12056. */
  12057. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12058. /**
  12059. * Removes the mouse input support from the manager
  12060. * @returns the current input manager
  12061. */
  12062. removeMouse(): FreeCameraInputsManager;
  12063. /**
  12064. * Add touch input support to the input manager.
  12065. * @returns the current input manager
  12066. */
  12067. addTouch(): FreeCameraInputsManager;
  12068. }
  12069. }
  12070. declare module BABYLON {
  12071. /**
  12072. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12073. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12074. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12075. */
  12076. export class FreeCamera extends TargetCamera {
  12077. /**
  12078. * Define the collision ellipsoid of the camera.
  12079. * This is helpful to simulate a camera body like the player body around the camera
  12080. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12081. */
  12082. ellipsoid: Vector3;
  12083. /**
  12084. * Define an offset for the position of the ellipsoid around the camera.
  12085. * This can be helpful to determine the center of the body near the gravity center of the body
  12086. * instead of its head.
  12087. */
  12088. ellipsoidOffset: Vector3;
  12089. /**
  12090. * Enable or disable collisions of the camera with the rest of the scene objects.
  12091. */
  12092. checkCollisions: boolean;
  12093. /**
  12094. * Enable or disable gravity on the camera.
  12095. */
  12096. applyGravity: boolean;
  12097. /**
  12098. * Define the input manager associated to the camera.
  12099. */
  12100. inputs: FreeCameraInputsManager;
  12101. /**
  12102. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12103. * Higher values reduce sensitivity.
  12104. */
  12105. /**
  12106. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12107. * Higher values reduce sensitivity.
  12108. */
  12109. angularSensibility: number;
  12110. /**
  12111. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12112. */
  12113. keysUp: number[];
  12114. /**
  12115. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12116. */
  12117. keysDown: number[];
  12118. /**
  12119. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12120. */
  12121. keysLeft: number[];
  12122. /**
  12123. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12124. */
  12125. keysRight: number[];
  12126. /**
  12127. * Event raised when the camera collide with a mesh in the scene.
  12128. */
  12129. onCollide: (collidedMesh: AbstractMesh) => void;
  12130. private _collider;
  12131. private _needMoveForGravity;
  12132. private _oldPosition;
  12133. private _diffPosition;
  12134. private _newPosition;
  12135. /** @hidden */ localDirection: Vector3;
  12136. /** @hidden */ transformedDirection: Vector3;
  12137. /**
  12138. * Instantiates a Free Camera.
  12139. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12140. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12141. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12142. * @param name Define the name of the camera in the scene
  12143. * @param position Define the start position of the camera in the scene
  12144. * @param scene Define the scene the camera belongs to
  12145. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12146. */
  12147. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12148. /**
  12149. * Attached controls to the current camera.
  12150. * @param element Defines the element the controls should be listened from
  12151. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12152. */
  12153. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12154. /**
  12155. * Detach the current controls from the camera.
  12156. * The camera will stop reacting to inputs.
  12157. * @param element Defines the element to stop listening the inputs from
  12158. */
  12159. detachControl(element: HTMLElement): void;
  12160. private _collisionMask;
  12161. /**
  12162. * Define a collision mask to limit the list of object the camera can collide with
  12163. */
  12164. collisionMask: number;
  12165. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  12166. private _onCollisionPositionChange;
  12167. /** @hidden */ checkInputs(): void;
  12168. /** @hidden */ decideIfNeedsToMove(): boolean;
  12169. /** @hidden */ updatePosition(): void;
  12170. /**
  12171. * Destroy the camera and release the current resources hold by it.
  12172. */
  12173. dispose(): void;
  12174. /**
  12175. * Gets the current object class name.
  12176. * @return the class name
  12177. */
  12178. getClassName(): string;
  12179. }
  12180. }
  12181. declare module BABYLON {
  12182. /**
  12183. * Represents a gamepad control stick position
  12184. */
  12185. export class StickValues {
  12186. /**
  12187. * The x component of the control stick
  12188. */
  12189. x: number;
  12190. /**
  12191. * The y component of the control stick
  12192. */
  12193. y: number;
  12194. /**
  12195. * Initializes the gamepad x and y control stick values
  12196. * @param x The x component of the gamepad control stick value
  12197. * @param y The y component of the gamepad control stick value
  12198. */
  12199. constructor(
  12200. /**
  12201. * The x component of the control stick
  12202. */
  12203. x: number,
  12204. /**
  12205. * The y component of the control stick
  12206. */
  12207. y: number);
  12208. }
  12209. /**
  12210. * An interface which manages callbacks for gamepad button changes
  12211. */
  12212. export interface GamepadButtonChanges {
  12213. /**
  12214. * Called when a gamepad has been changed
  12215. */
  12216. changed: boolean;
  12217. /**
  12218. * Called when a gamepad press event has been triggered
  12219. */
  12220. pressChanged: boolean;
  12221. /**
  12222. * Called when a touch event has been triggered
  12223. */
  12224. touchChanged: boolean;
  12225. /**
  12226. * Called when a value has changed
  12227. */
  12228. valueChanged: boolean;
  12229. }
  12230. /**
  12231. * Represents a gamepad
  12232. */
  12233. export class Gamepad {
  12234. /**
  12235. * The id of the gamepad
  12236. */
  12237. id: string;
  12238. /**
  12239. * The index of the gamepad
  12240. */
  12241. index: number;
  12242. /**
  12243. * The browser gamepad
  12244. */
  12245. browserGamepad: any;
  12246. /**
  12247. * Specifies what type of gamepad this represents
  12248. */
  12249. type: number;
  12250. private _leftStick;
  12251. private _rightStick;
  12252. /** @hidden */ isConnected: boolean;
  12253. private _leftStickAxisX;
  12254. private _leftStickAxisY;
  12255. private _rightStickAxisX;
  12256. private _rightStickAxisY;
  12257. /**
  12258. * Triggered when the left control stick has been changed
  12259. */
  12260. private _onleftstickchanged;
  12261. /**
  12262. * Triggered when the right control stick has been changed
  12263. */
  12264. private _onrightstickchanged;
  12265. /**
  12266. * Represents a gamepad controller
  12267. */
  12268. static GAMEPAD: number;
  12269. /**
  12270. * Represents a generic controller
  12271. */
  12272. static GENERIC: number;
  12273. /**
  12274. * Represents an XBox controller
  12275. */
  12276. static XBOX: number;
  12277. /**
  12278. * Represents a pose-enabled controller
  12279. */
  12280. static POSE_ENABLED: number;
  12281. /**
  12282. * Specifies whether the left control stick should be Y-inverted
  12283. */
  12284. protected _invertLeftStickY: boolean;
  12285. /**
  12286. * Specifies if the gamepad has been connected
  12287. */
  12288. readonly isConnected: boolean;
  12289. /**
  12290. * Initializes the gamepad
  12291. * @param id The id of the gamepad
  12292. * @param index The index of the gamepad
  12293. * @param browserGamepad The browser gamepad
  12294. * @param leftStickX The x component of the left joystick
  12295. * @param leftStickY The y component of the left joystick
  12296. * @param rightStickX The x component of the right joystick
  12297. * @param rightStickY The y component of the right joystick
  12298. */
  12299. constructor(
  12300. /**
  12301. * The id of the gamepad
  12302. */
  12303. id: string,
  12304. /**
  12305. * The index of the gamepad
  12306. */
  12307. index: number,
  12308. /**
  12309. * The browser gamepad
  12310. */
  12311. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12312. /**
  12313. * Callback triggered when the left joystick has changed
  12314. * @param callback
  12315. */
  12316. onleftstickchanged(callback: (values: StickValues) => void): void;
  12317. /**
  12318. * Callback triggered when the right joystick has changed
  12319. * @param callback
  12320. */
  12321. onrightstickchanged(callback: (values: StickValues) => void): void;
  12322. /**
  12323. * Gets the left joystick
  12324. */
  12325. /**
  12326. * Sets the left joystick values
  12327. */
  12328. leftStick: StickValues;
  12329. /**
  12330. * Gets the right joystick
  12331. */
  12332. /**
  12333. * Sets the right joystick value
  12334. */
  12335. rightStick: StickValues;
  12336. /**
  12337. * Updates the gamepad joystick positions
  12338. */
  12339. update(): void;
  12340. /**
  12341. * Disposes the gamepad
  12342. */
  12343. dispose(): void;
  12344. }
  12345. /**
  12346. * Represents a generic gamepad
  12347. */
  12348. export class GenericPad extends Gamepad {
  12349. private _buttons;
  12350. private _onbuttondown;
  12351. private _onbuttonup;
  12352. /**
  12353. * Observable triggered when a button has been pressed
  12354. */
  12355. onButtonDownObservable: Observable<number>;
  12356. /**
  12357. * Observable triggered when a button has been released
  12358. */
  12359. onButtonUpObservable: Observable<number>;
  12360. /**
  12361. * Callback triggered when a button has been pressed
  12362. * @param callback Called when a button has been pressed
  12363. */
  12364. onbuttondown(callback: (buttonPressed: number) => void): void;
  12365. /**
  12366. * Callback triggered when a button has been released
  12367. * @param callback Called when a button has been released
  12368. */
  12369. onbuttonup(callback: (buttonReleased: number) => void): void;
  12370. /**
  12371. * Initializes the generic gamepad
  12372. * @param id The id of the generic gamepad
  12373. * @param index The index of the generic gamepad
  12374. * @param browserGamepad The browser gamepad
  12375. */
  12376. constructor(id: string, index: number, browserGamepad: any);
  12377. private _setButtonValue;
  12378. /**
  12379. * Updates the generic gamepad
  12380. */
  12381. update(): void;
  12382. /**
  12383. * Disposes the generic gamepad
  12384. */
  12385. dispose(): void;
  12386. }
  12387. }
  12388. declare module BABYLON {
  12389. /**
  12390. * Defines the types of pose enabled controllers that are supported
  12391. */
  12392. export enum PoseEnabledControllerType {
  12393. /**
  12394. * HTC Vive
  12395. */
  12396. VIVE = 0,
  12397. /**
  12398. * Oculus Rift
  12399. */
  12400. OCULUS = 1,
  12401. /**
  12402. * Windows mixed reality
  12403. */
  12404. WINDOWS = 2,
  12405. /**
  12406. * Samsung gear VR
  12407. */
  12408. GEAR_VR = 3,
  12409. /**
  12410. * Google Daydream
  12411. */
  12412. DAYDREAM = 4,
  12413. /**
  12414. * Generic
  12415. */
  12416. GENERIC = 5
  12417. }
  12418. /**
  12419. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12420. */
  12421. export interface MutableGamepadButton {
  12422. /**
  12423. * Value of the button/trigger
  12424. */
  12425. value: number;
  12426. /**
  12427. * If the button/trigger is currently touched
  12428. */
  12429. touched: boolean;
  12430. /**
  12431. * If the button/trigger is currently pressed
  12432. */
  12433. pressed: boolean;
  12434. }
  12435. /**
  12436. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12437. * @hidden
  12438. */
  12439. export interface ExtendedGamepadButton extends GamepadButton {
  12440. /**
  12441. * If the button/trigger is currently pressed
  12442. */
  12443. readonly pressed: boolean;
  12444. /**
  12445. * If the button/trigger is currently touched
  12446. */
  12447. readonly touched: boolean;
  12448. /**
  12449. * Value of the button/trigger
  12450. */
  12451. readonly value: number;
  12452. }
  12453. /** @hidden */
  12454. export interface _GamePadFactory {
  12455. /**
  12456. * Returns wether or not the current gamepad can be created for this type of controller.
  12457. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12458. * @returns true if it can be created, otherwise false
  12459. */
  12460. canCreate(gamepadInfo: any): boolean;
  12461. /**
  12462. * Creates a new instance of the Gamepad.
  12463. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12464. * @returns the new gamepad instance
  12465. */
  12466. create(gamepadInfo: any): Gamepad;
  12467. }
  12468. /**
  12469. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12470. */
  12471. export class PoseEnabledControllerHelper {
  12472. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12473. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12474. /**
  12475. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12476. * @param vrGamepad the gamepad to initialized
  12477. * @returns a vr controller of the type the gamepad identified as
  12478. */
  12479. static InitiateController(vrGamepad: any): Gamepad;
  12480. }
  12481. /**
  12482. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12483. */
  12484. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12485. private _deviceRoomPosition;
  12486. private _deviceRoomRotationQuaternion;
  12487. /**
  12488. * The device position in babylon space
  12489. */
  12490. devicePosition: Vector3;
  12491. /**
  12492. * The device rotation in babylon space
  12493. */
  12494. deviceRotationQuaternion: Quaternion;
  12495. /**
  12496. * The scale factor of the device in babylon space
  12497. */
  12498. deviceScaleFactor: number;
  12499. /**
  12500. * (Likely devicePosition should be used instead) The device position in its room space
  12501. */
  12502. position: Vector3;
  12503. /**
  12504. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12505. */
  12506. rotationQuaternion: Quaternion;
  12507. /**
  12508. * The type of controller (Eg. Windows mixed reality)
  12509. */
  12510. controllerType: PoseEnabledControllerType;
  12511. protected _calculatedPosition: Vector3;
  12512. private _calculatedRotation;
  12513. /**
  12514. * The raw pose from the device
  12515. */
  12516. rawPose: DevicePose;
  12517. private _trackPosition;
  12518. private _maxRotationDistFromHeadset;
  12519. private _draggedRoomRotation;
  12520. /**
  12521. * @hidden
  12522. */ disableTrackPosition(fixedPosition: Vector3): void;
  12523. /**
  12524. * Internal, the mesh attached to the controller
  12525. * @hidden
  12526. */ mesh: Nullable<AbstractMesh>;
  12527. private _poseControlledCamera;
  12528. private _leftHandSystemQuaternion;
  12529. /**
  12530. * Internal, matrix used to convert room space to babylon space
  12531. * @hidden
  12532. */ deviceToWorld: Matrix;
  12533. /**
  12534. * Node to be used when casting a ray from the controller
  12535. * @hidden
  12536. */ pointingPoseNode: Nullable<TransformNode>;
  12537. /**
  12538. * Name of the child mesh that can be used to cast a ray from the controller
  12539. */
  12540. static readonly POINTING_POSE: string;
  12541. /**
  12542. * Creates a new PoseEnabledController from a gamepad
  12543. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12544. */
  12545. constructor(browserGamepad: any);
  12546. private _workingMatrix;
  12547. /**
  12548. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12549. */
  12550. update(): void;
  12551. /**
  12552. * Updates only the pose device and mesh without doing any button event checking
  12553. */
  12554. protected _updatePoseAndMesh(): void;
  12555. /**
  12556. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12557. * @param poseData raw pose fromthe device
  12558. */
  12559. updateFromDevice(poseData: DevicePose): void;
  12560. /**
  12561. * @hidden
  12562. */ meshAttachedObservable: Observable<AbstractMesh>;
  12563. /**
  12564. * Attaches a mesh to the controller
  12565. * @param mesh the mesh to be attached
  12566. */
  12567. attachToMesh(mesh: AbstractMesh): void;
  12568. /**
  12569. * Attaches the controllers mesh to a camera
  12570. * @param camera the camera the mesh should be attached to
  12571. */
  12572. attachToPoseControlledCamera(camera: TargetCamera): void;
  12573. /**
  12574. * Disposes of the controller
  12575. */
  12576. dispose(): void;
  12577. /**
  12578. * The mesh that is attached to the controller
  12579. */
  12580. readonly mesh: Nullable<AbstractMesh>;
  12581. /**
  12582. * Gets the ray of the controller in the direction the controller is pointing
  12583. * @param length the length the resulting ray should be
  12584. * @returns a ray in the direction the controller is pointing
  12585. */
  12586. getForwardRay(length?: number): Ray;
  12587. }
  12588. }
  12589. declare module BABYLON {
  12590. /**
  12591. * Defines the WebVRController object that represents controllers tracked in 3D space
  12592. */
  12593. export abstract class WebVRController extends PoseEnabledController {
  12594. /**
  12595. * Internal, the default controller model for the controller
  12596. */
  12597. protected _defaultModel: AbstractMesh;
  12598. /**
  12599. * Fired when the trigger state has changed
  12600. */
  12601. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12602. /**
  12603. * Fired when the main button state has changed
  12604. */
  12605. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12606. /**
  12607. * Fired when the secondary button state has changed
  12608. */
  12609. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12610. /**
  12611. * Fired when the pad state has changed
  12612. */
  12613. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12614. /**
  12615. * Fired when controllers stick values have changed
  12616. */
  12617. onPadValuesChangedObservable: Observable<StickValues>;
  12618. /**
  12619. * Array of button availible on the controller
  12620. */
  12621. protected _buttons: Array<MutableGamepadButton>;
  12622. private _onButtonStateChange;
  12623. /**
  12624. * Fired when a controller button's state has changed
  12625. * @param callback the callback containing the button that was modified
  12626. */
  12627. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12628. /**
  12629. * X and Y axis corrisponding to the controllers joystick
  12630. */
  12631. pad: StickValues;
  12632. /**
  12633. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12634. */
  12635. hand: string;
  12636. /**
  12637. * The default controller model for the controller
  12638. */
  12639. readonly defaultModel: AbstractMesh;
  12640. /**
  12641. * Creates a new WebVRController from a gamepad
  12642. * @param vrGamepad the gamepad that the WebVRController should be created from
  12643. */
  12644. constructor(vrGamepad: any);
  12645. /**
  12646. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12647. */
  12648. update(): void;
  12649. /**
  12650. * Function to be called when a button is modified
  12651. */
  12652. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12653. /**
  12654. * Loads a mesh and attaches it to the controller
  12655. * @param scene the scene the mesh should be added to
  12656. * @param meshLoaded callback for when the mesh has been loaded
  12657. */
  12658. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12659. private _setButtonValue;
  12660. private _changes;
  12661. private _checkChanges;
  12662. /**
  12663. * Disposes of th webVRCOntroller
  12664. */
  12665. dispose(): void;
  12666. }
  12667. }
  12668. declare module BABYLON {
  12669. /**
  12670. * The HemisphericLight simulates the ambient environment light,
  12671. * so the passed direction is the light reflection direction, not the incoming direction.
  12672. */
  12673. export class HemisphericLight extends Light {
  12674. /**
  12675. * The groundColor is the light in the opposite direction to the one specified during creation.
  12676. * 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.
  12677. */
  12678. groundColor: Color3;
  12679. /**
  12680. * The light reflection direction, not the incoming direction.
  12681. */
  12682. direction: Vector3;
  12683. /**
  12684. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12685. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12686. * The HemisphericLight can't cast shadows.
  12687. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12688. * @param name The friendly name of the light
  12689. * @param direction The direction of the light reflection
  12690. * @param scene The scene the light belongs to
  12691. */
  12692. constructor(name: string, direction: Vector3, scene: Scene);
  12693. protected _buildUniformLayout(): void;
  12694. /**
  12695. * Returns the string "HemisphericLight".
  12696. * @return The class name
  12697. */
  12698. getClassName(): string;
  12699. /**
  12700. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12701. * Returns the updated direction.
  12702. * @param target The target the direction should point to
  12703. * @return The computed direction
  12704. */
  12705. setDirectionToTarget(target: Vector3): Vector3;
  12706. /**
  12707. * Returns the shadow generator associated to the light.
  12708. * @returns Always null for hemispheric lights because it does not support shadows.
  12709. */
  12710. getShadowGenerator(): Nullable<IShadowGenerator>;
  12711. /**
  12712. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12713. * @param effect The effect to update
  12714. * @param lightIndex The index of the light in the effect to update
  12715. * @returns The hemispheric light
  12716. */
  12717. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12718. /**
  12719. * Computes the world matrix of the node
  12720. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12721. * @param useWasUpdatedFlag defines a reserved property
  12722. * @returns the world matrix
  12723. */
  12724. computeWorldMatrix(): Matrix;
  12725. /**
  12726. * Returns the integer 3.
  12727. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12728. */
  12729. getTypeID(): number;
  12730. /**
  12731. * Prepares the list of defines specific to the light type.
  12732. * @param defines the list of defines
  12733. * @param lightIndex defines the index of the light for the effect
  12734. */
  12735. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12736. }
  12737. }
  12738. declare module BABYLON {
  12739. /** @hidden */
  12740. export var vrMultiviewToSingleviewPixelShader: {
  12741. name: string;
  12742. shader: string;
  12743. };
  12744. }
  12745. declare module BABYLON {
  12746. /**
  12747. * Renders to multiple views with a single draw call
  12748. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12749. */
  12750. export class MultiviewRenderTarget extends RenderTargetTexture {
  12751. /**
  12752. * Creates a multiview render target
  12753. * @param scene scene used with the render target
  12754. * @param size the size of the render target (used for each view)
  12755. */
  12756. constructor(scene: Scene, size?: number | {
  12757. width: number;
  12758. height: number;
  12759. } | {
  12760. ratio: number;
  12761. });
  12762. /**
  12763. * @hidden
  12764. * @param faceIndex the face index, if its a cube texture
  12765. */ bindFrameBuffer(faceIndex?: number): void;
  12766. /**
  12767. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  12768. * @returns the view count
  12769. */
  12770. getViewCount(): number;
  12771. }
  12772. }
  12773. declare module BABYLON {
  12774. interface Engine {
  12775. /**
  12776. * Creates a new multiview render target
  12777. * @param width defines the width of the texture
  12778. * @param height defines the height of the texture
  12779. * @returns the created multiview texture
  12780. */
  12781. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  12782. /**
  12783. * Binds a multiview framebuffer to be drawn to
  12784. * @param multiviewTexture texture to bind
  12785. */
  12786. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  12787. }
  12788. interface Camera {
  12789. /**
  12790. * @hidden
  12791. * 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)
  12792. */ useMultiviewToSingleView: boolean;
  12793. /**
  12794. * @hidden
  12795. * 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)
  12796. */ multiviewTexture: Nullable<RenderTargetTexture>;
  12797. /**
  12798. * @hidden
  12799. * ensures the multiview texture of the camera exists and has the specified width/height
  12800. * @param width height to set on the multiview texture
  12801. * @param height width to set on the multiview texture
  12802. */ resizeOrCreateMultiviewTexture(width: number, height: number): void;
  12803. }
  12804. interface Scene {
  12805. /** @hidden */ transformMatrixR: Matrix;
  12806. /** @hidden */ multiviewSceneUbo: Nullable<UniformBuffer>;
  12807. /** @hidden */ createMultiviewUbo(): void;
  12808. /** @hidden */ updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  12809. /** @hidden */ renderMultiviewToSingleView(camera: Camera): void;
  12810. }
  12811. }
  12812. declare module BABYLON {
  12813. /**
  12814. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  12815. * This will not be used for webXR as it supports displaying texture arrays directly
  12816. */
  12817. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  12818. /**
  12819. * Initializes a VRMultiviewToSingleview
  12820. * @param name name of the post process
  12821. * @param camera camera to be applied to
  12822. * @param scaleFactor scaling factor to the size of the output texture
  12823. */
  12824. constructor(name: string, camera: Camera, scaleFactor: number);
  12825. }
  12826. }
  12827. declare module BABYLON {
  12828. /**
  12829. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  12830. * IMPORTANT!! The data is right-hand data.
  12831. * @export
  12832. * @interface DevicePose
  12833. */
  12834. export interface DevicePose {
  12835. /**
  12836. * The position of the device, values in array are [x,y,z].
  12837. */
  12838. readonly position: Nullable<Float32Array>;
  12839. /**
  12840. * The linearVelocity of the device, values in array are [x,y,z].
  12841. */
  12842. readonly linearVelocity: Nullable<Float32Array>;
  12843. /**
  12844. * The linearAcceleration of the device, values in array are [x,y,z].
  12845. */
  12846. readonly linearAcceleration: Nullable<Float32Array>;
  12847. /**
  12848. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  12849. */
  12850. readonly orientation: Nullable<Float32Array>;
  12851. /**
  12852. * The angularVelocity of the device, values in array are [x,y,z].
  12853. */
  12854. readonly angularVelocity: Nullable<Float32Array>;
  12855. /**
  12856. * The angularAcceleration of the device, values in array are [x,y,z].
  12857. */
  12858. readonly angularAcceleration: Nullable<Float32Array>;
  12859. }
  12860. /**
  12861. * Interface representing a pose controlled object in Babylon.
  12862. * A pose controlled object has both regular pose values as well as pose values
  12863. * from an external device such as a VR head mounted display
  12864. */
  12865. export interface PoseControlled {
  12866. /**
  12867. * The position of the object in babylon space.
  12868. */
  12869. position: Vector3;
  12870. /**
  12871. * The rotation quaternion of the object in babylon space.
  12872. */
  12873. rotationQuaternion: Quaternion;
  12874. /**
  12875. * The position of the device in babylon space.
  12876. */
  12877. devicePosition?: Vector3;
  12878. /**
  12879. * The rotation quaternion of the device in babylon space.
  12880. */
  12881. deviceRotationQuaternion: Quaternion;
  12882. /**
  12883. * The raw pose coming from the device.
  12884. */
  12885. rawPose: Nullable<DevicePose>;
  12886. /**
  12887. * The scale of the device to be used when translating from device space to babylon space.
  12888. */
  12889. deviceScaleFactor: number;
  12890. /**
  12891. * Updates the poseControlled values based on the input device pose.
  12892. * @param poseData the pose data to update the object with
  12893. */
  12894. updateFromDevice(poseData: DevicePose): void;
  12895. }
  12896. /**
  12897. * Set of options to customize the webVRCamera
  12898. */
  12899. export interface WebVROptions {
  12900. /**
  12901. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  12902. */
  12903. trackPosition?: boolean;
  12904. /**
  12905. * Sets the scale of the vrDevice in babylon space. (default: 1)
  12906. */
  12907. positionScale?: number;
  12908. /**
  12909. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  12910. */
  12911. displayName?: string;
  12912. /**
  12913. * Should the native controller meshes be initialized. (default: true)
  12914. */
  12915. controllerMeshes?: boolean;
  12916. /**
  12917. * Creating a default HemiLight only on controllers. (default: true)
  12918. */
  12919. defaultLightingOnControllers?: boolean;
  12920. /**
  12921. * If you don't want to use the default VR button of the helper. (default: false)
  12922. */
  12923. useCustomVRButton?: boolean;
  12924. /**
  12925. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  12926. */
  12927. customVRButton?: HTMLButtonElement;
  12928. /**
  12929. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  12930. */
  12931. rayLength?: number;
  12932. /**
  12933. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  12934. */
  12935. defaultHeight?: number;
  12936. /**
  12937. * If multiview should be used if availible (default: false)
  12938. */
  12939. useMultiview?: boolean;
  12940. }
  12941. /**
  12942. * This represents a WebVR camera.
  12943. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  12944. * @example http://doc.babylonjs.com/how_to/webvr_camera
  12945. */
  12946. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  12947. private webVROptions;
  12948. /**
  12949. * @hidden
  12950. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  12951. */ vrDevice: any;
  12952. /**
  12953. * The rawPose of the vrDevice.
  12954. */
  12955. rawPose: Nullable<DevicePose>;
  12956. private _onVREnabled;
  12957. private _specsVersion;
  12958. private _attached;
  12959. private _frameData;
  12960. protected _descendants: Array<Node>;
  12961. private _deviceRoomPosition;
  12962. /** @hidden */ deviceRoomRotationQuaternion: Quaternion;
  12963. private _standingMatrix;
  12964. /**
  12965. * Represents device position in babylon space.
  12966. */
  12967. devicePosition: Vector3;
  12968. /**
  12969. * Represents device rotation in babylon space.
  12970. */
  12971. deviceRotationQuaternion: Quaternion;
  12972. /**
  12973. * The scale of the device to be used when translating from device space to babylon space.
  12974. */
  12975. deviceScaleFactor: number;
  12976. private _deviceToWorld;
  12977. private _worldToDevice;
  12978. /**
  12979. * References to the webVR controllers for the vrDevice.
  12980. */
  12981. controllers: Array<WebVRController>;
  12982. /**
  12983. * Emits an event when a controller is attached.
  12984. */
  12985. onControllersAttachedObservable: Observable<WebVRController[]>;
  12986. /**
  12987. * Emits an event when a controller's mesh has been loaded;
  12988. */
  12989. onControllerMeshLoadedObservable: Observable<WebVRController>;
  12990. /**
  12991. * Emits an event when the HMD's pose has been updated.
  12992. */
  12993. onPoseUpdatedFromDeviceObservable: Observable<any>;
  12994. private _poseSet;
  12995. /**
  12996. * If the rig cameras be used as parent instead of this camera.
  12997. */
  12998. rigParenting: boolean;
  12999. private _lightOnControllers;
  13000. private _defaultHeight?;
  13001. /**
  13002. * Instantiates a WebVRFreeCamera.
  13003. * @param name The name of the WebVRFreeCamera
  13004. * @param position The starting anchor position for the camera
  13005. * @param scene The scene the camera belongs to
  13006. * @param webVROptions a set of customizable options for the webVRCamera
  13007. */
  13008. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13009. /**
  13010. * Gets the device distance from the ground in meters.
  13011. * @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.
  13012. */
  13013. deviceDistanceToRoomGround(): number;
  13014. /**
  13015. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13016. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13017. */
  13018. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13019. /**
  13020. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13021. * @returns A promise with a boolean set to if the standing matrix is supported.
  13022. */
  13023. useStandingMatrixAsync(): Promise<boolean>;
  13024. /**
  13025. * Disposes the camera
  13026. */
  13027. dispose(): void;
  13028. /**
  13029. * Gets a vrController by name.
  13030. * @param name The name of the controller to retreive
  13031. * @returns the controller matching the name specified or null if not found
  13032. */
  13033. getControllerByName(name: string): Nullable<WebVRController>;
  13034. private _leftController;
  13035. /**
  13036. * The controller corrisponding to the users left hand.
  13037. */
  13038. readonly leftController: Nullable<WebVRController>;
  13039. private _rightController;
  13040. /**
  13041. * The controller corrisponding to the users right hand.
  13042. */
  13043. readonly rightController: Nullable<WebVRController>;
  13044. /**
  13045. * Casts a ray forward from the vrCamera's gaze.
  13046. * @param length Length of the ray (default: 100)
  13047. * @returns the ray corrisponding to the gaze
  13048. */
  13049. getForwardRay(length?: number): Ray;
  13050. /**
  13051. * @hidden
  13052. * Updates the camera based on device's frame data
  13053. */ checkInputs(): void;
  13054. /**
  13055. * Updates the poseControlled values based on the input device pose.
  13056. * @param poseData Pose coming from the device
  13057. */
  13058. updateFromDevice(poseData: DevicePose): void;
  13059. private _htmlElementAttached;
  13060. private _detachIfAttached;
  13061. /**
  13062. * WebVR's attach control will start broadcasting frames to the device.
  13063. * Note that in certain browsers (chrome for example) this function must be called
  13064. * within a user-interaction callback. Example:
  13065. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13066. *
  13067. * @param element html element to attach the vrDevice to
  13068. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13069. */
  13070. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13071. /**
  13072. * Detaches the camera from the html element and disables VR
  13073. *
  13074. * @param element html element to detach from
  13075. */
  13076. detachControl(element: HTMLElement): void;
  13077. /**
  13078. * @returns the name of this class
  13079. */
  13080. getClassName(): string;
  13081. /**
  13082. * Calls resetPose on the vrDisplay
  13083. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13084. */
  13085. resetToCurrentRotation(): void;
  13086. /**
  13087. * @hidden
  13088. * Updates the rig cameras (left and right eye)
  13089. */ updateRigCameras(): void;
  13090. private _workingVector;
  13091. private _oneVector;
  13092. private _workingMatrix;
  13093. private updateCacheCalled;
  13094. private _correctPositionIfNotTrackPosition;
  13095. /**
  13096. * @hidden
  13097. * Updates the cached values of the camera
  13098. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13099. */ updateCache(ignoreParentClass?: boolean): void;
  13100. /**
  13101. * @hidden
  13102. * Get current device position in babylon world
  13103. */ computeDevicePosition(): void;
  13104. /**
  13105. * Updates the current device position and rotation in the babylon world
  13106. */
  13107. update(): void;
  13108. /**
  13109. * @hidden
  13110. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13111. * @returns an identity matrix
  13112. */ getViewMatrix(): Matrix;
  13113. private _tmpMatrix;
  13114. /**
  13115. * This function is called by the two RIG cameras.
  13116. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13117. * @hidden
  13118. */ getWebVRViewMatrix(): Matrix;
  13119. /** @hidden */ getWebVRProjectionMatrix(): Matrix;
  13120. private _onGamepadConnectedObserver;
  13121. private _onGamepadDisconnectedObserver;
  13122. private _updateCacheWhenTrackingDisabledObserver;
  13123. /**
  13124. * Initializes the controllers and their meshes
  13125. */
  13126. initControllers(): void;
  13127. }
  13128. }
  13129. declare module BABYLON {
  13130. /**
  13131. * Size options for a post process
  13132. */
  13133. export type PostProcessOptions = {
  13134. width: number;
  13135. height: number;
  13136. };
  13137. /**
  13138. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13139. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13140. */
  13141. export class PostProcess {
  13142. /** Name of the PostProcess. */
  13143. name: string;
  13144. /**
  13145. * Gets or sets the unique id of the post process
  13146. */
  13147. uniqueId: number;
  13148. /**
  13149. * Width of the texture to apply the post process on
  13150. */
  13151. width: number;
  13152. /**
  13153. * Height of the texture to apply the post process on
  13154. */
  13155. height: number;
  13156. /**
  13157. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13158. * @hidden
  13159. */ outputTexture: Nullable<InternalTexture>;
  13160. /**
  13161. * Sampling mode used by the shader
  13162. * See https://doc.babylonjs.com/classes/3.1/texture
  13163. */
  13164. renderTargetSamplingMode: number;
  13165. /**
  13166. * Clear color to use when screen clearing
  13167. */
  13168. clearColor: Color4;
  13169. /**
  13170. * If the buffer needs to be cleared before applying the post process. (default: true)
  13171. * Should be set to false if shader will overwrite all previous pixels.
  13172. */
  13173. autoClear: boolean;
  13174. /**
  13175. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13176. */
  13177. alphaMode: number;
  13178. /**
  13179. * Sets the setAlphaBlendConstants of the babylon engine
  13180. */
  13181. alphaConstants: Color4;
  13182. /**
  13183. * Animations to be used for the post processing
  13184. */
  13185. animations: Animation[];
  13186. /**
  13187. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13188. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13189. */
  13190. enablePixelPerfectMode: boolean;
  13191. /**
  13192. * Force the postprocess to be applied without taking in account viewport
  13193. */
  13194. forceFullscreenViewport: boolean;
  13195. /**
  13196. * List of inspectable custom properties (used by the Inspector)
  13197. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13198. */
  13199. inspectableCustomProperties: IInspectable[];
  13200. /**
  13201. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13202. *
  13203. * | Value | Type | Description |
  13204. * | ----- | ----------------------------------- | ----------- |
  13205. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13206. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13207. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13208. *
  13209. */
  13210. scaleMode: number;
  13211. /**
  13212. * Force textures to be a power of two (default: false)
  13213. */
  13214. alwaysForcePOT: boolean;
  13215. private _samples;
  13216. /**
  13217. * Number of sample textures (default: 1)
  13218. */
  13219. samples: number;
  13220. /**
  13221. * Modify the scale of the post process to be the same as the viewport (default: false)
  13222. */
  13223. adaptScaleToCurrentViewport: boolean;
  13224. private _camera;
  13225. private _scene;
  13226. private _engine;
  13227. private _options;
  13228. private _reusable;
  13229. private _textureType;
  13230. /**
  13231. * Smart array of input and output textures for the post process.
  13232. * @hidden
  13233. */ textures: SmartArray<InternalTexture>;
  13234. /**
  13235. * The index in _textures that corresponds to the output texture.
  13236. * @hidden
  13237. */ currentRenderTextureInd: number;
  13238. private _effect;
  13239. private _samplers;
  13240. private _fragmentUrl;
  13241. private _vertexUrl;
  13242. private _parameters;
  13243. private _scaleRatio;
  13244. protected _indexParameters: any;
  13245. private _shareOutputWithPostProcess;
  13246. private _texelSize;
  13247. private _forcedOutputTexture;
  13248. /**
  13249. * Returns the fragment url or shader name used in the post process.
  13250. * @returns the fragment url or name in the shader store.
  13251. */
  13252. getEffectName(): string;
  13253. /**
  13254. * An event triggered when the postprocess is activated.
  13255. */
  13256. onActivateObservable: Observable<Camera>;
  13257. private _onActivateObserver;
  13258. /**
  13259. * A function that is added to the onActivateObservable
  13260. */
  13261. onActivate: Nullable<(camera: Camera) => void>;
  13262. /**
  13263. * An event triggered when the postprocess changes its size.
  13264. */
  13265. onSizeChangedObservable: Observable<PostProcess>;
  13266. private _onSizeChangedObserver;
  13267. /**
  13268. * A function that is added to the onSizeChangedObservable
  13269. */
  13270. onSizeChanged: (postProcess: PostProcess) => void;
  13271. /**
  13272. * An event triggered when the postprocess applies its effect.
  13273. */
  13274. onApplyObservable: Observable<Effect>;
  13275. private _onApplyObserver;
  13276. /**
  13277. * A function that is added to the onApplyObservable
  13278. */
  13279. onApply: (effect: Effect) => void;
  13280. /**
  13281. * An event triggered before rendering the postprocess
  13282. */
  13283. onBeforeRenderObservable: Observable<Effect>;
  13284. private _onBeforeRenderObserver;
  13285. /**
  13286. * A function that is added to the onBeforeRenderObservable
  13287. */
  13288. onBeforeRender: (effect: Effect) => void;
  13289. /**
  13290. * An event triggered after rendering the postprocess
  13291. */
  13292. onAfterRenderObservable: Observable<Effect>;
  13293. private _onAfterRenderObserver;
  13294. /**
  13295. * A function that is added to the onAfterRenderObservable
  13296. */
  13297. onAfterRender: (efect: Effect) => void;
  13298. /**
  13299. * 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
  13300. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13301. */
  13302. inputTexture: InternalTexture;
  13303. /**
  13304. * Gets the camera which post process is applied to.
  13305. * @returns The camera the post process is applied to.
  13306. */
  13307. getCamera(): Camera;
  13308. /**
  13309. * Gets the texel size of the postprocess.
  13310. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13311. */
  13312. readonly texelSize: Vector2;
  13313. /**
  13314. * Creates a new instance PostProcess
  13315. * @param name The name of the PostProcess.
  13316. * @param fragmentUrl The url of the fragment shader to be used.
  13317. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13318. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13319. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13320. * @param camera The camera to apply the render pass to.
  13321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13322. * @param engine The engine which the post process will be applied. (default: current engine)
  13323. * @param reusable If the post process can be reused on the same frame. (default: false)
  13324. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13325. * @param textureType Type of textures used when performing the post process. (default: 0)
  13326. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13327. * @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
  13328. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13329. */
  13330. constructor(
  13331. /** Name of the PostProcess. */
  13332. 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);
  13333. /**
  13334. * Gets a string idenfifying the name of the class
  13335. * @returns "PostProcess" string
  13336. */
  13337. getClassName(): string;
  13338. /**
  13339. * Gets the engine which this post process belongs to.
  13340. * @returns The engine the post process was enabled with.
  13341. */
  13342. getEngine(): Engine;
  13343. /**
  13344. * The effect that is created when initializing the post process.
  13345. * @returns The created effect corrisponding the the postprocess.
  13346. */
  13347. getEffect(): Effect;
  13348. /**
  13349. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13350. * @param postProcess The post process to share the output with.
  13351. * @returns This post process.
  13352. */
  13353. shareOutputWith(postProcess: PostProcess): PostProcess;
  13354. /**
  13355. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13356. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13357. */
  13358. useOwnOutput(): void;
  13359. /**
  13360. * Updates the effect with the current post process compile time values and recompiles the shader.
  13361. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13362. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13363. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13364. * @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
  13365. * @param onCompiled Called when the shader has been compiled.
  13366. * @param onError Called if there is an error when compiling a shader.
  13367. */
  13368. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13369. /**
  13370. * The post process is reusable if it can be used multiple times within one frame.
  13371. * @returns If the post process is reusable
  13372. */
  13373. isReusable(): boolean;
  13374. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13375. markTextureDirty(): void;
  13376. /**
  13377. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13378. * 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.
  13379. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13380. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13381. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13382. * @returns The target texture that was bound to be written to.
  13383. */
  13384. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13385. /**
  13386. * If the post process is supported.
  13387. */
  13388. readonly isSupported: boolean;
  13389. /**
  13390. * The aspect ratio of the output texture.
  13391. */
  13392. readonly aspectRatio: number;
  13393. /**
  13394. * Get a value indicating if the post-process is ready to be used
  13395. * @returns true if the post-process is ready (shader is compiled)
  13396. */
  13397. isReady(): boolean;
  13398. /**
  13399. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13400. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13401. */
  13402. apply(): Nullable<Effect>;
  13403. private _disposeTextures;
  13404. /**
  13405. * Disposes the post process.
  13406. * @param camera The camera to dispose the post process on.
  13407. */
  13408. dispose(camera?: Camera): void;
  13409. }
  13410. }
  13411. declare module BABYLON {
  13412. /**
  13413. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13414. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13415. */
  13416. export class PostProcessManager {
  13417. private _scene;
  13418. private _indexBuffer;
  13419. private _vertexBuffers;
  13420. /**
  13421. * Creates a new instance PostProcess
  13422. * @param scene The scene that the post process is associated with.
  13423. */
  13424. constructor(scene: Scene);
  13425. private _prepareBuffers;
  13426. private _buildIndexBuffer;
  13427. /**
  13428. * Rebuilds the vertex buffers of the manager.
  13429. * @hidden
  13430. */ rebuild(): void;
  13431. /**
  13432. * Prepares a frame to be run through a post process.
  13433. * @param sourceTexture The input texture to the post procesess. (default: null)
  13434. * @param postProcesses An array of post processes to be run. (default: null)
  13435. * @returns True if the post processes were able to be run.
  13436. * @hidden
  13437. */ prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13438. /**
  13439. * Manually render a set of post processes to a texture.
  13440. * @param postProcesses An array of post processes to be run.
  13441. * @param targetTexture The target texture to render to.
  13442. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13443. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13444. * @param lodLevel defines which lod of the texture to render to
  13445. */
  13446. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13447. /**
  13448. * Finalize the result of the output of the postprocesses.
  13449. * @param doNotPresent If true the result will not be displayed to the screen.
  13450. * @param targetTexture The target texture to render to.
  13451. * @param faceIndex The index of the face to bind the target texture to.
  13452. * @param postProcesses The array of post processes to render.
  13453. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13454. * @hidden
  13455. */ finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13456. /**
  13457. * Disposes of the post process manager.
  13458. */
  13459. dispose(): void;
  13460. }
  13461. }
  13462. declare module BABYLON {
  13463. interface AbstractScene {
  13464. /**
  13465. * The list of layers (background and foreground) of the scene
  13466. */
  13467. layers: Array<Layer>;
  13468. }
  13469. /**
  13470. * Defines the layer scene component responsible to manage any layers
  13471. * in a given scene.
  13472. */
  13473. export class LayerSceneComponent implements ISceneComponent {
  13474. /**
  13475. * The component name helpfull to identify the component in the list of scene components.
  13476. */
  13477. readonly name: string;
  13478. /**
  13479. * The scene the component belongs to.
  13480. */
  13481. scene: Scene;
  13482. private _engine;
  13483. /**
  13484. * Creates a new instance of the component for the given scene
  13485. * @param scene Defines the scene to register the component in
  13486. */
  13487. constructor(scene: Scene);
  13488. /**
  13489. * Registers the component in a given scene
  13490. */
  13491. register(): void;
  13492. /**
  13493. * Rebuilds the elements related to this component in case of
  13494. * context lost for instance.
  13495. */
  13496. rebuild(): void;
  13497. /**
  13498. * Disposes the component and the associated ressources.
  13499. */
  13500. dispose(): void;
  13501. private _draw;
  13502. private _drawCameraPredicate;
  13503. private _drawCameraBackground;
  13504. private _drawCameraForeground;
  13505. private _drawRenderTargetPredicate;
  13506. private _drawRenderTargetBackground;
  13507. private _drawRenderTargetForeground;
  13508. }
  13509. }
  13510. declare module BABYLON {
  13511. /** @hidden */
  13512. export var layerPixelShader: {
  13513. name: string;
  13514. shader: string;
  13515. };
  13516. }
  13517. declare module BABYLON {
  13518. /** @hidden */
  13519. export var layerVertexShader: {
  13520. name: string;
  13521. shader: string;
  13522. };
  13523. }
  13524. declare module BABYLON {
  13525. /**
  13526. * This represents a full screen 2d layer.
  13527. * This can be useful to display a picture in the background of your scene for instance.
  13528. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13529. */
  13530. export class Layer {
  13531. /**
  13532. * Define the name of the layer.
  13533. */
  13534. name: string;
  13535. /**
  13536. * Define the texture the layer should display.
  13537. */
  13538. texture: Nullable<Texture>;
  13539. /**
  13540. * Is the layer in background or foreground.
  13541. */
  13542. isBackground: boolean;
  13543. /**
  13544. * Define the color of the layer (instead of texture).
  13545. */
  13546. color: Color4;
  13547. /**
  13548. * Define the scale of the layer in order to zoom in out of the texture.
  13549. */
  13550. scale: Vector2;
  13551. /**
  13552. * Define an offset for the layer in order to shift the texture.
  13553. */
  13554. offset: Vector2;
  13555. /**
  13556. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  13557. */
  13558. alphaBlendingMode: number;
  13559. /**
  13560. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  13561. * Alpha test will not mix with the background color in case of transparency.
  13562. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  13563. */
  13564. alphaTest: boolean;
  13565. /**
  13566. * Define a mask to restrict the layer to only some of the scene cameras.
  13567. */
  13568. layerMask: number;
  13569. /**
  13570. * Define the list of render target the layer is visible into.
  13571. */
  13572. renderTargetTextures: RenderTargetTexture[];
  13573. /**
  13574. * Define if the layer is only used in renderTarget or if it also
  13575. * renders in the main frame buffer of the canvas.
  13576. */
  13577. renderOnlyInRenderTargetTextures: boolean;
  13578. private _scene;
  13579. private _vertexBuffers;
  13580. private _indexBuffer;
  13581. private _effect;
  13582. private _alphaTestEffect;
  13583. /**
  13584. * An event triggered when the layer is disposed.
  13585. */
  13586. onDisposeObservable: Observable<Layer>;
  13587. private _onDisposeObserver;
  13588. /**
  13589. * Back compatibility with callback before the onDisposeObservable existed.
  13590. * The set callback will be triggered when the layer has been disposed.
  13591. */
  13592. onDispose: () => void;
  13593. /**
  13594. * An event triggered before rendering the scene
  13595. */
  13596. onBeforeRenderObservable: Observable<Layer>;
  13597. private _onBeforeRenderObserver;
  13598. /**
  13599. * Back compatibility with callback before the onBeforeRenderObservable existed.
  13600. * The set callback will be triggered just before rendering the layer.
  13601. */
  13602. onBeforeRender: () => void;
  13603. /**
  13604. * An event triggered after rendering the scene
  13605. */
  13606. onAfterRenderObservable: Observable<Layer>;
  13607. private _onAfterRenderObserver;
  13608. /**
  13609. * Back compatibility with callback before the onAfterRenderObservable existed.
  13610. * The set callback will be triggered just after rendering the layer.
  13611. */
  13612. onAfterRender: () => void;
  13613. /**
  13614. * Instantiates a new layer.
  13615. * This represents a full screen 2d layer.
  13616. * This can be useful to display a picture in the background of your scene for instance.
  13617. * @see https://www.babylonjs-playground.com/#08A2BS#1
  13618. * @param name Define the name of the layer in the scene
  13619. * @param imgUrl Define the url of the texture to display in the layer
  13620. * @param scene Define the scene the layer belongs to
  13621. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  13622. * @param color Defines a color for the layer
  13623. */
  13624. constructor(
  13625. /**
  13626. * Define the name of the layer.
  13627. */
  13628. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  13629. private _createIndexBuffer;
  13630. /** @hidden */ rebuild(): void;
  13631. /**
  13632. * Renders the layer in the scene.
  13633. */
  13634. render(): void;
  13635. /**
  13636. * Disposes and releases the associated ressources.
  13637. */
  13638. dispose(): void;
  13639. }
  13640. }
  13641. declare module BABYLON {
  13642. interface AbstractScene {
  13643. /**
  13644. * The list of procedural textures added to the scene
  13645. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13646. */
  13647. proceduralTextures: Array<ProceduralTexture>;
  13648. }
  13649. /**
  13650. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13651. * in a given scene.
  13652. */
  13653. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13654. /**
  13655. * The component name helpfull to identify the component in the list of scene components.
  13656. */
  13657. readonly name: string;
  13658. /**
  13659. * The scene the component belongs to.
  13660. */
  13661. scene: Scene;
  13662. /**
  13663. * Creates a new instance of the component for the given scene
  13664. * @param scene Defines the scene to register the component in
  13665. */
  13666. constructor(scene: Scene);
  13667. /**
  13668. * Registers the component in a given scene
  13669. */
  13670. register(): void;
  13671. /**
  13672. * Rebuilds the elements related to this component in case of
  13673. * context lost for instance.
  13674. */
  13675. rebuild(): void;
  13676. /**
  13677. * Disposes the component and the associated ressources.
  13678. */
  13679. dispose(): void;
  13680. private _beforeClear;
  13681. }
  13682. }
  13683. declare module BABYLON {
  13684. /** @hidden */
  13685. export var proceduralVertexShader: {
  13686. name: string;
  13687. shader: string;
  13688. };
  13689. }
  13690. declare module BABYLON {
  13691. /**
  13692. * 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.
  13693. * This is the base class of any Procedural texture and contains most of the shareable code.
  13694. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13695. */
  13696. export class ProceduralTexture extends Texture {
  13697. isCube: boolean;
  13698. /**
  13699. * Define if the texture is enabled or not (disabled texture will not render)
  13700. */
  13701. isEnabled: boolean;
  13702. /**
  13703. * Define if the texture must be cleared before rendering (default is true)
  13704. */
  13705. autoClear: boolean;
  13706. /**
  13707. * Callback called when the texture is generated
  13708. */
  13709. onGenerated: () => void;
  13710. /**
  13711. * Event raised when the texture is generated
  13712. */
  13713. onGeneratedObservable: Observable<ProceduralTexture>;
  13714. /** @hidden */ generateMipMaps: boolean;
  13715. /** @hidden **/ effect: Effect;
  13716. /** @hidden */ textures: {
  13717. [key: string]: Texture;
  13718. };
  13719. private _size;
  13720. private _currentRefreshId;
  13721. private _refreshRate;
  13722. private _vertexBuffers;
  13723. private _indexBuffer;
  13724. private _uniforms;
  13725. private _samplers;
  13726. private _fragment;
  13727. private _floats;
  13728. private _ints;
  13729. private _floatsArrays;
  13730. private _colors3;
  13731. private _colors4;
  13732. private _vectors2;
  13733. private _vectors3;
  13734. private _matrices;
  13735. private _fallbackTexture;
  13736. private _fallbackTextureUsed;
  13737. private _engine;
  13738. private _cachedDefines;
  13739. private _contentUpdateId;
  13740. private _contentData;
  13741. /**
  13742. * Instantiates a new procedural texture.
  13743. * 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.
  13744. * This is the base class of any Procedural texture and contains most of the shareable code.
  13745. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13746. * @param name Define the name of the texture
  13747. * @param size Define the size of the texture to create
  13748. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13749. * @param scene Define the scene the texture belongs to
  13750. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13751. * @param generateMipMaps Define if the texture should creates mip maps or not
  13752. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13753. */
  13754. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13755. /**
  13756. * The effect that is created when initializing the post process.
  13757. * @returns The created effect corrisponding the the postprocess.
  13758. */
  13759. getEffect(): Effect;
  13760. /**
  13761. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13762. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13763. */
  13764. getContent(): Nullable<ArrayBufferView>;
  13765. private _createIndexBuffer;
  13766. /** @hidden */ rebuild(): void;
  13767. /**
  13768. * Resets the texture in order to recreate its associated resources.
  13769. * This can be called in case of context loss
  13770. */
  13771. reset(): void;
  13772. protected _getDefines(): string;
  13773. /**
  13774. * Is the texture ready to be used ? (rendered at least once)
  13775. * @returns true if ready, otherwise, false.
  13776. */
  13777. isReady(): boolean;
  13778. /**
  13779. * Resets the refresh counter of the texture and start bak from scratch.
  13780. * Could be useful to regenerate the texture if it is setup to render only once.
  13781. */
  13782. resetRefreshCounter(): void;
  13783. /**
  13784. * Set the fragment shader to use in order to render the texture.
  13785. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13786. */
  13787. setFragment(fragment: any): void;
  13788. /**
  13789. * Define the refresh rate of the texture or the rendering frequency.
  13790. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13791. */
  13792. refreshRate: number;
  13793. /** @hidden */ shouldRender(): boolean;
  13794. /**
  13795. * Get the size the texture is rendering at.
  13796. * @returns the size (texture is always squared)
  13797. */
  13798. getRenderSize(): number;
  13799. /**
  13800. * Resize the texture to new value.
  13801. * @param size Define the new size the texture should have
  13802. * @param generateMipMaps Define whether the new texture should create mip maps
  13803. */
  13804. resize(size: number, generateMipMaps: boolean): void;
  13805. private _checkUniform;
  13806. /**
  13807. * Set a texture in the shader program used to render.
  13808. * @param name Define the name of the uniform samplers as defined in the shader
  13809. * @param texture Define the texture to bind to this sampler
  13810. * @return the texture itself allowing "fluent" like uniform updates
  13811. */
  13812. setTexture(name: string, texture: Texture): ProceduralTexture;
  13813. /**
  13814. * Set a float in the shader.
  13815. * @param name Define the name of the uniform as defined in the shader
  13816. * @param value Define the value to give to the uniform
  13817. * @return the texture itself allowing "fluent" like uniform updates
  13818. */
  13819. setFloat(name: string, value: number): ProceduralTexture;
  13820. /**
  13821. * Set a int in the shader.
  13822. * @param name Define the name of the uniform as defined in the shader
  13823. * @param value Define the value to give to the uniform
  13824. * @return the texture itself allowing "fluent" like uniform updates
  13825. */
  13826. setInt(name: string, value: number): ProceduralTexture;
  13827. /**
  13828. * Set an array of floats in the shader.
  13829. * @param name Define the name of the uniform as defined in the shader
  13830. * @param value Define the value to give to the uniform
  13831. * @return the texture itself allowing "fluent" like uniform updates
  13832. */
  13833. setFloats(name: string, value: number[]): ProceduralTexture;
  13834. /**
  13835. * Set a vec3 in the shader from a Color3.
  13836. * @param name Define the name of the uniform as defined in the shader
  13837. * @param value Define the value to give to the uniform
  13838. * @return the texture itself allowing "fluent" like uniform updates
  13839. */
  13840. setColor3(name: string, value: Color3): ProceduralTexture;
  13841. /**
  13842. * Set a vec4 in the shader from a Color4.
  13843. * @param name Define the name of the uniform as defined in the shader
  13844. * @param value Define the value to give to the uniform
  13845. * @return the texture itself allowing "fluent" like uniform updates
  13846. */
  13847. setColor4(name: string, value: Color4): ProceduralTexture;
  13848. /**
  13849. * Set a vec2 in the shader from a Vector2.
  13850. * @param name Define the name of the uniform as defined in the shader
  13851. * @param value Define the value to give to the uniform
  13852. * @return the texture itself allowing "fluent" like uniform updates
  13853. */
  13854. setVector2(name: string, value: Vector2): ProceduralTexture;
  13855. /**
  13856. * Set a vec3 in the shader from a Vector3.
  13857. * @param name Define the name of the uniform as defined in the shader
  13858. * @param value Define the value to give to the uniform
  13859. * @return the texture itself allowing "fluent" like uniform updates
  13860. */
  13861. setVector3(name: string, value: Vector3): ProceduralTexture;
  13862. /**
  13863. * Set a mat4 in the shader from a MAtrix.
  13864. * @param name Define the name of the uniform as defined in the shader
  13865. * @param value Define the value to give to the uniform
  13866. * @return the texture itself allowing "fluent" like uniform updates
  13867. */
  13868. setMatrix(name: string, value: Matrix): ProceduralTexture;
  13869. /**
  13870. * Render the texture to its associated render target.
  13871. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  13872. */
  13873. render(useCameraPostProcess?: boolean): void;
  13874. /**
  13875. * Clone the texture.
  13876. * @returns the cloned texture
  13877. */
  13878. clone(): ProceduralTexture;
  13879. /**
  13880. * Dispose the texture and release its asoociated resources.
  13881. */
  13882. dispose(): void;
  13883. }
  13884. }
  13885. declare module BABYLON {
  13886. /**
  13887. * This represents the base class for particle system in Babylon.
  13888. * 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.
  13889. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  13890. * @example https://doc.babylonjs.com/babylon101/particles
  13891. */
  13892. export class BaseParticleSystem {
  13893. /**
  13894. * Source color is added to the destination color without alpha affecting the result
  13895. */
  13896. static BLENDMODE_ONEONE: number;
  13897. /**
  13898. * Blend current color and particle color using particle’s alpha
  13899. */
  13900. static BLENDMODE_STANDARD: number;
  13901. /**
  13902. * Add current color and particle color multiplied by particle’s alpha
  13903. */
  13904. static BLENDMODE_ADD: number;
  13905. /**
  13906. * Multiply current color with particle color
  13907. */
  13908. static BLENDMODE_MULTIPLY: number;
  13909. /**
  13910. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  13911. */
  13912. static BLENDMODE_MULTIPLYADD: number;
  13913. /**
  13914. * List of animations used by the particle system.
  13915. */
  13916. animations: Animation[];
  13917. /**
  13918. * The id of the Particle system.
  13919. */
  13920. id: string;
  13921. /**
  13922. * The friendly name of the Particle system.
  13923. */
  13924. name: string;
  13925. /**
  13926. * The rendering group used by the Particle system to chose when to render.
  13927. */
  13928. renderingGroupId: number;
  13929. /**
  13930. * The emitter represents the Mesh or position we are attaching the particle system to.
  13931. */
  13932. emitter: Nullable<AbstractMesh | Vector3>;
  13933. /**
  13934. * The maximum number of particles to emit per frame
  13935. */
  13936. emitRate: number;
  13937. /**
  13938. * If you want to launch only a few particles at once, that can be done, as well.
  13939. */
  13940. manualEmitCount: number;
  13941. /**
  13942. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13943. */
  13944. updateSpeed: number;
  13945. /**
  13946. * The amount of time the particle system is running (depends of the overall update speed).
  13947. */
  13948. targetStopDuration: number;
  13949. /**
  13950. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13951. */
  13952. disposeOnStop: boolean;
  13953. /**
  13954. * Minimum power of emitting particles.
  13955. */
  13956. minEmitPower: number;
  13957. /**
  13958. * Maximum power of emitting particles.
  13959. */
  13960. maxEmitPower: number;
  13961. /**
  13962. * Minimum life time of emitting particles.
  13963. */
  13964. minLifeTime: number;
  13965. /**
  13966. * Maximum life time of emitting particles.
  13967. */
  13968. maxLifeTime: number;
  13969. /**
  13970. * Minimum Size of emitting particles.
  13971. */
  13972. minSize: number;
  13973. /**
  13974. * Maximum Size of emitting particles.
  13975. */
  13976. maxSize: number;
  13977. /**
  13978. * Minimum scale of emitting particles on X axis.
  13979. */
  13980. minScaleX: number;
  13981. /**
  13982. * Maximum scale of emitting particles on X axis.
  13983. */
  13984. maxScaleX: number;
  13985. /**
  13986. * Minimum scale of emitting particles on Y axis.
  13987. */
  13988. minScaleY: number;
  13989. /**
  13990. * Maximum scale of emitting particles on Y axis.
  13991. */
  13992. maxScaleY: number;
  13993. /**
  13994. * Gets or sets the minimal initial rotation in radians.
  13995. */
  13996. minInitialRotation: number;
  13997. /**
  13998. * Gets or sets the maximal initial rotation in radians.
  13999. */
  14000. maxInitialRotation: number;
  14001. /**
  14002. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14003. */
  14004. minAngularSpeed: number;
  14005. /**
  14006. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14007. */
  14008. maxAngularSpeed: number;
  14009. /**
  14010. * The texture used to render each particle. (this can be a spritesheet)
  14011. */
  14012. particleTexture: Nullable<Texture>;
  14013. /**
  14014. * The layer mask we are rendering the particles through.
  14015. */
  14016. layerMask: number;
  14017. /**
  14018. * This can help using your own shader to render the particle system.
  14019. * The according effect will be created
  14020. */
  14021. customShader: any;
  14022. /**
  14023. * By default particle system starts as soon as they are created. This prevents the
  14024. * automatic start to happen and let you decide when to start emitting particles.
  14025. */
  14026. preventAutoStart: boolean;
  14027. private _noiseTexture;
  14028. /**
  14029. * Gets or sets a texture used to add random noise to particle positions
  14030. */
  14031. noiseTexture: Nullable<ProceduralTexture>;
  14032. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14033. noiseStrength: Vector3;
  14034. /**
  14035. * Callback triggered when the particle animation is ending.
  14036. */
  14037. onAnimationEnd: Nullable<() => void>;
  14038. /**
  14039. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14040. */
  14041. blendMode: number;
  14042. /**
  14043. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14044. * to override the particles.
  14045. */
  14046. forceDepthWrite: boolean;
  14047. /** 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 */
  14048. preWarmCycles: number;
  14049. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14050. preWarmStepOffset: number;
  14051. /**
  14052. * 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)
  14053. */
  14054. spriteCellChangeSpeed: number;
  14055. /**
  14056. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14057. */
  14058. startSpriteCellID: number;
  14059. /**
  14060. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14061. */
  14062. endSpriteCellID: number;
  14063. /**
  14064. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14065. */
  14066. spriteCellWidth: number;
  14067. /**
  14068. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14069. */
  14070. spriteCellHeight: number;
  14071. /**
  14072. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14073. */
  14074. spriteRandomStartCell: boolean;
  14075. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14076. translationPivot: Vector2;
  14077. /** @hidden */
  14078. protected _isAnimationSheetEnabled: boolean;
  14079. /**
  14080. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14081. */
  14082. beginAnimationOnStart: boolean;
  14083. /**
  14084. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14085. */
  14086. beginAnimationFrom: number;
  14087. /**
  14088. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14089. */
  14090. beginAnimationTo: number;
  14091. /**
  14092. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14093. */
  14094. beginAnimationLoop: boolean;
  14095. /**
  14096. * Gets or sets a world offset applied to all particles
  14097. */
  14098. worldOffset: Vector3;
  14099. /**
  14100. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14101. */
  14102. isAnimationSheetEnabled: boolean;
  14103. /**
  14104. * Get hosting scene
  14105. * @returns the scene
  14106. */
  14107. getScene(): Scene;
  14108. /**
  14109. * You can use gravity if you want to give an orientation to your particles.
  14110. */
  14111. gravity: Vector3;
  14112. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14113. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14114. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14115. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14116. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14117. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14118. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14119. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14120. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14121. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14122. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14123. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14124. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14125. /**
  14126. * Defines the delay in milliseconds before starting the system (0 by default)
  14127. */
  14128. startDelay: number;
  14129. /**
  14130. * Gets the current list of drag gradients.
  14131. * You must use addDragGradient and removeDragGradient to udpate this list
  14132. * @returns the list of drag gradients
  14133. */
  14134. getDragGradients(): Nullable<Array<FactorGradient>>;
  14135. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14136. limitVelocityDamping: number;
  14137. /**
  14138. * Gets the current list of limit velocity gradients.
  14139. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14140. * @returns the list of limit velocity gradients
  14141. */
  14142. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14143. /**
  14144. * Gets the current list of color gradients.
  14145. * You must use addColorGradient and removeColorGradient to udpate this list
  14146. * @returns the list of color gradients
  14147. */
  14148. getColorGradients(): Nullable<Array<ColorGradient>>;
  14149. /**
  14150. * Gets the current list of size gradients.
  14151. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14152. * @returns the list of size gradients
  14153. */
  14154. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14155. /**
  14156. * Gets the current list of color remap gradients.
  14157. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14158. * @returns the list of color remap gradients
  14159. */
  14160. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14161. /**
  14162. * Gets the current list of alpha remap gradients.
  14163. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14164. * @returns the list of alpha remap gradients
  14165. */
  14166. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14167. /**
  14168. * Gets the current list of life time gradients.
  14169. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14170. * @returns the list of life time gradients
  14171. */
  14172. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14173. /**
  14174. * Gets the current list of angular speed gradients.
  14175. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14176. * @returns the list of angular speed gradients
  14177. */
  14178. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14179. /**
  14180. * Gets the current list of velocity gradients.
  14181. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14182. * @returns the list of velocity gradients
  14183. */
  14184. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14185. /**
  14186. * Gets the current list of start size gradients.
  14187. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14188. * @returns the list of start size gradients
  14189. */
  14190. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14191. /**
  14192. * Gets the current list of emit rate gradients.
  14193. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14194. * @returns the list of emit rate gradients
  14195. */
  14196. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14197. /**
  14198. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14199. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14200. */
  14201. direction1: Vector3;
  14202. /**
  14203. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14204. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14205. */
  14206. direction2: Vector3;
  14207. /**
  14208. * 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.
  14209. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14210. */
  14211. minEmitBox: Vector3;
  14212. /**
  14213. * 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.
  14214. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14215. */
  14216. maxEmitBox: Vector3;
  14217. /**
  14218. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14219. */
  14220. color1: Color4;
  14221. /**
  14222. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14223. */
  14224. color2: Color4;
  14225. /**
  14226. * Color the particle will have at the end of its lifetime
  14227. */
  14228. colorDead: Color4;
  14229. /**
  14230. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14231. */
  14232. textureMask: Color4;
  14233. /**
  14234. * The particle emitter type defines the emitter used by the particle system.
  14235. * It can be for example box, sphere, or cone...
  14236. */
  14237. particleEmitterType: IParticleEmitterType;
  14238. /** @hidden */ isSubEmitter: boolean;
  14239. /**
  14240. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14241. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14242. */
  14243. billboardMode: number;
  14244. protected _isBillboardBased: boolean;
  14245. /**
  14246. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14247. */
  14248. isBillboardBased: boolean;
  14249. /**
  14250. * The scene the particle system belongs to.
  14251. */
  14252. protected _scene: Scene;
  14253. /**
  14254. * Local cache of defines for image processing.
  14255. */
  14256. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14257. /**
  14258. * Default configuration related to image processing available in the standard Material.
  14259. */
  14260. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14261. /**
  14262. * Gets the image processing configuration used either in this material.
  14263. */
  14264. /**
  14265. * Sets the Default image processing configuration used either in the this material.
  14266. *
  14267. * If sets to null, the scene one is in use.
  14268. */
  14269. imageProcessingConfiguration: ImageProcessingConfiguration;
  14270. /**
  14271. * Attaches a new image processing configuration to the Standard Material.
  14272. * @param configuration
  14273. */
  14274. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14275. /** @hidden */
  14276. protected _reset(): void;
  14277. /** @hidden */
  14278. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14279. /**
  14280. * Instantiates a particle system.
  14281. * 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.
  14282. * @param name The name of the particle system
  14283. */
  14284. constructor(name: string);
  14285. /**
  14286. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14287. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14288. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14289. * @returns the emitter
  14290. */
  14291. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14292. /**
  14293. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14294. * @param radius The radius of the hemisphere to emit from
  14295. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14296. * @returns the emitter
  14297. */
  14298. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14299. /**
  14300. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14301. * @param radius The radius of the sphere to emit from
  14302. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14303. * @returns the emitter
  14304. */
  14305. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14306. /**
  14307. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14308. * @param radius The radius of the sphere to emit from
  14309. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14310. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14311. * @returns the emitter
  14312. */
  14313. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14314. /**
  14315. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14316. * @param radius The radius of the emission cylinder
  14317. * @param height The height of the emission cylinder
  14318. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14319. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14320. * @returns the emitter
  14321. */
  14322. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14323. /**
  14324. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14325. * @param radius The radius of the cylinder to emit from
  14326. * @param height The height of the emission cylinder
  14327. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14328. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14329. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14330. * @returns the emitter
  14331. */
  14332. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14333. /**
  14334. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14335. * @param radius The radius of the cone to emit from
  14336. * @param angle The base angle of the cone
  14337. * @returns the emitter
  14338. */
  14339. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14340. /**
  14341. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14342. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14343. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14344. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14345. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14346. * @returns the emitter
  14347. */
  14348. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14349. }
  14350. }
  14351. declare module BABYLON {
  14352. /**
  14353. * Type of sub emitter
  14354. */
  14355. export enum SubEmitterType {
  14356. /**
  14357. * Attached to the particle over it's lifetime
  14358. */
  14359. ATTACHED = 0,
  14360. /**
  14361. * Created when the particle dies
  14362. */
  14363. END = 1
  14364. }
  14365. /**
  14366. * Sub emitter class used to emit particles from an existing particle
  14367. */
  14368. export class SubEmitter {
  14369. /**
  14370. * the particle system to be used by the sub emitter
  14371. */
  14372. particleSystem: ParticleSystem;
  14373. /**
  14374. * Type of the submitter (Default: END)
  14375. */
  14376. type: SubEmitterType;
  14377. /**
  14378. * 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)
  14379. * Note: This only is supported when using an emitter of type Mesh
  14380. */
  14381. inheritDirection: boolean;
  14382. /**
  14383. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14384. */
  14385. inheritedVelocityAmount: number;
  14386. /**
  14387. * Creates a sub emitter
  14388. * @param particleSystem the particle system to be used by the sub emitter
  14389. */
  14390. constructor(
  14391. /**
  14392. * the particle system to be used by the sub emitter
  14393. */
  14394. particleSystem: ParticleSystem);
  14395. /**
  14396. * Clones the sub emitter
  14397. * @returns the cloned sub emitter
  14398. */
  14399. clone(): SubEmitter;
  14400. /**
  14401. * Serialize current object to a JSON object
  14402. * @returns the serialized object
  14403. */
  14404. serialize(): any;
  14405. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14406. /**
  14407. * Creates a new SubEmitter from a serialized JSON version
  14408. * @param serializationObject defines the JSON object to read from
  14409. * @param scene defines the hosting scene
  14410. * @param rootUrl defines the rootUrl for data loading
  14411. * @returns a new SubEmitter
  14412. */
  14413. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14414. /** Release associated resources */
  14415. dispose(): void;
  14416. }
  14417. }
  14418. declare module BABYLON {
  14419. /** @hidden */
  14420. export var clipPlaneFragmentDeclaration: {
  14421. name: string;
  14422. shader: string;
  14423. };
  14424. }
  14425. declare module BABYLON {
  14426. /** @hidden */
  14427. export var imageProcessingDeclaration: {
  14428. name: string;
  14429. shader: string;
  14430. };
  14431. }
  14432. declare module BABYLON {
  14433. /** @hidden */
  14434. export var imageProcessingFunctions: {
  14435. name: string;
  14436. shader: string;
  14437. };
  14438. }
  14439. declare module BABYLON {
  14440. /** @hidden */
  14441. export var clipPlaneFragment: {
  14442. name: string;
  14443. shader: string;
  14444. };
  14445. }
  14446. declare module BABYLON {
  14447. /** @hidden */
  14448. export var particlesPixelShader: {
  14449. name: string;
  14450. shader: string;
  14451. };
  14452. }
  14453. declare module BABYLON {
  14454. /** @hidden */
  14455. export var clipPlaneVertexDeclaration: {
  14456. name: string;
  14457. shader: string;
  14458. };
  14459. }
  14460. declare module BABYLON {
  14461. /** @hidden */
  14462. export var clipPlaneVertex: {
  14463. name: string;
  14464. shader: string;
  14465. };
  14466. }
  14467. declare module BABYLON {
  14468. /** @hidden */
  14469. export var particlesVertexShader: {
  14470. name: string;
  14471. shader: string;
  14472. };
  14473. }
  14474. declare module BABYLON {
  14475. /**
  14476. * This represents a particle system in Babylon.
  14477. * 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.
  14478. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14479. * @example https://doc.babylonjs.com/babylon101/particles
  14480. */
  14481. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14482. /**
  14483. * Billboard mode will only apply to Y axis
  14484. */
  14485. static readonly BILLBOARDMODE_Y: number;
  14486. /**
  14487. * Billboard mode will apply to all axes
  14488. */
  14489. static readonly BILLBOARDMODE_ALL: number;
  14490. /**
  14491. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14492. */
  14493. static readonly BILLBOARDMODE_STRETCHED: number;
  14494. /**
  14495. * This function can be defined to provide custom update for active particles.
  14496. * This function will be called instead of regular update (age, position, color, etc.).
  14497. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14498. */
  14499. updateFunction: (particles: Particle[]) => void;
  14500. private _emitterWorldMatrix;
  14501. /**
  14502. * This function can be defined to specify initial direction for every new particle.
  14503. * It by default use the emitterType defined function
  14504. */
  14505. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14506. /**
  14507. * This function can be defined to specify initial position for every new particle.
  14508. * It by default use the emitterType defined function
  14509. */
  14510. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14511. /**
  14512. * @hidden
  14513. */ inheritedVelocityOffset: Vector3;
  14514. /**
  14515. * An event triggered when the system is disposed
  14516. */
  14517. onDisposeObservable: Observable<ParticleSystem>;
  14518. private _onDisposeObserver;
  14519. /**
  14520. * Sets a callback that will be triggered when the system is disposed
  14521. */
  14522. onDispose: () => void;
  14523. private _particles;
  14524. private _epsilon;
  14525. private _capacity;
  14526. private _stockParticles;
  14527. private _newPartsExcess;
  14528. private _vertexData;
  14529. private _vertexBuffer;
  14530. private _vertexBuffers;
  14531. private _spriteBuffer;
  14532. private _indexBuffer;
  14533. private _effect;
  14534. private _customEffect;
  14535. private _cachedDefines;
  14536. private _scaledColorStep;
  14537. private _colorDiff;
  14538. private _scaledDirection;
  14539. private _scaledGravity;
  14540. private _currentRenderId;
  14541. private _alive;
  14542. private _useInstancing;
  14543. private _started;
  14544. private _stopped;
  14545. private _actualFrame;
  14546. private _scaledUpdateSpeed;
  14547. private _vertexBufferSize;
  14548. /** @hidden */ currentEmitRateGradient: Nullable<FactorGradient>;
  14549. /** @hidden */ currentEmitRate1: number;
  14550. /** @hidden */ currentEmitRate2: number;
  14551. /** @hidden */ currentStartSizeGradient: Nullable<FactorGradient>;
  14552. /** @hidden */ currentStartSize1: number;
  14553. /** @hidden */ currentStartSize2: number;
  14554. private readonly _rawTextureWidth;
  14555. private _rampGradientsTexture;
  14556. private _useRampGradients;
  14557. /** Gets or sets a boolean indicating that ramp gradients must be used
  14558. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14559. */
  14560. useRampGradients: boolean;
  14561. /**
  14562. * 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.
  14563. * 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: [])
  14564. */
  14565. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14566. private _subEmitters;
  14567. /**
  14568. * @hidden
  14569. * If the particle systems emitter should be disposed when the particle system is disposed
  14570. */ disposeEmitterOnDispose: boolean;
  14571. /**
  14572. * The current active Sub-systems, this property is used by the root particle system only.
  14573. */
  14574. activeSubSystems: Array<ParticleSystem>;
  14575. private _rootParticleSystem;
  14576. /**
  14577. * Gets the current list of active particles
  14578. */
  14579. readonly particles: Particle[];
  14580. /**
  14581. * Returns the string "ParticleSystem"
  14582. * @returns a string containing the class name
  14583. */
  14584. getClassName(): string;
  14585. /**
  14586. * Instantiates a particle system.
  14587. * 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.
  14588. * @param name The name of the particle system
  14589. * @param capacity The max number of particles alive at the same time
  14590. * @param scene The scene the particle system belongs to
  14591. * @param customEffect a custom effect used to change the way particles are rendered by default
  14592. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14593. * @param epsilon Offset used to render the particles
  14594. */
  14595. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14596. private _addFactorGradient;
  14597. private _removeFactorGradient;
  14598. /**
  14599. * Adds a new life time gradient
  14600. * @param gradient defines the gradient to use (between 0 and 1)
  14601. * @param factor defines the life time factor to affect to the specified gradient
  14602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14603. * @returns the current particle system
  14604. */
  14605. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14606. /**
  14607. * Remove a specific life time gradient
  14608. * @param gradient defines the gradient to remove
  14609. * @returns the current particle system
  14610. */
  14611. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14612. /**
  14613. * Adds a new size gradient
  14614. * @param gradient defines the gradient to use (between 0 and 1)
  14615. * @param factor defines the size factor to affect to the specified gradient
  14616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14617. * @returns the current particle system
  14618. */
  14619. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14620. /**
  14621. * Remove a specific size gradient
  14622. * @param gradient defines the gradient to remove
  14623. * @returns the current particle system
  14624. */
  14625. removeSizeGradient(gradient: number): IParticleSystem;
  14626. /**
  14627. * Adds a new color remap gradient
  14628. * @param gradient defines the gradient to use (between 0 and 1)
  14629. * @param min defines the color remap minimal range
  14630. * @param max defines the color remap maximal range
  14631. * @returns the current particle system
  14632. */
  14633. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14634. /**
  14635. * Remove a specific color remap gradient
  14636. * @param gradient defines the gradient to remove
  14637. * @returns the current particle system
  14638. */
  14639. removeColorRemapGradient(gradient: number): IParticleSystem;
  14640. /**
  14641. * Adds a new alpha remap gradient
  14642. * @param gradient defines the gradient to use (between 0 and 1)
  14643. * @param min defines the alpha remap minimal range
  14644. * @param max defines the alpha remap maximal range
  14645. * @returns the current particle system
  14646. */
  14647. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14648. /**
  14649. * Remove a specific alpha remap gradient
  14650. * @param gradient defines the gradient to remove
  14651. * @returns the current particle system
  14652. */
  14653. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14654. /**
  14655. * Adds a new angular speed gradient
  14656. * @param gradient defines the gradient to use (between 0 and 1)
  14657. * @param factor defines the angular speed to affect to the specified gradient
  14658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14659. * @returns the current particle system
  14660. */
  14661. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14662. /**
  14663. * Remove a specific angular speed gradient
  14664. * @param gradient defines the gradient to remove
  14665. * @returns the current particle system
  14666. */
  14667. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14668. /**
  14669. * Adds a new velocity gradient
  14670. * @param gradient defines the gradient to use (between 0 and 1)
  14671. * @param factor defines the velocity to affect to the specified gradient
  14672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14673. * @returns the current particle system
  14674. */
  14675. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14676. /**
  14677. * Remove a specific velocity gradient
  14678. * @param gradient defines the gradient to remove
  14679. * @returns the current particle system
  14680. */
  14681. removeVelocityGradient(gradient: number): IParticleSystem;
  14682. /**
  14683. * Adds a new limit velocity gradient
  14684. * @param gradient defines the gradient to use (between 0 and 1)
  14685. * @param factor defines the limit velocity value to affect to the specified gradient
  14686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14687. * @returns the current particle system
  14688. */
  14689. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14690. /**
  14691. * Remove a specific limit velocity gradient
  14692. * @param gradient defines the gradient to remove
  14693. * @returns the current particle system
  14694. */
  14695. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14696. /**
  14697. * Adds a new drag gradient
  14698. * @param gradient defines the gradient to use (between 0 and 1)
  14699. * @param factor defines the drag value to affect to the specified gradient
  14700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14701. * @returns the current particle system
  14702. */
  14703. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14704. /**
  14705. * Remove a specific drag gradient
  14706. * @param gradient defines the gradient to remove
  14707. * @returns the current particle system
  14708. */
  14709. removeDragGradient(gradient: number): IParticleSystem;
  14710. /**
  14711. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14712. * @param gradient defines the gradient to use (between 0 and 1)
  14713. * @param factor defines the emit rate value to affect to the specified gradient
  14714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14715. * @returns the current particle system
  14716. */
  14717. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14718. /**
  14719. * Remove a specific emit rate gradient
  14720. * @param gradient defines the gradient to remove
  14721. * @returns the current particle system
  14722. */
  14723. removeEmitRateGradient(gradient: number): IParticleSystem;
  14724. /**
  14725. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14726. * @param gradient defines the gradient to use (between 0 and 1)
  14727. * @param factor defines the start size value to affect to the specified gradient
  14728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14729. * @returns the current particle system
  14730. */
  14731. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14732. /**
  14733. * Remove a specific start size gradient
  14734. * @param gradient defines the gradient to remove
  14735. * @returns the current particle system
  14736. */
  14737. removeStartSizeGradient(gradient: number): IParticleSystem;
  14738. private _createRampGradientTexture;
  14739. /**
  14740. * Gets the current list of ramp gradients.
  14741. * You must use addRampGradient and removeRampGradient to udpate this list
  14742. * @returns the list of ramp gradients
  14743. */
  14744. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14745. /**
  14746. * Adds a new ramp gradient used to remap particle colors
  14747. * @param gradient defines the gradient to use (between 0 and 1)
  14748. * @param color defines the color to affect to the specified gradient
  14749. * @returns the current particle system
  14750. */
  14751. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14752. /**
  14753. * Remove a specific ramp gradient
  14754. * @param gradient defines the gradient to remove
  14755. * @returns the current particle system
  14756. */
  14757. removeRampGradient(gradient: number): ParticleSystem;
  14758. /**
  14759. * Adds a new color gradient
  14760. * @param gradient defines the gradient to use (between 0 and 1)
  14761. * @param color1 defines the color to affect to the specified gradient
  14762. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14763. * @returns this particle system
  14764. */
  14765. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14766. /**
  14767. * Remove a specific color gradient
  14768. * @param gradient defines the gradient to remove
  14769. * @returns this particle system
  14770. */
  14771. removeColorGradient(gradient: number): IParticleSystem;
  14772. private _fetchR;
  14773. protected _reset(): void;
  14774. private _resetEffect;
  14775. private _createVertexBuffers;
  14776. private _createIndexBuffer;
  14777. /**
  14778. * Gets the maximum number of particles active at the same time.
  14779. * @returns The max number of active particles.
  14780. */
  14781. getCapacity(): number;
  14782. /**
  14783. * Gets whether there are still active particles in the system.
  14784. * @returns True if it is alive, otherwise false.
  14785. */
  14786. isAlive(): boolean;
  14787. /**
  14788. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14789. * @returns True if it has been started, otherwise false.
  14790. */
  14791. isStarted(): boolean;
  14792. private _prepareSubEmitterInternalArray;
  14793. /**
  14794. * Starts the particle system and begins to emit
  14795. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14796. */
  14797. start(delay?: number): void;
  14798. /**
  14799. * Stops the particle system.
  14800. * @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.
  14801. */
  14802. stop(stopSubEmitters?: boolean): void;
  14803. /**
  14804. * Remove all active particles
  14805. */
  14806. reset(): void;
  14807. /**
  14808. * @hidden (for internal use only)
  14809. */ appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14810. /**
  14811. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14812. * Its lifetime will start back at 0.
  14813. */
  14814. recycleParticle: (particle: Particle) => void;
  14815. private _stopSubEmitters;
  14816. private _createParticle;
  14817. private _removeFromRoot;
  14818. private _emitFromParticle;
  14819. private _update;
  14820. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14821. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14822. /** @hidden */
  14823. private _getEffect;
  14824. /**
  14825. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14826. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14827. */
  14828. animate(preWarmOnly?: boolean): void;
  14829. private _appendParticleVertices;
  14830. /**
  14831. * Rebuilds the particle system.
  14832. */
  14833. rebuild(): void;
  14834. /**
  14835. * Is this system ready to be used/rendered
  14836. * @return true if the system is ready
  14837. */
  14838. isReady(): boolean;
  14839. private _render;
  14840. /**
  14841. * Renders the particle system in its current state.
  14842. * @returns the current number of particles
  14843. */
  14844. render(): number;
  14845. /**
  14846. * Disposes the particle system and free the associated resources
  14847. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14848. */
  14849. dispose(disposeTexture?: boolean): void;
  14850. /**
  14851. * Clones the particle system.
  14852. * @param name The name of the cloned object
  14853. * @param newEmitter The new emitter to use
  14854. * @returns the cloned particle system
  14855. */
  14856. clone(name: string, newEmitter: any): ParticleSystem;
  14857. /**
  14858. * Serializes the particle system to a JSON object.
  14859. * @returns the JSON object
  14860. */
  14861. serialize(): any;
  14862. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  14863. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  14864. /**
  14865. * Parses a JSON object to create a particle system.
  14866. * @param parsedParticleSystem The JSON object to parse
  14867. * @param scene The scene to create the particle system in
  14868. * @param rootUrl The root url to use to load external dependencies like texture
  14869. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  14870. * @returns the Parsed particle system
  14871. */
  14872. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  14873. }
  14874. }
  14875. declare module BABYLON {
  14876. /**
  14877. * A particle represents one of the element emitted by a particle system.
  14878. * This is mainly define by its coordinates, direction, velocity and age.
  14879. */
  14880. export class Particle {
  14881. /**
  14882. * The particle system the particle belongs to.
  14883. */
  14884. particleSystem: ParticleSystem;
  14885. private static _Count;
  14886. /**
  14887. * Unique ID of the particle
  14888. */
  14889. id: number;
  14890. /**
  14891. * The world position of the particle in the scene.
  14892. */
  14893. position: Vector3;
  14894. /**
  14895. * The world direction of the particle in the scene.
  14896. */
  14897. direction: Vector3;
  14898. /**
  14899. * The color of the particle.
  14900. */
  14901. color: Color4;
  14902. /**
  14903. * The color change of the particle per step.
  14904. */
  14905. colorStep: Color4;
  14906. /**
  14907. * Defines how long will the life of the particle be.
  14908. */
  14909. lifeTime: number;
  14910. /**
  14911. * The current age of the particle.
  14912. */
  14913. age: number;
  14914. /**
  14915. * The current size of the particle.
  14916. */
  14917. size: number;
  14918. /**
  14919. * The current scale of the particle.
  14920. */
  14921. scale: Vector2;
  14922. /**
  14923. * The current angle of the particle.
  14924. */
  14925. angle: number;
  14926. /**
  14927. * Defines how fast is the angle changing.
  14928. */
  14929. angularSpeed: number;
  14930. /**
  14931. * Defines the cell index used by the particle to be rendered from a sprite.
  14932. */
  14933. cellIndex: number;
  14934. /**
  14935. * The information required to support color remapping
  14936. */
  14937. remapData: Vector4;
  14938. /** @hidden */ randomCellOffset?: number;
  14939. /** @hidden */ initialDirection: Nullable<Vector3>;
  14940. /** @hidden */ attachedSubEmitters: Nullable<Array<SubEmitter>>;
  14941. /** @hidden */ initialStartSpriteCellID: number;
  14942. /** @hidden */ initialEndSpriteCellID: number;
  14943. /** @hidden */ currentColorGradient: Nullable<ColorGradient>;
  14944. /** @hidden */ currentColor1: Color4;
  14945. /** @hidden */ currentColor2: Color4;
  14946. /** @hidden */ currentSizeGradient: Nullable<FactorGradient>;
  14947. /** @hidden */ currentSize1: number;
  14948. /** @hidden */ currentSize2: number;
  14949. /** @hidden */ currentAngularSpeedGradient: Nullable<FactorGradient>;
  14950. /** @hidden */ currentAngularSpeed1: number;
  14951. /** @hidden */ currentAngularSpeed2: number;
  14952. /** @hidden */ currentVelocityGradient: Nullable<FactorGradient>;
  14953. /** @hidden */ currentVelocity1: number;
  14954. /** @hidden */ currentVelocity2: number;
  14955. /** @hidden */ currentLimitVelocityGradient: Nullable<FactorGradient>;
  14956. /** @hidden */ currentLimitVelocity1: number;
  14957. /** @hidden */ currentLimitVelocity2: number;
  14958. /** @hidden */ currentDragGradient: Nullable<FactorGradient>;
  14959. /** @hidden */ currentDrag1: number;
  14960. /** @hidden */ currentDrag2: number;
  14961. /** @hidden */ randomNoiseCoordinates1: Vector3;
  14962. /** @hidden */ randomNoiseCoordinates2: Vector3;
  14963. /**
  14964. * Creates a new instance Particle
  14965. * @param particleSystem the particle system the particle belongs to
  14966. */
  14967. constructor(
  14968. /**
  14969. * The particle system the particle belongs to.
  14970. */
  14971. particleSystem: ParticleSystem);
  14972. private updateCellInfoFromSystem;
  14973. /**
  14974. * Defines how the sprite cell index is updated for the particle
  14975. */
  14976. updateCellIndex(): void;
  14977. /** @hidden */ inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  14978. /** @hidden */ inheritParticleInfoToSubEmitters(): void;
  14979. /** @hidden */ reset(): void;
  14980. /**
  14981. * Copy the properties of particle to another one.
  14982. * @param other the particle to copy the information to.
  14983. */
  14984. copyTo(other: Particle): void;
  14985. }
  14986. }
  14987. declare module BABYLON {
  14988. /**
  14989. * Particle emitter represents a volume emitting particles.
  14990. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  14991. */
  14992. export interface IParticleEmitterType {
  14993. /**
  14994. * Called by the particle System when the direction is computed for the created particle.
  14995. * @param worldMatrix is the world matrix of the particle system
  14996. * @param directionToUpdate is the direction vector to update with the result
  14997. * @param particle is the particle we are computed the direction for
  14998. */
  14999. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15000. /**
  15001. * Called by the particle System when the position is computed for the created particle.
  15002. * @param worldMatrix is the world matrix of the particle system
  15003. * @param positionToUpdate is the position vector to update with the result
  15004. * @param particle is the particle we are computed the position for
  15005. */
  15006. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15007. /**
  15008. * Clones the current emitter and returns a copy of it
  15009. * @returns the new emitter
  15010. */
  15011. clone(): IParticleEmitterType;
  15012. /**
  15013. * Called by the GPUParticleSystem to setup the update shader
  15014. * @param effect defines the update shader
  15015. */
  15016. applyToShader(effect: Effect): void;
  15017. /**
  15018. * Returns a string to use to update the GPU particles update shader
  15019. * @returns the effect defines string
  15020. */
  15021. getEffectDefines(): string;
  15022. /**
  15023. * Returns a string representing the class name
  15024. * @returns a string containing the class name
  15025. */
  15026. getClassName(): string;
  15027. /**
  15028. * Serializes the particle system to a JSON object.
  15029. * @returns the JSON object
  15030. */
  15031. serialize(): any;
  15032. /**
  15033. * Parse properties from a JSON object
  15034. * @param serializationObject defines the JSON object
  15035. */
  15036. parse(serializationObject: any): void;
  15037. }
  15038. }
  15039. declare module BABYLON {
  15040. /**
  15041. * Particle emitter emitting particles from the inside of a box.
  15042. * It emits the particles randomly between 2 given directions.
  15043. */
  15044. export class BoxParticleEmitter implements IParticleEmitterType {
  15045. /**
  15046. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15047. */
  15048. direction1: Vector3;
  15049. /**
  15050. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15051. */
  15052. direction2: Vector3;
  15053. /**
  15054. * 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.
  15055. */
  15056. minEmitBox: Vector3;
  15057. /**
  15058. * 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.
  15059. */
  15060. maxEmitBox: Vector3;
  15061. /**
  15062. * Creates a new instance BoxParticleEmitter
  15063. */
  15064. constructor();
  15065. /**
  15066. * Called by the particle System when the direction is computed for the created particle.
  15067. * @param worldMatrix is the world matrix of the particle system
  15068. * @param directionToUpdate is the direction vector to update with the result
  15069. * @param particle is the particle we are computed the direction for
  15070. */
  15071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15072. /**
  15073. * Called by the particle System when the position is computed for the created particle.
  15074. * @param worldMatrix is the world matrix of the particle system
  15075. * @param positionToUpdate is the position vector to update with the result
  15076. * @param particle is the particle we are computed the position for
  15077. */
  15078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15079. /**
  15080. * Clones the current emitter and returns a copy of it
  15081. * @returns the new emitter
  15082. */
  15083. clone(): BoxParticleEmitter;
  15084. /**
  15085. * Called by the GPUParticleSystem to setup the update shader
  15086. * @param effect defines the update shader
  15087. */
  15088. applyToShader(effect: Effect): void;
  15089. /**
  15090. * Returns a string to use to update the GPU particles update shader
  15091. * @returns a string containng the defines string
  15092. */
  15093. getEffectDefines(): string;
  15094. /**
  15095. * Returns the string "BoxParticleEmitter"
  15096. * @returns a string containing the class name
  15097. */
  15098. getClassName(): string;
  15099. /**
  15100. * Serializes the particle system to a JSON object.
  15101. * @returns the JSON object
  15102. */
  15103. serialize(): any;
  15104. /**
  15105. * Parse properties from a JSON object
  15106. * @param serializationObject defines the JSON object
  15107. */
  15108. parse(serializationObject: any): void;
  15109. }
  15110. }
  15111. declare module BABYLON {
  15112. /**
  15113. * Particle emitter emitting particles from the inside of a cone.
  15114. * It emits the particles alongside the cone volume from the base to the particle.
  15115. * The emission direction might be randomized.
  15116. */
  15117. export class ConeParticleEmitter implements IParticleEmitterType {
  15118. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15119. directionRandomizer: number;
  15120. private _radius;
  15121. private _angle;
  15122. private _height;
  15123. /**
  15124. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15125. */
  15126. radiusRange: number;
  15127. /**
  15128. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15129. */
  15130. heightRange: number;
  15131. /**
  15132. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15133. */
  15134. emitFromSpawnPointOnly: boolean;
  15135. /**
  15136. * Gets or sets the radius of the emission cone
  15137. */
  15138. radius: number;
  15139. /**
  15140. * Gets or sets the angle of the emission cone
  15141. */
  15142. angle: number;
  15143. private _buildHeight;
  15144. /**
  15145. * Creates a new instance ConeParticleEmitter
  15146. * @param radius the radius of the emission cone (1 by default)
  15147. * @param angle the cone base angle (PI by default)
  15148. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15149. */
  15150. constructor(radius?: number, angle?: number,
  15151. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15152. directionRandomizer?: number);
  15153. /**
  15154. * Called by the particle System when the direction is computed for the created particle.
  15155. * @param worldMatrix is the world matrix of the particle system
  15156. * @param directionToUpdate is the direction vector to update with the result
  15157. * @param particle is the particle we are computed the direction for
  15158. */
  15159. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15160. /**
  15161. * Called by the particle System when the position is computed for the created particle.
  15162. * @param worldMatrix is the world matrix of the particle system
  15163. * @param positionToUpdate is the position vector to update with the result
  15164. * @param particle is the particle we are computed the position for
  15165. */
  15166. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15167. /**
  15168. * Clones the current emitter and returns a copy of it
  15169. * @returns the new emitter
  15170. */
  15171. clone(): ConeParticleEmitter;
  15172. /**
  15173. * Called by the GPUParticleSystem to setup the update shader
  15174. * @param effect defines the update shader
  15175. */
  15176. applyToShader(effect: Effect): void;
  15177. /**
  15178. * Returns a string to use to update the GPU particles update shader
  15179. * @returns a string containng the defines string
  15180. */
  15181. getEffectDefines(): string;
  15182. /**
  15183. * Returns the string "ConeParticleEmitter"
  15184. * @returns a string containing the class name
  15185. */
  15186. getClassName(): string;
  15187. /**
  15188. * Serializes the particle system to a JSON object.
  15189. * @returns the JSON object
  15190. */
  15191. serialize(): any;
  15192. /**
  15193. * Parse properties from a JSON object
  15194. * @param serializationObject defines the JSON object
  15195. */
  15196. parse(serializationObject: any): void;
  15197. }
  15198. }
  15199. declare module BABYLON {
  15200. /**
  15201. * Particle emitter emitting particles from the inside of a cylinder.
  15202. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15203. */
  15204. export class CylinderParticleEmitter implements IParticleEmitterType {
  15205. /**
  15206. * The radius of the emission cylinder.
  15207. */
  15208. radius: number;
  15209. /**
  15210. * The height of the emission cylinder.
  15211. */
  15212. height: number;
  15213. /**
  15214. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15215. */
  15216. radiusRange: number;
  15217. /**
  15218. * How much to randomize the particle direction [0-1].
  15219. */
  15220. directionRandomizer: number;
  15221. /**
  15222. * Creates a new instance CylinderParticleEmitter
  15223. * @param radius the radius of the emission cylinder (1 by default)
  15224. * @param height the height of the emission cylinder (1 by default)
  15225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15226. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15227. */
  15228. constructor(
  15229. /**
  15230. * The radius of the emission cylinder.
  15231. */
  15232. radius?: number,
  15233. /**
  15234. * The height of the emission cylinder.
  15235. */
  15236. height?: number,
  15237. /**
  15238. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15239. */
  15240. radiusRange?: number,
  15241. /**
  15242. * How much to randomize the particle direction [0-1].
  15243. */
  15244. directionRandomizer?: number);
  15245. /**
  15246. * Called by the particle System when the direction is computed for the created particle.
  15247. * @param worldMatrix is the world matrix of the particle system
  15248. * @param directionToUpdate is the direction vector to update with the result
  15249. * @param particle is the particle we are computed the direction for
  15250. */
  15251. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15252. /**
  15253. * Called by the particle System when the position is computed for the created particle.
  15254. * @param worldMatrix is the world matrix of the particle system
  15255. * @param positionToUpdate is the position vector to update with the result
  15256. * @param particle is the particle we are computed the position for
  15257. */
  15258. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15259. /**
  15260. * Clones the current emitter and returns a copy of it
  15261. * @returns the new emitter
  15262. */
  15263. clone(): CylinderParticleEmitter;
  15264. /**
  15265. * Called by the GPUParticleSystem to setup the update shader
  15266. * @param effect defines the update shader
  15267. */
  15268. applyToShader(effect: Effect): void;
  15269. /**
  15270. * Returns a string to use to update the GPU particles update shader
  15271. * @returns a string containng the defines string
  15272. */
  15273. getEffectDefines(): string;
  15274. /**
  15275. * Returns the string "CylinderParticleEmitter"
  15276. * @returns a string containing the class name
  15277. */
  15278. getClassName(): string;
  15279. /**
  15280. * Serializes the particle system to a JSON object.
  15281. * @returns the JSON object
  15282. */
  15283. serialize(): any;
  15284. /**
  15285. * Parse properties from a JSON object
  15286. * @param serializationObject defines the JSON object
  15287. */
  15288. parse(serializationObject: any): void;
  15289. }
  15290. /**
  15291. * Particle emitter emitting particles from the inside of a cylinder.
  15292. * It emits the particles randomly between two vectors.
  15293. */
  15294. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15295. /**
  15296. * The min limit of the emission direction.
  15297. */
  15298. direction1: Vector3;
  15299. /**
  15300. * The max limit of the emission direction.
  15301. */
  15302. direction2: Vector3;
  15303. /**
  15304. * Creates a new instance CylinderDirectedParticleEmitter
  15305. * @param radius the radius of the emission cylinder (1 by default)
  15306. * @param height the height of the emission cylinder (1 by default)
  15307. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15308. * @param direction1 the min limit of the emission direction (up vector by default)
  15309. * @param direction2 the max limit of the emission direction (up vector by default)
  15310. */
  15311. constructor(radius?: number, height?: number, radiusRange?: number,
  15312. /**
  15313. * The min limit of the emission direction.
  15314. */
  15315. direction1?: Vector3,
  15316. /**
  15317. * The max limit of the emission direction.
  15318. */
  15319. direction2?: Vector3);
  15320. /**
  15321. * Called by the particle System when the direction is computed for the created particle.
  15322. * @param worldMatrix is the world matrix of the particle system
  15323. * @param directionToUpdate is the direction vector to update with the result
  15324. * @param particle is the particle we are computed the direction for
  15325. */
  15326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15327. /**
  15328. * Clones the current emitter and returns a copy of it
  15329. * @returns the new emitter
  15330. */
  15331. clone(): CylinderDirectedParticleEmitter;
  15332. /**
  15333. * Called by the GPUParticleSystem to setup the update shader
  15334. * @param effect defines the update shader
  15335. */
  15336. applyToShader(effect: Effect): void;
  15337. /**
  15338. * Returns a string to use to update the GPU particles update shader
  15339. * @returns a string containng the defines string
  15340. */
  15341. getEffectDefines(): string;
  15342. /**
  15343. * Returns the string "CylinderDirectedParticleEmitter"
  15344. * @returns a string containing the class name
  15345. */
  15346. getClassName(): string;
  15347. /**
  15348. * Serializes the particle system to a JSON object.
  15349. * @returns the JSON object
  15350. */
  15351. serialize(): any;
  15352. /**
  15353. * Parse properties from a JSON object
  15354. * @param serializationObject defines the JSON object
  15355. */
  15356. parse(serializationObject: any): void;
  15357. }
  15358. }
  15359. declare module BABYLON {
  15360. /**
  15361. * Particle emitter emitting particles from the inside of a hemisphere.
  15362. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15363. */
  15364. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15365. /**
  15366. * The radius of the emission hemisphere.
  15367. */
  15368. radius: number;
  15369. /**
  15370. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15371. */
  15372. radiusRange: number;
  15373. /**
  15374. * How much to randomize the particle direction [0-1].
  15375. */
  15376. directionRandomizer: number;
  15377. /**
  15378. * Creates a new instance HemisphericParticleEmitter
  15379. * @param radius the radius of the emission hemisphere (1 by default)
  15380. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15381. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15382. */
  15383. constructor(
  15384. /**
  15385. * The radius of the emission hemisphere.
  15386. */
  15387. radius?: number,
  15388. /**
  15389. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15390. */
  15391. radiusRange?: number,
  15392. /**
  15393. * How much to randomize the particle direction [0-1].
  15394. */
  15395. directionRandomizer?: number);
  15396. /**
  15397. * Called by the particle System when the direction is computed for the created particle.
  15398. * @param worldMatrix is the world matrix of the particle system
  15399. * @param directionToUpdate is the direction vector to update with the result
  15400. * @param particle is the particle we are computed the direction for
  15401. */
  15402. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15403. /**
  15404. * Called by the particle System when the position is computed for the created particle.
  15405. * @param worldMatrix is the world matrix of the particle system
  15406. * @param positionToUpdate is the position vector to update with the result
  15407. * @param particle is the particle we are computed the position for
  15408. */
  15409. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15410. /**
  15411. * Clones the current emitter and returns a copy of it
  15412. * @returns the new emitter
  15413. */
  15414. clone(): HemisphericParticleEmitter;
  15415. /**
  15416. * Called by the GPUParticleSystem to setup the update shader
  15417. * @param effect defines the update shader
  15418. */
  15419. applyToShader(effect: Effect): void;
  15420. /**
  15421. * Returns a string to use to update the GPU particles update shader
  15422. * @returns a string containng the defines string
  15423. */
  15424. getEffectDefines(): string;
  15425. /**
  15426. * Returns the string "HemisphericParticleEmitter"
  15427. * @returns a string containing the class name
  15428. */
  15429. getClassName(): string;
  15430. /**
  15431. * Serializes the particle system to a JSON object.
  15432. * @returns the JSON object
  15433. */
  15434. serialize(): any;
  15435. /**
  15436. * Parse properties from a JSON object
  15437. * @param serializationObject defines the JSON object
  15438. */
  15439. parse(serializationObject: any): void;
  15440. }
  15441. }
  15442. declare module BABYLON {
  15443. /**
  15444. * Particle emitter emitting particles from a point.
  15445. * It emits the particles randomly between 2 given directions.
  15446. */
  15447. export class PointParticleEmitter implements IParticleEmitterType {
  15448. /**
  15449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15450. */
  15451. direction1: Vector3;
  15452. /**
  15453. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15454. */
  15455. direction2: Vector3;
  15456. /**
  15457. * Creates a new instance PointParticleEmitter
  15458. */
  15459. constructor();
  15460. /**
  15461. * Called by the particle System when the direction is computed for the created particle.
  15462. * @param worldMatrix is the world matrix of the particle system
  15463. * @param directionToUpdate is the direction vector to update with the result
  15464. * @param particle is the particle we are computed the direction for
  15465. */
  15466. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15467. /**
  15468. * Called by the particle System when the position is computed for the created particle.
  15469. * @param worldMatrix is the world matrix of the particle system
  15470. * @param positionToUpdate is the position vector to update with the result
  15471. * @param particle is the particle we are computed the position for
  15472. */
  15473. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15474. /**
  15475. * Clones the current emitter and returns a copy of it
  15476. * @returns the new emitter
  15477. */
  15478. clone(): PointParticleEmitter;
  15479. /**
  15480. * Called by the GPUParticleSystem to setup the update shader
  15481. * @param effect defines the update shader
  15482. */
  15483. applyToShader(effect: Effect): void;
  15484. /**
  15485. * Returns a string to use to update the GPU particles update shader
  15486. * @returns a string containng the defines string
  15487. */
  15488. getEffectDefines(): string;
  15489. /**
  15490. * Returns the string "PointParticleEmitter"
  15491. * @returns a string containing the class name
  15492. */
  15493. getClassName(): string;
  15494. /**
  15495. * Serializes the particle system to a JSON object.
  15496. * @returns the JSON object
  15497. */
  15498. serialize(): any;
  15499. /**
  15500. * Parse properties from a JSON object
  15501. * @param serializationObject defines the JSON object
  15502. */
  15503. parse(serializationObject: any): void;
  15504. }
  15505. }
  15506. declare module BABYLON {
  15507. /**
  15508. * Particle emitter emitting particles from the inside of a sphere.
  15509. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15510. */
  15511. export class SphereParticleEmitter implements IParticleEmitterType {
  15512. /**
  15513. * The radius of the emission sphere.
  15514. */
  15515. radius: number;
  15516. /**
  15517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15518. */
  15519. radiusRange: number;
  15520. /**
  15521. * How much to randomize the particle direction [0-1].
  15522. */
  15523. directionRandomizer: number;
  15524. /**
  15525. * Creates a new instance SphereParticleEmitter
  15526. * @param radius the radius of the emission sphere (1 by default)
  15527. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15528. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15529. */
  15530. constructor(
  15531. /**
  15532. * The radius of the emission sphere.
  15533. */
  15534. radius?: number,
  15535. /**
  15536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15537. */
  15538. radiusRange?: number,
  15539. /**
  15540. * How much to randomize the particle direction [0-1].
  15541. */
  15542. directionRandomizer?: number);
  15543. /**
  15544. * Called by the particle System when the direction is computed for the created particle.
  15545. * @param worldMatrix is the world matrix of the particle system
  15546. * @param directionToUpdate is the direction vector to update with the result
  15547. * @param particle is the particle we are computed the direction for
  15548. */
  15549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15550. /**
  15551. * Called by the particle System when the position is computed for the created particle.
  15552. * @param worldMatrix is the world matrix of the particle system
  15553. * @param positionToUpdate is the position vector to update with the result
  15554. * @param particle is the particle we are computed the position for
  15555. */
  15556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15557. /**
  15558. * Clones the current emitter and returns a copy of it
  15559. * @returns the new emitter
  15560. */
  15561. clone(): SphereParticleEmitter;
  15562. /**
  15563. * Called by the GPUParticleSystem to setup the update shader
  15564. * @param effect defines the update shader
  15565. */
  15566. applyToShader(effect: Effect): void;
  15567. /**
  15568. * Returns a string to use to update the GPU particles update shader
  15569. * @returns a string containng the defines string
  15570. */
  15571. getEffectDefines(): string;
  15572. /**
  15573. * Returns the string "SphereParticleEmitter"
  15574. * @returns a string containing the class name
  15575. */
  15576. getClassName(): string;
  15577. /**
  15578. * Serializes the particle system to a JSON object.
  15579. * @returns the JSON object
  15580. */
  15581. serialize(): any;
  15582. /**
  15583. * Parse properties from a JSON object
  15584. * @param serializationObject defines the JSON object
  15585. */
  15586. parse(serializationObject: any): void;
  15587. }
  15588. /**
  15589. * Particle emitter emitting particles from the inside of a sphere.
  15590. * It emits the particles randomly between two vectors.
  15591. */
  15592. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15593. /**
  15594. * The min limit of the emission direction.
  15595. */
  15596. direction1: Vector3;
  15597. /**
  15598. * The max limit of the emission direction.
  15599. */
  15600. direction2: Vector3;
  15601. /**
  15602. * Creates a new instance SphereDirectedParticleEmitter
  15603. * @param radius the radius of the emission sphere (1 by default)
  15604. * @param direction1 the min limit of the emission direction (up vector by default)
  15605. * @param direction2 the max limit of the emission direction (up vector by default)
  15606. */
  15607. constructor(radius?: number,
  15608. /**
  15609. * The min limit of the emission direction.
  15610. */
  15611. direction1?: Vector3,
  15612. /**
  15613. * The max limit of the emission direction.
  15614. */
  15615. direction2?: Vector3);
  15616. /**
  15617. * Called by the particle System when the direction is computed for the created particle.
  15618. * @param worldMatrix is the world matrix of the particle system
  15619. * @param directionToUpdate is the direction vector to update with the result
  15620. * @param particle is the particle we are computed the direction for
  15621. */
  15622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15623. /**
  15624. * Clones the current emitter and returns a copy of it
  15625. * @returns the new emitter
  15626. */
  15627. clone(): SphereDirectedParticleEmitter;
  15628. /**
  15629. * Called by the GPUParticleSystem to setup the update shader
  15630. * @param effect defines the update shader
  15631. */
  15632. applyToShader(effect: Effect): void;
  15633. /**
  15634. * Returns a string to use to update the GPU particles update shader
  15635. * @returns a string containng the defines string
  15636. */
  15637. getEffectDefines(): string;
  15638. /**
  15639. * Returns the string "SphereDirectedParticleEmitter"
  15640. * @returns a string containing the class name
  15641. */
  15642. getClassName(): string;
  15643. /**
  15644. * Serializes the particle system to a JSON object.
  15645. * @returns the JSON object
  15646. */
  15647. serialize(): any;
  15648. /**
  15649. * Parse properties from a JSON object
  15650. * @param serializationObject defines the JSON object
  15651. */
  15652. parse(serializationObject: any): void;
  15653. }
  15654. }
  15655. declare module BABYLON {
  15656. /**
  15657. * Interface representing a particle system in Babylon.js.
  15658. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15659. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15660. */
  15661. export interface IParticleSystem {
  15662. /**
  15663. * List of animations used by the particle system.
  15664. */
  15665. animations: Animation[];
  15666. /**
  15667. * The id of the Particle system.
  15668. */
  15669. id: string;
  15670. /**
  15671. * The name of the Particle system.
  15672. */
  15673. name: string;
  15674. /**
  15675. * The emitter represents the Mesh or position we are attaching the particle system to.
  15676. */
  15677. emitter: Nullable<AbstractMesh | Vector3>;
  15678. /**
  15679. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15680. */
  15681. isBillboardBased: boolean;
  15682. /**
  15683. * The rendering group used by the Particle system to chose when to render.
  15684. */
  15685. renderingGroupId: number;
  15686. /**
  15687. * The layer mask we are rendering the particles through.
  15688. */
  15689. layerMask: number;
  15690. /**
  15691. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15692. */
  15693. updateSpeed: number;
  15694. /**
  15695. * The amount of time the particle system is running (depends of the overall update speed).
  15696. */
  15697. targetStopDuration: number;
  15698. /**
  15699. * The texture used to render each particle. (this can be a spritesheet)
  15700. */
  15701. particleTexture: Nullable<Texture>;
  15702. /**
  15703. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15704. */
  15705. blendMode: number;
  15706. /**
  15707. * Minimum life time of emitting particles.
  15708. */
  15709. minLifeTime: number;
  15710. /**
  15711. * Maximum life time of emitting particles.
  15712. */
  15713. maxLifeTime: number;
  15714. /**
  15715. * Minimum Size of emitting particles.
  15716. */
  15717. minSize: number;
  15718. /**
  15719. * Maximum Size of emitting particles.
  15720. */
  15721. maxSize: number;
  15722. /**
  15723. * Minimum scale of emitting particles on X axis.
  15724. */
  15725. minScaleX: number;
  15726. /**
  15727. * Maximum scale of emitting particles on X axis.
  15728. */
  15729. maxScaleX: number;
  15730. /**
  15731. * Minimum scale of emitting particles on Y axis.
  15732. */
  15733. minScaleY: number;
  15734. /**
  15735. * Maximum scale of emitting particles on Y axis.
  15736. */
  15737. maxScaleY: number;
  15738. /**
  15739. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15740. */
  15741. color1: Color4;
  15742. /**
  15743. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15744. */
  15745. color2: Color4;
  15746. /**
  15747. * Color the particle will have at the end of its lifetime.
  15748. */
  15749. colorDead: Color4;
  15750. /**
  15751. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15752. */
  15753. emitRate: number;
  15754. /**
  15755. * You can use gravity if you want to give an orientation to your particles.
  15756. */
  15757. gravity: Vector3;
  15758. /**
  15759. * Minimum power of emitting particles.
  15760. */
  15761. minEmitPower: number;
  15762. /**
  15763. * Maximum power of emitting particles.
  15764. */
  15765. maxEmitPower: number;
  15766. /**
  15767. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15768. */
  15769. minAngularSpeed: number;
  15770. /**
  15771. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15772. */
  15773. maxAngularSpeed: number;
  15774. /**
  15775. * Gets or sets the minimal initial rotation in radians.
  15776. */
  15777. minInitialRotation: number;
  15778. /**
  15779. * Gets or sets the maximal initial rotation in radians.
  15780. */
  15781. maxInitialRotation: number;
  15782. /**
  15783. * The particle emitter type defines the emitter used by the particle system.
  15784. * It can be for example box, sphere, or cone...
  15785. */
  15786. particleEmitterType: Nullable<IParticleEmitterType>;
  15787. /**
  15788. * Defines the delay in milliseconds before starting the system (0 by default)
  15789. */
  15790. startDelay: number;
  15791. /**
  15792. * 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
  15793. */
  15794. preWarmCycles: number;
  15795. /**
  15796. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15797. */
  15798. preWarmStepOffset: number;
  15799. /**
  15800. * 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)
  15801. */
  15802. spriteCellChangeSpeed: number;
  15803. /**
  15804. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15805. */
  15806. startSpriteCellID: number;
  15807. /**
  15808. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15809. */
  15810. endSpriteCellID: number;
  15811. /**
  15812. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15813. */
  15814. spriteCellWidth: number;
  15815. /**
  15816. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15817. */
  15818. spriteCellHeight: number;
  15819. /**
  15820. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15821. */
  15822. spriteRandomStartCell: boolean;
  15823. /**
  15824. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15825. */
  15826. isAnimationSheetEnabled: boolean;
  15827. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15828. translationPivot: Vector2;
  15829. /**
  15830. * Gets or sets a texture used to add random noise to particle positions
  15831. */
  15832. noiseTexture: Nullable<BaseTexture>;
  15833. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15834. noiseStrength: Vector3;
  15835. /**
  15836. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15837. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15838. */
  15839. billboardMode: number;
  15840. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15841. limitVelocityDamping: number;
  15842. /**
  15843. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15844. */
  15845. beginAnimationOnStart: boolean;
  15846. /**
  15847. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15848. */
  15849. beginAnimationFrom: number;
  15850. /**
  15851. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15852. */
  15853. beginAnimationTo: number;
  15854. /**
  15855. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15856. */
  15857. beginAnimationLoop: boolean;
  15858. /**
  15859. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15860. */
  15861. disposeOnStop: boolean;
  15862. /**
  15863. * Gets the maximum number of particles active at the same time.
  15864. * @returns The max number of active particles.
  15865. */
  15866. getCapacity(): number;
  15867. /**
  15868. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15869. * @returns True if it has been started, otherwise false.
  15870. */
  15871. isStarted(): boolean;
  15872. /**
  15873. * Animates the particle system for this frame.
  15874. */
  15875. animate(): void;
  15876. /**
  15877. * Renders the particle system in its current state.
  15878. * @returns the current number of particles
  15879. */
  15880. render(): number;
  15881. /**
  15882. * Dispose the particle system and frees its associated resources.
  15883. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15884. */
  15885. dispose(disposeTexture?: boolean): void;
  15886. /**
  15887. * Clones the particle system.
  15888. * @param name The name of the cloned object
  15889. * @param newEmitter The new emitter to use
  15890. * @returns the cloned particle system
  15891. */
  15892. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  15893. /**
  15894. * Serializes the particle system to a JSON object.
  15895. * @returns the JSON object
  15896. */
  15897. serialize(): any;
  15898. /**
  15899. * Rebuild the particle system
  15900. */
  15901. rebuild(): void;
  15902. /**
  15903. * Starts the particle system and begins to emit
  15904. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  15905. */
  15906. start(delay?: number): void;
  15907. /**
  15908. * Stops the particle system.
  15909. */
  15910. stop(): void;
  15911. /**
  15912. * Remove all active particles
  15913. */
  15914. reset(): void;
  15915. /**
  15916. * Is this system ready to be used/rendered
  15917. * @return true if the system is ready
  15918. */
  15919. isReady(): boolean;
  15920. /**
  15921. * Adds a new color gradient
  15922. * @param gradient defines the gradient to use (between 0 and 1)
  15923. * @param color1 defines the color to affect to the specified gradient
  15924. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15925. * @returns the current particle system
  15926. */
  15927. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15928. /**
  15929. * Remove a specific color gradient
  15930. * @param gradient defines the gradient to remove
  15931. * @returns the current particle system
  15932. */
  15933. removeColorGradient(gradient: number): IParticleSystem;
  15934. /**
  15935. * Adds a new size gradient
  15936. * @param gradient defines the gradient to use (between 0 and 1)
  15937. * @param factor defines the size factor to affect to the specified gradient
  15938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15939. * @returns the current particle system
  15940. */
  15941. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15942. /**
  15943. * Remove a specific size gradient
  15944. * @param gradient defines the gradient to remove
  15945. * @returns the current particle system
  15946. */
  15947. removeSizeGradient(gradient: number): IParticleSystem;
  15948. /**
  15949. * Gets the current list of color gradients.
  15950. * You must use addColorGradient and removeColorGradient to udpate this list
  15951. * @returns the list of color gradients
  15952. */
  15953. getColorGradients(): Nullable<Array<ColorGradient>>;
  15954. /**
  15955. * Gets the current list of size gradients.
  15956. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15957. * @returns the list of size gradients
  15958. */
  15959. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15960. /**
  15961. * Gets the current list of angular speed gradients.
  15962. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15963. * @returns the list of angular speed gradients
  15964. */
  15965. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15966. /**
  15967. * Adds a new angular speed gradient
  15968. * @param gradient defines the gradient to use (between 0 and 1)
  15969. * @param factor defines the angular speed to affect to the specified gradient
  15970. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15971. * @returns the current particle system
  15972. */
  15973. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15974. /**
  15975. * Remove a specific angular speed gradient
  15976. * @param gradient defines the gradient to remove
  15977. * @returns the current particle system
  15978. */
  15979. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15980. /**
  15981. * Gets the current list of velocity gradients.
  15982. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15983. * @returns the list of velocity gradients
  15984. */
  15985. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15986. /**
  15987. * Adds a new velocity gradient
  15988. * @param gradient defines the gradient to use (between 0 and 1)
  15989. * @param factor defines the velocity to affect to the specified gradient
  15990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15991. * @returns the current particle system
  15992. */
  15993. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15994. /**
  15995. * Remove a specific velocity gradient
  15996. * @param gradient defines the gradient to remove
  15997. * @returns the current particle system
  15998. */
  15999. removeVelocityGradient(gradient: number): IParticleSystem;
  16000. /**
  16001. * Gets the current list of limit velocity gradients.
  16002. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16003. * @returns the list of limit velocity gradients
  16004. */
  16005. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16006. /**
  16007. * Adds a new limit velocity gradient
  16008. * @param gradient defines the gradient to use (between 0 and 1)
  16009. * @param factor defines the limit velocity to affect to the specified gradient
  16010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16011. * @returns the current particle system
  16012. */
  16013. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16014. /**
  16015. * Remove a specific limit velocity gradient
  16016. * @param gradient defines the gradient to remove
  16017. * @returns the current particle system
  16018. */
  16019. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16020. /**
  16021. * Adds a new drag gradient
  16022. * @param gradient defines the gradient to use (between 0 and 1)
  16023. * @param factor defines the drag to affect to the specified gradient
  16024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16025. * @returns the current particle system
  16026. */
  16027. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16028. /**
  16029. * Remove a specific drag gradient
  16030. * @param gradient defines the gradient to remove
  16031. * @returns the current particle system
  16032. */
  16033. removeDragGradient(gradient: number): IParticleSystem;
  16034. /**
  16035. * Gets the current list of drag gradients.
  16036. * You must use addDragGradient and removeDragGradient to udpate this list
  16037. * @returns the list of drag gradients
  16038. */
  16039. getDragGradients(): Nullable<Array<FactorGradient>>;
  16040. /**
  16041. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16042. * @param gradient defines the gradient to use (between 0 and 1)
  16043. * @param factor defines the emit rate to affect to the specified gradient
  16044. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16045. * @returns the current particle system
  16046. */
  16047. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16048. /**
  16049. * Remove a specific emit rate gradient
  16050. * @param gradient defines the gradient to remove
  16051. * @returns the current particle system
  16052. */
  16053. removeEmitRateGradient(gradient: number): IParticleSystem;
  16054. /**
  16055. * Gets the current list of emit rate gradients.
  16056. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16057. * @returns the list of emit rate gradients
  16058. */
  16059. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16060. /**
  16061. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16062. * @param gradient defines the gradient to use (between 0 and 1)
  16063. * @param factor defines the start size to affect to the specified gradient
  16064. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16065. * @returns the current particle system
  16066. */
  16067. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16068. /**
  16069. * Remove a specific start size gradient
  16070. * @param gradient defines the gradient to remove
  16071. * @returns the current particle system
  16072. */
  16073. removeStartSizeGradient(gradient: number): IParticleSystem;
  16074. /**
  16075. * Gets the current list of start size gradients.
  16076. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16077. * @returns the list of start size gradients
  16078. */
  16079. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16080. /**
  16081. * Adds a new life time gradient
  16082. * @param gradient defines the gradient to use (between 0 and 1)
  16083. * @param factor defines the life time factor to affect to the specified gradient
  16084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16085. * @returns the current particle system
  16086. */
  16087. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16088. /**
  16089. * Remove a specific life time gradient
  16090. * @param gradient defines the gradient to remove
  16091. * @returns the current particle system
  16092. */
  16093. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16094. /**
  16095. * Gets the current list of life time gradients.
  16096. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16097. * @returns the list of life time gradients
  16098. */
  16099. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16100. /**
  16101. * Gets the current list of color gradients.
  16102. * You must use addColorGradient and removeColorGradient to udpate this list
  16103. * @returns the list of color gradients
  16104. */
  16105. getColorGradients(): Nullable<Array<ColorGradient>>;
  16106. /**
  16107. * Adds a new ramp gradient used to remap particle colors
  16108. * @param gradient defines the gradient to use (between 0 and 1)
  16109. * @param color defines the color to affect to the specified gradient
  16110. * @returns the current particle system
  16111. */
  16112. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16113. /**
  16114. * Gets the current list of ramp gradients.
  16115. * You must use addRampGradient and removeRampGradient to udpate this list
  16116. * @returns the list of ramp gradients
  16117. */
  16118. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16119. /** Gets or sets a boolean indicating that ramp gradients must be used
  16120. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16121. */
  16122. useRampGradients: boolean;
  16123. /**
  16124. * Adds a new color remap gradient
  16125. * @param gradient defines the gradient to use (between 0 and 1)
  16126. * @param min defines the color remap minimal range
  16127. * @param max defines the color remap maximal range
  16128. * @returns the current particle system
  16129. */
  16130. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16131. /**
  16132. * Gets the current list of color remap gradients.
  16133. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16134. * @returns the list of color remap gradients
  16135. */
  16136. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16137. /**
  16138. * Adds a new alpha remap gradient
  16139. * @param gradient defines the gradient to use (between 0 and 1)
  16140. * @param min defines the alpha remap minimal range
  16141. * @param max defines the alpha remap maximal range
  16142. * @returns the current particle system
  16143. */
  16144. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16145. /**
  16146. * Gets the current list of alpha remap gradients.
  16147. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16148. * @returns the list of alpha remap gradients
  16149. */
  16150. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16151. /**
  16152. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16153. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16154. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16155. * @returns the emitter
  16156. */
  16157. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16158. /**
  16159. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16160. * @param radius The radius of the hemisphere to emit from
  16161. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16162. * @returns the emitter
  16163. */
  16164. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16165. /**
  16166. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16167. * @param radius The radius of the sphere to emit from
  16168. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16169. * @returns the emitter
  16170. */
  16171. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16172. /**
  16173. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16174. * @param radius The radius of the sphere to emit from
  16175. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16176. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16177. * @returns the emitter
  16178. */
  16179. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16180. /**
  16181. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16182. * @param radius The radius of the emission cylinder
  16183. * @param height The height of the emission cylinder
  16184. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16185. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16186. * @returns the emitter
  16187. */
  16188. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16189. /**
  16190. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16191. * @param radius The radius of the cylinder to emit from
  16192. * @param height The height of the emission cylinder
  16193. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16196. * @returns the emitter
  16197. */
  16198. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16199. /**
  16200. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16201. * @param radius The radius of the cone to emit from
  16202. * @param angle The base angle of the cone
  16203. * @returns the emitter
  16204. */
  16205. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16206. /**
  16207. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16208. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16209. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16210. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16211. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16212. * @returns the emitter
  16213. */
  16214. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16215. /**
  16216. * Get hosting scene
  16217. * @returns the scene
  16218. */
  16219. getScene(): Scene;
  16220. }
  16221. }
  16222. declare module BABYLON {
  16223. /**
  16224. * Creates an instance based on a source mesh.
  16225. */
  16226. export class InstancedMesh extends AbstractMesh {
  16227. private _sourceMesh;
  16228. private _currentLOD;
  16229. /** @hidden */ indexInSourceMeshInstanceArray: number;
  16230. constructor(name: string, source: Mesh);
  16231. /**
  16232. * Returns the string "InstancedMesh".
  16233. */
  16234. getClassName(): string;
  16235. /**
  16236. * If the source mesh receives shadows
  16237. */
  16238. readonly receiveShadows: boolean;
  16239. /**
  16240. * The material of the source mesh
  16241. */
  16242. readonly material: Nullable<Material>;
  16243. /**
  16244. * Visibility of the source mesh
  16245. */
  16246. readonly visibility: number;
  16247. /**
  16248. * Skeleton of the source mesh
  16249. */
  16250. readonly skeleton: Nullable<Skeleton>;
  16251. /**
  16252. * Rendering ground id of the source mesh
  16253. */
  16254. renderingGroupId: number;
  16255. /**
  16256. * Returns the total number of vertices (integer).
  16257. */
  16258. getTotalVertices(): number;
  16259. /**
  16260. * Returns a positive integer : the total number of indices in this mesh geometry.
  16261. * @returns the numner of indices or zero if the mesh has no geometry.
  16262. */
  16263. getTotalIndices(): number;
  16264. /**
  16265. * The source mesh of the instance
  16266. */
  16267. readonly sourceMesh: Mesh;
  16268. /**
  16269. * Is this node ready to be used/rendered
  16270. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16271. * @return {boolean} is it ready
  16272. */
  16273. isReady(completeCheck?: boolean): boolean;
  16274. /**
  16275. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16276. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16277. * @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.
  16278. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16279. */
  16280. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16281. /**
  16282. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16283. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16284. * The `data` are either a numeric array either a Float32Array.
  16285. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16286. * 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).
  16287. * Note that a new underlying VertexBuffer object is created each call.
  16288. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16289. *
  16290. * Possible `kind` values :
  16291. * - VertexBuffer.PositionKind
  16292. * - VertexBuffer.UVKind
  16293. * - VertexBuffer.UV2Kind
  16294. * - VertexBuffer.UV3Kind
  16295. * - VertexBuffer.UV4Kind
  16296. * - VertexBuffer.UV5Kind
  16297. * - VertexBuffer.UV6Kind
  16298. * - VertexBuffer.ColorKind
  16299. * - VertexBuffer.MatricesIndicesKind
  16300. * - VertexBuffer.MatricesIndicesExtraKind
  16301. * - VertexBuffer.MatricesWeightsKind
  16302. * - VertexBuffer.MatricesWeightsExtraKind
  16303. *
  16304. * Returns the Mesh.
  16305. */
  16306. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16307. /**
  16308. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16309. * If the mesh has no geometry, it is simply returned as it is.
  16310. * The `data` are either a numeric array either a Float32Array.
  16311. * No new underlying VertexBuffer object is created.
  16312. * 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.
  16313. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16314. *
  16315. * Possible `kind` values :
  16316. * - VertexBuffer.PositionKind
  16317. * - VertexBuffer.UVKind
  16318. * - VertexBuffer.UV2Kind
  16319. * - VertexBuffer.UV3Kind
  16320. * - VertexBuffer.UV4Kind
  16321. * - VertexBuffer.UV5Kind
  16322. * - VertexBuffer.UV6Kind
  16323. * - VertexBuffer.ColorKind
  16324. * - VertexBuffer.MatricesIndicesKind
  16325. * - VertexBuffer.MatricesIndicesExtraKind
  16326. * - VertexBuffer.MatricesWeightsKind
  16327. * - VertexBuffer.MatricesWeightsExtraKind
  16328. *
  16329. * Returns the Mesh.
  16330. */
  16331. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16332. /**
  16333. * Sets the mesh indices.
  16334. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16335. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16336. * This method creates a new index buffer each call.
  16337. * Returns the Mesh.
  16338. */
  16339. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16340. /**
  16341. * Boolean : True if the mesh owns the requested kind of data.
  16342. */
  16343. isVerticesDataPresent(kind: string): boolean;
  16344. /**
  16345. * Returns an array of indices (IndicesArray).
  16346. */
  16347. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16348. /**
  16349. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16350. * This means the mesh underlying bounding box and sphere are recomputed.
  16351. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16352. * @returns the current mesh
  16353. */
  16354. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16355. /** @hidden */ preActivate(): InstancedMesh;
  16356. /** @hidden */ activate(renderId: number): InstancedMesh;
  16357. /**
  16358. * Returns the current associated LOD AbstractMesh.
  16359. */
  16360. getLOD(camera: Camera): AbstractMesh;
  16361. /** @hidden */ syncSubMeshes(): InstancedMesh;
  16362. /** @hidden */ generatePointsArray(): boolean;
  16363. /**
  16364. * Creates a new InstancedMesh from the current mesh.
  16365. * - name (string) : the cloned mesh name
  16366. * - newParent (optional Node) : the optional Node to parent the clone to.
  16367. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16368. *
  16369. * Returns the clone.
  16370. */
  16371. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16372. /**
  16373. * Disposes the InstancedMesh.
  16374. * Returns nothing.
  16375. */
  16376. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16377. }
  16378. }
  16379. declare module BABYLON {
  16380. /**
  16381. * Defines the options associated with the creation of a shader material.
  16382. */
  16383. export interface IShaderMaterialOptions {
  16384. /**
  16385. * Does the material work in alpha blend mode
  16386. */
  16387. needAlphaBlending: boolean;
  16388. /**
  16389. * Does the material work in alpha test mode
  16390. */
  16391. needAlphaTesting: boolean;
  16392. /**
  16393. * The list of attribute names used in the shader
  16394. */
  16395. attributes: string[];
  16396. /**
  16397. * The list of unifrom names used in the shader
  16398. */
  16399. uniforms: string[];
  16400. /**
  16401. * The list of UBO names used in the shader
  16402. */
  16403. uniformBuffers: string[];
  16404. /**
  16405. * The list of sampler names used in the shader
  16406. */
  16407. samplers: string[];
  16408. /**
  16409. * The list of defines used in the shader
  16410. */
  16411. defines: string[];
  16412. }
  16413. /**
  16414. * 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.
  16415. *
  16416. * This returned material effects how the mesh will look based on the code in the shaders.
  16417. *
  16418. * @see http://doc.babylonjs.com/how_to/shader_material
  16419. */
  16420. export class ShaderMaterial extends Material {
  16421. private _shaderPath;
  16422. private _options;
  16423. private _textures;
  16424. private _textureArrays;
  16425. private _floats;
  16426. private _ints;
  16427. private _floatsArrays;
  16428. private _colors3;
  16429. private _colors3Arrays;
  16430. private _colors4;
  16431. private _vectors2;
  16432. private _vectors3;
  16433. private _vectors4;
  16434. private _matrices;
  16435. private _matrices3x3;
  16436. private _matrices2x2;
  16437. private _vectors2Arrays;
  16438. private _vectors3Arrays;
  16439. private _cachedWorldViewMatrix;
  16440. private _renderId;
  16441. /**
  16442. * Instantiate a new shader material.
  16443. * 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.
  16444. * This returned material effects how the mesh will look based on the code in the shaders.
  16445. * @see http://doc.babylonjs.com/how_to/shader_material
  16446. * @param name Define the name of the material in the scene
  16447. * @param scene Define the scene the material belongs to
  16448. * @param shaderPath Defines the route to the shader code in one of three ways:
  16449. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16450. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16451. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16452. * @param options Define the options used to create the shader
  16453. */
  16454. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16455. /**
  16456. * Gets the options used to compile the shader.
  16457. * They can be modified to trigger a new compilation
  16458. */
  16459. readonly options: IShaderMaterialOptions;
  16460. /**
  16461. * Gets the current class name of the material e.g. "ShaderMaterial"
  16462. * Mainly use in serialization.
  16463. * @returns the class name
  16464. */
  16465. getClassName(): string;
  16466. /**
  16467. * Specifies if the material will require alpha blending
  16468. * @returns a boolean specifying if alpha blending is needed
  16469. */
  16470. needAlphaBlending(): boolean;
  16471. /**
  16472. * Specifies if this material should be rendered in alpha test mode
  16473. * @returns a boolean specifying if an alpha test is needed.
  16474. */
  16475. needAlphaTesting(): boolean;
  16476. private _checkUniform;
  16477. /**
  16478. * Set a texture in the shader.
  16479. * @param name Define the name of the uniform samplers as defined in the shader
  16480. * @param texture Define the texture to bind to this sampler
  16481. * @return the material itself allowing "fluent" like uniform updates
  16482. */
  16483. setTexture(name: string, texture: Texture): ShaderMaterial;
  16484. /**
  16485. * Set a texture array in the shader.
  16486. * @param name Define the name of the uniform sampler array as defined in the shader
  16487. * @param textures Define the list of textures to bind to this sampler
  16488. * @return the material itself allowing "fluent" like uniform updates
  16489. */
  16490. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16491. /**
  16492. * Set a float in the shader.
  16493. * @param name Define the name of the uniform as defined in the shader
  16494. * @param value Define the value to give to the uniform
  16495. * @return the material itself allowing "fluent" like uniform updates
  16496. */
  16497. setFloat(name: string, value: number): ShaderMaterial;
  16498. /**
  16499. * Set a int in the shader.
  16500. * @param name Define the name of the uniform as defined in the shader
  16501. * @param value Define the value to give to the uniform
  16502. * @return the material itself allowing "fluent" like uniform updates
  16503. */
  16504. setInt(name: string, value: number): ShaderMaterial;
  16505. /**
  16506. * Set an array of floats in the shader.
  16507. * @param name Define the name of the uniform as defined in the shader
  16508. * @param value Define the value to give to the uniform
  16509. * @return the material itself allowing "fluent" like uniform updates
  16510. */
  16511. setFloats(name: string, value: number[]): ShaderMaterial;
  16512. /**
  16513. * Set a vec3 in the shader from a Color3.
  16514. * @param name Define the name of the uniform as defined in the shader
  16515. * @param value Define the value to give to the uniform
  16516. * @return the material itself allowing "fluent" like uniform updates
  16517. */
  16518. setColor3(name: string, value: Color3): ShaderMaterial;
  16519. /**
  16520. * Set a vec3 array in the shader from a Color3 array.
  16521. * @param name Define the name of the uniform as defined in the shader
  16522. * @param value Define the value to give to the uniform
  16523. * @return the material itself allowing "fluent" like uniform updates
  16524. */
  16525. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16526. /**
  16527. * Set a vec4 in the shader from a Color4.
  16528. * @param name Define the name of the uniform as defined in the shader
  16529. * @param value Define the value to give to the uniform
  16530. * @return the material itself allowing "fluent" like uniform updates
  16531. */
  16532. setColor4(name: string, value: Color4): ShaderMaterial;
  16533. /**
  16534. * Set a vec2 in the shader from a Vector2.
  16535. * @param name Define the name of the uniform as defined in the shader
  16536. * @param value Define the value to give to the uniform
  16537. * @return the material itself allowing "fluent" like uniform updates
  16538. */
  16539. setVector2(name: string, value: Vector2): ShaderMaterial;
  16540. /**
  16541. * Set a vec3 in the shader from a Vector3.
  16542. * @param name Define the name of the uniform as defined in the shader
  16543. * @param value Define the value to give to the uniform
  16544. * @return the material itself allowing "fluent" like uniform updates
  16545. */
  16546. setVector3(name: string, value: Vector3): ShaderMaterial;
  16547. /**
  16548. * Set a vec4 in the shader from a Vector4.
  16549. * @param name Define the name of the uniform as defined in the shader
  16550. * @param value Define the value to give to the uniform
  16551. * @return the material itself allowing "fluent" like uniform updates
  16552. */
  16553. setVector4(name: string, value: Vector4): ShaderMaterial;
  16554. /**
  16555. * Set a mat4 in the shader from a Matrix.
  16556. * @param name Define the name of the uniform as defined in the shader
  16557. * @param value Define the value to give to the uniform
  16558. * @return the material itself allowing "fluent" like uniform updates
  16559. */
  16560. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16561. /**
  16562. * Set a mat3 in the shader from a Float32Array.
  16563. * @param name Define the name of the uniform as defined in the shader
  16564. * @param value Define the value to give to the uniform
  16565. * @return the material itself allowing "fluent" like uniform updates
  16566. */
  16567. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16568. /**
  16569. * Set a mat2 in the shader from a Float32Array.
  16570. * @param name Define the name of the uniform as defined in the shader
  16571. * @param value Define the value to give to the uniform
  16572. * @return the material itself allowing "fluent" like uniform updates
  16573. */
  16574. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16575. /**
  16576. * Set a vec2 array in the shader from a number array.
  16577. * @param name Define the name of the uniform as defined in the shader
  16578. * @param value Define the value to give to the uniform
  16579. * @return the material itself allowing "fluent" like uniform updates
  16580. */
  16581. setArray2(name: string, value: number[]): ShaderMaterial;
  16582. /**
  16583. * Set a vec3 array in the shader from a number array.
  16584. * @param name Define the name of the uniform as defined in the shader
  16585. * @param value Define the value to give to the uniform
  16586. * @return the material itself allowing "fluent" like uniform updates
  16587. */
  16588. setArray3(name: string, value: number[]): ShaderMaterial;
  16589. private _checkCache;
  16590. /**
  16591. * Specifies that the submesh is ready to be used
  16592. * @param mesh defines the mesh to check
  16593. * @param subMesh defines which submesh to check
  16594. * @param useInstances specifies that instances should be used
  16595. * @returns a boolean indicating that the submesh is ready or not
  16596. */
  16597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16598. /**
  16599. * Checks if the material is ready to render the requested mesh
  16600. * @param mesh Define the mesh to render
  16601. * @param useInstances Define whether or not the material is used with instances
  16602. * @returns true if ready, otherwise false
  16603. */
  16604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16605. /**
  16606. * Binds the world matrix to the material
  16607. * @param world defines the world transformation matrix
  16608. */
  16609. bindOnlyWorldMatrix(world: Matrix): void;
  16610. /**
  16611. * Binds the material to the mesh
  16612. * @param world defines the world transformation matrix
  16613. * @param mesh defines the mesh to bind the material to
  16614. */
  16615. bind(world: Matrix, mesh?: Mesh): void;
  16616. /**
  16617. * Gets the active textures from the material
  16618. * @returns an array of textures
  16619. */
  16620. getActiveTextures(): BaseTexture[];
  16621. /**
  16622. * Specifies if the material uses a texture
  16623. * @param texture defines the texture to check against the material
  16624. * @returns a boolean specifying if the material uses the texture
  16625. */
  16626. hasTexture(texture: BaseTexture): boolean;
  16627. /**
  16628. * Makes a duplicate of the material, and gives it a new name
  16629. * @param name defines the new name for the duplicated material
  16630. * @returns the cloned material
  16631. */
  16632. clone(name: string): ShaderMaterial;
  16633. /**
  16634. * Disposes the material
  16635. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16636. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16637. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16638. */
  16639. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16640. /**
  16641. * Serializes this material in a JSON representation
  16642. * @returns the serialized material object
  16643. */
  16644. serialize(): any;
  16645. /**
  16646. * Creates a shader material from parsed shader material data
  16647. * @param source defines the JSON represnetation of the material
  16648. * @param scene defines the hosting scene
  16649. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16650. * @returns a new material
  16651. */
  16652. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16653. }
  16654. }
  16655. declare module BABYLON {
  16656. /** @hidden */
  16657. export var colorPixelShader: {
  16658. name: string;
  16659. shader: string;
  16660. };
  16661. }
  16662. declare module BABYLON {
  16663. /** @hidden */
  16664. export var colorVertexShader: {
  16665. name: string;
  16666. shader: string;
  16667. };
  16668. }
  16669. declare module BABYLON {
  16670. /**
  16671. * Line mesh
  16672. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16673. */
  16674. export class LinesMesh extends Mesh {
  16675. /**
  16676. * If vertex color should be applied to the mesh
  16677. */
  16678. useVertexColor?: boolean | undefined;
  16679. /**
  16680. * If vertex alpha should be applied to the mesh
  16681. */
  16682. useVertexAlpha?: boolean | undefined;
  16683. /**
  16684. * Color of the line (Default: White)
  16685. */
  16686. color: Color3;
  16687. /**
  16688. * Alpha of the line (Default: 1)
  16689. */
  16690. alpha: number;
  16691. /**
  16692. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16693. * This margin is expressed in world space coordinates, so its value may vary.
  16694. * Default value is 0.1
  16695. */
  16696. intersectionThreshold: number;
  16697. private _colorShader;
  16698. /**
  16699. * Creates a new LinesMesh
  16700. * @param name defines the name
  16701. * @param scene defines the hosting scene
  16702. * @param parent defines the parent mesh if any
  16703. * @param source defines the optional source LinesMesh used to clone data from
  16704. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16705. * When false, achieved by calling a clone(), also passing False.
  16706. * This will make creation of children, recursive.
  16707. * @param useVertexColor defines if this LinesMesh supports vertex color
  16708. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16709. */
  16710. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16711. /**
  16712. * If vertex color should be applied to the mesh
  16713. */
  16714. useVertexColor?: boolean | undefined,
  16715. /**
  16716. * If vertex alpha should be applied to the mesh
  16717. */
  16718. useVertexAlpha?: boolean | undefined);
  16719. private _addClipPlaneDefine;
  16720. private _removeClipPlaneDefine;
  16721. isReady(): boolean;
  16722. /**
  16723. * Returns the string "LineMesh"
  16724. */
  16725. getClassName(): string;
  16726. /**
  16727. * @hidden
  16728. */
  16729. /**
  16730. * @hidden
  16731. */
  16732. material: Material;
  16733. /**
  16734. * @hidden
  16735. */
  16736. readonly checkCollisions: boolean;
  16737. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16738. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16739. /**
  16740. * Disposes of the line mesh
  16741. * @param doNotRecurse If children should be disposed
  16742. */
  16743. dispose(doNotRecurse?: boolean): void;
  16744. /**
  16745. * Returns a new LineMesh object cloned from the current one.
  16746. */
  16747. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16748. /**
  16749. * Creates a new InstancedLinesMesh object from the mesh model.
  16750. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16751. * @param name defines the name of the new instance
  16752. * @returns a new InstancedLinesMesh
  16753. */
  16754. createInstance(name: string): InstancedLinesMesh;
  16755. }
  16756. /**
  16757. * Creates an instance based on a source LinesMesh
  16758. */
  16759. export class InstancedLinesMesh extends InstancedMesh {
  16760. /**
  16761. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16762. * This margin is expressed in world space coordinates, so its value may vary.
  16763. * Initilized with the intersectionThreshold value of the source LinesMesh
  16764. */
  16765. intersectionThreshold: number;
  16766. constructor(name: string, source: LinesMesh);
  16767. /**
  16768. * Returns the string "InstancedLinesMesh".
  16769. */
  16770. getClassName(): string;
  16771. }
  16772. }
  16773. declare module BABYLON {
  16774. /** @hidden */
  16775. export var linePixelShader: {
  16776. name: string;
  16777. shader: string;
  16778. };
  16779. }
  16780. declare module BABYLON {
  16781. /** @hidden */
  16782. export var lineVertexShader: {
  16783. name: string;
  16784. shader: string;
  16785. };
  16786. }
  16787. declare module BABYLON {
  16788. interface AbstractMesh {
  16789. /**
  16790. * Disables the mesh edge rendering mode
  16791. * @returns the currentAbstractMesh
  16792. */
  16793. disableEdgesRendering(): AbstractMesh;
  16794. /**
  16795. * Enables the edge rendering mode on the mesh.
  16796. * This mode makes the mesh edges visible
  16797. * @param epsilon defines the maximal distance between two angles to detect a face
  16798. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16799. * @returns the currentAbstractMesh
  16800. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16801. */
  16802. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16803. /**
  16804. * Gets the edgesRenderer associated with the mesh
  16805. */
  16806. edgesRenderer: Nullable<EdgesRenderer>;
  16807. }
  16808. interface LinesMesh {
  16809. /**
  16810. * Enables the edge rendering mode on the mesh.
  16811. * This mode makes the mesh edges visible
  16812. * @param epsilon defines the maximal distance between two angles to detect a face
  16813. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16814. * @returns the currentAbstractMesh
  16815. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16816. */
  16817. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16818. }
  16819. interface InstancedLinesMesh {
  16820. /**
  16821. * Enables the edge rendering mode on the mesh.
  16822. * This mode makes the mesh edges visible
  16823. * @param epsilon defines the maximal distance between two angles to detect a face
  16824. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16825. * @returns the current InstancedLinesMesh
  16826. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16827. */
  16828. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16829. }
  16830. /**
  16831. * Defines the minimum contract an Edges renderer should follow.
  16832. */
  16833. export interface IEdgesRenderer extends IDisposable {
  16834. /**
  16835. * Gets or sets a boolean indicating if the edgesRenderer is active
  16836. */
  16837. isEnabled: boolean;
  16838. /**
  16839. * Renders the edges of the attached mesh,
  16840. */
  16841. render(): void;
  16842. /**
  16843. * Checks wether or not the edges renderer is ready to render.
  16844. * @return true if ready, otherwise false.
  16845. */
  16846. isReady(): boolean;
  16847. }
  16848. /**
  16849. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16850. */
  16851. export class EdgesRenderer implements IEdgesRenderer {
  16852. /**
  16853. * Define the size of the edges with an orthographic camera
  16854. */
  16855. edgesWidthScalerForOrthographic: number;
  16856. /**
  16857. * Define the size of the edges with a perspective camera
  16858. */
  16859. edgesWidthScalerForPerspective: number;
  16860. protected _source: AbstractMesh;
  16861. protected _linesPositions: number[];
  16862. protected _linesNormals: number[];
  16863. protected _linesIndices: number[];
  16864. protected _epsilon: number;
  16865. protected _indicesCount: number;
  16866. protected _lineShader: ShaderMaterial;
  16867. protected _ib: WebGLBuffer;
  16868. protected _buffers: {
  16869. [key: string]: Nullable<VertexBuffer>;
  16870. };
  16871. protected _checkVerticesInsteadOfIndices: boolean;
  16872. private _meshRebuildObserver;
  16873. private _meshDisposeObserver;
  16874. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16875. isEnabled: boolean;
  16876. /**
  16877. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16878. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16879. * @param source Mesh used to create edges
  16880. * @param epsilon sum of angles in adjacency to check for edge
  16881. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16882. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16883. */
  16884. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16885. protected _prepareRessources(): void;
  16886. /** @hidden */ rebuild(): void;
  16887. /**
  16888. * Releases the required resources for the edges renderer
  16889. */
  16890. dispose(): void;
  16891. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16892. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16893. /**
  16894. * Checks if the pair of p0 and p1 is en edge
  16895. * @param faceIndex
  16896. * @param edge
  16897. * @param faceNormals
  16898. * @param p0
  16899. * @param p1
  16900. * @private
  16901. */
  16902. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16903. /**
  16904. * push line into the position, normal and index buffer
  16905. * @protected
  16906. */
  16907. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16908. /**
  16909. * Generates lines edges from adjacencjes
  16910. * @private
  16911. */ generateEdgesLines(): void;
  16912. /**
  16913. * Checks wether or not the edges renderer is ready to render.
  16914. * @return true if ready, otherwise false.
  16915. */
  16916. isReady(): boolean;
  16917. /**
  16918. * Renders the edges of the attached mesh,
  16919. */
  16920. render(): void;
  16921. }
  16922. /**
  16923. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16924. */
  16925. export class LineEdgesRenderer extends EdgesRenderer {
  16926. /**
  16927. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16928. * @param source LineMesh used to generate edges
  16929. * @param epsilon not important (specified angle for edge detection)
  16930. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16931. */
  16932. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16933. /**
  16934. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16935. */ generateEdgesLines(): void;
  16936. }
  16937. }
  16938. declare module BABYLON {
  16939. /**
  16940. * This represents the object necessary to create a rendering group.
  16941. * This is exclusively used and created by the rendering manager.
  16942. * To modify the behavior, you use the available helpers in your scene or meshes.
  16943. * @hidden
  16944. */
  16945. export class RenderingGroup {
  16946. index: number;
  16947. private _scene;
  16948. private _opaqueSubMeshes;
  16949. private _transparentSubMeshes;
  16950. private _alphaTestSubMeshes;
  16951. private _depthOnlySubMeshes;
  16952. private _particleSystems;
  16953. private _spriteManagers;
  16954. private _opaqueSortCompareFn;
  16955. private _alphaTestSortCompareFn;
  16956. private _transparentSortCompareFn;
  16957. private _renderOpaque;
  16958. private _renderAlphaTest;
  16959. private _renderTransparent;
  16960. private _edgesRenderers;
  16961. onBeforeTransparentRendering: () => void;
  16962. /**
  16963. * Set the opaque sort comparison function.
  16964. * If null the sub meshes will be render in the order they were created
  16965. */
  16966. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16967. /**
  16968. * Set the alpha test sort comparison function.
  16969. * If null the sub meshes will be render in the order they were created
  16970. */
  16971. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16972. /**
  16973. * Set the transparent sort comparison function.
  16974. * If null the sub meshes will be render in the order they were created
  16975. */
  16976. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16977. /**
  16978. * Creates a new rendering group.
  16979. * @param index The rendering group index
  16980. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16981. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16982. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16983. */
  16984. 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>);
  16985. /**
  16986. * Render all the sub meshes contained in the group.
  16987. * @param customRenderFunction Used to override the default render behaviour of the group.
  16988. * @returns true if rendered some submeshes.
  16989. */
  16990. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16991. /**
  16992. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16993. * @param subMeshes The submeshes to render
  16994. */
  16995. private renderOpaqueSorted;
  16996. /**
  16997. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16998. * @param subMeshes The submeshes to render
  16999. */
  17000. private renderAlphaTestSorted;
  17001. /**
  17002. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17003. * @param subMeshes The submeshes to render
  17004. */
  17005. private renderTransparentSorted;
  17006. /**
  17007. * Renders the submeshes in a specified order.
  17008. * @param subMeshes The submeshes to sort before render
  17009. * @param sortCompareFn The comparison function use to sort
  17010. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17011. * @param transparent Specifies to activate blending if true
  17012. */
  17013. private static renderSorted;
  17014. /**
  17015. * Renders the submeshes in the order they were dispatched (no sort applied).
  17016. * @param subMeshes The submeshes to render
  17017. */
  17018. private static renderUnsorted;
  17019. /**
  17020. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17021. * are rendered back to front if in the same alpha index.
  17022. *
  17023. * @param a The first submesh
  17024. * @param b The second submesh
  17025. * @returns The result of the comparison
  17026. */
  17027. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17028. /**
  17029. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17030. * are rendered back to front.
  17031. *
  17032. * @param a The first submesh
  17033. * @param b The second submesh
  17034. * @returns The result of the comparison
  17035. */
  17036. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17037. /**
  17038. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17039. * are rendered front to back (prevent overdraw).
  17040. *
  17041. * @param a The first submesh
  17042. * @param b The second submesh
  17043. * @returns The result of the comparison
  17044. */
  17045. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17046. /**
  17047. * Resets the different lists of submeshes to prepare a new frame.
  17048. */
  17049. prepare(): void;
  17050. dispose(): void;
  17051. /**
  17052. * Inserts the submesh in its correct queue depending on its material.
  17053. * @param subMesh The submesh to dispatch
  17054. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17055. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17056. */
  17057. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17058. dispatchSprites(spriteManager: ISpriteManager): void;
  17059. dispatchParticles(particleSystem: IParticleSystem): void;
  17060. private _renderParticles;
  17061. private _renderSprites;
  17062. }
  17063. }
  17064. declare module BABYLON {
  17065. /**
  17066. * Interface describing the different options available in the rendering manager
  17067. * regarding Auto Clear between groups.
  17068. */
  17069. export interface IRenderingManagerAutoClearSetup {
  17070. /**
  17071. * Defines whether or not autoclear is enable.
  17072. */
  17073. autoClear: boolean;
  17074. /**
  17075. * Defines whether or not to autoclear the depth buffer.
  17076. */
  17077. depth: boolean;
  17078. /**
  17079. * Defines whether or not to autoclear the stencil buffer.
  17080. */
  17081. stencil: boolean;
  17082. }
  17083. /**
  17084. * This class is used by the onRenderingGroupObservable
  17085. */
  17086. export class RenderingGroupInfo {
  17087. /**
  17088. * The Scene that being rendered
  17089. */
  17090. scene: Scene;
  17091. /**
  17092. * The camera currently used for the rendering pass
  17093. */
  17094. camera: Nullable<Camera>;
  17095. /**
  17096. * The ID of the renderingGroup being processed
  17097. */
  17098. renderingGroupId: number;
  17099. }
  17100. /**
  17101. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17102. * It is enable to manage the different groups as well as the different necessary sort functions.
  17103. * This should not be used directly aside of the few static configurations
  17104. */
  17105. export class RenderingManager {
  17106. /**
  17107. * The max id used for rendering groups (not included)
  17108. */
  17109. static MAX_RENDERINGGROUPS: number;
  17110. /**
  17111. * The min id used for rendering groups (included)
  17112. */
  17113. static MIN_RENDERINGGROUPS: number;
  17114. /**
  17115. * Used to globally prevent autoclearing scenes.
  17116. */
  17117. static AUTOCLEAR: boolean;
  17118. /**
  17119. * @hidden
  17120. */ useSceneAutoClearSetup: boolean;
  17121. private _scene;
  17122. private _renderingGroups;
  17123. private _depthStencilBufferAlreadyCleaned;
  17124. private _autoClearDepthStencil;
  17125. private _customOpaqueSortCompareFn;
  17126. private _customAlphaTestSortCompareFn;
  17127. private _customTransparentSortCompareFn;
  17128. private _renderingGroupInfo;
  17129. /**
  17130. * Instantiates a new rendering group for a particular scene
  17131. * @param scene Defines the scene the groups belongs to
  17132. */
  17133. constructor(scene: Scene);
  17134. private _clearDepthStencilBuffer;
  17135. /**
  17136. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17137. * @hidden
  17138. */
  17139. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17140. /**
  17141. * Resets the different information of the group to prepare a new frame
  17142. * @hidden
  17143. */
  17144. reset(): void;
  17145. /**
  17146. * Dispose and release the group and its associated resources.
  17147. * @hidden
  17148. */
  17149. dispose(): void;
  17150. /**
  17151. * Clear the info related to rendering groups preventing retention points during dispose.
  17152. */
  17153. freeRenderingGroups(): void;
  17154. private _prepareRenderingGroup;
  17155. /**
  17156. * Add a sprite manager to the rendering manager in order to render it this frame.
  17157. * @param spriteManager Define the sprite manager to render
  17158. */
  17159. dispatchSprites(spriteManager: ISpriteManager): void;
  17160. /**
  17161. * Add a particle system to the rendering manager in order to render it this frame.
  17162. * @param particleSystem Define the particle system to render
  17163. */
  17164. dispatchParticles(particleSystem: IParticleSystem): void;
  17165. /**
  17166. * Add a submesh to the manager in order to render it this frame
  17167. * @param subMesh The submesh to dispatch
  17168. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17169. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17170. */
  17171. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17172. /**
  17173. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17174. * This allowed control for front to back rendering or reversly depending of the special needs.
  17175. *
  17176. * @param renderingGroupId The rendering group id corresponding to its index
  17177. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17178. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17179. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17180. */
  17181. 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;
  17182. /**
  17183. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17184. *
  17185. * @param renderingGroupId The rendering group id corresponding to its index
  17186. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17187. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17188. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17189. */
  17190. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17191. /**
  17192. * Gets the current auto clear configuration for one rendering group of the rendering
  17193. * manager.
  17194. * @param index the rendering group index to get the information for
  17195. * @returns The auto clear setup for the requested rendering group
  17196. */
  17197. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17198. }
  17199. }
  17200. declare module BABYLON {
  17201. /**
  17202. * This Helps creating a texture that will be created from a camera in your scene.
  17203. * It is basically a dynamic texture that could be used to create special effects for instance.
  17204. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17205. */
  17206. export class RenderTargetTexture extends Texture {
  17207. isCube: boolean;
  17208. /**
  17209. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17210. */
  17211. static readonly REFRESHRATE_RENDER_ONCE: number;
  17212. /**
  17213. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17214. */
  17215. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17216. /**
  17217. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17218. * the central point of your effect and can save a lot of performances.
  17219. */
  17220. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17221. /**
  17222. * Use this predicate to dynamically define the list of mesh you want to render.
  17223. * If set, the renderList property will be overwritten.
  17224. */
  17225. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17226. private _renderList;
  17227. /**
  17228. * Use this list to define the list of mesh you want to render.
  17229. */
  17230. renderList: Nullable<Array<AbstractMesh>>;
  17231. private _hookArray;
  17232. /**
  17233. * Define if particles should be rendered in your texture.
  17234. */
  17235. renderParticles: boolean;
  17236. /**
  17237. * Define if sprites should be rendered in your texture.
  17238. */
  17239. renderSprites: boolean;
  17240. /**
  17241. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17242. */
  17243. coordinatesMode: number;
  17244. /**
  17245. * Define the camera used to render the texture.
  17246. */
  17247. activeCamera: Nullable<Camera>;
  17248. /**
  17249. * Override the render function of the texture with your own one.
  17250. */
  17251. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17252. /**
  17253. * Define if camera post processes should be use while rendering the texture.
  17254. */
  17255. useCameraPostProcesses: boolean;
  17256. /**
  17257. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17258. */
  17259. ignoreCameraViewport: boolean;
  17260. private _postProcessManager;
  17261. private _postProcesses;
  17262. private _resizeObserver;
  17263. /**
  17264. * An event triggered when the texture is unbind.
  17265. */
  17266. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17267. /**
  17268. * An event triggered when the texture is unbind.
  17269. */
  17270. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17271. private _onAfterUnbindObserver;
  17272. /**
  17273. * Set a after unbind callback in the texture.
  17274. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17275. */
  17276. onAfterUnbind: () => void;
  17277. /**
  17278. * An event triggered before rendering the texture
  17279. */
  17280. onBeforeRenderObservable: Observable<number>;
  17281. private _onBeforeRenderObserver;
  17282. /**
  17283. * Set a before render callback in the texture.
  17284. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17285. */
  17286. onBeforeRender: (faceIndex: number) => void;
  17287. /**
  17288. * An event triggered after rendering the texture
  17289. */
  17290. onAfterRenderObservable: Observable<number>;
  17291. private _onAfterRenderObserver;
  17292. /**
  17293. * Set a after render callback in the texture.
  17294. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17295. */
  17296. onAfterRender: (faceIndex: number) => void;
  17297. /**
  17298. * An event triggered after the texture clear
  17299. */
  17300. onClearObservable: Observable<Engine>;
  17301. private _onClearObserver;
  17302. /**
  17303. * Set a clear callback in the texture.
  17304. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17305. */
  17306. onClear: (Engine: Engine) => void;
  17307. /**
  17308. * Define the clear color of the Render Target if it should be different from the scene.
  17309. */
  17310. clearColor: Color4;
  17311. protected _size: number | {
  17312. width: number;
  17313. height: number;
  17314. };
  17315. protected _initialSizeParameter: number | {
  17316. width: number;
  17317. height: number;
  17318. } | {
  17319. ratio: number;
  17320. };
  17321. protected _sizeRatio: Nullable<number>;
  17322. /** @hidden */ generateMipMaps: boolean;
  17323. protected _renderingManager: RenderingManager;
  17324. /** @hidden */ waitingRenderList: string[];
  17325. protected _doNotChangeAspectRatio: boolean;
  17326. protected _currentRefreshId: number;
  17327. protected _refreshRate: number;
  17328. protected _textureMatrix: Matrix;
  17329. protected _samples: number;
  17330. protected _renderTargetOptions: RenderTargetCreationOptions;
  17331. /**
  17332. * Gets render target creation options that were used.
  17333. */
  17334. readonly renderTargetOptions: RenderTargetCreationOptions;
  17335. protected _engine: Engine;
  17336. protected _onRatioRescale(): void;
  17337. /**
  17338. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17339. * It must define where the camera used to render the texture is set
  17340. */
  17341. boundingBoxPosition: Vector3;
  17342. private _boundingBoxSize;
  17343. /**
  17344. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17345. * When defined, the cubemap will switch to local mode
  17346. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17347. * @example https://www.babylonjs-playground.com/#RNASML
  17348. */
  17349. boundingBoxSize: Vector3;
  17350. /**
  17351. * In case the RTT has been created with a depth texture, get the associated
  17352. * depth texture.
  17353. * Otherwise, return null.
  17354. */
  17355. depthStencilTexture: Nullable<InternalTexture>;
  17356. /**
  17357. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17358. * or used a shadow, depth texture...
  17359. * @param name The friendly name of the texture
  17360. * @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)
  17361. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17362. * @param generateMipMaps True if mip maps need to be generated after render.
  17363. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17364. * @param type The type of the buffer in the RTT (int, half float, float...)
  17365. * @param isCube True if a cube texture needs to be created
  17366. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17367. * @param generateDepthBuffer True to generate a depth buffer
  17368. * @param generateStencilBuffer True to generate a stencil buffer
  17369. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17370. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17371. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17372. */
  17373. constructor(name: string, size: number | {
  17374. width: number;
  17375. height: number;
  17376. } | {
  17377. ratio: number;
  17378. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17379. /**
  17380. * Creates a depth stencil texture.
  17381. * This is only available in WebGL 2 or with the depth texture extension available.
  17382. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17383. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17384. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17385. */
  17386. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17387. private _processSizeParameter;
  17388. /**
  17389. * Define the number of samples to use in case of MSAA.
  17390. * It defaults to one meaning no MSAA has been enabled.
  17391. */
  17392. samples: number;
  17393. /**
  17394. * Resets the refresh counter of the texture and start bak from scratch.
  17395. * Could be useful to regenerate the texture if it is setup to render only once.
  17396. */
  17397. resetRefreshCounter(): void;
  17398. /**
  17399. * Define the refresh rate of the texture or the rendering frequency.
  17400. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17401. */
  17402. refreshRate: number;
  17403. /**
  17404. * Adds a post process to the render target rendering passes.
  17405. * @param postProcess define the post process to add
  17406. */
  17407. addPostProcess(postProcess: PostProcess): void;
  17408. /**
  17409. * Clear all the post processes attached to the render target
  17410. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17411. */
  17412. clearPostProcesses(dispose?: boolean): void;
  17413. /**
  17414. * Remove one of the post process from the list of attached post processes to the texture
  17415. * @param postProcess define the post process to remove from the list
  17416. */
  17417. removePostProcess(postProcess: PostProcess): void;
  17418. /** @hidden */ shouldRender(): boolean;
  17419. /**
  17420. * Gets the actual render size of the texture.
  17421. * @returns the width of the render size
  17422. */
  17423. getRenderSize(): number;
  17424. /**
  17425. * Gets the actual render width of the texture.
  17426. * @returns the width of the render size
  17427. */
  17428. getRenderWidth(): number;
  17429. /**
  17430. * Gets the actual render height of the texture.
  17431. * @returns the height of the render size
  17432. */
  17433. getRenderHeight(): number;
  17434. /**
  17435. * Get if the texture can be rescaled or not.
  17436. */
  17437. readonly canRescale: boolean;
  17438. /**
  17439. * Resize the texture using a ratio.
  17440. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17441. */
  17442. scale(ratio: number): void;
  17443. /**
  17444. * Get the texture reflection matrix used to rotate/transform the reflection.
  17445. * @returns the reflection matrix
  17446. */
  17447. getReflectionTextureMatrix(): Matrix;
  17448. /**
  17449. * Resize the texture to a new desired size.
  17450. * Be carrefull as it will recreate all the data in the new texture.
  17451. * @param size Define the new size. It can be:
  17452. * - a number for squared texture,
  17453. * - an object containing { width: number, height: number }
  17454. * - or an object containing a ratio { ratio: number }
  17455. */
  17456. resize(size: number | {
  17457. width: number;
  17458. height: number;
  17459. } | {
  17460. ratio: number;
  17461. }): void;
  17462. /**
  17463. * Renders all the objects from the render list into the texture.
  17464. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17465. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17466. */
  17467. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17468. private _bestReflectionRenderTargetDimension;
  17469. /**
  17470. * @hidden
  17471. * @param faceIndex face index to bind to if this is a cubetexture
  17472. */ bindFrameBuffer(faceIndex?: number): void;
  17473. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17474. private renderToTarget;
  17475. /**
  17476. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17477. * This allowed control for front to back rendering or reversly depending of the special needs.
  17478. *
  17479. * @param renderingGroupId The rendering group id corresponding to its index
  17480. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17481. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17482. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17483. */
  17484. 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;
  17485. /**
  17486. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17487. *
  17488. * @param renderingGroupId The rendering group id corresponding to its index
  17489. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17490. */
  17491. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17492. /**
  17493. * Clones the texture.
  17494. * @returns the cloned texture
  17495. */
  17496. clone(): RenderTargetTexture;
  17497. /**
  17498. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17499. * @returns The JSON representation of the texture
  17500. */
  17501. serialize(): any;
  17502. /**
  17503. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17504. */
  17505. disposeFramebufferObjects(): void;
  17506. /**
  17507. * Dispose the texture and release its associated resources.
  17508. */
  17509. dispose(): void;
  17510. /** @hidden */ rebuild(): void;
  17511. /**
  17512. * Clear the info related to rendering groups preventing retention point in material dispose.
  17513. */
  17514. freeRenderingGroups(): void;
  17515. /**
  17516. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17517. * @returns the view count
  17518. */
  17519. getViewCount(): number;
  17520. }
  17521. }
  17522. declare module BABYLON {
  17523. /**
  17524. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17525. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17526. * You can then easily use it as a reflectionTexture on a flat surface.
  17527. * In case the surface is not a plane, please consider relying on reflection probes.
  17528. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17529. */
  17530. export class MirrorTexture extends RenderTargetTexture {
  17531. private scene;
  17532. /**
  17533. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17534. * 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.
  17535. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17536. */
  17537. mirrorPlane: Plane;
  17538. /**
  17539. * Define the blur ratio used to blur the reflection if needed.
  17540. */
  17541. blurRatio: number;
  17542. /**
  17543. * Define the adaptive blur kernel used to blur the reflection if needed.
  17544. * This will autocompute the closest best match for the `blurKernel`
  17545. */
  17546. adaptiveBlurKernel: number;
  17547. /**
  17548. * Define the blur kernel used to blur the reflection if needed.
  17549. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17550. */
  17551. blurKernel: number;
  17552. /**
  17553. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17554. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17555. */
  17556. blurKernelX: number;
  17557. /**
  17558. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17559. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17560. */
  17561. blurKernelY: number;
  17562. private _autoComputeBlurKernel;
  17563. protected _onRatioRescale(): void;
  17564. private _updateGammaSpace;
  17565. private _imageProcessingConfigChangeObserver;
  17566. private _transformMatrix;
  17567. private _mirrorMatrix;
  17568. private _savedViewMatrix;
  17569. private _blurX;
  17570. private _blurY;
  17571. private _adaptiveBlurKernel;
  17572. private _blurKernelX;
  17573. private _blurKernelY;
  17574. private _blurRatio;
  17575. /**
  17576. * Instantiates a Mirror Texture.
  17577. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17578. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17579. * You can then easily use it as a reflectionTexture on a flat surface.
  17580. * In case the surface is not a plane, please consider relying on reflection probes.
  17581. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17582. * @param name
  17583. * @param size
  17584. * @param scene
  17585. * @param generateMipMaps
  17586. * @param type
  17587. * @param samplingMode
  17588. * @param generateDepthBuffer
  17589. */
  17590. constructor(name: string, size: number | {
  17591. width: number;
  17592. height: number;
  17593. } | {
  17594. ratio: number;
  17595. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17596. private _preparePostProcesses;
  17597. /**
  17598. * Clone the mirror texture.
  17599. * @returns the cloned texture
  17600. */
  17601. clone(): MirrorTexture;
  17602. /**
  17603. * Serialize the texture to a JSON representation you could use in Parse later on
  17604. * @returns the serialized JSON representation
  17605. */
  17606. serialize(): any;
  17607. /**
  17608. * Dispose the texture and release its associated resources.
  17609. */
  17610. dispose(): void;
  17611. }
  17612. }
  17613. declare module BABYLON {
  17614. /**
  17615. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17616. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17617. */
  17618. export class Texture extends BaseTexture {
  17619. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17620. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17621. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17622. /** nearest is mag = nearest and min = nearest and mip = linear */
  17623. static readonly NEAREST_SAMPLINGMODE: number;
  17624. /** nearest is mag = nearest and min = nearest and mip = linear */
  17625. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17626. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17627. static readonly BILINEAR_SAMPLINGMODE: number;
  17628. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17629. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17630. /** Trilinear is mag = linear and min = linear and mip = linear */
  17631. static readonly TRILINEAR_SAMPLINGMODE: number;
  17632. /** Trilinear is mag = linear and min = linear and mip = linear */
  17633. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17634. /** mag = nearest and min = nearest and mip = nearest */
  17635. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17636. /** mag = nearest and min = linear and mip = nearest */
  17637. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17638. /** mag = nearest and min = linear and mip = linear */
  17639. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17640. /** mag = nearest and min = linear and mip = none */
  17641. static readonly NEAREST_LINEAR: number;
  17642. /** mag = nearest and min = nearest and mip = none */
  17643. static readonly NEAREST_NEAREST: number;
  17644. /** mag = linear and min = nearest and mip = nearest */
  17645. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17646. /** mag = linear and min = nearest and mip = linear */
  17647. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17648. /** mag = linear and min = linear and mip = none */
  17649. static readonly LINEAR_LINEAR: number;
  17650. /** mag = linear and min = nearest and mip = none */
  17651. static readonly LINEAR_NEAREST: number;
  17652. /** Explicit coordinates mode */
  17653. static readonly EXPLICIT_MODE: number;
  17654. /** Spherical coordinates mode */
  17655. static readonly SPHERICAL_MODE: number;
  17656. /** Planar coordinates mode */
  17657. static readonly PLANAR_MODE: number;
  17658. /** Cubic coordinates mode */
  17659. static readonly CUBIC_MODE: number;
  17660. /** Projection coordinates mode */
  17661. static readonly PROJECTION_MODE: number;
  17662. /** Inverse Cubic coordinates mode */
  17663. static readonly SKYBOX_MODE: number;
  17664. /** Inverse Cubic coordinates mode */
  17665. static readonly INVCUBIC_MODE: number;
  17666. /** Equirectangular coordinates mode */
  17667. static readonly EQUIRECTANGULAR_MODE: number;
  17668. /** Equirectangular Fixed coordinates mode */
  17669. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17670. /** Equirectangular Fixed Mirrored coordinates mode */
  17671. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17672. /** Texture is not repeating outside of 0..1 UVs */
  17673. static readonly CLAMP_ADDRESSMODE: number;
  17674. /** Texture is repeating outside of 0..1 UVs */
  17675. static readonly WRAP_ADDRESSMODE: number;
  17676. /** Texture is repeating and mirrored */
  17677. static readonly MIRROR_ADDRESSMODE: number;
  17678. /**
  17679. * 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
  17680. */
  17681. static UseSerializedUrlIfAny: boolean;
  17682. /**
  17683. * Define the url of the texture.
  17684. */
  17685. url: Nullable<string>;
  17686. /**
  17687. * Define an offset on the texture to offset the u coordinates of the UVs
  17688. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17689. */
  17690. uOffset: number;
  17691. /**
  17692. * Define an offset on the texture to offset the v coordinates of the UVs
  17693. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17694. */
  17695. vOffset: number;
  17696. /**
  17697. * Define an offset on the texture to scale the u coordinates of the UVs
  17698. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17699. */
  17700. uScale: number;
  17701. /**
  17702. * Define an offset on the texture to scale the v coordinates of the UVs
  17703. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17704. */
  17705. vScale: number;
  17706. /**
  17707. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17708. * @see http://doc.babylonjs.com/how_to/more_materials
  17709. */
  17710. uAng: number;
  17711. /**
  17712. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17713. * @see http://doc.babylonjs.com/how_to/more_materials
  17714. */
  17715. vAng: number;
  17716. /**
  17717. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17718. * @see http://doc.babylonjs.com/how_to/more_materials
  17719. */
  17720. wAng: number;
  17721. /**
  17722. * Defines the center of rotation (U)
  17723. */
  17724. uRotationCenter: number;
  17725. /**
  17726. * Defines the center of rotation (V)
  17727. */
  17728. vRotationCenter: number;
  17729. /**
  17730. * Defines the center of rotation (W)
  17731. */
  17732. wRotationCenter: number;
  17733. /**
  17734. * Are mip maps generated for this texture or not.
  17735. */
  17736. readonly noMipmap: boolean;
  17737. /**
  17738. * List of inspectable custom properties (used by the Inspector)
  17739. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17740. */
  17741. inspectableCustomProperties: IInspectable[];
  17742. private _noMipmap;
  17743. /** @hidden */ invertY: boolean;
  17744. private _rowGenerationMatrix;
  17745. private _cachedTextureMatrix;
  17746. private _projectionModeMatrix;
  17747. private _t0;
  17748. private _t1;
  17749. private _t2;
  17750. private _cachedUOffset;
  17751. private _cachedVOffset;
  17752. private _cachedUScale;
  17753. private _cachedVScale;
  17754. private _cachedUAng;
  17755. private _cachedVAng;
  17756. private _cachedWAng;
  17757. private _cachedProjectionMatrixId;
  17758. private _cachedCoordinatesMode;
  17759. /** @hidden */
  17760. protected _initialSamplingMode: number;
  17761. /** @hidden */ buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17762. private _deleteBuffer;
  17763. protected _format: Nullable<number>;
  17764. private _delayedOnLoad;
  17765. private _delayedOnError;
  17766. /**
  17767. * Observable triggered once the texture has been loaded.
  17768. */
  17769. onLoadObservable: Observable<Texture>;
  17770. protected _isBlocking: boolean;
  17771. /**
  17772. * Is the texture preventing material to render while loading.
  17773. * If false, a default texture will be used instead of the loading one during the preparation step.
  17774. */
  17775. isBlocking: boolean;
  17776. /**
  17777. * Get the current sampling mode associated with the texture.
  17778. */
  17779. readonly samplingMode: number;
  17780. /**
  17781. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17782. */
  17783. readonly invertY: boolean;
  17784. /**
  17785. * Instantiates a new texture.
  17786. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17787. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17788. * @param url define the url of the picture to load as a texture
  17789. * @param scene define the scene the texture will belong to
  17790. * @param noMipmap define if the texture will require mip maps or not
  17791. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17792. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17793. * @param onLoad define a callback triggered when the texture has been loaded
  17794. * @param onError define a callback triggered when an error occurred during the loading session
  17795. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17796. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17797. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17798. */
  17799. 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);
  17800. /**
  17801. * Update the url (and optional buffer) of this texture if url was null during construction.
  17802. * @param url the url of the texture
  17803. * @param buffer the buffer of the texture (defaults to null)
  17804. * @param onLoad callback called when the texture is loaded (defaults to null)
  17805. */
  17806. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17807. /**
  17808. * Finish the loading sequence of a texture flagged as delayed load.
  17809. * @hidden
  17810. */
  17811. delayLoad(): void;
  17812. private _prepareRowForTextureGeneration;
  17813. /**
  17814. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17815. * @returns the transform matrix of the texture.
  17816. */
  17817. getTextureMatrix(): Matrix;
  17818. /**
  17819. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17820. * @returns The reflection texture transform
  17821. */
  17822. getReflectionTextureMatrix(): Matrix;
  17823. /**
  17824. * Clones the texture.
  17825. * @returns the cloned texture
  17826. */
  17827. clone(): Texture;
  17828. /**
  17829. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17830. * @returns The JSON representation of the texture
  17831. */
  17832. serialize(): any;
  17833. /**
  17834. * Get the current class name of the texture useful for serialization or dynamic coding.
  17835. * @returns "Texture"
  17836. */
  17837. getClassName(): string;
  17838. /**
  17839. * Dispose the texture and release its associated resources.
  17840. */
  17841. dispose(): void;
  17842. /**
  17843. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17844. * @param parsedTexture Define the JSON representation of the texture
  17845. * @param scene Define the scene the parsed texture should be instantiated in
  17846. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17847. * @returns The parsed texture if successful
  17848. */
  17849. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17850. /**
  17851. * Creates a texture from its base 64 representation.
  17852. * @param data Define the base64 payload without the data: prefix
  17853. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17854. * @param scene Define the scene the texture should belong to
  17855. * @param noMipmap Forces the texture to not create mip map information if true
  17856. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17857. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17858. * @param onLoad define a callback triggered when the texture has been loaded
  17859. * @param onError define a callback triggered when an error occurred during the loading session
  17860. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17861. * @returns the created texture
  17862. */
  17863. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17864. /**
  17865. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17866. * @param data Define the base64 payload without the data: prefix
  17867. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17868. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17869. * @param scene Define the scene the texture should belong to
  17870. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17871. * @param noMipmap Forces the texture to not create mip map information if true
  17872. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17873. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17874. * @param onLoad define a callback triggered when the texture has been loaded
  17875. * @param onError define a callback triggered when an error occurred during the loading session
  17876. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17877. * @returns the created texture
  17878. */
  17879. 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;
  17880. }
  17881. }
  17882. declare module BABYLON {
  17883. /**
  17884. * Raw texture can help creating a texture directly from an array of data.
  17885. * This can be super useful if you either get the data from an uncompressed source or
  17886. * if you wish to create your texture pixel by pixel.
  17887. */
  17888. export class RawTexture extends Texture {
  17889. /**
  17890. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17891. */
  17892. format: number;
  17893. private _engine;
  17894. /**
  17895. * Instantiates a new RawTexture.
  17896. * Raw texture can help creating a texture directly from an array of data.
  17897. * This can be super useful if you either get the data from an uncompressed source or
  17898. * if you wish to create your texture pixel by pixel.
  17899. * @param data define the array of data to use to create the texture
  17900. * @param width define the width of the texture
  17901. * @param height define the height of the texture
  17902. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17903. * @param scene define the scene the texture belongs to
  17904. * @param generateMipMaps define whether mip maps should be generated or not
  17905. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17906. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17907. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17908. */
  17909. constructor(data: ArrayBufferView, width: number, height: number,
  17910. /**
  17911. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  17912. */
  17913. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  17914. /**
  17915. * Updates the texture underlying data.
  17916. * @param data Define the new data of the texture
  17917. */
  17918. update(data: ArrayBufferView): void;
  17919. /**
  17920. * Creates a luminance texture from some data.
  17921. * @param data Define the texture data
  17922. * @param width Define the width of the texture
  17923. * @param height Define the height of the texture
  17924. * @param scene Define the scene the texture belongs to
  17925. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17926. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17927. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17928. * @returns the luminance texture
  17929. */
  17930. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17931. /**
  17932. * Creates a luminance alpha texture from some data.
  17933. * @param data Define the texture data
  17934. * @param width Define the width of the texture
  17935. * @param height Define the height of the texture
  17936. * @param scene Define the scene the texture belongs to
  17937. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17938. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17939. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17940. * @returns the luminance alpha texture
  17941. */
  17942. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17943. /**
  17944. * Creates an alpha texture from some data.
  17945. * @param data Define the texture data
  17946. * @param width Define the width of the texture
  17947. * @param height Define the height of the texture
  17948. * @param scene Define the scene the texture belongs to
  17949. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17950. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17951. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17952. * @returns the alpha texture
  17953. */
  17954. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  17955. /**
  17956. * Creates a RGB texture from some data.
  17957. * @param data Define the texture data
  17958. * @param width Define the width of the texture
  17959. * @param height Define the height of the texture
  17960. * @param scene Define the scene the texture belongs to
  17961. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17962. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17963. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17964. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17965. * @returns the RGB alpha texture
  17966. */
  17967. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17968. /**
  17969. * Creates a RGBA texture from some data.
  17970. * @param data Define the texture data
  17971. * @param width Define the width of the texture
  17972. * @param height Define the height of the texture
  17973. * @param scene Define the scene the texture belongs to
  17974. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17975. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17976. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17977. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17978. * @returns the RGBA texture
  17979. */
  17980. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17981. /**
  17982. * Creates a R texture from some data.
  17983. * @param data Define the texture data
  17984. * @param width Define the width of the texture
  17985. * @param height Define the height of the texture
  17986. * @param scene Define the scene the texture belongs to
  17987. * @param generateMipMaps Define whether or not to create mip maps for the texture
  17988. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  17989. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  17990. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  17991. * @returns the R texture
  17992. */
  17993. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  17994. }
  17995. }
  17996. declare module BABYLON {
  17997. /**
  17998. * Defines a runtime animation
  17999. */
  18000. export class RuntimeAnimation {
  18001. private _events;
  18002. /**
  18003. * The current frame of the runtime animation
  18004. */
  18005. private _currentFrame;
  18006. /**
  18007. * The animation used by the runtime animation
  18008. */
  18009. private _animation;
  18010. /**
  18011. * The target of the runtime animation
  18012. */
  18013. private _target;
  18014. /**
  18015. * The initiating animatable
  18016. */
  18017. private _host;
  18018. /**
  18019. * The original value of the runtime animation
  18020. */
  18021. private _originalValue;
  18022. /**
  18023. * The original blend value of the runtime animation
  18024. */
  18025. private _originalBlendValue;
  18026. /**
  18027. * The offsets cache of the runtime animation
  18028. */
  18029. private _offsetsCache;
  18030. /**
  18031. * The high limits cache of the runtime animation
  18032. */
  18033. private _highLimitsCache;
  18034. /**
  18035. * Specifies if the runtime animation has been stopped
  18036. */
  18037. private _stopped;
  18038. /**
  18039. * The blending factor of the runtime animation
  18040. */
  18041. private _blendingFactor;
  18042. /**
  18043. * The BabylonJS scene
  18044. */
  18045. private _scene;
  18046. /**
  18047. * The current value of the runtime animation
  18048. */
  18049. private _currentValue;
  18050. /** @hidden */ workValue: any;
  18051. /**
  18052. * The active target of the runtime animation
  18053. */
  18054. private _activeTarget;
  18055. /**
  18056. * The target path of the runtime animation
  18057. */
  18058. private _targetPath;
  18059. /**
  18060. * The weight of the runtime animation
  18061. */
  18062. private _weight;
  18063. /**
  18064. * The ratio offset of the runtime animation
  18065. */
  18066. private _ratioOffset;
  18067. /**
  18068. * The previous delay of the runtime animation
  18069. */
  18070. private _previousDelay;
  18071. /**
  18072. * The previous ratio of the runtime animation
  18073. */
  18074. private _previousRatio;
  18075. /**
  18076. * Gets the current frame of the runtime animation
  18077. */
  18078. readonly currentFrame: number;
  18079. /**
  18080. * Gets the weight of the runtime animation
  18081. */
  18082. readonly weight: number;
  18083. /**
  18084. * Gets the current value of the runtime animation
  18085. */
  18086. readonly currentValue: any;
  18087. /**
  18088. * Gets the target path of the runtime animation
  18089. */
  18090. readonly targetPath: string;
  18091. /**
  18092. * Gets the actual target of the runtime animation
  18093. */
  18094. readonly target: any;
  18095. /**
  18096. * Create a new RuntimeAnimation object
  18097. * @param target defines the target of the animation
  18098. * @param animation defines the source animation object
  18099. * @param scene defines the hosting scene
  18100. * @param host defines the initiating Animatable
  18101. */
  18102. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18103. /**
  18104. * Gets the animation from the runtime animation
  18105. */
  18106. readonly animation: Animation;
  18107. /**
  18108. * Resets the runtime animation to the beginning
  18109. * @param restoreOriginal defines whether to restore the target property to the original value
  18110. */
  18111. reset(restoreOriginal?: boolean): void;
  18112. /**
  18113. * Specifies if the runtime animation is stopped
  18114. * @returns Boolean specifying if the runtime animation is stopped
  18115. */
  18116. isStopped(): boolean;
  18117. /**
  18118. * Disposes of the runtime animation
  18119. */
  18120. dispose(): void;
  18121. /**
  18122. * Interpolates the animation from the current frame
  18123. * @param currentFrame The frame to interpolate the animation to
  18124. * @param repeatCount The number of times that the animation should loop
  18125. * @param loopMode The type of looping mode to use
  18126. * @param offsetValue Animation offset value
  18127. * @param highLimitValue The high limit value
  18128. * @returns The interpolated value
  18129. */
  18130. private _interpolate;
  18131. /**
  18132. * Apply the interpolated value to the target
  18133. * @param currentValue defines the value computed by the animation
  18134. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18135. */
  18136. setValue(currentValue: any, weight?: number): void;
  18137. private _setValue;
  18138. /**
  18139. * Gets the loop pmode of the runtime animation
  18140. * @returns Loop Mode
  18141. */
  18142. private _getCorrectLoopMode;
  18143. /**
  18144. * Move the current animation to a given frame
  18145. * @param frame defines the frame to move to
  18146. */
  18147. goToFrame(frame: number): void;
  18148. /**
  18149. * @hidden Internal use only
  18150. */ prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18151. /**
  18152. * Execute the current animation
  18153. * @param delay defines the delay to add to the current frame
  18154. * @param from defines the lower bound of the animation range
  18155. * @param to defines the upper bound of the animation range
  18156. * @param loop defines if the current animation must loop
  18157. * @param speedRatio defines the current speed ratio
  18158. * @param weight defines the weight of the animation (default is -1 so no weight)
  18159. * @param onLoop optional callback called when animation loops
  18160. * @returns a boolean indicating if the animation is running
  18161. */
  18162. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number, onLoop?: () => void): boolean;
  18163. }
  18164. }
  18165. declare module BABYLON {
  18166. /**
  18167. * Class used to store an actual running animation
  18168. */
  18169. export class Animatable {
  18170. /** defines the target object */
  18171. target: any;
  18172. /** defines the starting frame number (default is 0) */
  18173. fromFrame: number;
  18174. /** defines the ending frame number (default is 100) */
  18175. toFrame: number;
  18176. /** defines if the animation must loop (default is false) */
  18177. loopAnimation: boolean;
  18178. /** defines a callback to call when animation ends if it is not looping */
  18179. onAnimationEnd?: (() => void) | null | undefined;
  18180. /** defines a callback to call when animation loops */
  18181. onAnimationLoop?: (() => void) | null | undefined;
  18182. private _localDelayOffset;
  18183. private _pausedDelay;
  18184. private _runtimeAnimations;
  18185. private _paused;
  18186. private _scene;
  18187. private _speedRatio;
  18188. private _weight;
  18189. private _syncRoot;
  18190. /**
  18191. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18192. * This will only apply for non looping animation (default is true)
  18193. */
  18194. disposeOnEnd: boolean;
  18195. /**
  18196. * Gets a boolean indicating if the animation has started
  18197. */
  18198. animationStarted: boolean;
  18199. /**
  18200. * Observer raised when the animation ends
  18201. */
  18202. onAnimationEndObservable: Observable<Animatable>;
  18203. /**
  18204. * Observer raised when the animation loops
  18205. */
  18206. onAnimationLoopObservable: Observable<Animatable>;
  18207. /**
  18208. * Gets the root Animatable used to synchronize and normalize animations
  18209. */
  18210. readonly syncRoot: Animatable;
  18211. /**
  18212. * Gets the current frame of the first RuntimeAnimation
  18213. * Used to synchronize Animatables
  18214. */
  18215. readonly masterFrame: number;
  18216. /**
  18217. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18218. */
  18219. weight: number;
  18220. /**
  18221. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18222. */
  18223. speedRatio: number;
  18224. /**
  18225. * Creates a new Animatable
  18226. * @param scene defines the hosting scene
  18227. * @param target defines the target object
  18228. * @param fromFrame defines the starting frame number (default is 0)
  18229. * @param toFrame defines the ending frame number (default is 100)
  18230. * @param loopAnimation defines if the animation must loop (default is false)
  18231. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18232. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18233. * @param animations defines a group of animation to add to the new Animatable
  18234. * @param onAnimationLoop defines a callback to call when animation loops
  18235. */
  18236. constructor(scene: Scene,
  18237. /** defines the target object */
  18238. target: any,
  18239. /** defines the starting frame number (default is 0) */
  18240. fromFrame?: number,
  18241. /** defines the ending frame number (default is 100) */
  18242. toFrame?: number,
  18243. /** defines if the animation must loop (default is false) */
  18244. loopAnimation?: boolean, speedRatio?: number,
  18245. /** defines a callback to call when animation ends if it is not looping */
  18246. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18247. /** defines a callback to call when animation loops */
  18248. onAnimationLoop?: (() => void) | null | undefined);
  18249. /**
  18250. * Synchronize and normalize current Animatable with a source Animatable
  18251. * This is useful when using animation weights and when animations are not of the same length
  18252. * @param root defines the root Animatable to synchronize with
  18253. * @returns the current Animatable
  18254. */
  18255. syncWith(root: Animatable): Animatable;
  18256. /**
  18257. * Gets the list of runtime animations
  18258. * @returns an array of RuntimeAnimation
  18259. */
  18260. getAnimations(): RuntimeAnimation[];
  18261. /**
  18262. * Adds more animations to the current animatable
  18263. * @param target defines the target of the animations
  18264. * @param animations defines the new animations to add
  18265. */
  18266. appendAnimations(target: any, animations: Animation[]): void;
  18267. /**
  18268. * Gets the source animation for a specific property
  18269. * @param property defines the propertyu to look for
  18270. * @returns null or the source animation for the given property
  18271. */
  18272. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18273. /**
  18274. * Gets the runtime animation for a specific property
  18275. * @param property defines the propertyu to look for
  18276. * @returns null or the runtime animation for the given property
  18277. */
  18278. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18279. /**
  18280. * Resets the animatable to its original state
  18281. */
  18282. reset(): void;
  18283. /**
  18284. * Allows the animatable to blend with current running animations
  18285. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18286. * @param blendingSpeed defines the blending speed to use
  18287. */
  18288. enableBlending(blendingSpeed: number): void;
  18289. /**
  18290. * Disable animation blending
  18291. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18292. */
  18293. disableBlending(): void;
  18294. /**
  18295. * Jump directly to a given frame
  18296. * @param frame defines the frame to jump to
  18297. */
  18298. goToFrame(frame: number): void;
  18299. /**
  18300. * Pause the animation
  18301. */
  18302. pause(): void;
  18303. /**
  18304. * Restart the animation
  18305. */
  18306. restart(): void;
  18307. private _raiseOnAnimationEnd;
  18308. /**
  18309. * Stop and delete the current animation
  18310. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18311. * @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)
  18312. */
  18313. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18314. /**
  18315. * Wait asynchronously for the animation to end
  18316. * @returns a promise which will be fullfilled when the animation ends
  18317. */
  18318. waitAsync(): Promise<Animatable>;
  18319. /** @hidden */ animate(delay: number): boolean;
  18320. }
  18321. interface Scene {
  18322. /** @hidden */ registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18323. /** @hidden */ processLateAnimationBindingsForMatrices(holder: {
  18324. totalWeight: number;
  18325. animations: RuntimeAnimation[];
  18326. originalValue: Matrix;
  18327. }): any;
  18328. /** @hidden */ processLateAnimationBindingsForQuaternions(holder: {
  18329. totalWeight: number;
  18330. animations: RuntimeAnimation[];
  18331. originalValue: Quaternion;
  18332. }, refQuaternion: Quaternion): Quaternion;
  18333. /** @hidden */ processLateAnimationBindings(): void;
  18334. /**
  18335. * Will start the animation sequence of a given target
  18336. * @param target defines the target
  18337. * @param from defines from which frame should animation start
  18338. * @param to defines until which frame should animation run.
  18339. * @param weight defines the weight to apply to the animation (1.0 by default)
  18340. * @param loop defines if the animation loops
  18341. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18342. * @param onAnimationEnd defines the function to be executed when the animation ends
  18343. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18344. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18345. * @param onAnimationLoop defines the callback to call when an animation loops
  18346. * @returns the animatable object created for this animation
  18347. */
  18348. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18349. /**
  18350. * Will start the animation sequence of a given target
  18351. * @param target defines the target
  18352. * @param from defines from which frame should animation start
  18353. * @param to defines until which frame should animation run.
  18354. * @param loop defines if the animation loops
  18355. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18356. * @param onAnimationEnd defines the function to be executed when the animation ends
  18357. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18358. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18359. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18360. * @param onAnimationLoop defines the callback to call when an animation loops
  18361. * @returns the animatable object created for this animation
  18362. */
  18363. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18364. /**
  18365. * Will start the animation sequence of a given target and its hierarchy
  18366. * @param target defines the target
  18367. * @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.
  18368. * @param from defines from which frame should animation start
  18369. * @param to defines until which frame should animation run.
  18370. * @param loop defines if the animation loops
  18371. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18372. * @param onAnimationEnd defines the function to be executed when the animation ends
  18373. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18374. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18375. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18376. * @param onAnimationLoop defines the callback to call when an animation loops
  18377. * @returns the list of created animatables
  18378. */
  18379. 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[];
  18380. /**
  18381. * Begin a new animation on a given node
  18382. * @param target defines the target where the animation will take place
  18383. * @param animations defines the list of animations to start
  18384. * @param from defines the initial value
  18385. * @param to defines the final value
  18386. * @param loop defines if you want animation to loop (off by default)
  18387. * @param speedRatio defines the speed ratio to apply to all animations
  18388. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18389. * @param onAnimationLoop defines the callback to call when an animation loops
  18390. * @returns the list of created animatables
  18391. */
  18392. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18393. /**
  18394. * Begin a new animation on a given node and its hierarchy
  18395. * @param target defines the root node where the animation will take place
  18396. * @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.
  18397. * @param animations defines the list of animations to start
  18398. * @param from defines the initial value
  18399. * @param to defines the final value
  18400. * @param loop defines if you want animation to loop (off by default)
  18401. * @param speedRatio defines the speed ratio to apply to all animations
  18402. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18403. * @param onAnimationLoop defines the callback to call when an animation loops
  18404. * @returns the list of animatables created for all nodes
  18405. */
  18406. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18407. /**
  18408. * Gets the animatable associated with a specific target
  18409. * @param target defines the target of the animatable
  18410. * @returns the required animatable if found
  18411. */
  18412. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18413. /**
  18414. * Gets all animatables associated with a given target
  18415. * @param target defines the target to look animatables for
  18416. * @returns an array of Animatables
  18417. */
  18418. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18419. /**
  18420. * Will stop the animation of the given target
  18421. * @param target - the target
  18422. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  18423. * @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)
  18424. */
  18425. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  18426. /**
  18427. * Stops and removes all animations that have been applied to the scene
  18428. */
  18429. stopAllAnimations(): void;
  18430. }
  18431. interface Bone {
  18432. /**
  18433. * Copy an animation range from another bone
  18434. * @param source defines the source bone
  18435. * @param rangeName defines the range name to copy
  18436. * @param frameOffset defines the frame offset
  18437. * @param rescaleAsRequired defines if rescaling must be applied if required
  18438. * @param skelDimensionsRatio defines the scaling ratio
  18439. * @returns true if operation was successful
  18440. */
  18441. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18442. }
  18443. }
  18444. declare module BABYLON {
  18445. /**
  18446. * Class used to handle skinning animations
  18447. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18448. */
  18449. export class Skeleton implements IAnimatable {
  18450. /** defines the skeleton name */
  18451. name: string;
  18452. /** defines the skeleton Id */
  18453. id: string;
  18454. /**
  18455. * Defines the list of child bones
  18456. */
  18457. bones: Bone[];
  18458. /**
  18459. * Defines an estimate of the dimension of the skeleton at rest
  18460. */
  18461. dimensionsAtRest: Vector3;
  18462. /**
  18463. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18464. */
  18465. needInitialSkinMatrix: boolean;
  18466. /**
  18467. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18468. */
  18469. overrideMesh: Nullable<AbstractMesh>;
  18470. /**
  18471. * Gets the list of animations attached to this skeleton
  18472. */
  18473. animations: Array<Animation>;
  18474. private _scene;
  18475. private _isDirty;
  18476. private _transformMatrices;
  18477. private _transformMatrixTexture;
  18478. private _meshesWithPoseMatrix;
  18479. private _animatables;
  18480. private _identity;
  18481. private _synchronizedWithMesh;
  18482. private _ranges;
  18483. private _lastAbsoluteTransformsUpdateId;
  18484. private _canUseTextureForBones;
  18485. private _uniqueId;
  18486. /** @hidden */ numBonesWithLinkedTransformNode: number;
  18487. /**
  18488. * Specifies if the skeleton should be serialized
  18489. */
  18490. doNotSerialize: boolean;
  18491. private _useTextureToStoreBoneMatrices;
  18492. /**
  18493. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18494. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18495. */
  18496. useTextureToStoreBoneMatrices: boolean;
  18497. private _animationPropertiesOverride;
  18498. /**
  18499. * Gets or sets the animation properties override
  18500. */
  18501. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18502. /**
  18503. * List of inspectable custom properties (used by the Inspector)
  18504. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18505. */
  18506. inspectableCustomProperties: IInspectable[];
  18507. /**
  18508. * An observable triggered before computing the skeleton's matrices
  18509. */
  18510. onBeforeComputeObservable: Observable<Skeleton>;
  18511. /**
  18512. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18513. */
  18514. readonly isUsingTextureForMatrices: boolean;
  18515. /**
  18516. * Gets the unique ID of this skeleton
  18517. */
  18518. readonly uniqueId: number;
  18519. /**
  18520. * Creates a new skeleton
  18521. * @param name defines the skeleton name
  18522. * @param id defines the skeleton Id
  18523. * @param scene defines the hosting scene
  18524. */
  18525. constructor(
  18526. /** defines the skeleton name */
  18527. name: string,
  18528. /** defines the skeleton Id */
  18529. id: string, scene: Scene);
  18530. /**
  18531. * Gets the current object class name.
  18532. * @return the class name
  18533. */
  18534. getClassName(): string;
  18535. /**
  18536. * Returns an array containing the root bones
  18537. * @returns an array containing the root bones
  18538. */
  18539. getChildren(): Array<Bone>;
  18540. /**
  18541. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18542. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18543. * @returns a Float32Array containing matrices data
  18544. */
  18545. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18546. /**
  18547. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18548. * @returns a raw texture containing the data
  18549. */
  18550. getTransformMatrixTexture(): Nullable<RawTexture>;
  18551. /**
  18552. * Gets the current hosting scene
  18553. * @returns a scene object
  18554. */
  18555. getScene(): Scene;
  18556. /**
  18557. * Gets a string representing the current skeleton data
  18558. * @param fullDetails defines a boolean indicating if we want a verbose version
  18559. * @returns a string representing the current skeleton data
  18560. */
  18561. toString(fullDetails?: boolean): string;
  18562. /**
  18563. * Get bone's index searching by name
  18564. * @param name defines bone's name to search for
  18565. * @return the indice of the bone. Returns -1 if not found
  18566. */
  18567. getBoneIndexByName(name: string): number;
  18568. /**
  18569. * Creater a new animation range
  18570. * @param name defines the name of the range
  18571. * @param from defines the start key
  18572. * @param to defines the end key
  18573. */
  18574. createAnimationRange(name: string, from: number, to: number): void;
  18575. /**
  18576. * Delete a specific animation range
  18577. * @param name defines the name of the range
  18578. * @param deleteFrames defines if frames must be removed as well
  18579. */
  18580. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18581. /**
  18582. * Gets a specific animation range
  18583. * @param name defines the name of the range to look for
  18584. * @returns the requested animation range or null if not found
  18585. */
  18586. getAnimationRange(name: string): Nullable<AnimationRange>;
  18587. /**
  18588. * Gets the list of all animation ranges defined on this skeleton
  18589. * @returns an array
  18590. */
  18591. getAnimationRanges(): Nullable<AnimationRange>[];
  18592. /**
  18593. * Copy animation range from a source skeleton.
  18594. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18595. * @param source defines the source skeleton
  18596. * @param name defines the name of the range to copy
  18597. * @param rescaleAsRequired defines if rescaling must be applied if required
  18598. * @returns true if operation was successful
  18599. */
  18600. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18601. /**
  18602. * Forces the skeleton to go to rest pose
  18603. */
  18604. returnToRest(): void;
  18605. private _getHighestAnimationFrame;
  18606. /**
  18607. * Begin a specific animation range
  18608. * @param name defines the name of the range to start
  18609. * @param loop defines if looping must be turned on (false by default)
  18610. * @param speedRatio defines the speed ratio to apply (1 by default)
  18611. * @param onAnimationEnd defines a callback which will be called when animation will end
  18612. * @returns a new animatable
  18613. */
  18614. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18615. /** @hidden */ markAsDirty(): void;
  18616. /** @hidden */ registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18617. /** @hidden */ unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18618. private _computeTransformMatrices;
  18619. /**
  18620. * Build all resources required to render a skeleton
  18621. */
  18622. prepare(): void;
  18623. /**
  18624. * Gets the list of animatables currently running for this skeleton
  18625. * @returns an array of animatables
  18626. */
  18627. getAnimatables(): IAnimatable[];
  18628. /**
  18629. * Clone the current skeleton
  18630. * @param name defines the name of the new skeleton
  18631. * @param id defines the id of the enw skeleton
  18632. * @returns the new skeleton
  18633. */
  18634. clone(name: string, id: string): Skeleton;
  18635. /**
  18636. * Enable animation blending for this skeleton
  18637. * @param blendingSpeed defines the blending speed to apply
  18638. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18639. */
  18640. enableBlending(blendingSpeed?: number): void;
  18641. /**
  18642. * Releases all resources associated with the current skeleton
  18643. */
  18644. dispose(): void;
  18645. /**
  18646. * Serialize the skeleton in a JSON object
  18647. * @returns a JSON object
  18648. */
  18649. serialize(): any;
  18650. /**
  18651. * Creates a new skeleton from serialized data
  18652. * @param parsedSkeleton defines the serialized data
  18653. * @param scene defines the hosting scene
  18654. * @returns a new skeleton
  18655. */
  18656. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18657. /**
  18658. * Compute all node absolute transforms
  18659. * @param forceUpdate defines if computation must be done even if cache is up to date
  18660. */
  18661. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18662. /**
  18663. * Gets the root pose matrix
  18664. * @returns a matrix
  18665. */
  18666. getPoseMatrix(): Nullable<Matrix>;
  18667. /**
  18668. * Sorts bones per internal index
  18669. */
  18670. sortBones(): void;
  18671. private _sortBones;
  18672. }
  18673. }
  18674. declare module BABYLON {
  18675. /**
  18676. * Defines a target to use with MorphTargetManager
  18677. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18678. */
  18679. export class MorphTarget implements IAnimatable {
  18680. /** defines the name of the target */
  18681. name: string;
  18682. /**
  18683. * Gets or sets the list of animations
  18684. */
  18685. animations: Animation[];
  18686. private _scene;
  18687. private _positions;
  18688. private _normals;
  18689. private _tangents;
  18690. private _influence;
  18691. /**
  18692. * Observable raised when the influence changes
  18693. */
  18694. onInfluenceChanged: Observable<boolean>;
  18695. /** @hidden */ onDataLayoutChanged: Observable<void>;
  18696. /**
  18697. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18698. */
  18699. influence: number;
  18700. /**
  18701. * Gets or sets the id of the morph Target
  18702. */
  18703. id: string;
  18704. private _animationPropertiesOverride;
  18705. /**
  18706. * Gets or sets the animation properties override
  18707. */
  18708. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18709. /**
  18710. * Creates a new MorphTarget
  18711. * @param name defines the name of the target
  18712. * @param influence defines the influence to use
  18713. * @param scene defines the scene the morphtarget belongs to
  18714. */
  18715. constructor(
  18716. /** defines the name of the target */
  18717. name: string, influence?: number, scene?: Nullable<Scene>);
  18718. /**
  18719. * Gets a boolean defining if the target contains position data
  18720. */
  18721. readonly hasPositions: boolean;
  18722. /**
  18723. * Gets a boolean defining if the target contains normal data
  18724. */
  18725. readonly hasNormals: boolean;
  18726. /**
  18727. * Gets a boolean defining if the target contains tangent data
  18728. */
  18729. readonly hasTangents: boolean;
  18730. /**
  18731. * Affects position data to this target
  18732. * @param data defines the position data to use
  18733. */
  18734. setPositions(data: Nullable<FloatArray>): void;
  18735. /**
  18736. * Gets the position data stored in this target
  18737. * @returns a FloatArray containing the position data (or null if not present)
  18738. */
  18739. getPositions(): Nullable<FloatArray>;
  18740. /**
  18741. * Affects normal data to this target
  18742. * @param data defines the normal data to use
  18743. */
  18744. setNormals(data: Nullable<FloatArray>): void;
  18745. /**
  18746. * Gets the normal data stored in this target
  18747. * @returns a FloatArray containing the normal data (or null if not present)
  18748. */
  18749. getNormals(): Nullable<FloatArray>;
  18750. /**
  18751. * Affects tangent data to this target
  18752. * @param data defines the tangent data to use
  18753. */
  18754. setTangents(data: Nullable<FloatArray>): void;
  18755. /**
  18756. * Gets the tangent data stored in this target
  18757. * @returns a FloatArray containing the tangent data (or null if not present)
  18758. */
  18759. getTangents(): Nullable<FloatArray>;
  18760. /**
  18761. * Serializes the current target into a Serialization object
  18762. * @returns the serialized object
  18763. */
  18764. serialize(): any;
  18765. /**
  18766. * Returns the string "MorphTarget"
  18767. * @returns "MorphTarget"
  18768. */
  18769. getClassName(): string;
  18770. /**
  18771. * Creates a new target from serialized data
  18772. * @param serializationObject defines the serialized data to use
  18773. * @returns a new MorphTarget
  18774. */
  18775. static Parse(serializationObject: any): MorphTarget;
  18776. /**
  18777. * Creates a MorphTarget from mesh data
  18778. * @param mesh defines the source mesh
  18779. * @param name defines the name to use for the new target
  18780. * @param influence defines the influence to attach to the target
  18781. * @returns a new MorphTarget
  18782. */
  18783. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  18784. }
  18785. }
  18786. declare module BABYLON {
  18787. /**
  18788. * This class is used to deform meshes using morphing between different targets
  18789. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18790. */
  18791. export class MorphTargetManager {
  18792. private _targets;
  18793. private _targetInfluenceChangedObservers;
  18794. private _targetDataLayoutChangedObservers;
  18795. private _activeTargets;
  18796. private _scene;
  18797. private _influences;
  18798. private _supportsNormals;
  18799. private _supportsTangents;
  18800. private _vertexCount;
  18801. private _uniqueId;
  18802. private _tempInfluences;
  18803. /**
  18804. * Creates a new MorphTargetManager
  18805. * @param scene defines the current scene
  18806. */
  18807. constructor(scene?: Nullable<Scene>);
  18808. /**
  18809. * Gets the unique ID of this manager
  18810. */
  18811. readonly uniqueId: number;
  18812. /**
  18813. * Gets the number of vertices handled by this manager
  18814. */
  18815. readonly vertexCount: number;
  18816. /**
  18817. * Gets a boolean indicating if this manager supports morphing of normals
  18818. */
  18819. readonly supportsNormals: boolean;
  18820. /**
  18821. * Gets a boolean indicating if this manager supports morphing of tangents
  18822. */
  18823. readonly supportsTangents: boolean;
  18824. /**
  18825. * Gets the number of targets stored in this manager
  18826. */
  18827. readonly numTargets: number;
  18828. /**
  18829. * Gets the number of influencers (ie. the number of targets with influences > 0)
  18830. */
  18831. readonly numInfluencers: number;
  18832. /**
  18833. * Gets the list of influences (one per target)
  18834. */
  18835. readonly influences: Float32Array;
  18836. /**
  18837. * Gets the active target at specified index. An active target is a target with an influence > 0
  18838. * @param index defines the index to check
  18839. * @returns the requested target
  18840. */
  18841. getActiveTarget(index: number): MorphTarget;
  18842. /**
  18843. * Gets the target at specified index
  18844. * @param index defines the index to check
  18845. * @returns the requested target
  18846. */
  18847. getTarget(index: number): MorphTarget;
  18848. /**
  18849. * Add a new target to this manager
  18850. * @param target defines the target to add
  18851. */
  18852. addTarget(target: MorphTarget): void;
  18853. /**
  18854. * Removes a target from the manager
  18855. * @param target defines the target to remove
  18856. */
  18857. removeTarget(target: MorphTarget): void;
  18858. /**
  18859. * Serializes the current manager into a Serialization object
  18860. * @returns the serialized object
  18861. */
  18862. serialize(): any;
  18863. private _syncActiveTargets;
  18864. /**
  18865. * Syncrhonize the targets with all the meshes using this morph target manager
  18866. */
  18867. synchronize(): void;
  18868. /**
  18869. * Creates a new MorphTargetManager from serialized data
  18870. * @param serializationObject defines the serialized data
  18871. * @param scene defines the hosting scene
  18872. * @returns the new MorphTargetManager
  18873. */
  18874. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  18875. }
  18876. }
  18877. declare module BABYLON {
  18878. /**
  18879. * Mesh representing the gorund
  18880. */
  18881. export class GroundMesh extends Mesh {
  18882. /** If octree should be generated */
  18883. generateOctree: boolean;
  18884. private _heightQuads;
  18885. /** @hidden */ subdivisionsX: number;
  18886. /** @hidden */ subdivisionsY: number;
  18887. /** @hidden */ width: number;
  18888. /** @hidden */ height: number;
  18889. /** @hidden */ minX: number;
  18890. /** @hidden */ maxX: number;
  18891. /** @hidden */ minZ: number;
  18892. /** @hidden */ maxZ: number;
  18893. constructor(name: string, scene: Scene);
  18894. /**
  18895. * "GroundMesh"
  18896. * @returns "GroundMesh"
  18897. */
  18898. getClassName(): string;
  18899. /**
  18900. * The minimum of x and y subdivisions
  18901. */
  18902. readonly subdivisions: number;
  18903. /**
  18904. * X subdivisions
  18905. */
  18906. readonly subdivisionsX: number;
  18907. /**
  18908. * Y subdivisions
  18909. */
  18910. readonly subdivisionsY: number;
  18911. /**
  18912. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  18913. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  18914. * @param chunksCount the number of subdivisions for x and y
  18915. * @param octreeBlocksSize (Default: 32)
  18916. */
  18917. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  18918. /**
  18919. * Returns a height (y) value in the Worl system :
  18920. * the ground altitude at the coordinates (x, z) expressed in the World system.
  18921. * @param x x coordinate
  18922. * @param z z coordinate
  18923. * @returns the ground y position if (x, z) are outside the ground surface.
  18924. */
  18925. getHeightAtCoordinates(x: number, z: number): number;
  18926. /**
  18927. * Returns a normalized vector (Vector3) orthogonal to the ground
  18928. * at the ground coordinates (x, z) expressed in the World system.
  18929. * @param x x coordinate
  18930. * @param z z coordinate
  18931. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  18932. */
  18933. getNormalAtCoordinates(x: number, z: number): Vector3;
  18934. /**
  18935. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  18936. * at the ground coordinates (x, z) expressed in the World system.
  18937. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  18938. * @param x x coordinate
  18939. * @param z z coordinate
  18940. * @param ref vector to store the result
  18941. * @returns the GroundMesh.
  18942. */
  18943. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  18944. /**
  18945. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  18946. * if the ground has been updated.
  18947. * This can be used in the render loop.
  18948. * @returns the GroundMesh.
  18949. */
  18950. updateCoordinateHeights(): GroundMesh;
  18951. private _getFacetAt;
  18952. private _initHeightQuads;
  18953. private _computeHeightQuads;
  18954. /**
  18955. * Serializes this ground mesh
  18956. * @param serializationObject object to write serialization to
  18957. */
  18958. serialize(serializationObject: any): void;
  18959. /**
  18960. * Parses a serialized ground mesh
  18961. * @param parsedMesh the serialized mesh
  18962. * @param scene the scene to create the ground mesh in
  18963. * @returns the created ground mesh
  18964. */
  18965. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  18966. }
  18967. }
  18968. declare module BABYLON {
  18969. /**
  18970. * Interface for Physics-Joint data
  18971. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  18972. */
  18973. export interface PhysicsJointData {
  18974. /**
  18975. * The main pivot of the joint
  18976. */
  18977. mainPivot?: Vector3;
  18978. /**
  18979. * The connected pivot of the joint
  18980. */
  18981. connectedPivot?: Vector3;
  18982. /**
  18983. * The main axis of the joint
  18984. */
  18985. mainAxis?: Vector3;
  18986. /**
  18987. * The connected axis of the joint
  18988. */
  18989. connectedAxis?: Vector3;
  18990. /**
  18991. * The collision of the joint
  18992. */
  18993. collision?: boolean;
  18994. /**
  18995. * Native Oimo/Cannon/Energy data
  18996. */
  18997. nativeParams?: any;
  18998. }
  18999. /**
  19000. * This is a holder class for the physics joint created by the physics plugin
  19001. * It holds a set of functions to control the underlying joint
  19002. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19003. */
  19004. export class PhysicsJoint {
  19005. /**
  19006. * The type of the physics joint
  19007. */
  19008. type: number;
  19009. /**
  19010. * The data for the physics joint
  19011. */
  19012. jointData: PhysicsJointData;
  19013. private _physicsJoint;
  19014. protected _physicsPlugin: IPhysicsEnginePlugin;
  19015. /**
  19016. * Initializes the physics joint
  19017. * @param type The type of the physics joint
  19018. * @param jointData The data for the physics joint
  19019. */
  19020. constructor(
  19021. /**
  19022. * The type of the physics joint
  19023. */
  19024. type: number,
  19025. /**
  19026. * The data for the physics joint
  19027. */
  19028. jointData: PhysicsJointData);
  19029. /**
  19030. * Gets the physics joint
  19031. */
  19032. /**
  19033. * Sets the physics joint
  19034. */
  19035. physicsJoint: any;
  19036. /**
  19037. * Sets the physics plugin
  19038. */
  19039. physicsPlugin: IPhysicsEnginePlugin;
  19040. /**
  19041. * Execute a function that is physics-plugin specific.
  19042. * @param {Function} func the function that will be executed.
  19043. * It accepts two parameters: the physics world and the physics joint
  19044. */
  19045. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19046. /**
  19047. * Distance-Joint type
  19048. */
  19049. static DistanceJoint: number;
  19050. /**
  19051. * Hinge-Joint type
  19052. */
  19053. static HingeJoint: number;
  19054. /**
  19055. * Ball-and-Socket joint type
  19056. */
  19057. static BallAndSocketJoint: number;
  19058. /**
  19059. * Wheel-Joint type
  19060. */
  19061. static WheelJoint: number;
  19062. /**
  19063. * Slider-Joint type
  19064. */
  19065. static SliderJoint: number;
  19066. /**
  19067. * Prismatic-Joint type
  19068. */
  19069. static PrismaticJoint: number;
  19070. /**
  19071. * Universal-Joint type
  19072. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19073. */
  19074. static UniversalJoint: number;
  19075. /**
  19076. * Hinge-Joint 2 type
  19077. */
  19078. static Hinge2Joint: number;
  19079. /**
  19080. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19081. */
  19082. static PointToPointJoint: number;
  19083. /**
  19084. * Spring-Joint type
  19085. */
  19086. static SpringJoint: number;
  19087. /**
  19088. * Lock-Joint type
  19089. */
  19090. static LockJoint: number;
  19091. }
  19092. /**
  19093. * A class representing a physics distance joint
  19094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19095. */
  19096. export class DistanceJoint extends PhysicsJoint {
  19097. /**
  19098. *
  19099. * @param jointData The data for the Distance-Joint
  19100. */
  19101. constructor(jointData: DistanceJointData);
  19102. /**
  19103. * Update the predefined distance.
  19104. * @param maxDistance The maximum preferred distance
  19105. * @param minDistance The minimum preferred distance
  19106. */
  19107. updateDistance(maxDistance: number, minDistance?: number): void;
  19108. }
  19109. /**
  19110. * Represents a Motor-Enabled Joint
  19111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19112. */
  19113. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19114. /**
  19115. * Initializes the Motor-Enabled Joint
  19116. * @param type The type of the joint
  19117. * @param jointData The physica joint data for the joint
  19118. */
  19119. constructor(type: number, jointData: PhysicsJointData);
  19120. /**
  19121. * Set the motor values.
  19122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19123. * @param force the force to apply
  19124. * @param maxForce max force for this motor.
  19125. */
  19126. setMotor(force?: number, maxForce?: number): void;
  19127. /**
  19128. * Set the motor's limits.
  19129. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19130. * @param upperLimit The upper limit of the motor
  19131. * @param lowerLimit The lower limit of the motor
  19132. */
  19133. setLimit(upperLimit: number, lowerLimit?: number): void;
  19134. }
  19135. /**
  19136. * This class represents a single physics Hinge-Joint
  19137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19138. */
  19139. export class HingeJoint extends MotorEnabledJoint {
  19140. /**
  19141. * Initializes the Hinge-Joint
  19142. * @param jointData The joint data for the Hinge-Joint
  19143. */
  19144. constructor(jointData: PhysicsJointData);
  19145. /**
  19146. * Set the motor values.
  19147. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19148. * @param {number} force the force to apply
  19149. * @param {number} maxForce max force for this motor.
  19150. */
  19151. setMotor(force?: number, maxForce?: number): void;
  19152. /**
  19153. * Set the motor's limits.
  19154. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19155. * @param upperLimit The upper limit of the motor
  19156. * @param lowerLimit The lower limit of the motor
  19157. */
  19158. setLimit(upperLimit: number, lowerLimit?: number): void;
  19159. }
  19160. /**
  19161. * This class represents a dual hinge physics joint (same as wheel joint)
  19162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19163. */
  19164. export class Hinge2Joint extends MotorEnabledJoint {
  19165. /**
  19166. * Initializes the Hinge2-Joint
  19167. * @param jointData The joint data for the Hinge2-Joint
  19168. */
  19169. constructor(jointData: PhysicsJointData);
  19170. /**
  19171. * Set the motor values.
  19172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19173. * @param {number} targetSpeed the speed the motor is to reach
  19174. * @param {number} maxForce max force for this motor.
  19175. * @param {motorIndex} the motor's index, 0 or 1.
  19176. */
  19177. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19178. /**
  19179. * Set the motor limits.
  19180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19181. * @param {number} upperLimit the upper limit
  19182. * @param {number} lowerLimit lower limit
  19183. * @param {motorIndex} the motor's index, 0 or 1.
  19184. */
  19185. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19186. }
  19187. /**
  19188. * Interface for a motor enabled joint
  19189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19190. */
  19191. export interface IMotorEnabledJoint {
  19192. /**
  19193. * Physics joint
  19194. */
  19195. physicsJoint: any;
  19196. /**
  19197. * Sets the motor of the motor-enabled joint
  19198. * @param force The force of the motor
  19199. * @param maxForce The maximum force of the motor
  19200. * @param motorIndex The index of the motor
  19201. */
  19202. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19203. /**
  19204. * Sets the limit of the motor
  19205. * @param upperLimit The upper limit of the motor
  19206. * @param lowerLimit The lower limit of the motor
  19207. * @param motorIndex The index of the motor
  19208. */
  19209. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19210. }
  19211. /**
  19212. * Joint data for a Distance-Joint
  19213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19214. */
  19215. export interface DistanceJointData extends PhysicsJointData {
  19216. /**
  19217. * Max distance the 2 joint objects can be apart
  19218. */
  19219. maxDistance: number;
  19220. }
  19221. /**
  19222. * Joint data from a spring joint
  19223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19224. */
  19225. export interface SpringJointData extends PhysicsJointData {
  19226. /**
  19227. * Length of the spring
  19228. */
  19229. length: number;
  19230. /**
  19231. * Stiffness of the spring
  19232. */
  19233. stiffness: number;
  19234. /**
  19235. * Damping of the spring
  19236. */
  19237. damping: number;
  19238. /** this callback will be called when applying the force to the impostors. */
  19239. forceApplicationCallback: () => void;
  19240. }
  19241. }
  19242. declare module BABYLON {
  19243. /**
  19244. * Holds the data for the raycast result
  19245. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19246. */
  19247. export class PhysicsRaycastResult {
  19248. private _hasHit;
  19249. private _hitDistance;
  19250. private _hitNormalWorld;
  19251. private _hitPointWorld;
  19252. private _rayFromWorld;
  19253. private _rayToWorld;
  19254. /**
  19255. * Gets if there was a hit
  19256. */
  19257. readonly hasHit: boolean;
  19258. /**
  19259. * Gets the distance from the hit
  19260. */
  19261. readonly hitDistance: number;
  19262. /**
  19263. * Gets the hit normal/direction in the world
  19264. */
  19265. readonly hitNormalWorld: Vector3;
  19266. /**
  19267. * Gets the hit point in the world
  19268. */
  19269. readonly hitPointWorld: Vector3;
  19270. /**
  19271. * Gets the ray "start point" of the ray in the world
  19272. */
  19273. readonly rayFromWorld: Vector3;
  19274. /**
  19275. * Gets the ray "end point" of the ray in the world
  19276. */
  19277. readonly rayToWorld: Vector3;
  19278. /**
  19279. * Sets the hit data (normal & point in world space)
  19280. * @param hitNormalWorld defines the normal in world space
  19281. * @param hitPointWorld defines the point in world space
  19282. */
  19283. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19284. /**
  19285. * Sets the distance from the start point to the hit point
  19286. * @param distance
  19287. */
  19288. setHitDistance(distance: number): void;
  19289. /**
  19290. * Calculates the distance manually
  19291. */
  19292. calculateHitDistance(): void;
  19293. /**
  19294. * Resets all the values to default
  19295. * @param from The from point on world space
  19296. * @param to The to point on world space
  19297. */
  19298. reset(from?: Vector3, to?: Vector3): void;
  19299. }
  19300. /**
  19301. * Interface for the size containing width and height
  19302. */
  19303. interface IXYZ {
  19304. /**
  19305. * X
  19306. */
  19307. x: number;
  19308. /**
  19309. * Y
  19310. */
  19311. y: number;
  19312. /**
  19313. * Z
  19314. */
  19315. z: number;
  19316. }
  19317. }
  19318. declare module BABYLON {
  19319. /**
  19320. * Interface used to describe a physics joint
  19321. */
  19322. export interface PhysicsImpostorJoint {
  19323. /** Defines the main impostor to which the joint is linked */
  19324. mainImpostor: PhysicsImpostor;
  19325. /** Defines the impostor that is connected to the main impostor using this joint */
  19326. connectedImpostor: PhysicsImpostor;
  19327. /** Defines the joint itself */
  19328. joint: PhysicsJoint;
  19329. }
  19330. /** @hidden */
  19331. export interface IPhysicsEnginePlugin {
  19332. world: any;
  19333. name: string;
  19334. setGravity(gravity: Vector3): void;
  19335. setTimeStep(timeStep: number): void;
  19336. getTimeStep(): number;
  19337. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19338. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19339. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19340. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19341. removePhysicsBody(impostor: PhysicsImpostor): void;
  19342. generateJoint(joint: PhysicsImpostorJoint): void;
  19343. removeJoint(joint: PhysicsImpostorJoint): void;
  19344. isSupported(): boolean;
  19345. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19346. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19347. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19348. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19349. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19350. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19351. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19352. getBodyMass(impostor: PhysicsImpostor): number;
  19353. getBodyFriction(impostor: PhysicsImpostor): number;
  19354. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19355. getBodyRestitution(impostor: PhysicsImpostor): number;
  19356. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19357. getBodyPressure?(impostor: PhysicsImpostor): number;
  19358. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19359. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19360. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19361. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19362. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19363. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19364. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19365. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19366. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19367. sleepBody(impostor: PhysicsImpostor): void;
  19368. wakeUpBody(impostor: PhysicsImpostor): void;
  19369. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19370. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19371. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19372. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19373. getRadius(impostor: PhysicsImpostor): number;
  19374. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19375. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19376. dispose(): void;
  19377. }
  19378. /**
  19379. * Interface used to define a physics engine
  19380. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19381. */
  19382. export interface IPhysicsEngine {
  19383. /**
  19384. * Gets the gravity vector used by the simulation
  19385. */
  19386. gravity: Vector3;
  19387. /**
  19388. * Sets the gravity vector used by the simulation
  19389. * @param gravity defines the gravity vector to use
  19390. */
  19391. setGravity(gravity: Vector3): void;
  19392. /**
  19393. * Set the time step of the physics engine.
  19394. * Default is 1/60.
  19395. * To slow it down, enter 1/600 for example.
  19396. * To speed it up, 1/30
  19397. * @param newTimeStep the new timestep to apply to this world.
  19398. */
  19399. setTimeStep(newTimeStep: number): void;
  19400. /**
  19401. * Get the time step of the physics engine.
  19402. * @returns the current time step
  19403. */
  19404. getTimeStep(): number;
  19405. /**
  19406. * Release all resources
  19407. */
  19408. dispose(): void;
  19409. /**
  19410. * Gets the name of the current physics plugin
  19411. * @returns the name of the plugin
  19412. */
  19413. getPhysicsPluginName(): string;
  19414. /**
  19415. * Adding a new impostor for the impostor tracking.
  19416. * This will be done by the impostor itself.
  19417. * @param impostor the impostor to add
  19418. */
  19419. addImpostor(impostor: PhysicsImpostor): void;
  19420. /**
  19421. * Remove an impostor from the engine.
  19422. * This impostor and its mesh will not longer be updated by the physics engine.
  19423. * @param impostor the impostor to remove
  19424. */
  19425. removeImpostor(impostor: PhysicsImpostor): void;
  19426. /**
  19427. * Add a joint to the physics engine
  19428. * @param mainImpostor defines the main impostor to which the joint is added.
  19429. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19430. * @param joint defines the joint that will connect both impostors.
  19431. */
  19432. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19433. /**
  19434. * Removes a joint from the simulation
  19435. * @param mainImpostor defines the impostor used with the joint
  19436. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19437. * @param joint defines the joint to remove
  19438. */
  19439. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19440. /**
  19441. * Gets the current plugin used to run the simulation
  19442. * @returns current plugin
  19443. */
  19444. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19445. /**
  19446. * Gets the list of physic impostors
  19447. * @returns an array of PhysicsImpostor
  19448. */
  19449. getImpostors(): Array<PhysicsImpostor>;
  19450. /**
  19451. * Gets the impostor for a physics enabled object
  19452. * @param object defines the object impersonated by the impostor
  19453. * @returns the PhysicsImpostor or null if not found
  19454. */
  19455. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19456. /**
  19457. * Gets the impostor for a physics body object
  19458. * @param body defines physics body used by the impostor
  19459. * @returns the PhysicsImpostor or null if not found
  19460. */
  19461. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19462. /**
  19463. * Does a raycast in the physics world
  19464. * @param from when should the ray start?
  19465. * @param to when should the ray end?
  19466. * @returns PhysicsRaycastResult
  19467. */
  19468. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19469. /**
  19470. * Called by the scene. No need to call it.
  19471. * @param delta defines the timespam between frames
  19472. */ step(delta: number): void;
  19473. }
  19474. }
  19475. declare module BABYLON {
  19476. /**
  19477. * The interface for the physics imposter parameters
  19478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19479. */
  19480. export interface PhysicsImpostorParameters {
  19481. /**
  19482. * The mass of the physics imposter
  19483. */
  19484. mass: number;
  19485. /**
  19486. * The friction of the physics imposter
  19487. */
  19488. friction?: number;
  19489. /**
  19490. * The coefficient of restitution of the physics imposter
  19491. */
  19492. restitution?: number;
  19493. /**
  19494. * The native options of the physics imposter
  19495. */
  19496. nativeOptions?: any;
  19497. /**
  19498. * Specifies if the parent should be ignored
  19499. */
  19500. ignoreParent?: boolean;
  19501. /**
  19502. * Specifies if bi-directional transformations should be disabled
  19503. */
  19504. disableBidirectionalTransformation?: boolean;
  19505. /**
  19506. * The pressure inside the physics imposter, soft object only
  19507. */
  19508. pressure?: number;
  19509. /**
  19510. * The stiffness the physics imposter, soft object only
  19511. */
  19512. stiffness?: number;
  19513. /**
  19514. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19515. */
  19516. velocityIterations?: number;
  19517. /**
  19518. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19519. */
  19520. positionIterations?: number;
  19521. /**
  19522. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19523. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19524. * Add to fix multiple points
  19525. */
  19526. fixedPoints?: number;
  19527. /**
  19528. * The collision margin around a soft object
  19529. */
  19530. margin?: number;
  19531. /**
  19532. * The collision margin around a soft object
  19533. */
  19534. damping?: number;
  19535. /**
  19536. * The path for a rope based on an extrusion
  19537. */
  19538. path?: any;
  19539. /**
  19540. * The shape of an extrusion used for a rope based on an extrusion
  19541. */
  19542. shape?: any;
  19543. }
  19544. /**
  19545. * Interface for a physics-enabled object
  19546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19547. */
  19548. export interface IPhysicsEnabledObject {
  19549. /**
  19550. * The position of the physics-enabled object
  19551. */
  19552. position: Vector3;
  19553. /**
  19554. * The rotation of the physics-enabled object
  19555. */
  19556. rotationQuaternion: Nullable<Quaternion>;
  19557. /**
  19558. * The scale of the physics-enabled object
  19559. */
  19560. scaling: Vector3;
  19561. /**
  19562. * The rotation of the physics-enabled object
  19563. */
  19564. rotation?: Vector3;
  19565. /**
  19566. * The parent of the physics-enabled object
  19567. */
  19568. parent?: any;
  19569. /**
  19570. * The bounding info of the physics-enabled object
  19571. * @returns The bounding info of the physics-enabled object
  19572. */
  19573. getBoundingInfo(): BoundingInfo;
  19574. /**
  19575. * Computes the world matrix
  19576. * @param force Specifies if the world matrix should be computed by force
  19577. * @returns A world matrix
  19578. */
  19579. computeWorldMatrix(force: boolean): Matrix;
  19580. /**
  19581. * Gets the world matrix
  19582. * @returns A world matrix
  19583. */
  19584. getWorldMatrix?(): Matrix;
  19585. /**
  19586. * Gets the child meshes
  19587. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19588. * @returns An array of abstract meshes
  19589. */
  19590. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19591. /**
  19592. * Gets the vertex data
  19593. * @param kind The type of vertex data
  19594. * @returns A nullable array of numbers, or a float32 array
  19595. */
  19596. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19597. /**
  19598. * Gets the indices from the mesh
  19599. * @returns A nullable array of index arrays
  19600. */
  19601. getIndices?(): Nullable<IndicesArray>;
  19602. /**
  19603. * Gets the scene from the mesh
  19604. * @returns the indices array or null
  19605. */
  19606. getScene?(): Scene;
  19607. /**
  19608. * Gets the absolute position from the mesh
  19609. * @returns the absolute position
  19610. */
  19611. getAbsolutePosition(): Vector3;
  19612. /**
  19613. * Gets the absolute pivot point from the mesh
  19614. * @returns the absolute pivot point
  19615. */
  19616. getAbsolutePivotPoint(): Vector3;
  19617. /**
  19618. * Rotates the mesh
  19619. * @param axis The axis of rotation
  19620. * @param amount The amount of rotation
  19621. * @param space The space of the rotation
  19622. * @returns The rotation transform node
  19623. */
  19624. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19625. /**
  19626. * Translates the mesh
  19627. * @param axis The axis of translation
  19628. * @param distance The distance of translation
  19629. * @param space The space of the translation
  19630. * @returns The transform node
  19631. */
  19632. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19633. /**
  19634. * Sets the absolute position of the mesh
  19635. * @param absolutePosition The absolute position of the mesh
  19636. * @returns The transform node
  19637. */
  19638. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19639. /**
  19640. * Gets the class name of the mesh
  19641. * @returns The class name
  19642. */
  19643. getClassName(): string;
  19644. }
  19645. /**
  19646. * Represents a physics imposter
  19647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19648. */
  19649. export class PhysicsImpostor {
  19650. /**
  19651. * The physics-enabled object used as the physics imposter
  19652. */
  19653. object: IPhysicsEnabledObject;
  19654. /**
  19655. * The type of the physics imposter
  19656. */
  19657. type: number;
  19658. private _options;
  19659. private _scene?;
  19660. /**
  19661. * The default object size of the imposter
  19662. */
  19663. static DEFAULT_OBJECT_SIZE: Vector3;
  19664. /**
  19665. * The identity quaternion of the imposter
  19666. */
  19667. static IDENTITY_QUATERNION: Quaternion;
  19668. /** @hidden */ pluginData: any;
  19669. private _physicsEngine;
  19670. private _physicsBody;
  19671. private _bodyUpdateRequired;
  19672. private _onBeforePhysicsStepCallbacks;
  19673. private _onAfterPhysicsStepCallbacks;
  19674. /** @hidden */ onPhysicsCollideCallbacks: Array<{
  19675. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19676. otherImpostors: Array<PhysicsImpostor>;
  19677. }>;
  19678. private _deltaPosition;
  19679. private _deltaRotation;
  19680. private _deltaRotationConjugated;
  19681. /** hidden */ isFromLine: boolean;
  19682. private _parent;
  19683. private _isDisposed;
  19684. private static _tmpVecs;
  19685. private static _tmpQuat;
  19686. /**
  19687. * Specifies if the physics imposter is disposed
  19688. */
  19689. readonly isDisposed: boolean;
  19690. /**
  19691. * Gets the mass of the physics imposter
  19692. */
  19693. mass: number;
  19694. /**
  19695. * Gets the coefficient of friction
  19696. */
  19697. /**
  19698. * Sets the coefficient of friction
  19699. */
  19700. friction: number;
  19701. /**
  19702. * Gets the coefficient of restitution
  19703. */
  19704. /**
  19705. * Sets the coefficient of restitution
  19706. */
  19707. restitution: number;
  19708. /**
  19709. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  19710. */
  19711. /**
  19712. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  19713. */
  19714. pressure: number;
  19715. /**
  19716. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19717. */
  19718. /**
  19719. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  19720. */
  19721. stiffness: number;
  19722. /**
  19723. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19724. */
  19725. /**
  19726. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  19727. */
  19728. velocityIterations: number;
  19729. /**
  19730. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19731. */
  19732. /**
  19733. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  19734. */
  19735. positionIterations: number;
  19736. /**
  19737. * The unique id of the physics imposter
  19738. * set by the physics engine when adding this impostor to the array
  19739. */
  19740. uniqueId: number;
  19741. /**
  19742. * @hidden
  19743. */
  19744. soft: boolean;
  19745. /**
  19746. * @hidden
  19747. */
  19748. segments: number;
  19749. private _joints;
  19750. /**
  19751. * Initializes the physics imposter
  19752. * @param object The physics-enabled object used as the physics imposter
  19753. * @param type The type of the physics imposter
  19754. * @param _options The options for the physics imposter
  19755. * @param _scene The Babylon scene
  19756. */
  19757. constructor(
  19758. /**
  19759. * The physics-enabled object used as the physics imposter
  19760. */
  19761. object: IPhysicsEnabledObject,
  19762. /**
  19763. * The type of the physics imposter
  19764. */
  19765. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  19766. /**
  19767. * This function will completly initialize this impostor.
  19768. * It will create a new body - but only if this mesh has no parent.
  19769. * If it has, this impostor will not be used other than to define the impostor
  19770. * of the child mesh.
  19771. * @hidden
  19772. */ init(): void;
  19773. private _getPhysicsParent;
  19774. /**
  19775. * Should a new body be generated.
  19776. * @returns boolean specifying if body initialization is required
  19777. */
  19778. isBodyInitRequired(): boolean;
  19779. /**
  19780. * Sets the updated scaling
  19781. * @param updated Specifies if the scaling is updated
  19782. */
  19783. setScalingUpdated(): void;
  19784. /**
  19785. * Force a regeneration of this or the parent's impostor's body.
  19786. * Use under cautious - This will remove all joints already implemented.
  19787. */
  19788. forceUpdate(): void;
  19789. /**
  19790. * Gets the body that holds this impostor. Either its own, or its parent.
  19791. */
  19792. /**
  19793. * Set the physics body. Used mainly by the physics engine/plugin
  19794. */
  19795. physicsBody: any;
  19796. /**
  19797. * Get the parent of the physics imposter
  19798. * @returns Physics imposter or null
  19799. */
  19800. /**
  19801. * Sets the parent of the physics imposter
  19802. */
  19803. parent: Nullable<PhysicsImpostor>;
  19804. /**
  19805. * Resets the update flags
  19806. */
  19807. resetUpdateFlags(): void;
  19808. /**
  19809. * Gets the object extend size
  19810. * @returns the object extend size
  19811. */
  19812. getObjectExtendSize(): Vector3;
  19813. /**
  19814. * Gets the object center
  19815. * @returns The object center
  19816. */
  19817. getObjectCenter(): Vector3;
  19818. /**
  19819. * Get a specific parametes from the options parameter
  19820. * @param paramName The object parameter name
  19821. * @returns The object parameter
  19822. */
  19823. getParam(paramName: string): any;
  19824. /**
  19825. * Sets a specific parameter in the options given to the physics plugin
  19826. * @param paramName The parameter name
  19827. * @param value The value of the parameter
  19828. */
  19829. setParam(paramName: string, value: number): void;
  19830. /**
  19831. * Specifically change the body's mass option. Won't recreate the physics body object
  19832. * @param mass The mass of the physics imposter
  19833. */
  19834. setMass(mass: number): void;
  19835. /**
  19836. * Gets the linear velocity
  19837. * @returns linear velocity or null
  19838. */
  19839. getLinearVelocity(): Nullable<Vector3>;
  19840. /**
  19841. * Sets the linear velocity
  19842. * @param velocity linear velocity or null
  19843. */
  19844. setLinearVelocity(velocity: Nullable<Vector3>): void;
  19845. /**
  19846. * Gets the angular velocity
  19847. * @returns angular velocity or null
  19848. */
  19849. getAngularVelocity(): Nullable<Vector3>;
  19850. /**
  19851. * Sets the angular velocity
  19852. * @param velocity The velocity or null
  19853. */
  19854. setAngularVelocity(velocity: Nullable<Vector3>): void;
  19855. /**
  19856. * Execute a function with the physics plugin native code
  19857. * Provide a function the will have two variables - the world object and the physics body object
  19858. * @param func The function to execute with the physics plugin native code
  19859. */
  19860. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  19861. /**
  19862. * Register a function that will be executed before the physics world is stepping forward
  19863. * @param func The function to execute before the physics world is stepped forward
  19864. */
  19865. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19866. /**
  19867. * Unregister a function that will be executed before the physics world is stepping forward
  19868. * @param func The function to execute before the physics world is stepped forward
  19869. */
  19870. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19871. /**
  19872. * Register a function that will be executed after the physics step
  19873. * @param func The function to execute after physics step
  19874. */
  19875. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19876. /**
  19877. * Unregisters a function that will be executed after the physics step
  19878. * @param func The function to execute after physics step
  19879. */
  19880. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  19881. /**
  19882. * register a function that will be executed when this impostor collides against a different body
  19883. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  19884. * @param func Callback that is executed on collision
  19885. */
  19886. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  19887. /**
  19888. * Unregisters the physics imposter on contact
  19889. * @param collideAgainst The physics object to collide against
  19890. * @param func Callback to execute on collision
  19891. */
  19892. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  19893. private _tmpQuat;
  19894. private _tmpQuat2;
  19895. /**
  19896. * Get the parent rotation
  19897. * @returns The parent rotation
  19898. */
  19899. getParentsRotation(): Quaternion;
  19900. /**
  19901. * this function is executed by the physics engine.
  19902. */
  19903. beforeStep: () => void;
  19904. /**
  19905. * this function is executed by the physics engine
  19906. */
  19907. afterStep: () => void;
  19908. /**
  19909. * Legacy collision detection event support
  19910. */
  19911. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  19912. /**
  19913. * event and body object due to cannon's event-based architecture.
  19914. */
  19915. onCollide: (e: {
  19916. body: any;
  19917. }) => void;
  19918. /**
  19919. * Apply a force
  19920. * @param force The force to apply
  19921. * @param contactPoint The contact point for the force
  19922. * @returns The physics imposter
  19923. */
  19924. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19925. /**
  19926. * Apply an impulse
  19927. * @param force The impulse force
  19928. * @param contactPoint The contact point for the impulse force
  19929. * @returns The physics imposter
  19930. */
  19931. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  19932. /**
  19933. * A help function to create a joint
  19934. * @param otherImpostor A physics imposter used to create a joint
  19935. * @param jointType The type of joint
  19936. * @param jointData The data for the joint
  19937. * @returns The physics imposter
  19938. */
  19939. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  19940. /**
  19941. * Add a joint to this impostor with a different impostor
  19942. * @param otherImpostor A physics imposter used to add a joint
  19943. * @param joint The joint to add
  19944. * @returns The physics imposter
  19945. */
  19946. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  19947. /**
  19948. * Add an anchor to a cloth impostor
  19949. * @param otherImpostor rigid impostor to anchor to
  19950. * @param width ratio across width from 0 to 1
  19951. * @param height ratio up height from 0 to 1
  19952. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  19953. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  19954. * @returns impostor the soft imposter
  19955. */
  19956. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19957. /**
  19958. * Add a hook to a rope impostor
  19959. * @param otherImpostor rigid impostor to anchor to
  19960. * @param length ratio across rope from 0 to 1
  19961. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  19962. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  19963. * @returns impostor the rope imposter
  19964. */
  19965. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  19966. /**
  19967. * Will keep this body still, in a sleep mode.
  19968. * @returns the physics imposter
  19969. */
  19970. sleep(): PhysicsImpostor;
  19971. /**
  19972. * Wake the body up.
  19973. * @returns The physics imposter
  19974. */
  19975. wakeUp(): PhysicsImpostor;
  19976. /**
  19977. * Clones the physics imposter
  19978. * @param newObject The physics imposter clones to this physics-enabled object
  19979. * @returns A nullable physics imposter
  19980. */
  19981. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19982. /**
  19983. * Disposes the physics imposter
  19984. */
  19985. dispose(): void;
  19986. /**
  19987. * Sets the delta position
  19988. * @param position The delta position amount
  19989. */
  19990. setDeltaPosition(position: Vector3): void;
  19991. /**
  19992. * Sets the delta rotation
  19993. * @param rotation The delta rotation amount
  19994. */
  19995. setDeltaRotation(rotation: Quaternion): void;
  19996. /**
  19997. * Gets the box size of the physics imposter and stores the result in the input parameter
  19998. * @param result Stores the box size
  19999. * @returns The physics imposter
  20000. */
  20001. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20002. /**
  20003. * Gets the radius of the physics imposter
  20004. * @returns Radius of the physics imposter
  20005. */
  20006. getRadius(): number;
  20007. /**
  20008. * Sync a bone with this impostor
  20009. * @param bone The bone to sync to the impostor.
  20010. * @param boneMesh The mesh that the bone is influencing.
  20011. * @param jointPivot The pivot of the joint / bone in local space.
  20012. * @param distToJoint Optional distance from the impostor to the joint.
  20013. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20014. */
  20015. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20016. /**
  20017. * Sync impostor to a bone
  20018. * @param bone The bone that the impostor will be synced to.
  20019. * @param boneMesh The mesh that the bone is influencing.
  20020. * @param jointPivot The pivot of the joint / bone in local space.
  20021. * @param distToJoint Optional distance from the impostor to the joint.
  20022. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20023. * @param boneAxis Optional vector3 axis the bone is aligned with
  20024. */
  20025. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20026. /**
  20027. * No-Imposter type
  20028. */
  20029. static NoImpostor: number;
  20030. /**
  20031. * Sphere-Imposter type
  20032. */
  20033. static SphereImpostor: number;
  20034. /**
  20035. * Box-Imposter type
  20036. */
  20037. static BoxImpostor: number;
  20038. /**
  20039. * Plane-Imposter type
  20040. */
  20041. static PlaneImpostor: number;
  20042. /**
  20043. * Mesh-imposter type
  20044. */
  20045. static MeshImpostor: number;
  20046. /**
  20047. * Cylinder-Imposter type
  20048. */
  20049. static CylinderImpostor: number;
  20050. /**
  20051. * Particle-Imposter type
  20052. */
  20053. static ParticleImpostor: number;
  20054. /**
  20055. * Heightmap-Imposter type
  20056. */
  20057. static HeightmapImpostor: number;
  20058. /**
  20059. * ConvexHull-Impostor type (Ammo.js plugin only)
  20060. */
  20061. static ConvexHullImpostor: number;
  20062. /**
  20063. * Rope-Imposter type
  20064. */
  20065. static RopeImpostor: number;
  20066. /**
  20067. * Cloth-Imposter type
  20068. */
  20069. static ClothImpostor: number;
  20070. /**
  20071. * Softbody-Imposter type
  20072. */
  20073. static SoftbodyImpostor: number;
  20074. }
  20075. }
  20076. declare module BABYLON {
  20077. /**
  20078. * Class used to represent a specific level of detail of a mesh
  20079. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20080. */
  20081. export class MeshLODLevel {
  20082. /** Defines the distance where this level should star being displayed */
  20083. distance: number;
  20084. /** Defines the mesh to use to render this level */
  20085. mesh: Nullable<Mesh>;
  20086. /**
  20087. * Creates a new LOD level
  20088. * @param distance defines the distance where this level should star being displayed
  20089. * @param mesh defines the mesh to use to render this level
  20090. */
  20091. constructor(
  20092. /** Defines the distance where this level should star being displayed */
  20093. distance: number,
  20094. /** Defines the mesh to use to render this level */
  20095. mesh: Nullable<Mesh>);
  20096. }
  20097. /**
  20098. * @hidden
  20099. **/
  20100. export class _CreationDataStorage {
  20101. closePath?: boolean;
  20102. closeArray?: boolean;
  20103. idx: number[];
  20104. dashSize: number;
  20105. gapSize: number;
  20106. path3D: Path3D;
  20107. pathArray: Vector3[][];
  20108. arc: number;
  20109. radius: number;
  20110. cap: number;
  20111. tessellation: number;
  20112. }
  20113. /**
  20114. * @hidden
  20115. **/ private class _InstanceDataStorage {
  20116. visibleInstances: any;
  20117. renderIdForInstances: number[];
  20118. batchCache: _InstancesBatch;
  20119. instancesBufferSize: number;
  20120. instancesBuffer: Nullable<Buffer>;
  20121. instancesData: Float32Array;
  20122. overridenInstanceCount: number;
  20123. }
  20124. /**
  20125. * @hidden
  20126. **/
  20127. export class _InstancesBatch {
  20128. mustReturn: boolean;
  20129. visibleInstances: Nullable<InstancedMesh[]>[];
  20130. renderSelf: boolean[];
  20131. }
  20132. /**
  20133. * Class used to represent renderable models
  20134. */
  20135. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20136. /**
  20137. * Mesh side orientation : usually the external or front surface
  20138. */
  20139. static readonly FRONTSIDE: number;
  20140. /**
  20141. * Mesh side orientation : usually the internal or back surface
  20142. */
  20143. static readonly BACKSIDE: number;
  20144. /**
  20145. * Mesh side orientation : both internal and external or front and back surfaces
  20146. */
  20147. static readonly DOUBLESIDE: number;
  20148. /**
  20149. * Mesh side orientation : by default, `FRONTSIDE`
  20150. */
  20151. static readonly DEFAULTSIDE: number;
  20152. /**
  20153. * Mesh cap setting : no cap
  20154. */
  20155. static readonly NO_CAP: number;
  20156. /**
  20157. * Mesh cap setting : one cap at the beginning of the mesh
  20158. */
  20159. static readonly CAP_START: number;
  20160. /**
  20161. * Mesh cap setting : one cap at the end of the mesh
  20162. */
  20163. static readonly CAP_END: number;
  20164. /**
  20165. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20166. */
  20167. static readonly CAP_ALL: number;
  20168. /**
  20169. * Gets the default side orientation.
  20170. * @param orientation the orientation to value to attempt to get
  20171. * @returns the default orientation
  20172. * @hidden
  20173. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20174. private _onBeforeRenderObservable;
  20175. private _onBeforeBindObservable;
  20176. private _onAfterRenderObservable;
  20177. private _onBeforeDrawObservable;
  20178. /**
  20179. * An event triggered before rendering the mesh
  20180. */
  20181. readonly onBeforeRenderObservable: Observable<Mesh>;
  20182. /**
  20183. * An event triggered before binding the mesh
  20184. */
  20185. readonly onBeforeBindObservable: Observable<Mesh>;
  20186. /**
  20187. * An event triggered after rendering the mesh
  20188. */
  20189. readonly onAfterRenderObservable: Observable<Mesh>;
  20190. /**
  20191. * An event triggered before drawing the mesh
  20192. */
  20193. readonly onBeforeDrawObservable: Observable<Mesh>;
  20194. private _onBeforeDrawObserver;
  20195. /**
  20196. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20197. */
  20198. onBeforeDraw: () => void;
  20199. /**
  20200. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20201. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20202. */
  20203. delayLoadState: number;
  20204. /**
  20205. * Gets the list of instances created from this mesh
  20206. * it is not supposed to be modified manually.
  20207. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20208. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20209. */
  20210. instances: InstancedMesh[];
  20211. /**
  20212. * Gets the file containing delay loading data for this mesh
  20213. */
  20214. delayLoadingFile: string;
  20215. /** @hidden */ binaryInfo: any;
  20216. private _LODLevels;
  20217. /**
  20218. * User defined function used to change how LOD level selection is done
  20219. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20220. */
  20221. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20222. private _morphTargetManager;
  20223. /**
  20224. * Gets or sets the morph target manager
  20225. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20226. */
  20227. morphTargetManager: Nullable<MorphTargetManager>;
  20228. /** @hidden */ creationDataStorage: Nullable<_CreationDataStorage>;
  20229. /** @hidden */ geometry: Nullable<Geometry>;
  20230. /** @hidden */ delayInfo: Array<string>;
  20231. /** @hidden */ delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20232. /** @hidden */ instanceDataStorage: _InstanceDataStorage;
  20233. private _effectiveMaterial;
  20234. /** @hidden */ shouldGenerateFlatShading: boolean;
  20235. private _preActivateId;
  20236. /** @hidden */ originalBuilderSideOrientation: number;
  20237. /**
  20238. * Use this property to change the original side orientation defined at construction time
  20239. */
  20240. overrideMaterialSideOrientation: Nullable<number>;
  20241. private _areNormalsFrozen;
  20242. private _sourcePositions;
  20243. private _sourceNormals;
  20244. private _source;
  20245. private meshMap;
  20246. /**
  20247. * Gets the source mesh (the one used to clone this one from)
  20248. */
  20249. readonly source: Nullable<Mesh>;
  20250. /**
  20251. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20252. */
  20253. isUnIndexed: boolean;
  20254. /**
  20255. * @constructor
  20256. * @param name The value used by scene.getMeshByName() to do a lookup.
  20257. * @param scene The scene to add this mesh to.
  20258. * @param parent The parent of this mesh, if it has one
  20259. * @param source An optional Mesh from which geometry is shared, cloned.
  20260. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20261. * When false, achieved by calling a clone(), also passing False.
  20262. * This will make creation of children, recursive.
  20263. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20264. */
  20265. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20266. /**
  20267. * Gets the class name
  20268. * @returns the string "Mesh".
  20269. */
  20270. getClassName(): string;
  20271. /** @hidden */ protected readonly _isMesh: boolean;
  20272. /**
  20273. * Returns a description of this mesh
  20274. * @param fullDetails define if full details about this mesh must be used
  20275. * @returns a descriptive string representing this mesh
  20276. */
  20277. toString(fullDetails?: boolean): string;
  20278. /** @hidden */ unBindEffect(): void;
  20279. /**
  20280. * Gets a boolean indicating if this mesh has LOD
  20281. */
  20282. readonly hasLODLevels: boolean;
  20283. /**
  20284. * Gets the list of MeshLODLevel associated with the current mesh
  20285. * @returns an array of MeshLODLevel
  20286. */
  20287. getLODLevels(): MeshLODLevel[];
  20288. private _sortLODLevels;
  20289. /**
  20290. * Add a mesh as LOD level triggered at the given distance.
  20291. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20292. * @param distance The distance from the center of the object to show this level
  20293. * @param mesh The mesh to be added as LOD level (can be null)
  20294. * @return This mesh (for chaining)
  20295. */
  20296. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20297. /**
  20298. * Returns the LOD level mesh at the passed distance or null if not found.
  20299. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20300. * @param distance The distance from the center of the object to show this level
  20301. * @returns a Mesh or `null`
  20302. */
  20303. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20304. /**
  20305. * Remove a mesh from the LOD array
  20306. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20307. * @param mesh defines the mesh to be removed
  20308. * @return This mesh (for chaining)
  20309. */
  20310. removeLODLevel(mesh: Mesh): Mesh;
  20311. /**
  20312. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20313. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20314. * @param camera defines the camera to use to compute distance
  20315. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20316. * @return This mesh (for chaining)
  20317. */
  20318. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20319. /**
  20320. * Gets the mesh internal Geometry object
  20321. */
  20322. readonly geometry: Nullable<Geometry>;
  20323. /**
  20324. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20325. * @returns the total number of vertices
  20326. */
  20327. getTotalVertices(): number;
  20328. /**
  20329. * Returns the content of an associated vertex buffer
  20330. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20331. * - VertexBuffer.PositionKind
  20332. * - VertexBuffer.UVKind
  20333. * - VertexBuffer.UV2Kind
  20334. * - VertexBuffer.UV3Kind
  20335. * - VertexBuffer.UV4Kind
  20336. * - VertexBuffer.UV5Kind
  20337. * - VertexBuffer.UV6Kind
  20338. * - VertexBuffer.ColorKind
  20339. * - VertexBuffer.MatricesIndicesKind
  20340. * - VertexBuffer.MatricesIndicesExtraKind
  20341. * - VertexBuffer.MatricesWeightsKind
  20342. * - VertexBuffer.MatricesWeightsExtraKind
  20343. * @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
  20344. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20345. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20346. */
  20347. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20348. /**
  20349. * Returns the mesh VertexBuffer object from the requested `kind`
  20350. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20351. * - VertexBuffer.PositionKind
  20352. * - VertexBuffer.UVKind
  20353. * - VertexBuffer.UV2Kind
  20354. * - VertexBuffer.UV3Kind
  20355. * - VertexBuffer.UV4Kind
  20356. * - VertexBuffer.UV5Kind
  20357. * - VertexBuffer.UV6Kind
  20358. * - VertexBuffer.ColorKind
  20359. * - VertexBuffer.MatricesIndicesKind
  20360. * - VertexBuffer.MatricesIndicesExtraKind
  20361. * - VertexBuffer.MatricesWeightsKind
  20362. * - VertexBuffer.MatricesWeightsExtraKind
  20363. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20364. */
  20365. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20366. /**
  20367. * Tests if a specific vertex buffer is associated with this mesh
  20368. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20369. * - VertexBuffer.PositionKind
  20370. * - VertexBuffer.UVKind
  20371. * - VertexBuffer.UV2Kind
  20372. * - VertexBuffer.UV3Kind
  20373. * - VertexBuffer.UV4Kind
  20374. * - VertexBuffer.UV5Kind
  20375. * - VertexBuffer.UV6Kind
  20376. * - VertexBuffer.ColorKind
  20377. * - VertexBuffer.MatricesIndicesKind
  20378. * - VertexBuffer.MatricesIndicesExtraKind
  20379. * - VertexBuffer.MatricesWeightsKind
  20380. * - VertexBuffer.MatricesWeightsExtraKind
  20381. * @returns a boolean
  20382. */
  20383. isVerticesDataPresent(kind: string): boolean;
  20384. /**
  20385. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20386. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20387. * - VertexBuffer.PositionKind
  20388. * - VertexBuffer.UVKind
  20389. * - VertexBuffer.UV2Kind
  20390. * - VertexBuffer.UV3Kind
  20391. * - VertexBuffer.UV4Kind
  20392. * - VertexBuffer.UV5Kind
  20393. * - VertexBuffer.UV6Kind
  20394. * - VertexBuffer.ColorKind
  20395. * - VertexBuffer.MatricesIndicesKind
  20396. * - VertexBuffer.MatricesIndicesExtraKind
  20397. * - VertexBuffer.MatricesWeightsKind
  20398. * - VertexBuffer.MatricesWeightsExtraKind
  20399. * @returns a boolean
  20400. */
  20401. isVertexBufferUpdatable(kind: string): boolean;
  20402. /**
  20403. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20404. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20405. * - VertexBuffer.PositionKind
  20406. * - VertexBuffer.UVKind
  20407. * - VertexBuffer.UV2Kind
  20408. * - VertexBuffer.UV3Kind
  20409. * - VertexBuffer.UV4Kind
  20410. * - VertexBuffer.UV5Kind
  20411. * - VertexBuffer.UV6Kind
  20412. * - VertexBuffer.ColorKind
  20413. * - VertexBuffer.MatricesIndicesKind
  20414. * - VertexBuffer.MatricesIndicesExtraKind
  20415. * - VertexBuffer.MatricesWeightsKind
  20416. * - VertexBuffer.MatricesWeightsExtraKind
  20417. * @returns an array of strings
  20418. */
  20419. getVerticesDataKinds(): string[];
  20420. /**
  20421. * Returns a positive integer : the total number of indices in this mesh geometry.
  20422. * @returns the numner of indices or zero if the mesh has no geometry.
  20423. */
  20424. getTotalIndices(): number;
  20425. /**
  20426. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20427. * @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.
  20428. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20429. * @returns the indices array or an empty array if the mesh has no geometry
  20430. */
  20431. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20432. readonly isBlocked: boolean;
  20433. /**
  20434. * Determine if the current mesh is ready to be rendered
  20435. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20436. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20437. * @returns true if all associated assets are ready (material, textures, shaders)
  20438. */
  20439. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20440. /**
  20441. * 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.
  20442. */
  20443. readonly areNormalsFrozen: boolean;
  20444. /**
  20445. * 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.
  20446. * @returns the current mesh
  20447. */
  20448. freezeNormals(): Mesh;
  20449. /**
  20450. * 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
  20451. * @returns the current mesh
  20452. */
  20453. unfreezeNormals(): Mesh;
  20454. /**
  20455. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20456. */
  20457. overridenInstanceCount: number;
  20458. /** @hidden */ preActivate(): Mesh;
  20459. /** @hidden */ preActivateForIntermediateRendering(renderId: number): Mesh;
  20460. /** @hidden */ registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20461. /**
  20462. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20463. * This means the mesh underlying bounding box and sphere are recomputed.
  20464. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20465. * @returns the current mesh
  20466. */
  20467. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20468. /** @hidden */ createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20469. /**
  20470. * This function will subdivide the mesh into multiple submeshes
  20471. * @param count defines the expected number of submeshes
  20472. */
  20473. subdivide(count: number): void;
  20474. /**
  20475. * Copy a FloatArray into a specific associated vertex buffer
  20476. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20477. * - VertexBuffer.PositionKind
  20478. * - VertexBuffer.UVKind
  20479. * - VertexBuffer.UV2Kind
  20480. * - VertexBuffer.UV3Kind
  20481. * - VertexBuffer.UV4Kind
  20482. * - VertexBuffer.UV5Kind
  20483. * - VertexBuffer.UV6Kind
  20484. * - VertexBuffer.ColorKind
  20485. * - VertexBuffer.MatricesIndicesKind
  20486. * - VertexBuffer.MatricesIndicesExtraKind
  20487. * - VertexBuffer.MatricesWeightsKind
  20488. * - VertexBuffer.MatricesWeightsExtraKind
  20489. * @param data defines the data source
  20490. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20491. * @param stride defines the data stride size (can be null)
  20492. * @returns the current mesh
  20493. */
  20494. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20495. /**
  20496. * Flags an associated vertex buffer as updatable
  20497. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20498. * - VertexBuffer.PositionKind
  20499. * - VertexBuffer.UVKind
  20500. * - VertexBuffer.UV2Kind
  20501. * - VertexBuffer.UV3Kind
  20502. * - VertexBuffer.UV4Kind
  20503. * - VertexBuffer.UV5Kind
  20504. * - VertexBuffer.UV6Kind
  20505. * - VertexBuffer.ColorKind
  20506. * - VertexBuffer.MatricesIndicesKind
  20507. * - VertexBuffer.MatricesIndicesExtraKind
  20508. * - VertexBuffer.MatricesWeightsKind
  20509. * - VertexBuffer.MatricesWeightsExtraKind
  20510. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20511. */
  20512. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20513. /**
  20514. * Sets the mesh global Vertex Buffer
  20515. * @param buffer defines the buffer to use
  20516. * @returns the current mesh
  20517. */
  20518. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20519. /**
  20520. * Update a specific associated vertex buffer
  20521. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20522. * - VertexBuffer.PositionKind
  20523. * - VertexBuffer.UVKind
  20524. * - VertexBuffer.UV2Kind
  20525. * - VertexBuffer.UV3Kind
  20526. * - VertexBuffer.UV4Kind
  20527. * - VertexBuffer.UV5Kind
  20528. * - VertexBuffer.UV6Kind
  20529. * - VertexBuffer.ColorKind
  20530. * - VertexBuffer.MatricesIndicesKind
  20531. * - VertexBuffer.MatricesIndicesExtraKind
  20532. * - VertexBuffer.MatricesWeightsKind
  20533. * - VertexBuffer.MatricesWeightsExtraKind
  20534. * @param data defines the data source
  20535. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20536. * @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)
  20537. * @returns the current mesh
  20538. */
  20539. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20540. /**
  20541. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20542. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20543. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20544. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20545. * @returns the current mesh
  20546. */
  20547. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20548. /**
  20549. * Creates a un-shared specific occurence of the geometry for the mesh.
  20550. * @returns the current mesh
  20551. */
  20552. makeGeometryUnique(): Mesh;
  20553. /**
  20554. * Set the index buffer of this mesh
  20555. * @param indices defines the source data
  20556. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20557. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20558. * @returns the current mesh
  20559. */
  20560. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20561. /**
  20562. * Update the current index buffer
  20563. * @param indices defines the source data
  20564. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20565. * @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)
  20566. * @returns the current mesh
  20567. */
  20568. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20569. /**
  20570. * Invert the geometry to move from a right handed system to a left handed one.
  20571. * @returns the current mesh
  20572. */
  20573. toLeftHanded(): Mesh;
  20574. /** @hidden */ bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20575. /** @hidden */ draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20576. /**
  20577. * Registers for this mesh a javascript function called just before the rendering process
  20578. * @param func defines the function to call before rendering this mesh
  20579. * @returns the current mesh
  20580. */
  20581. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20582. /**
  20583. * Disposes a previously registered javascript function called before the rendering
  20584. * @param func defines the function to remove
  20585. * @returns the current mesh
  20586. */
  20587. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20588. /**
  20589. * Registers for this mesh a javascript function called just after the rendering is complete
  20590. * @param func defines the function to call after rendering this mesh
  20591. * @returns the current mesh
  20592. */
  20593. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20594. /**
  20595. * Disposes a previously registered javascript function called after the rendering.
  20596. * @param func defines the function to remove
  20597. * @returns the current mesh
  20598. */
  20599. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20600. /** @hidden */ getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20601. /** @hidden */ renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20602. /** @hidden */ processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20603. /**
  20604. * 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
  20605. * @param subMesh defines the subMesh to render
  20606. * @param enableAlphaMode defines if alpha mode can be changed
  20607. * @returns the current mesh
  20608. */
  20609. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20610. private _onBeforeDraw;
  20611. /**
  20612. * Renormalize the mesh and patch it up if there are no weights
  20613. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20614. * However in the case of zero weights then we set just a single influence to 1.
  20615. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20616. */
  20617. cleanMatrixWeights(): void;
  20618. private normalizeSkinFourWeights;
  20619. private normalizeSkinWeightsAndExtra;
  20620. /**
  20621. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20622. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20623. * the user know there was an issue with importing the mesh
  20624. * @returns a validation object with skinned, valid and report string
  20625. */
  20626. validateSkinning(): {
  20627. skinned: boolean;
  20628. valid: boolean;
  20629. report: string;
  20630. };
  20631. /** @hidden */ checkDelayState(): Mesh;
  20632. private _queueLoad;
  20633. /**
  20634. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20635. * A mesh is in the frustum if its bounding box intersects the frustum
  20636. * @param frustumPlanes defines the frustum to test
  20637. * @returns true if the mesh is in the frustum planes
  20638. */
  20639. isInFrustum(frustumPlanes: Plane[]): boolean;
  20640. /**
  20641. * Sets the mesh material by the material or multiMaterial `id` property
  20642. * @param id is a string identifying the material or the multiMaterial
  20643. * @returns the current mesh
  20644. */
  20645. setMaterialByID(id: string): Mesh;
  20646. /**
  20647. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20648. * @returns an array of IAnimatable
  20649. */
  20650. getAnimatables(): IAnimatable[];
  20651. /**
  20652. * Modifies the mesh geometry according to the passed transformation matrix.
  20653. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20654. * The mesh normals are modified using the same transformation.
  20655. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20656. * @param transform defines the transform matrix to use
  20657. * @see http://doc.babylonjs.com/resources/baking_transformations
  20658. * @returns the current mesh
  20659. */
  20660. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20661. /**
  20662. * Modifies the mesh geometry according to its own current World Matrix.
  20663. * The mesh World Matrix is then reset.
  20664. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20665. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20666. * @see http://doc.babylonjs.com/resources/baking_transformations
  20667. * @returns the current mesh
  20668. */
  20669. bakeCurrentTransformIntoVertices(): Mesh;
  20670. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20671. /** @hidden */ resetPointsArrayCache(): Mesh;
  20672. /** @hidden */ generatePointsArray(): boolean;
  20673. /**
  20674. * Returns a new Mesh object generated from the current mesh properties.
  20675. * This method must not get confused with createInstance()
  20676. * @param name is a string, the name given to the new mesh
  20677. * @param newParent can be any Node object (default `null`)
  20678. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20679. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  20680. * @returns a new mesh
  20681. */
  20682. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  20683. /**
  20684. * Releases resources associated with this mesh.
  20685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20687. */
  20688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  20689. /**
  20690. * Modifies the mesh geometry according to a displacement map.
  20691. * 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.
  20692. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20693. * @param url is a string, the URL from the image file is to be downloaded.
  20694. * @param minHeight is the lower limit of the displacement.
  20695. * @param maxHeight is the upper limit of the displacement.
  20696. * @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.
  20697. * @param uvOffset is an optional vector2 used to offset UV.
  20698. * @param uvScale is an optional vector2 used to scale UV.
  20699. * @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.
  20700. * @returns the Mesh.
  20701. */
  20702. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20703. /**
  20704. * Modifies the mesh geometry according to a displacementMap buffer.
  20705. * 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.
  20706. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  20707. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  20708. * @param heightMapWidth is the width of the buffer image.
  20709. * @param heightMapHeight is the height of the buffer image.
  20710. * @param minHeight is the lower limit of the displacement.
  20711. * @param maxHeight is the upper limit of the displacement.
  20712. * @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.
  20713. * @param uvOffset is an optional vector2 used to offset UV.
  20714. * @param uvScale is an optional vector2 used to scale UV.
  20715. * @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.
  20716. * @returns the Mesh.
  20717. */
  20718. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  20719. /**
  20720. * Modify the mesh to get a flat shading rendering.
  20721. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  20722. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  20723. * @returns current mesh
  20724. */
  20725. convertToFlatShadedMesh(): Mesh;
  20726. /**
  20727. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  20728. * In other words, more vertices, no more indices and a single bigger VBO.
  20729. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  20730. * @returns current mesh
  20731. */
  20732. convertToUnIndexedMesh(): Mesh;
  20733. /**
  20734. * Inverses facet orientations.
  20735. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20736. * @param flipNormals will also inverts the normals
  20737. * @returns current mesh
  20738. */
  20739. flipFaces(flipNormals?: boolean): Mesh;
  20740. /**
  20741. * Increase the number of facets and hence vertices in a mesh
  20742. * Vertex normals are interpolated from existing vertex normals
  20743. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20744. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  20745. */
  20746. increaseVertices(numberPerEdge: number): void;
  20747. /**
  20748. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  20749. * This will undo any application of covertToFlatShadedMesh
  20750. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  20751. */
  20752. forceSharedVertices(): void;
  20753. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  20754. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  20755. /**
  20756. * Creates a new InstancedMesh object from the mesh model.
  20757. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20758. * @param name defines the name of the new instance
  20759. * @returns a new InstancedMesh
  20760. */
  20761. createInstance(name: string): InstancedMesh;
  20762. /**
  20763. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  20764. * After this call, all the mesh instances have the same submeshes than the current mesh.
  20765. * @returns the current mesh
  20766. */
  20767. synchronizeInstances(): Mesh;
  20768. /**
  20769. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  20770. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  20771. * This should be used together with the simplification to avoid disappearing triangles.
  20772. * @param successCallback an optional success callback to be called after the optimization finished.
  20773. * @returns the current mesh
  20774. */
  20775. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  20776. /**
  20777. * Serialize current mesh
  20778. * @param serializationObject defines the object which will receive the serialization data
  20779. */
  20780. serialize(serializationObject: any): void;
  20781. /** @hidden */ syncGeometryWithMorphTargetManager(): void;
  20782. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  20783. /**
  20784. * Returns a new Mesh object parsed from the source provided.
  20785. * @param parsedMesh is the source
  20786. * @param scene defines the hosting scene
  20787. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  20788. * @returns a new Mesh
  20789. */
  20790. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  20791. /**
  20792. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  20793. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20794. * @param name defines the name of the mesh to create
  20795. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  20796. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  20797. * @param closePath creates a seam between the first and the last points of each path of the path array
  20798. * @param offset is taken in account only if the `pathArray` is containing a single path
  20799. * @param scene defines the hosting scene
  20800. * @param updatable defines if the mesh must be flagged as updatable
  20801. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20802. * @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)
  20803. * @returns a new Mesh
  20804. */
  20805. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20806. /**
  20807. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  20808. * @param name defines the name of the mesh to create
  20809. * @param radius sets the radius size (float) of the polygon (default 0.5)
  20810. * @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
  20811. * @param scene defines the hosting scene
  20812. * @param updatable defines if the mesh must be flagged as updatable
  20813. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20814. * @returns a new Mesh
  20815. */
  20816. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20817. /**
  20818. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  20819. * @param name defines the name of the mesh to create
  20820. * @param size sets the size (float) of each box side (default 1)
  20821. * @param scene defines the hosting scene
  20822. * @param updatable defines if the mesh must be flagged as updatable
  20823. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20824. * @returns a new Mesh
  20825. */
  20826. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  20827. /**
  20828. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  20829. * @param name defines the name of the mesh to create
  20830. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20831. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20832. * @param scene defines the hosting scene
  20833. * @param updatable defines if the mesh must be flagged as updatable
  20834. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20835. * @returns a new Mesh
  20836. */
  20837. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20838. /**
  20839. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  20840. * @param name defines the name of the mesh to create
  20841. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  20842. * @param diameter sets the diameter size (float) of the sphere (default 1)
  20843. * @param scene defines the hosting scene
  20844. * @returns a new Mesh
  20845. */
  20846. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  20847. /**
  20848. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  20849. * @param name defines the name of the mesh to create
  20850. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  20851. * @param diameterTop set the top cap diameter (floats, default 1)
  20852. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  20853. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  20854. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  20855. * @param scene defines the hosting scene
  20856. * @param updatable defines if the mesh must be flagged as updatable
  20857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20858. * @returns a new Mesh
  20859. */
  20860. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  20861. /**
  20862. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  20863. * @param name defines the name of the mesh to create
  20864. * @param diameter sets the diameter size (float) of the torus (default 1)
  20865. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  20866. * @param tessellation sets the number of torus sides (postive integer, default 16)
  20867. * @param scene defines the hosting scene
  20868. * @param updatable defines if the mesh must be flagged as updatable
  20869. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20870. * @returns a new Mesh
  20871. */
  20872. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20873. /**
  20874. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  20875. * @param name defines the name of the mesh to create
  20876. * @param radius sets the global radius size (float) of the torus knot (default 2)
  20877. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  20878. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  20879. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  20880. * @param p the number of windings on X axis (positive integers, default 2)
  20881. * @param q the number of windings on Y axis (positive integers, default 3)
  20882. * @param scene defines the hosting scene
  20883. * @param updatable defines if the mesh must be flagged as updatable
  20884. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20885. * @returns a new Mesh
  20886. */
  20887. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20888. /**
  20889. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  20890. * @param name defines the name of the mesh to create
  20891. * @param points is an array successive Vector3
  20892. * @param scene defines the hosting scene
  20893. * @param updatable defines if the mesh must be flagged as updatable
  20894. * @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).
  20895. * @returns a new Mesh
  20896. */
  20897. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  20898. /**
  20899. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  20900. * @param name defines the name of the mesh to create
  20901. * @param points is an array successive Vector3
  20902. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  20903. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  20904. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  20905. * @param scene defines the hosting scene
  20906. * @param updatable defines if the mesh must be flagged as updatable
  20907. * @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)
  20908. * @returns a new Mesh
  20909. */
  20910. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  20911. /**
  20912. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  20913. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  20914. * 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.
  20915. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20916. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  20917. * Remember you can only change the shape positions, not their number when updating a polygon.
  20918. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  20919. * @param name defines the name of the mesh to create
  20920. * @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
  20921. * @param scene defines the hosting scene
  20922. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20923. * @param updatable defines if the mesh must be flagged as updatable
  20924. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20925. * @param earcutInjection can be used to inject your own earcut reference
  20926. * @returns a new Mesh
  20927. */
  20928. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20929. /**
  20930. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  20931. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  20932. * @param name defines the name of the mesh to create
  20933. * @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
  20934. * @param depth defines the height of extrusion
  20935. * @param scene defines the hosting scene
  20936. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  20937. * @param updatable defines if the mesh must be flagged as updatable
  20938. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20939. * @param earcutInjection can be used to inject your own earcut reference
  20940. * @returns a new Mesh
  20941. */
  20942. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  20943. /**
  20944. * Creates an extruded shape mesh.
  20945. * 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
  20946. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  20947. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20948. * @param name defines the name of the mesh to create
  20949. * @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
  20950. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20951. * @param scale is the value to scale the shape
  20952. * @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
  20953. * @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
  20954. * @param scene defines the hosting scene
  20955. * @param updatable defines if the mesh must be flagged as updatable
  20956. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20957. * @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)
  20958. * @returns a new Mesh
  20959. */
  20960. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  20961. /**
  20962. * Creates an custom extruded shape mesh.
  20963. * The custom extrusion is a parametric shape.
  20964. * It has no predefined shape. Its final shape will depend on the input parameters.
  20965. * Please consider using the same method from the MeshBuilder class instead
  20966. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  20967. * @param name defines the name of the mesh to create
  20968. * @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
  20969. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  20970. * @param scaleFunction is a custom Javascript function called on each path point
  20971. * @param rotationFunction is a custom Javascript function called on each path point
  20972. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  20973. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  20974. * @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
  20975. * @param scene defines the hosting scene
  20976. * @param updatable defines if the mesh must be flagged as updatable
  20977. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20978. * @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)
  20979. * @returns a new Mesh
  20980. */
  20981. 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;
  20982. /**
  20983. * Creates lathe mesh.
  20984. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  20985. * Please consider using the same method from the MeshBuilder class instead
  20986. * @param name defines the name of the mesh to create
  20987. * @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
  20988. * @param radius is the radius value of the lathe
  20989. * @param tessellation is the side number of the lathe.
  20990. * @param scene defines the hosting scene
  20991. * @param updatable defines if the mesh must be flagged as updatable
  20992. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  20993. * @returns a new Mesh
  20994. */
  20995. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  20996. /**
  20997. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  20998. * @param name defines the name of the mesh to create
  20999. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21000. * @param scene defines the hosting scene
  21001. * @param updatable defines if the mesh must be flagged as updatable
  21002. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21003. * @returns a new Mesh
  21004. */
  21005. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21006. /**
  21007. * Creates a ground mesh.
  21008. * Please consider using the same method from the MeshBuilder class instead
  21009. * @param name defines the name of the mesh to create
  21010. * @param width set the width of the ground
  21011. * @param height set the height of the ground
  21012. * @param subdivisions sets the number of subdivisions per side
  21013. * @param scene defines the hosting scene
  21014. * @param updatable defines if the mesh must be flagged as updatable
  21015. * @returns a new Mesh
  21016. */
  21017. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21018. /**
  21019. * Creates a tiled ground mesh.
  21020. * Please consider using the same method from the MeshBuilder class instead
  21021. * @param name defines the name of the mesh to create
  21022. * @param xmin set the ground minimum X coordinate
  21023. * @param zmin set the ground minimum Y coordinate
  21024. * @param xmax set the ground maximum X coordinate
  21025. * @param zmax set the ground maximum Z coordinate
  21026. * @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
  21027. * @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
  21028. * @param scene defines the hosting scene
  21029. * @param updatable defines if the mesh must be flagged as updatable
  21030. * @returns a new Mesh
  21031. */
  21032. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21033. w: number;
  21034. h: number;
  21035. }, precision: {
  21036. w: number;
  21037. h: number;
  21038. }, scene: Scene, updatable?: boolean): Mesh;
  21039. /**
  21040. * Creates a ground mesh from a height map.
  21041. * Please consider using the same method from the MeshBuilder class instead
  21042. * @see http://doc.babylonjs.com/babylon101/height_map
  21043. * @param name defines the name of the mesh to create
  21044. * @param url sets the URL of the height map image resource
  21045. * @param width set the ground width size
  21046. * @param height set the ground height size
  21047. * @param subdivisions sets the number of subdivision per side
  21048. * @param minHeight is the minimum altitude on the ground
  21049. * @param maxHeight is the maximum altitude on the ground
  21050. * @param scene defines the hosting scene
  21051. * @param updatable defines if the mesh must be flagged as updatable
  21052. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21053. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21054. * @returns a new Mesh
  21055. */
  21056. 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;
  21057. /**
  21058. * Creates a tube mesh.
  21059. * The tube is a parametric shape.
  21060. * It has no predefined shape. Its final shape will depend on the input parameters.
  21061. * Please consider using the same method from the MeshBuilder class instead
  21062. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21063. * @param name defines the name of the mesh to create
  21064. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21065. * @param radius sets the tube radius size
  21066. * @param tessellation is the number of sides on the tubular surface
  21067. * @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
  21068. * @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
  21069. * @param scene defines the hosting scene
  21070. * @param updatable defines if the mesh must be flagged as updatable
  21071. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21072. * @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)
  21073. * @returns a new Mesh
  21074. */
  21075. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21076. (i: number, distance: number): number;
  21077. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21078. /**
  21079. * Creates a polyhedron mesh.
  21080. * Please consider using the same method from the MeshBuilder class instead.
  21081. * * 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
  21082. * * The parameter `size` (positive float, default 1) sets the polygon size
  21083. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21084. * * 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`
  21085. * * 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
  21086. * * 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)`)
  21087. * * 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
  21088. * * 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
  21089. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21090. * * 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
  21091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21092. * @param name defines the name of the mesh to create
  21093. * @param options defines the options used to create the mesh
  21094. * @param scene defines the hosting scene
  21095. * @returns a new Mesh
  21096. */
  21097. static CreatePolyhedron(name: string, options: {
  21098. type?: number;
  21099. size?: number;
  21100. sizeX?: number;
  21101. sizeY?: number;
  21102. sizeZ?: number;
  21103. custom?: any;
  21104. faceUV?: Vector4[];
  21105. faceColors?: Color4[];
  21106. updatable?: boolean;
  21107. sideOrientation?: number;
  21108. }, scene: Scene): Mesh;
  21109. /**
  21110. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21111. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21112. * * 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`)
  21113. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21114. * * 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
  21115. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21116. * * 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
  21117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21118. * @param name defines the name of the mesh
  21119. * @param options defines the options used to create the mesh
  21120. * @param scene defines the hosting scene
  21121. * @returns a new Mesh
  21122. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21123. */
  21124. static CreateIcoSphere(name: string, options: {
  21125. radius?: number;
  21126. flat?: boolean;
  21127. subdivisions?: number;
  21128. sideOrientation?: number;
  21129. updatable?: boolean;
  21130. }, scene: Scene): Mesh;
  21131. /**
  21132. * Creates a decal mesh.
  21133. * Please consider using the same method from the MeshBuilder class instead.
  21134. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21135. * @param name defines the name of the mesh
  21136. * @param sourceMesh defines the mesh receiving the decal
  21137. * @param position sets the position of the decal in world coordinates
  21138. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21139. * @param size sets the decal scaling
  21140. * @param angle sets the angle to rotate the decal
  21141. * @returns a new Mesh
  21142. */
  21143. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21144. /**
  21145. * Prepare internal position array for software CPU skinning
  21146. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21147. */
  21148. setPositionsForCPUSkinning(): Float32Array;
  21149. /**
  21150. * Prepare internal normal array for software CPU skinning
  21151. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21152. */
  21153. setNormalsForCPUSkinning(): Float32Array;
  21154. /**
  21155. * Updates the vertex buffer by applying transformation from the bones
  21156. * @param skeleton defines the skeleton to apply to current mesh
  21157. * @returns the current mesh
  21158. */
  21159. applySkeleton(skeleton: Skeleton): Mesh;
  21160. /**
  21161. * 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
  21162. * @param meshes defines the list of meshes to scan
  21163. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21164. */
  21165. static MinMax(meshes: AbstractMesh[]): {
  21166. min: Vector3;
  21167. max: Vector3;
  21168. };
  21169. /**
  21170. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21171. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21172. * @returns a vector3
  21173. */
  21174. static Center(meshesOrMinMaxVector: {
  21175. min: Vector3;
  21176. max: Vector3;
  21177. } | AbstractMesh[]): Vector3;
  21178. /**
  21179. * Merge the array of meshes into a single mesh for performance reasons.
  21180. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21181. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21182. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21183. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21184. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21185. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21186. * @returns a new mesh
  21187. */
  21188. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21189. /** @hidden */
  21190. addInstance(instance: InstancedMesh): void;
  21191. /** @hidden */
  21192. removeInstance(instance: InstancedMesh): void;
  21193. }
  21194. }
  21195. declare module BABYLON {
  21196. /**
  21197. * Base class for the main features of a material in Babylon.js
  21198. */
  21199. export class Material implements IAnimatable {
  21200. /**
  21201. * Returns the triangle fill mode
  21202. */
  21203. static readonly TriangleFillMode: number;
  21204. /**
  21205. * Returns the wireframe mode
  21206. */
  21207. static readonly WireFrameFillMode: number;
  21208. /**
  21209. * Returns the point fill mode
  21210. */
  21211. static readonly PointFillMode: number;
  21212. /**
  21213. * Returns the point list draw mode
  21214. */
  21215. static readonly PointListDrawMode: number;
  21216. /**
  21217. * Returns the line list draw mode
  21218. */
  21219. static readonly LineListDrawMode: number;
  21220. /**
  21221. * Returns the line loop draw mode
  21222. */
  21223. static readonly LineLoopDrawMode: number;
  21224. /**
  21225. * Returns the line strip draw mode
  21226. */
  21227. static readonly LineStripDrawMode: number;
  21228. /**
  21229. * Returns the triangle strip draw mode
  21230. */
  21231. static readonly TriangleStripDrawMode: number;
  21232. /**
  21233. * Returns the triangle fan draw mode
  21234. */
  21235. static readonly TriangleFanDrawMode: number;
  21236. /**
  21237. * Stores the clock-wise side orientation
  21238. */
  21239. static readonly ClockWiseSideOrientation: number;
  21240. /**
  21241. * Stores the counter clock-wise side orientation
  21242. */
  21243. static readonly CounterClockWiseSideOrientation: number;
  21244. /**
  21245. * The dirty texture flag value
  21246. */
  21247. static readonly TextureDirtyFlag: number;
  21248. /**
  21249. * The dirty light flag value
  21250. */
  21251. static readonly LightDirtyFlag: number;
  21252. /**
  21253. * The dirty fresnel flag value
  21254. */
  21255. static readonly FresnelDirtyFlag: number;
  21256. /**
  21257. * The dirty attribute flag value
  21258. */
  21259. static readonly AttributesDirtyFlag: number;
  21260. /**
  21261. * The dirty misc flag value
  21262. */
  21263. static readonly MiscDirtyFlag: number;
  21264. /**
  21265. * The all dirty flag value
  21266. */
  21267. static readonly AllDirtyFlag: number;
  21268. /**
  21269. * The ID of the material
  21270. */
  21271. id: string;
  21272. /**
  21273. * Gets or sets the unique id of the material
  21274. */
  21275. uniqueId: number;
  21276. /**
  21277. * The name of the material
  21278. */
  21279. name: string;
  21280. /**
  21281. * Gets or sets user defined metadata
  21282. */
  21283. metadata: any;
  21284. /**
  21285. * For internal use only. Please do not use.
  21286. */
  21287. reservedDataStore: any;
  21288. /**
  21289. * Specifies if the ready state should be checked on each call
  21290. */
  21291. checkReadyOnEveryCall: boolean;
  21292. /**
  21293. * Specifies if the ready state should be checked once
  21294. */
  21295. checkReadyOnlyOnce: boolean;
  21296. /**
  21297. * The state of the material
  21298. */
  21299. state: string;
  21300. /**
  21301. * The alpha value of the material
  21302. */
  21303. protected _alpha: number;
  21304. /**
  21305. * List of inspectable custom properties (used by the Inspector)
  21306. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21307. */
  21308. inspectableCustomProperties: IInspectable[];
  21309. /**
  21310. * Sets the alpha value of the material
  21311. */
  21312. /**
  21313. * Gets the alpha value of the material
  21314. */
  21315. alpha: number;
  21316. /**
  21317. * Specifies if back face culling is enabled
  21318. */
  21319. protected _backFaceCulling: boolean;
  21320. /**
  21321. * Sets the back-face culling state
  21322. */
  21323. /**
  21324. * Gets the back-face culling state
  21325. */
  21326. backFaceCulling: boolean;
  21327. /**
  21328. * Stores the value for side orientation
  21329. */
  21330. sideOrientation: number;
  21331. /**
  21332. * Callback triggered when the material is compiled
  21333. */
  21334. onCompiled: (effect: Effect) => void;
  21335. /**
  21336. * Callback triggered when an error occurs
  21337. */
  21338. onError: (effect: Effect, errors: string) => void;
  21339. /**
  21340. * Callback triggered to get the render target textures
  21341. */
  21342. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  21343. /**
  21344. * Gets a boolean indicating that current material needs to register RTT
  21345. */
  21346. readonly hasRenderTargetTextures: boolean;
  21347. /**
  21348. * Specifies if the material should be serialized
  21349. */
  21350. doNotSerialize: boolean;
  21351. /**
  21352. * @hidden
  21353. */ storeEffectOnSubMeshes: boolean;
  21354. /**
  21355. * Stores the animations for the material
  21356. */
  21357. animations: Array<Animation>;
  21358. /**
  21359. * An event triggered when the material is disposed
  21360. */
  21361. onDisposeObservable: Observable<Material>;
  21362. /**
  21363. * An observer which watches for dispose events
  21364. */
  21365. private _onDisposeObserver;
  21366. private _onUnBindObservable;
  21367. /**
  21368. * Called during a dispose event
  21369. */
  21370. onDispose: () => void;
  21371. private _onBindObservable;
  21372. /**
  21373. * An event triggered when the material is bound
  21374. */
  21375. readonly onBindObservable: Observable<AbstractMesh>;
  21376. /**
  21377. * An observer which watches for bind events
  21378. */
  21379. private _onBindObserver;
  21380. /**
  21381. * Called during a bind event
  21382. */
  21383. onBind: (Mesh: AbstractMesh) => void;
  21384. /**
  21385. * An event triggered when the material is unbound
  21386. */
  21387. readonly onUnBindObservable: Observable<Material>;
  21388. /**
  21389. * Stores the value of the alpha mode
  21390. */
  21391. private _alphaMode;
  21392. /**
  21393. * Sets the value of the alpha mode.
  21394. *
  21395. * | Value | Type | Description |
  21396. * | --- | --- | --- |
  21397. * | 0 | ALPHA_DISABLE | |
  21398. * | 1 | ALPHA_ADD | |
  21399. * | 2 | ALPHA_COMBINE | |
  21400. * | 3 | ALPHA_SUBTRACT | |
  21401. * | 4 | ALPHA_MULTIPLY | |
  21402. * | 5 | ALPHA_MAXIMIZED | |
  21403. * | 6 | ALPHA_ONEONE | |
  21404. * | 7 | ALPHA_PREMULTIPLIED | |
  21405. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21406. * | 9 | ALPHA_INTERPOLATE | |
  21407. * | 10 | ALPHA_SCREENMODE | |
  21408. *
  21409. */
  21410. /**
  21411. * Gets the value of the alpha mode
  21412. */
  21413. alphaMode: number;
  21414. /**
  21415. * Stores the state of the need depth pre-pass value
  21416. */
  21417. private _needDepthPrePass;
  21418. /**
  21419. * Sets the need depth pre-pass value
  21420. */
  21421. /**
  21422. * Gets the depth pre-pass value
  21423. */
  21424. needDepthPrePass: boolean;
  21425. /**
  21426. * Specifies if depth writing should be disabled
  21427. */
  21428. disableDepthWrite: boolean;
  21429. /**
  21430. * Specifies if depth writing should be forced
  21431. */
  21432. forceDepthWrite: boolean;
  21433. /**
  21434. * Specifies if there should be a separate pass for culling
  21435. */
  21436. separateCullingPass: boolean;
  21437. /**
  21438. * Stores the state specifing if fog should be enabled
  21439. */
  21440. private _fogEnabled;
  21441. /**
  21442. * Sets the state for enabling fog
  21443. */
  21444. /**
  21445. * Gets the value of the fog enabled state
  21446. */
  21447. fogEnabled: boolean;
  21448. /**
  21449. * Stores the size of points
  21450. */
  21451. pointSize: number;
  21452. /**
  21453. * Stores the z offset value
  21454. */
  21455. zOffset: number;
  21456. /**
  21457. * Gets a value specifying if wireframe mode is enabled
  21458. */
  21459. /**
  21460. * Sets the state of wireframe mode
  21461. */
  21462. wireframe: boolean;
  21463. /**
  21464. * Gets the value specifying if point clouds are enabled
  21465. */
  21466. /**
  21467. * Sets the state of point cloud mode
  21468. */
  21469. pointsCloud: boolean;
  21470. /**
  21471. * Gets the material fill mode
  21472. */
  21473. /**
  21474. * Sets the material fill mode
  21475. */
  21476. fillMode: number;
  21477. /**
  21478. * @hidden
  21479. * Stores the effects for the material
  21480. */ effect: Nullable<Effect>;
  21481. /**
  21482. * @hidden
  21483. * Specifies if the material was previously ready
  21484. */ wasPreviouslyReady: boolean;
  21485. /**
  21486. * Specifies if uniform buffers should be used
  21487. */
  21488. private _useUBO;
  21489. /**
  21490. * Stores a reference to the scene
  21491. */
  21492. private _scene;
  21493. /**
  21494. * Stores the fill mode state
  21495. */
  21496. private _fillMode;
  21497. /**
  21498. * Specifies if the depth write state should be cached
  21499. */
  21500. private _cachedDepthWriteState;
  21501. /**
  21502. * Stores the uniform buffer
  21503. */
  21504. protected _uniformBuffer: UniformBuffer;
  21505. /** @hidden */ indexInSceneMaterialArray: number;
  21506. /** @hidden */
  21507. meshMap: Nullable<{
  21508. [id: string]: AbstractMesh | undefined;
  21509. }>;
  21510. /**
  21511. * Creates a material instance
  21512. * @param name defines the name of the material
  21513. * @param scene defines the scene to reference
  21514. * @param doNotAdd specifies if the material should be added to the scene
  21515. */
  21516. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21517. /**
  21518. * Returns a string representation of the current material
  21519. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21520. * @returns a string with material information
  21521. */
  21522. toString(fullDetails?: boolean): string;
  21523. /**
  21524. * Gets the class name of the material
  21525. * @returns a string with the class name of the material
  21526. */
  21527. getClassName(): string;
  21528. /**
  21529. * Specifies if updates for the material been locked
  21530. */
  21531. readonly isFrozen: boolean;
  21532. /**
  21533. * Locks updates for the material
  21534. */
  21535. freeze(): void;
  21536. /**
  21537. * Unlocks updates for the material
  21538. */
  21539. unfreeze(): void;
  21540. /**
  21541. * Specifies if the material is ready to be used
  21542. * @param mesh defines the mesh to check
  21543. * @param useInstances specifies if instances should be used
  21544. * @returns a boolean indicating if the material is ready to be used
  21545. */
  21546. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21547. /**
  21548. * Specifies that the submesh is ready to be used
  21549. * @param mesh defines the mesh to check
  21550. * @param subMesh defines which submesh to check
  21551. * @param useInstances specifies that instances should be used
  21552. * @returns a boolean indicating that the submesh is ready or not
  21553. */
  21554. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21555. /**
  21556. * Returns the material effect
  21557. * @returns the effect associated with the material
  21558. */
  21559. getEffect(): Nullable<Effect>;
  21560. /**
  21561. * Returns the current scene
  21562. * @returns a Scene
  21563. */
  21564. getScene(): Scene;
  21565. /**
  21566. * Specifies if the material will require alpha blending
  21567. * @returns a boolean specifying if alpha blending is needed
  21568. */
  21569. needAlphaBlending(): boolean;
  21570. /**
  21571. * Specifies if the mesh will require alpha blending
  21572. * @param mesh defines the mesh to check
  21573. * @returns a boolean specifying if alpha blending is needed for the mesh
  21574. */
  21575. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21576. /**
  21577. * Specifies if this material should be rendered in alpha test mode
  21578. * @returns a boolean specifying if an alpha test is needed.
  21579. */
  21580. needAlphaTesting(): boolean;
  21581. /**
  21582. * Gets the texture used for the alpha test
  21583. * @returns the texture to use for alpha testing
  21584. */
  21585. getAlphaTestTexture(): Nullable<BaseTexture>;
  21586. /**
  21587. * Marks the material to indicate that it needs to be re-calculated
  21588. */
  21589. markDirty(): void;
  21590. /** @hidden */ preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21591. /**
  21592. * Binds the material to the mesh
  21593. * @param world defines the world transformation matrix
  21594. * @param mesh defines the mesh to bind the material to
  21595. */
  21596. bind(world: Matrix, mesh?: Mesh): void;
  21597. /**
  21598. * Binds the submesh to the material
  21599. * @param world defines the world transformation matrix
  21600. * @param mesh defines the mesh containing the submesh
  21601. * @param subMesh defines the submesh to bind the material to
  21602. */
  21603. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21604. /**
  21605. * Binds the world matrix to the material
  21606. * @param world defines the world transformation matrix
  21607. */
  21608. bindOnlyWorldMatrix(world: Matrix): void;
  21609. /**
  21610. * Binds the scene's uniform buffer to the effect.
  21611. * @param effect defines the effect to bind to the scene uniform buffer
  21612. * @param sceneUbo defines the uniform buffer storing scene data
  21613. */
  21614. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21615. /**
  21616. * Binds the view matrix to the effect
  21617. * @param effect defines the effect to bind the view matrix to
  21618. */
  21619. bindView(effect: Effect): void;
  21620. /**
  21621. * Binds the view projection matrix to the effect
  21622. * @param effect defines the effect to bind the view projection matrix to
  21623. */
  21624. bindViewProjection(effect: Effect): void;
  21625. /**
  21626. * Specifies if material alpha testing should be turned on for the mesh
  21627. * @param mesh defines the mesh to check
  21628. */
  21629. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21630. /**
  21631. * Processes to execute after binding the material to a mesh
  21632. * @param mesh defines the rendered mesh
  21633. */
  21634. protected _afterBind(mesh?: Mesh): void;
  21635. /**
  21636. * Unbinds the material from the mesh
  21637. */
  21638. unbind(): void;
  21639. /**
  21640. * Gets the active textures from the material
  21641. * @returns an array of textures
  21642. */
  21643. getActiveTextures(): BaseTexture[];
  21644. /**
  21645. * Specifies if the material uses a texture
  21646. * @param texture defines the texture to check against the material
  21647. * @returns a boolean specifying if the material uses the texture
  21648. */
  21649. hasTexture(texture: BaseTexture): boolean;
  21650. /**
  21651. * Makes a duplicate of the material, and gives it a new name
  21652. * @param name defines the new name for the duplicated material
  21653. * @returns the cloned material
  21654. */
  21655. clone(name: string): Nullable<Material>;
  21656. /**
  21657. * Gets the meshes bound to the material
  21658. * @returns an array of meshes bound to the material
  21659. */
  21660. getBindedMeshes(): AbstractMesh[];
  21661. /**
  21662. * Force shader compilation
  21663. * @param mesh defines the mesh associated with this material
  21664. * @param onCompiled defines a function to execute once the material is compiled
  21665. * @param options defines the options to configure the compilation
  21666. */
  21667. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21668. clipPlane: boolean;
  21669. }>): void;
  21670. /**
  21671. * Force shader compilation
  21672. * @param mesh defines the mesh that will use this material
  21673. * @param options defines additional options for compiling the shaders
  21674. * @returns a promise that resolves when the compilation completes
  21675. */
  21676. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21677. clipPlane: boolean;
  21678. }>): Promise<void>;
  21679. private static readonly _ImageProcessingDirtyCallBack;
  21680. private static readonly _TextureDirtyCallBack;
  21681. private static readonly _FresnelDirtyCallBack;
  21682. private static readonly _MiscDirtyCallBack;
  21683. private static readonly _LightsDirtyCallBack;
  21684. private static readonly _AttributeDirtyCallBack;
  21685. private static _FresnelAndMiscDirtyCallBack;
  21686. private static _TextureAndMiscDirtyCallBack;
  21687. private static readonly _DirtyCallbackArray;
  21688. private static readonly _RunDirtyCallBacks;
  21689. /**
  21690. * Marks a define in the material to indicate that it needs to be re-computed
  21691. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21692. */
  21693. markAsDirty(flag: number): void;
  21694. /**
  21695. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21696. * @param func defines a function which checks material defines against the submeshes
  21697. */
  21698. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21699. /**
  21700. * Indicates that image processing needs to be re-calculated for all submeshes
  21701. */
  21702. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21703. /**
  21704. * Indicates that textures need to be re-calculated for all submeshes
  21705. */
  21706. protected _markAllSubMeshesAsTexturesDirty(): void;
  21707. /**
  21708. * Indicates that fresnel needs to be re-calculated for all submeshes
  21709. */
  21710. protected _markAllSubMeshesAsFresnelDirty(): void;
  21711. /**
  21712. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21713. */
  21714. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21715. /**
  21716. * Indicates that lights need to be re-calculated for all submeshes
  21717. */
  21718. protected _markAllSubMeshesAsLightsDirty(): void;
  21719. /**
  21720. * Indicates that attributes need to be re-calculated for all submeshes
  21721. */
  21722. protected _markAllSubMeshesAsAttributesDirty(): void;
  21723. /**
  21724. * Indicates that misc needs to be re-calculated for all submeshes
  21725. */
  21726. protected _markAllSubMeshesAsMiscDirty(): void;
  21727. /**
  21728. * Indicates that textures and misc need to be re-calculated for all submeshes
  21729. */
  21730. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21731. /**
  21732. * Disposes the material
  21733. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21734. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21735. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21736. */
  21737. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21738. /** @hidden */
  21739. private releaseVertexArrayObject;
  21740. /**
  21741. * Serializes this material
  21742. * @returns the serialized material object
  21743. */
  21744. serialize(): any;
  21745. /**
  21746. * Creates a material from parsed material data
  21747. * @param parsedMaterial defines parsed material data
  21748. * @param scene defines the hosting scene
  21749. * @param rootUrl defines the root URL to use to load textures
  21750. * @returns a new material
  21751. */
  21752. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  21753. }
  21754. }
  21755. declare module BABYLON {
  21756. /**
  21757. * Base class for submeshes
  21758. */
  21759. export class BaseSubMesh {
  21760. /** @hidden */ materialDefines: Nullable<MaterialDefines>;
  21761. /** @hidden */ materialEffect: Nullable<Effect>;
  21762. /**
  21763. * Gets associated effect
  21764. */
  21765. readonly effect: Nullable<Effect>;
  21766. /**
  21767. * Sets associated effect (effect used to render this submesh)
  21768. * @param effect defines the effect to associate with
  21769. * @param defines defines the set of defines used to compile this effect
  21770. */
  21771. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21772. }
  21773. /**
  21774. * Defines a subdivision inside a mesh
  21775. */
  21776. export class SubMesh extends BaseSubMesh implements ICullable {
  21777. /** the material index to use */
  21778. materialIndex: number;
  21779. /** vertex index start */
  21780. verticesStart: number;
  21781. /** vertices count */
  21782. verticesCount: number;
  21783. /** index start */
  21784. indexStart: number;
  21785. /** indices count */
  21786. indexCount: number;
  21787. /** @hidden */ linesIndexCount: number;
  21788. private _mesh;
  21789. private _renderingMesh;
  21790. private _boundingInfo;
  21791. private _linesIndexBuffer;
  21792. /** @hidden */ lastColliderWorldVertices: Nullable<Vector3[]>;
  21793. /** @hidden */ trianglePlanes: Plane[];
  21794. /** @hidden */ lastColliderTransformMatrix: Matrix;
  21795. /** @hidden */ renderId: number;
  21796. /** @hidden */ alphaIndex: number;
  21797. /** @hidden */ distanceToCamera: number;
  21798. /** @hidden */ id: number;
  21799. private _currentMaterial;
  21800. /**
  21801. * Add a new submesh to a mesh
  21802. * @param materialIndex defines the material index to use
  21803. * @param verticesStart defines vertex index start
  21804. * @param verticesCount defines vertices count
  21805. * @param indexStart defines index start
  21806. * @param indexCount defines indices count
  21807. * @param mesh defines the parent mesh
  21808. * @param renderingMesh defines an optional rendering mesh
  21809. * @param createBoundingBox defines if bounding box should be created for this submesh
  21810. * @returns the new submesh
  21811. */
  21812. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21813. /**
  21814. * Creates a new submesh
  21815. * @param materialIndex defines the material index to use
  21816. * @param verticesStart defines vertex index start
  21817. * @param verticesCount defines vertices count
  21818. * @param indexStart defines index start
  21819. * @param indexCount defines indices count
  21820. * @param mesh defines the parent mesh
  21821. * @param renderingMesh defines an optional rendering mesh
  21822. * @param createBoundingBox defines if bounding box should be created for this submesh
  21823. */
  21824. constructor(
  21825. /** the material index to use */
  21826. materialIndex: number,
  21827. /** vertex index start */
  21828. verticesStart: number,
  21829. /** vertices count */
  21830. verticesCount: number,
  21831. /** index start */
  21832. indexStart: number,
  21833. /** indices count */
  21834. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21835. /**
  21836. * Returns true if this submesh covers the entire parent mesh
  21837. * @ignorenaming
  21838. */
  21839. readonly IsGlobal: boolean;
  21840. /**
  21841. * Returns the submesh BoudingInfo object
  21842. * @returns current bounding info (or mesh's one if the submesh is global)
  21843. */
  21844. getBoundingInfo(): BoundingInfo;
  21845. /**
  21846. * Sets the submesh BoundingInfo
  21847. * @param boundingInfo defines the new bounding info to use
  21848. * @returns the SubMesh
  21849. */
  21850. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21851. /**
  21852. * Returns the mesh of the current submesh
  21853. * @return the parent mesh
  21854. */
  21855. getMesh(): AbstractMesh;
  21856. /**
  21857. * Returns the rendering mesh of the submesh
  21858. * @returns the rendering mesh (could be different from parent mesh)
  21859. */
  21860. getRenderingMesh(): Mesh;
  21861. /**
  21862. * Returns the submesh material
  21863. * @returns null or the current material
  21864. */
  21865. getMaterial(): Nullable<Material>;
  21866. /**
  21867. * Sets a new updated BoundingInfo object to the submesh
  21868. * @returns the SubMesh
  21869. */
  21870. refreshBoundingInfo(): SubMesh;
  21871. /** @hidden */ checkCollision(collider: Collider): boolean;
  21872. /**
  21873. * Updates the submesh BoundingInfo
  21874. * @param world defines the world matrix to use to update the bounding info
  21875. * @returns the submesh
  21876. */
  21877. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21878. /**
  21879. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21880. * @param frustumPlanes defines the frustum planes
  21881. * @returns true if the submesh is intersecting with the frustum
  21882. */
  21883. isInFrustum(frustumPlanes: Plane[]): boolean;
  21884. /**
  21885. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21886. * @param frustumPlanes defines the frustum planes
  21887. * @returns true if the submesh is inside the frustum
  21888. */
  21889. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21890. /**
  21891. * Renders the submesh
  21892. * @param enableAlphaMode defines if alpha needs to be used
  21893. * @returns the submesh
  21894. */
  21895. render(enableAlphaMode: boolean): SubMesh;
  21896. /**
  21897. * @hidden
  21898. */ getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  21899. /**
  21900. * Checks if the submesh intersects with a ray
  21901. * @param ray defines the ray to test
  21902. * @returns true is the passed ray intersects the submesh bounding box
  21903. */
  21904. canIntersects(ray: Ray): boolean;
  21905. /**
  21906. * Intersects current submesh with a ray
  21907. * @param ray defines the ray to test
  21908. * @param positions defines mesh's positions array
  21909. * @param indices defines mesh's indices array
  21910. * @param fastCheck defines if only bounding info should be used
  21911. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21912. * @returns intersection info or null if no intersection
  21913. */
  21914. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21915. /** @hidden */
  21916. private _intersectLines;
  21917. /** @hidden */
  21918. private _intersectTriangles;
  21919. /** @hidden */ rebuild(): void;
  21920. /**
  21921. * Creates a new submesh from the passed mesh
  21922. * @param newMesh defines the new hosting mesh
  21923. * @param newRenderingMesh defines an optional rendering mesh
  21924. * @returns the new submesh
  21925. */
  21926. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21927. /**
  21928. * Release associated resources
  21929. */
  21930. dispose(): void;
  21931. /**
  21932. * Gets the class name
  21933. * @returns the string "SubMesh".
  21934. */
  21935. getClassName(): string;
  21936. /**
  21937. * Creates a new submesh from indices data
  21938. * @param materialIndex the index of the main mesh material
  21939. * @param startIndex the index where to start the copy in the mesh indices array
  21940. * @param indexCount the number of indices to copy then from the startIndex
  21941. * @param mesh the main mesh to create the submesh from
  21942. * @param renderingMesh the optional rendering mesh
  21943. * @returns a new submesh
  21944. */
  21945. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21946. }
  21947. }
  21948. declare module BABYLON {
  21949. /**
  21950. * Class used to store geometry data (vertex buffers + index buffer)
  21951. */
  21952. export class Geometry implements IGetSetVerticesData {
  21953. /**
  21954. * Gets or sets the ID of the geometry
  21955. */
  21956. id: string;
  21957. /**
  21958. * Gets or sets the unique ID of the geometry
  21959. */
  21960. uniqueId: number;
  21961. /**
  21962. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21963. */
  21964. delayLoadState: number;
  21965. /**
  21966. * Gets the file containing the data to load when running in delay load state
  21967. */
  21968. delayLoadingFile: Nullable<string>;
  21969. /**
  21970. * Callback called when the geometry is updated
  21971. */
  21972. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21973. private _scene;
  21974. private _engine;
  21975. private _meshes;
  21976. private _totalVertices;
  21977. /** @hidden */ indices: IndicesArray;
  21978. /** @hidden */ vertexBuffers: {
  21979. [key: string]: VertexBuffer;
  21980. };
  21981. private _isDisposed;
  21982. private _extend;
  21983. private _boundingBias;
  21984. /** @hidden */ delayInfo: Array<string>;
  21985. private _indexBuffer;
  21986. private _indexBufferIsUpdatable;
  21987. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  21988. /** @hidden */ delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21989. /** @hidden */ softwareSkinningFrameId: number;
  21990. private _vertexArrayObjects;
  21991. private _updatable;
  21992. /** @hidden */ positions: Nullable<Vector3[]>;
  21993. /**
  21994. * 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
  21995. */
  21996. /**
  21997. * 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
  21998. */
  21999. boundingBias: Vector2;
  22000. /**
  22001. * Static function used to attach a new empty geometry to a mesh
  22002. * @param mesh defines the mesh to attach the geometry to
  22003. * @returns the new Geometry
  22004. */
  22005. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22006. /**
  22007. * Creates a new geometry
  22008. * @param id defines the unique ID
  22009. * @param scene defines the hosting scene
  22010. * @param vertexData defines the VertexData used to get geometry data
  22011. * @param updatable defines if geometry must be updatable (false by default)
  22012. * @param mesh defines the mesh that will be associated with the geometry
  22013. */
  22014. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22015. /**
  22016. * Gets the current extend of the geometry
  22017. */
  22018. readonly extend: {
  22019. minimum: Vector3;
  22020. maximum: Vector3;
  22021. };
  22022. /**
  22023. * Gets the hosting scene
  22024. * @returns the hosting Scene
  22025. */
  22026. getScene(): Scene;
  22027. /**
  22028. * Gets the hosting engine
  22029. * @returns the hosting Engine
  22030. */
  22031. getEngine(): Engine;
  22032. /**
  22033. * Defines if the geometry is ready to use
  22034. * @returns true if the geometry is ready to be used
  22035. */
  22036. isReady(): boolean;
  22037. /**
  22038. * Gets a value indicating that the geometry should not be serialized
  22039. */
  22040. readonly doNotSerialize: boolean;
  22041. /** @hidden */ rebuild(): void;
  22042. /**
  22043. * Affects all geometry data in one call
  22044. * @param vertexData defines the geometry data
  22045. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22046. */
  22047. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22048. /**
  22049. * Set specific vertex data
  22050. * @param kind defines the data kind (Position, normal, etc...)
  22051. * @param data defines the vertex data to use
  22052. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22053. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22054. */
  22055. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22056. /**
  22057. * Removes a specific vertex data
  22058. * @param kind defines the data kind (Position, normal, etc...)
  22059. */
  22060. removeVerticesData(kind: string): void;
  22061. /**
  22062. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22063. * @param buffer defines the vertex buffer to use
  22064. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22065. */
  22066. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22067. /**
  22068. * Update a specific vertex buffer
  22069. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  22070. * It will do nothing if the buffer is not updatable
  22071. * @param kind defines the data kind (Position, normal, etc...)
  22072. * @param data defines the data to use
  22073. * @param offset defines the offset in the target buffer where to store the data
  22074. * @param useBytes set to true if the offset is in bytes
  22075. */
  22076. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22077. /**
  22078. * Update a specific vertex buffer
  22079. * This function will create a new buffer if the current one is not updatable
  22080. * @param kind defines the data kind (Position, normal, etc...)
  22081. * @param data defines the data to use
  22082. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22083. */
  22084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22085. private _updateBoundingInfo;
  22086. /** @hidden */ bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  22087. /**
  22088. * Gets total number of vertices
  22089. * @returns the total number of vertices
  22090. */
  22091. getTotalVertices(): number;
  22092. /**
  22093. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22094. * @param kind defines the data kind (Position, normal, etc...)
  22095. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22096. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22097. * @returns a float array containing vertex data
  22098. */
  22099. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22100. /**
  22101. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22102. * @param kind defines the data kind (Position, normal, etc...)
  22103. * @returns true if the vertex buffer with the specified kind is updatable
  22104. */
  22105. isVertexBufferUpdatable(kind: string): boolean;
  22106. /**
  22107. * Gets a specific vertex buffer
  22108. * @param kind defines the data kind (Position, normal, etc...)
  22109. * @returns a VertexBuffer
  22110. */
  22111. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22112. /**
  22113. * Returns all vertex buffers
  22114. * @return an object holding all vertex buffers indexed by kind
  22115. */
  22116. getVertexBuffers(): Nullable<{
  22117. [key: string]: VertexBuffer;
  22118. }>;
  22119. /**
  22120. * Gets a boolean indicating if specific vertex buffer is present
  22121. * @param kind defines the data kind (Position, normal, etc...)
  22122. * @returns true if data is present
  22123. */
  22124. isVerticesDataPresent(kind: string): boolean;
  22125. /**
  22126. * Gets a list of all attached data kinds (Position, normal, etc...)
  22127. * @returns a list of string containing all kinds
  22128. */
  22129. getVerticesDataKinds(): string[];
  22130. /**
  22131. * Update index buffer
  22132. * @param indices defines the indices to store in the index buffer
  22133. * @param offset defines the offset in the target buffer where to store the data
  22134. * @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)
  22135. */
  22136. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22137. /**
  22138. * Creates a new index buffer
  22139. * @param indices defines the indices to store in the index buffer
  22140. * @param totalVertices defines the total number of vertices (could be null)
  22141. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22142. */
  22143. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22144. /**
  22145. * Return the total number of indices
  22146. * @returns the total number of indices
  22147. */
  22148. getTotalIndices(): number;
  22149. /**
  22150. * Gets the index buffer array
  22151. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22152. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22153. * @returns the index buffer array
  22154. */
  22155. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22156. /**
  22157. * Gets the index buffer
  22158. * @return the index buffer
  22159. */
  22160. getIndexBuffer(): Nullable<WebGLBuffer>;
  22161. /** @hidden */ releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22162. /**
  22163. * Release the associated resources for a specific mesh
  22164. * @param mesh defines the source mesh
  22165. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22166. */
  22167. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22168. /**
  22169. * Apply current geometry to a given mesh
  22170. * @param mesh defines the mesh to apply geometry to
  22171. */
  22172. applyToMesh(mesh: Mesh): void;
  22173. private _updateExtend;
  22174. private _applyToMesh;
  22175. private notifyUpdate;
  22176. /**
  22177. * Load the geometry if it was flagged as delay loaded
  22178. * @param scene defines the hosting scene
  22179. * @param onLoaded defines a callback called when the geometry is loaded
  22180. */
  22181. load(scene: Scene, onLoaded?: () => void): void;
  22182. private _queueLoad;
  22183. /**
  22184. * Invert the geometry to move from a right handed system to a left handed one.
  22185. */
  22186. toLeftHanded(): void;
  22187. /** @hidden */ resetPointsArrayCache(): void;
  22188. /** @hidden */ generatePointsArray(): boolean;
  22189. /**
  22190. * Gets a value indicating if the geometry is disposed
  22191. * @returns true if the geometry was disposed
  22192. */
  22193. isDisposed(): boolean;
  22194. private _disposeVertexArrayObjects;
  22195. /**
  22196. * Free all associated resources
  22197. */
  22198. dispose(): void;
  22199. /**
  22200. * Clone the current geometry into a new geometry
  22201. * @param id defines the unique ID of the new geometry
  22202. * @returns a new geometry object
  22203. */
  22204. copy(id: string): Geometry;
  22205. /**
  22206. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22207. * @return a JSON representation of the current geometry data (without the vertices data)
  22208. */
  22209. serialize(): any;
  22210. private toNumberArray;
  22211. /**
  22212. * Serialize all vertices data into a JSON oject
  22213. * @returns a JSON representation of the current geometry data
  22214. */
  22215. serializeVerticeData(): any;
  22216. /**
  22217. * Extracts a clone of a mesh geometry
  22218. * @param mesh defines the source mesh
  22219. * @param id defines the unique ID of the new geometry object
  22220. * @returns the new geometry object
  22221. */
  22222. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22223. /**
  22224. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22225. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22226. * Be aware Math.random() could cause collisions, but:
  22227. * "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"
  22228. * @returns a string containing a new GUID
  22229. */
  22230. static RandomId(): string;
  22231. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22232. private static _CleanMatricesWeights;
  22233. /**
  22234. * Create a new geometry from persisted data (Using .babylon file format)
  22235. * @param parsedVertexData defines the persisted data
  22236. * @param scene defines the hosting scene
  22237. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22238. * @returns the new geometry object
  22239. */
  22240. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22241. }
  22242. }
  22243. declare module BABYLON {
  22244. /**
  22245. * Define an interface for all classes that will get and set the data on vertices
  22246. */
  22247. export interface IGetSetVerticesData {
  22248. /**
  22249. * Gets a boolean indicating if specific vertex data is present
  22250. * @param kind defines the vertex data kind to use
  22251. * @returns true is data kind is present
  22252. */
  22253. isVerticesDataPresent(kind: string): boolean;
  22254. /**
  22255. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22256. * @param kind defines the data kind (Position, normal, etc...)
  22257. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22258. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22259. * @returns a float array containing vertex data
  22260. */
  22261. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22262. /**
  22263. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22264. * @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.
  22265. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22266. * @returns the indices array or an empty array if the mesh has no geometry
  22267. */
  22268. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22269. /**
  22270. * Set specific vertex data
  22271. * @param kind defines the data kind (Position, normal, etc...)
  22272. * @param data defines the vertex data to use
  22273. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22274. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22275. */
  22276. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22277. /**
  22278. * Update a specific associated vertex buffer
  22279. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22280. * - VertexBuffer.PositionKind
  22281. * - VertexBuffer.UVKind
  22282. * - VertexBuffer.UV2Kind
  22283. * - VertexBuffer.UV3Kind
  22284. * - VertexBuffer.UV4Kind
  22285. * - VertexBuffer.UV5Kind
  22286. * - VertexBuffer.UV6Kind
  22287. * - VertexBuffer.ColorKind
  22288. * - VertexBuffer.MatricesIndicesKind
  22289. * - VertexBuffer.MatricesIndicesExtraKind
  22290. * - VertexBuffer.MatricesWeightsKind
  22291. * - VertexBuffer.MatricesWeightsExtraKind
  22292. * @param data defines the data source
  22293. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22294. * @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)
  22295. */
  22296. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22297. /**
  22298. * Creates a new index buffer
  22299. * @param indices defines the indices to store in the index buffer
  22300. * @param totalVertices defines the total number of vertices (could be null)
  22301. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22302. */
  22303. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22304. }
  22305. /**
  22306. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22307. */
  22308. export class VertexData {
  22309. /**
  22310. * Mesh side orientation : usually the external or front surface
  22311. */
  22312. static readonly FRONTSIDE: number;
  22313. /**
  22314. * Mesh side orientation : usually the internal or back surface
  22315. */
  22316. static readonly BACKSIDE: number;
  22317. /**
  22318. * Mesh side orientation : both internal and external or front and back surfaces
  22319. */
  22320. static readonly DOUBLESIDE: number;
  22321. /**
  22322. * Mesh side orientation : by default, `FRONTSIDE`
  22323. */
  22324. static readonly DEFAULTSIDE: number;
  22325. /**
  22326. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22327. */
  22328. positions: Nullable<FloatArray>;
  22329. /**
  22330. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22331. */
  22332. normals: Nullable<FloatArray>;
  22333. /**
  22334. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22335. */
  22336. tangents: Nullable<FloatArray>;
  22337. /**
  22338. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22339. */
  22340. uvs: Nullable<FloatArray>;
  22341. /**
  22342. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22343. */
  22344. uvs2: Nullable<FloatArray>;
  22345. /**
  22346. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22347. */
  22348. uvs3: Nullable<FloatArray>;
  22349. /**
  22350. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22351. */
  22352. uvs4: Nullable<FloatArray>;
  22353. /**
  22354. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22355. */
  22356. uvs5: Nullable<FloatArray>;
  22357. /**
  22358. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22359. */
  22360. uvs6: Nullable<FloatArray>;
  22361. /**
  22362. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22363. */
  22364. colors: Nullable<FloatArray>;
  22365. /**
  22366. * 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).
  22367. */
  22368. matricesIndices: Nullable<FloatArray>;
  22369. /**
  22370. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22371. */
  22372. matricesWeights: Nullable<FloatArray>;
  22373. /**
  22374. * An array extending the number of possible indices
  22375. */
  22376. matricesIndicesExtra: Nullable<FloatArray>;
  22377. /**
  22378. * An array extending the number of possible weights when the number of indices is extended
  22379. */
  22380. matricesWeightsExtra: Nullable<FloatArray>;
  22381. /**
  22382. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22383. */
  22384. indices: Nullable<IndicesArray>;
  22385. /**
  22386. * Uses the passed data array to set the set the values for the specified kind of data
  22387. * @param data a linear array of floating numbers
  22388. * @param kind the type of data that is being set, eg positions, colors etc
  22389. */
  22390. set(data: FloatArray, kind: string): void;
  22391. /**
  22392. * Associates the vertexData to the passed Mesh.
  22393. * Sets it as updatable or not (default `false`)
  22394. * @param mesh the mesh the vertexData is applied to
  22395. * @param updatable when used and having the value true allows new data to update the vertexData
  22396. * @returns the VertexData
  22397. */
  22398. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22399. /**
  22400. * Associates the vertexData to the passed Geometry.
  22401. * Sets it as updatable or not (default `false`)
  22402. * @param geometry the geometry the vertexData is applied to
  22403. * @param updatable when used and having the value true allows new data to update the vertexData
  22404. * @returns VertexData
  22405. */
  22406. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22407. /**
  22408. * Updates the associated mesh
  22409. * @param mesh the mesh to be updated
  22410. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22411. * @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
  22412. * @returns VertexData
  22413. */
  22414. updateMesh(mesh: Mesh): VertexData;
  22415. /**
  22416. * Updates the associated geometry
  22417. * @param geometry the geometry to be updated
  22418. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22419. * @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
  22420. * @returns VertexData.
  22421. */
  22422. updateGeometry(geometry: Geometry): VertexData;
  22423. private _applyTo;
  22424. private _update;
  22425. /**
  22426. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22427. * @param matrix the transforming matrix
  22428. * @returns the VertexData
  22429. */
  22430. transform(matrix: Matrix): VertexData;
  22431. /**
  22432. * Merges the passed VertexData into the current one
  22433. * @param other the VertexData to be merged into the current one
  22434. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22435. * @returns the modified VertexData
  22436. */
  22437. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22438. private _mergeElement;
  22439. private _validate;
  22440. /**
  22441. * Serializes the VertexData
  22442. * @returns a serialized object
  22443. */
  22444. serialize(): any;
  22445. /**
  22446. * Extracts the vertexData from a mesh
  22447. * @param mesh the mesh from which to extract the VertexData
  22448. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22449. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22450. * @returns the object VertexData associated to the passed mesh
  22451. */
  22452. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22453. /**
  22454. * Extracts the vertexData from the geometry
  22455. * @param geometry the geometry from which to extract the VertexData
  22456. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22457. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22458. * @returns the object VertexData associated to the passed mesh
  22459. */
  22460. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22461. private static _ExtractFrom;
  22462. /**
  22463. * Creates the VertexData for a Ribbon
  22464. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22465. * * pathArray array of paths, each of which an array of successive Vector3
  22466. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22467. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22468. * * 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
  22469. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22470. * * 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)
  22471. * * 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)
  22472. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22473. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22474. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22475. * @returns the VertexData of the ribbon
  22476. */
  22477. static CreateRibbon(options: {
  22478. pathArray: Vector3[][];
  22479. closeArray?: boolean;
  22480. closePath?: boolean;
  22481. offset?: number;
  22482. sideOrientation?: number;
  22483. frontUVs?: Vector4;
  22484. backUVs?: Vector4;
  22485. invertUV?: boolean;
  22486. uvs?: Vector2[];
  22487. colors?: Color4[];
  22488. }): VertexData;
  22489. /**
  22490. * Creates the VertexData for a box
  22491. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22492. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22493. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22494. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22495. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22496. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22497. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22498. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22499. * * 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)
  22500. * * 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)
  22501. * @returns the VertexData of the box
  22502. */
  22503. static CreateBox(options: {
  22504. size?: number;
  22505. width?: number;
  22506. height?: number;
  22507. depth?: number;
  22508. faceUV?: Vector4[];
  22509. faceColors?: Color4[];
  22510. sideOrientation?: number;
  22511. frontUVs?: Vector4;
  22512. backUVs?: Vector4;
  22513. }): VertexData;
  22514. /**
  22515. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22516. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22517. * * segments sets the number of horizontal strips optional, default 32
  22518. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22519. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22520. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22521. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22522. * * 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
  22523. * * 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
  22524. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22525. * * 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)
  22526. * * 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)
  22527. * @returns the VertexData of the ellipsoid
  22528. */
  22529. static CreateSphere(options: {
  22530. segments?: number;
  22531. diameter?: number;
  22532. diameterX?: number;
  22533. diameterY?: number;
  22534. diameterZ?: number;
  22535. arc?: number;
  22536. slice?: number;
  22537. sideOrientation?: number;
  22538. frontUVs?: Vector4;
  22539. backUVs?: Vector4;
  22540. }): VertexData;
  22541. /**
  22542. * Creates the VertexData for a cylinder, cone or prism
  22543. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22544. * * height sets the height (y direction) of the cylinder, optional, default 2
  22545. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22546. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22547. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22548. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22549. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22550. * * 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
  22551. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22552. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22553. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22554. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22555. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22556. * * 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)
  22557. * * 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)
  22558. * @returns the VertexData of the cylinder, cone or prism
  22559. */
  22560. static CreateCylinder(options: {
  22561. height?: number;
  22562. diameterTop?: number;
  22563. diameterBottom?: number;
  22564. diameter?: number;
  22565. tessellation?: number;
  22566. subdivisions?: number;
  22567. arc?: number;
  22568. faceColors?: Color4[];
  22569. faceUV?: Vector4[];
  22570. hasRings?: boolean;
  22571. enclose?: boolean;
  22572. sideOrientation?: number;
  22573. frontUVs?: Vector4;
  22574. backUVs?: Vector4;
  22575. }): VertexData;
  22576. /**
  22577. * Creates the VertexData for a torus
  22578. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22579. * * diameter the diameter of the torus, optional default 1
  22580. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22581. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22582. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22583. * * 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)
  22584. * * 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)
  22585. * @returns the VertexData of the torus
  22586. */
  22587. static CreateTorus(options: {
  22588. diameter?: number;
  22589. thickness?: number;
  22590. tessellation?: number;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }): VertexData;
  22595. /**
  22596. * Creates the VertexData of the LineSystem
  22597. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22598. * - lines an array of lines, each line being an array of successive Vector3
  22599. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22600. * @returns the VertexData of the LineSystem
  22601. */
  22602. static CreateLineSystem(options: {
  22603. lines: Vector3[][];
  22604. colors?: Nullable<Color4[][]>;
  22605. }): VertexData;
  22606. /**
  22607. * Create the VertexData for a DashedLines
  22608. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22609. * - points an array successive Vector3
  22610. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22611. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22612. * - dashNb the intended total number of dashes, optional, default 200
  22613. * @returns the VertexData for the DashedLines
  22614. */
  22615. static CreateDashedLines(options: {
  22616. points: Vector3[];
  22617. dashSize?: number;
  22618. gapSize?: number;
  22619. dashNb?: number;
  22620. }): VertexData;
  22621. /**
  22622. * Creates the VertexData for a Ground
  22623. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22624. * - width the width (x direction) of the ground, optional, default 1
  22625. * - height the height (z direction) of the ground, optional, default 1
  22626. * - subdivisions the number of subdivisions per side, optional, default 1
  22627. * @returns the VertexData of the Ground
  22628. */
  22629. static CreateGround(options: {
  22630. width?: number;
  22631. height?: number;
  22632. subdivisions?: number;
  22633. subdivisionsX?: number;
  22634. subdivisionsY?: number;
  22635. }): VertexData;
  22636. /**
  22637. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22638. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22639. * * xmin the ground minimum X coordinate, optional, default -1
  22640. * * zmin the ground minimum Z coordinate, optional, default -1
  22641. * * xmax the ground maximum X coordinate, optional, default 1
  22642. * * zmax the ground maximum Z coordinate, optional, default 1
  22643. * * 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}
  22644. * * 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}
  22645. * @returns the VertexData of the TiledGround
  22646. */
  22647. static CreateTiledGround(options: {
  22648. xmin: number;
  22649. zmin: number;
  22650. xmax: number;
  22651. zmax: number;
  22652. subdivisions?: {
  22653. w: number;
  22654. h: number;
  22655. };
  22656. precision?: {
  22657. w: number;
  22658. h: number;
  22659. };
  22660. }): VertexData;
  22661. /**
  22662. * Creates the VertexData of the Ground designed from a heightmap
  22663. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22664. * * width the width (x direction) of the ground
  22665. * * height the height (z direction) of the ground
  22666. * * subdivisions the number of subdivisions per side
  22667. * * minHeight the minimum altitude on the ground, optional, default 0
  22668. * * maxHeight the maximum altitude on the ground, optional default 1
  22669. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22670. * * buffer the array holding the image color data
  22671. * * bufferWidth the width of image
  22672. * * bufferHeight the height of image
  22673. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22674. * @returns the VertexData of the Ground designed from a heightmap
  22675. */
  22676. static CreateGroundFromHeightMap(options: {
  22677. width: number;
  22678. height: number;
  22679. subdivisions: number;
  22680. minHeight: number;
  22681. maxHeight: number;
  22682. colorFilter: Color3;
  22683. buffer: Uint8Array;
  22684. bufferWidth: number;
  22685. bufferHeight: number;
  22686. alphaFilter: number;
  22687. }): VertexData;
  22688. /**
  22689. * Creates the VertexData for a Plane
  22690. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22691. * * size sets the width and height of the plane to the value of size, optional default 1
  22692. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22693. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22694. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22695. * * 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)
  22696. * * 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)
  22697. * @returns the VertexData of the box
  22698. */
  22699. static CreatePlane(options: {
  22700. size?: number;
  22701. width?: number;
  22702. height?: number;
  22703. sideOrientation?: number;
  22704. frontUVs?: Vector4;
  22705. backUVs?: Vector4;
  22706. }): VertexData;
  22707. /**
  22708. * Creates the VertexData of the Disc or regular Polygon
  22709. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22710. * * radius the radius of the disc, optional default 0.5
  22711. * * tessellation the number of polygon sides, optional, default 64
  22712. * * 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
  22713. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22714. * * 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)
  22715. * * 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)
  22716. * @returns the VertexData of the box
  22717. */
  22718. static CreateDisc(options: {
  22719. radius?: number;
  22720. tessellation?: number;
  22721. arc?: number;
  22722. sideOrientation?: number;
  22723. frontUVs?: Vector4;
  22724. backUVs?: Vector4;
  22725. }): VertexData;
  22726. /**
  22727. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22728. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22729. * @param polygon a mesh built from polygonTriangulation.build()
  22730. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22731. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22732. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22733. * @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)
  22734. * @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)
  22735. * @returns the VertexData of the Polygon
  22736. */
  22737. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22738. /**
  22739. * Creates the VertexData of the IcoSphere
  22740. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22741. * * radius the radius of the IcoSphere, optional default 1
  22742. * * radiusX allows stretching in the x direction, optional, default radius
  22743. * * radiusY allows stretching in the y direction, optional, default radius
  22744. * * radiusZ allows stretching in the z direction, optional, default radius
  22745. * * flat when true creates a flat shaded mesh, optional, default true
  22746. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22748. * * 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)
  22749. * * 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)
  22750. * @returns the VertexData of the IcoSphere
  22751. */
  22752. static CreateIcoSphere(options: {
  22753. radius?: number;
  22754. radiusX?: number;
  22755. radiusY?: number;
  22756. radiusZ?: number;
  22757. flat?: boolean;
  22758. subdivisions?: number;
  22759. sideOrientation?: number;
  22760. frontUVs?: Vector4;
  22761. backUVs?: Vector4;
  22762. }): VertexData;
  22763. /**
  22764. * Creates the VertexData for a Polyhedron
  22765. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22766. * * type provided types are:
  22767. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22768. * * 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)
  22769. * * size the size of the IcoSphere, optional default 1
  22770. * * sizeX allows stretching in the x direction, optional, default size
  22771. * * sizeY allows stretching in the y direction, optional, default size
  22772. * * sizeZ allows stretching in the z direction, optional, default size
  22773. * * 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
  22774. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22775. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22776. * * flat when true creates a flat shaded mesh, optional, default true
  22777. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22778. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22779. * * 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)
  22780. * * 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)
  22781. * @returns the VertexData of the Polyhedron
  22782. */
  22783. static CreatePolyhedron(options: {
  22784. type?: number;
  22785. size?: number;
  22786. sizeX?: number;
  22787. sizeY?: number;
  22788. sizeZ?: number;
  22789. custom?: any;
  22790. faceUV?: Vector4[];
  22791. faceColors?: Color4[];
  22792. flat?: boolean;
  22793. sideOrientation?: number;
  22794. frontUVs?: Vector4;
  22795. backUVs?: Vector4;
  22796. }): VertexData;
  22797. /**
  22798. * Creates the VertexData for a TorusKnot
  22799. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22800. * * radius the radius of the torus knot, optional, default 2
  22801. * * tube the thickness of the tube, optional, default 0.5
  22802. * * radialSegments the number of sides on each tube segments, optional, default 32
  22803. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22804. * * p the number of windings around the z axis, optional, default 2
  22805. * * q the number of windings around the x axis, optional, default 3
  22806. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22807. * * 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)
  22808. * * 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)
  22809. * @returns the VertexData of the Torus Knot
  22810. */
  22811. static CreateTorusKnot(options: {
  22812. radius?: number;
  22813. tube?: number;
  22814. radialSegments?: number;
  22815. tubularSegments?: number;
  22816. p?: number;
  22817. q?: number;
  22818. sideOrientation?: number;
  22819. frontUVs?: Vector4;
  22820. backUVs?: Vector4;
  22821. }): VertexData;
  22822. /**
  22823. * Compute normals for given positions and indices
  22824. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22825. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22826. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22827. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22828. * * facetNormals : optional array of facet normals (vector3)
  22829. * * facetPositions : optional array of facet positions (vector3)
  22830. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22831. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22832. * * bInfo : optional bounding info, required for facetPartitioning computation
  22833. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22834. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22835. * * useRightHandedSystem: optional boolean to for right handed system computation
  22836. * * depthSort : optional boolean to enable the facet depth sort computation
  22837. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22838. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22839. */
  22840. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22841. facetNormals?: any;
  22842. facetPositions?: any;
  22843. facetPartitioning?: any;
  22844. ratio?: number;
  22845. bInfo?: any;
  22846. bbSize?: Vector3;
  22847. subDiv?: any;
  22848. useRightHandedSystem?: boolean;
  22849. depthSort?: boolean;
  22850. distanceTo?: Vector3;
  22851. depthSortedFacets?: any;
  22852. }): void;
  22853. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22854. /**
  22855. * Applies VertexData created from the imported parameters to the geometry
  22856. * @param parsedVertexData the parsed data from an imported file
  22857. * @param geometry the geometry to apply the VertexData to
  22858. */
  22859. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22860. }
  22861. }
  22862. declare module BABYLON {
  22863. /**
  22864. * Class containing static functions to help procedurally build meshes
  22865. */
  22866. export class DiscBuilder {
  22867. /**
  22868. * Creates a plane polygonal mesh. By default, this is a disc
  22869. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  22870. * * 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
  22871. * * 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
  22872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  22873. * * 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
  22874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22875. * @param name defines the name of the mesh
  22876. * @param options defines the options used to create the mesh
  22877. * @param scene defines the hosting scene
  22878. * @returns the plane polygonal mesh
  22879. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  22880. */
  22881. static CreateDisc(name: string, options: {
  22882. radius?: number;
  22883. tessellation?: number;
  22884. arc?: number;
  22885. updatable?: boolean;
  22886. sideOrientation?: number;
  22887. frontUVs?: Vector4;
  22888. backUVs?: Vector4;
  22889. }, scene?: Nullable<Scene>): Mesh;
  22890. }
  22891. }
  22892. declare module BABYLON {
  22893. /**
  22894. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  22895. *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.
  22896. * The SPS is also a particle system. It provides some methods to manage the particles.
  22897. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  22898. *
  22899. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  22900. */
  22901. export class SolidParticleSystem implements IDisposable {
  22902. /**
  22903. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  22904. * Example : var p = SPS.particles[i];
  22905. */
  22906. particles: SolidParticle[];
  22907. /**
  22908. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  22909. */
  22910. nbParticles: number;
  22911. /**
  22912. * If the particles must ever face the camera (default false). Useful for planar particles.
  22913. */
  22914. billboard: boolean;
  22915. /**
  22916. * Recompute normals when adding a shape
  22917. */
  22918. recomputeNormals: boolean;
  22919. /**
  22920. * This a counter ofr your own usage. It's not set by any SPS functions.
  22921. */
  22922. counter: number;
  22923. /**
  22924. * The SPS name. This name is also given to the underlying mesh.
  22925. */
  22926. name: string;
  22927. /**
  22928. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  22929. */
  22930. mesh: Mesh;
  22931. /**
  22932. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  22933. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  22934. */
  22935. vars: any;
  22936. /**
  22937. * This array is populated when the SPS is set as 'pickable'.
  22938. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  22939. * Each element of this array is an object `{idx: int, faceId: int}`.
  22940. * `idx` is the picked particle index in the `SPS.particles` array
  22941. * `faceId` is the picked face index counted within this particle.
  22942. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  22943. */
  22944. pickedParticles: {
  22945. idx: number;
  22946. faceId: number;
  22947. }[];
  22948. /**
  22949. * This array is populated when `enableDepthSort` is set to true.
  22950. * Each element of this array is an instance of the class DepthSortedParticle.
  22951. */
  22952. depthSortedParticles: DepthSortedParticle[];
  22953. /**
  22954. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  22955. * @hidden
  22956. */ bSphereOnly: boolean;
  22957. /**
  22958. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  22959. * @hidden
  22960. */ bSphereRadiusFactor: number;
  22961. private _scene;
  22962. private _positions;
  22963. private _indices;
  22964. private _normals;
  22965. private _colors;
  22966. private _uvs;
  22967. private _indices32;
  22968. private _positions32;
  22969. private _normals32;
  22970. private _fixedNormal32;
  22971. private _colors32;
  22972. private _uvs32;
  22973. private _index;
  22974. private _updatable;
  22975. private _pickable;
  22976. private _isVisibilityBoxLocked;
  22977. private _alwaysVisible;
  22978. private _depthSort;
  22979. private _shapeCounter;
  22980. private _copy;
  22981. private _color;
  22982. private _computeParticleColor;
  22983. private _computeParticleTexture;
  22984. private _computeParticleRotation;
  22985. private _computeParticleVertex;
  22986. private _computeBoundingBox;
  22987. private _depthSortParticles;
  22988. private _camera;
  22989. private _mustUnrotateFixedNormals;
  22990. private _particlesIntersect;
  22991. private _needs32Bits;
  22992. /**
  22993. * Creates a SPS (Solid Particle System) object.
  22994. * @param name (String) is the SPS name, this will be the underlying mesh name.
  22995. * @param scene (Scene) is the scene in which the SPS is added.
  22996. * @param options defines the options of the sps e.g.
  22997. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  22998. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  22999. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23000. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23001. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23002. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23003. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23004. */
  23005. constructor(name: string, scene: Scene, options?: {
  23006. updatable?: boolean;
  23007. isPickable?: boolean;
  23008. enableDepthSort?: boolean;
  23009. particleIntersection?: boolean;
  23010. boundingSphereOnly?: boolean;
  23011. bSphereRadiusFactor?: number;
  23012. });
  23013. /**
  23014. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23015. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23016. * @returns the created mesh
  23017. */
  23018. buildMesh(): Mesh;
  23019. /**
  23020. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23021. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23022. * Thus the particles generated from `digest()` have their property `position` set yet.
  23023. * @param mesh ( Mesh ) is the mesh to be digested
  23024. * @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
  23025. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23026. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23027. * @returns the current SPS
  23028. */
  23029. digest(mesh: Mesh, options?: {
  23030. facetNb?: number;
  23031. number?: number;
  23032. delta?: number;
  23033. }): SolidParticleSystem;
  23034. private _unrotateFixedNormals;
  23035. private _resetCopy;
  23036. private _meshBuilder;
  23037. private _posToShape;
  23038. private _uvsToShapeUV;
  23039. private _addParticle;
  23040. /**
  23041. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23042. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23043. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23044. * @param nb (positive integer) the number of particles to be created from this model
  23045. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23046. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23047. * @returns the number of shapes in the system
  23048. */
  23049. addShape(mesh: Mesh, nb: number, options?: {
  23050. positionFunction?: any;
  23051. vertexFunction?: any;
  23052. }): number;
  23053. private _rebuildParticle;
  23054. /**
  23055. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23056. * @returns the SPS.
  23057. */
  23058. rebuildMesh(): SolidParticleSystem;
  23059. /**
  23060. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23061. * This method calls `updateParticle()` for each particle of the SPS.
  23062. * For an animated SPS, it is usually called within the render loop.
  23063. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23064. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23065. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23066. * @returns the SPS.
  23067. */
  23068. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23069. /**
  23070. * Disposes the SPS.
  23071. */
  23072. dispose(): void;
  23073. /**
  23074. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23075. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23076. * @returns the SPS.
  23077. */
  23078. refreshVisibleSize(): SolidParticleSystem;
  23079. /**
  23080. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23081. * @param size the size (float) of the visibility box
  23082. * note : this doesn't lock the SPS mesh bounding box.
  23083. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23084. */
  23085. setVisibilityBox(size: number): void;
  23086. /**
  23087. * Gets whether the SPS as always visible or not
  23088. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23089. */
  23090. /**
  23091. * Sets the SPS as always visible or not
  23092. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23093. */
  23094. isAlwaysVisible: boolean;
  23095. /**
  23096. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23097. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23098. */
  23099. /**
  23100. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23101. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23102. */
  23103. isVisibilityBoxLocked: boolean;
  23104. /**
  23105. * Tells to `setParticles()` to compute the particle rotations or not.
  23106. * Default value : true. The SPS is faster when it's set to false.
  23107. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23108. */
  23109. /**
  23110. * Gets if `setParticles()` computes the particle rotations or not.
  23111. * Default value : true. The SPS is faster when it's set to false.
  23112. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23113. */
  23114. computeParticleRotation: boolean;
  23115. /**
  23116. * Tells to `setParticles()` to compute the particle colors or not.
  23117. * Default value : true. The SPS is faster when it's set to false.
  23118. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23119. */
  23120. /**
  23121. * Gets if `setParticles()` computes the particle colors or not.
  23122. * Default value : true. The SPS is faster when it's set to false.
  23123. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23124. */
  23125. computeParticleColor: boolean;
  23126. /**
  23127. * Gets if `setParticles()` computes the particle textures or not.
  23128. * Default value : true. The SPS is faster when it's set to false.
  23129. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23130. */
  23131. computeParticleTexture: boolean;
  23132. /**
  23133. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23134. * Default value : false. The SPS is faster when it's set to false.
  23135. * Note : the particle custom vertex positions aren't stored values.
  23136. */
  23137. /**
  23138. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23139. * Default value : false. The SPS is faster when it's set to false.
  23140. * Note : the particle custom vertex positions aren't stored values.
  23141. */
  23142. computeParticleVertex: boolean;
  23143. /**
  23144. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23145. */
  23146. /**
  23147. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23148. */
  23149. computeBoundingBox: boolean;
  23150. /**
  23151. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23152. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23153. * Default : `true`
  23154. */
  23155. /**
  23156. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23157. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23158. * Default : `true`
  23159. */
  23160. depthSortParticles: boolean;
  23161. /**
  23162. * This function does nothing. It may be overwritten to set all the particle first values.
  23163. * The SPS doesn't call this function, you may have to call it by your own.
  23164. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23165. */
  23166. initParticles(): void;
  23167. /**
  23168. * This function does nothing. It may be overwritten to recycle a particle.
  23169. * The SPS doesn't call this function, you may have to call it by your own.
  23170. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23171. * @param particle The particle to recycle
  23172. * @returns the recycled particle
  23173. */
  23174. recycleParticle(particle: SolidParticle): SolidParticle;
  23175. /**
  23176. * Updates a particle : this function should be overwritten by the user.
  23177. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23178. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23179. * @example : just set a particle position or velocity and recycle conditions
  23180. * @param particle The particle to update
  23181. * @returns the updated particle
  23182. */
  23183. updateParticle(particle: SolidParticle): SolidParticle;
  23184. /**
  23185. * Updates a vertex of a particle : it can be overwritten by the user.
  23186. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23187. * @param particle the current particle
  23188. * @param vertex the current index of the current particle
  23189. * @param pt the index of the current vertex in the particle shape
  23190. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23191. * @example : just set a vertex particle position
  23192. * @returns the updated vertex
  23193. */
  23194. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23195. /**
  23196. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23197. * This does nothing and may be overwritten by the user.
  23198. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23199. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23200. * @param update the boolean update value actually passed to setParticles()
  23201. */
  23202. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23203. /**
  23204. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23205. * This will be passed three parameters.
  23206. * This does nothing and may be overwritten by the user.
  23207. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23208. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23209. * @param update the boolean update value actually passed to setParticles()
  23210. */
  23211. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23212. }
  23213. }
  23214. declare module BABYLON {
  23215. /**
  23216. * Represents one particle of a solid particle system.
  23217. */
  23218. export class SolidParticle {
  23219. /**
  23220. * particle global index
  23221. */
  23222. idx: number;
  23223. /**
  23224. * The color of the particle
  23225. */
  23226. color: Nullable<Color4>;
  23227. /**
  23228. * The world space position of the particle.
  23229. */
  23230. position: Vector3;
  23231. /**
  23232. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23233. */
  23234. rotation: Vector3;
  23235. /**
  23236. * The world space rotation quaternion of the particle.
  23237. */
  23238. rotationQuaternion: Nullable<Quaternion>;
  23239. /**
  23240. * The scaling of the particle.
  23241. */
  23242. scaling: Vector3;
  23243. /**
  23244. * The uvs of the particle.
  23245. */
  23246. uvs: Vector4;
  23247. /**
  23248. * The current speed of the particle.
  23249. */
  23250. velocity: Vector3;
  23251. /**
  23252. * The pivot point in the particle local space.
  23253. */
  23254. pivot: Vector3;
  23255. /**
  23256. * Must the particle be translated from its pivot point in its local space ?
  23257. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23258. * Default : false
  23259. */
  23260. translateFromPivot: boolean;
  23261. /**
  23262. * Is the particle active or not ?
  23263. */
  23264. alive: boolean;
  23265. /**
  23266. * Is the particle visible or not ?
  23267. */
  23268. isVisible: boolean;
  23269. /**
  23270. * Index of this particle in the global "positions" array (Internal use)
  23271. * @hidden
  23272. */ pos: number;
  23273. /**
  23274. * @hidden Index of this particle in the global "indices" array (Internal use)
  23275. */ ind: number;
  23276. /**
  23277. * @hidden ModelShape of this particle (Internal use)
  23278. */ model: ModelShape;
  23279. /**
  23280. * ModelShape id of this particle
  23281. */
  23282. shapeId: number;
  23283. /**
  23284. * Index of the particle in its shape id (Internal use)
  23285. */
  23286. idxInShape: number;
  23287. /**
  23288. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23289. */ modelBoundingInfo: BoundingInfo;
  23290. /**
  23291. * @hidden Particle BoundingInfo object (Internal use)
  23292. */ boundingInfo: BoundingInfo;
  23293. /**
  23294. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23295. */ sps: SolidParticleSystem;
  23296. /**
  23297. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23298. */ stillInvisible: boolean;
  23299. /**
  23300. * @hidden Last computed particle rotation matrix
  23301. */ rotationMatrix: number[];
  23302. /**
  23303. * Parent particle Id, if any.
  23304. * Default null.
  23305. */
  23306. parentId: Nullable<number>;
  23307. /**
  23308. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23309. * The possible values are :
  23310. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23311. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23313. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23314. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23315. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23316. * */
  23317. cullingStrategy: number;
  23318. /**
  23319. * @hidden Internal global position in the SPS.
  23320. */ globalPosition: Vector3;
  23321. /**
  23322. * Creates a Solid Particle object.
  23323. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23324. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23325. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23326. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23327. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23328. * @param shapeId (integer) is the model shape identifier in the SPS.
  23329. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23330. * @param sps defines the sps it is associated to
  23331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23332. */
  23333. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23334. /**
  23335. * Legacy support, changed scale to scaling
  23336. */
  23337. /**
  23338. * Legacy support, changed scale to scaling
  23339. */
  23340. scale: Vector3;
  23341. /**
  23342. * Legacy support, changed quaternion to rotationQuaternion
  23343. */
  23344. /**
  23345. * Legacy support, changed quaternion to rotationQuaternion
  23346. */
  23347. quaternion: Nullable<Quaternion>;
  23348. /**
  23349. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23350. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23351. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23352. * @returns true if it intersects
  23353. */
  23354. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23355. /**
  23356. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23357. * A particle is in the frustum if its bounding box intersects the frustum
  23358. * @param frustumPlanes defines the frustum to test
  23359. * @returns true if the particle is in the frustum planes
  23360. */
  23361. isInFrustum(frustumPlanes: Plane[]): boolean;
  23362. /**
  23363. * get the rotation matrix of the particle
  23364. * @hidden
  23365. */
  23366. getRotationMatrix(m: Matrix): void;
  23367. }
  23368. /**
  23369. * Represents the shape of the model used by one particle of a solid particle system.
  23370. * SPS internal tool, don't use it manually.
  23371. */
  23372. export class ModelShape {
  23373. /**
  23374. * The shape id
  23375. * @hidden
  23376. */
  23377. shapeID: number;
  23378. /**
  23379. * flat array of model positions (internal use)
  23380. * @hidden
  23381. */ shape: Vector3[];
  23382. /**
  23383. * flat array of model UVs (internal use)
  23384. * @hidden
  23385. */ shapeUV: number[];
  23386. /**
  23387. * length of the shape in the model indices array (internal use)
  23388. * @hidden
  23389. */ indicesLength: number;
  23390. /**
  23391. * Custom position function (internal use)
  23392. * @hidden
  23393. */ positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23394. /**
  23395. * Custom vertex function (internal use)
  23396. * @hidden
  23397. */ vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23398. /**
  23399. * 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.
  23400. * SPS internal tool, don't use it manually.
  23401. * @hidden
  23402. */
  23403. 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>);
  23404. }
  23405. /**
  23406. * Represents a Depth Sorted Particle in the solid particle system.
  23407. */
  23408. export class DepthSortedParticle {
  23409. /**
  23410. * Index of the particle in the "indices" array
  23411. */
  23412. ind: number;
  23413. /**
  23414. * Length of the particle shape in the "indices" array
  23415. */
  23416. indicesLength: number;
  23417. /**
  23418. * Squared distance from the particle to the camera
  23419. */
  23420. sqDistance: number;
  23421. }
  23422. }
  23423. declare module BABYLON {
  23424. /**
  23425. * Class used to store all common mesh properties
  23426. */
  23427. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23428. /** No occlusion */
  23429. static OCCLUSION_TYPE_NONE: number;
  23430. /** Occlusion set to optimisitic */
  23431. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23432. /** Occlusion set to strict */
  23433. static OCCLUSION_TYPE_STRICT: number;
  23434. /** Use an accurante occlusion algorithm */
  23435. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23436. /** Use a conservative occlusion algorithm */
  23437. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23438. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23439. * Test order :
  23440. * Is the bounding sphere outside the frustum ?
  23441. * If not, are the bounding box vertices outside the frustum ?
  23442. * It not, then the cullable object is in the frustum.
  23443. */
  23444. static readonly CULLINGSTRATEGY_STANDARD: number;
  23445. /** Culling strategy : Bounding Sphere Only.
  23446. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23447. * It's also less accurate than the standard because some not visible objects can still be selected.
  23448. * Test : is the bounding sphere outside the frustum ?
  23449. * If not, then the cullable object is in the frustum.
  23450. */
  23451. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23452. /** Culling strategy : Optimistic Inclusion.
  23453. * This in an inclusion test first, then the standard exclusion test.
  23454. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23455. * 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.
  23456. * Anyway, it's as accurate as the standard strategy.
  23457. * Test :
  23458. * Is the cullable object bounding sphere center in the frustum ?
  23459. * If not, apply the default culling strategy.
  23460. */
  23461. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23462. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23463. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23464. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23465. * 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.
  23466. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23467. * Test :
  23468. * Is the cullable object bounding sphere center in the frustum ?
  23469. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23470. */
  23471. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23472. /**
  23473. * No billboard
  23474. */
  23475. static readonly BILLBOARDMODE_NONE: number;
  23476. /** Billboard on X axis */
  23477. static readonly BILLBOARDMODE_X: number;
  23478. /** Billboard on Y axis */
  23479. static readonly BILLBOARDMODE_Y: number;
  23480. /** Billboard on Z axis */
  23481. static readonly BILLBOARDMODE_Z: number;
  23482. /** Billboard on all axes */
  23483. static readonly BILLBOARDMODE_ALL: number;
  23484. private _facetData;
  23485. /**
  23486. * The culling strategy to use to check whether the mesh must be rendered or not.
  23487. * This value can be changed at any time and will be used on the next render mesh selection.
  23488. * The possible values are :
  23489. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23490. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23491. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23492. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23493. * Please read each static variable documentation to get details about the culling process.
  23494. * */
  23495. cullingStrategy: number;
  23496. /**
  23497. * Gets the number of facets in the mesh
  23498. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23499. */
  23500. readonly facetNb: number;
  23501. /**
  23502. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23503. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23504. */
  23505. partitioningSubdivisions: number;
  23506. /**
  23507. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23508. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23510. */
  23511. partitioningBBoxRatio: number;
  23512. /**
  23513. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23514. * Works only for updatable meshes.
  23515. * Doesn't work with multi-materials
  23516. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23517. */
  23518. mustDepthSortFacets: boolean;
  23519. /**
  23520. * The location (Vector3) where the facet depth sort must be computed from.
  23521. * By default, the active camera position.
  23522. * Used only when facet depth sort is enabled
  23523. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23524. */
  23525. facetDepthSortFrom: Vector3;
  23526. /**
  23527. * gets a boolean indicating if facetData is enabled
  23528. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23529. */
  23530. readonly isFacetDataEnabled: boolean;
  23531. /** @hidden */ updateNonUniformScalingState(value: boolean): boolean;
  23532. /**
  23533. * An event triggered when this mesh collides with another one
  23534. */
  23535. onCollideObservable: Observable<AbstractMesh>;
  23536. private _onCollideObserver;
  23537. /** Set a function to call when this mesh collides with another one */
  23538. onCollide: () => void;
  23539. /**
  23540. * An event triggered when the collision's position changes
  23541. */
  23542. onCollisionPositionChangeObservable: Observable<Vector3>;
  23543. private _onCollisionPositionChangeObserver;
  23544. /** Set a function to call when the collision's position changes */
  23545. onCollisionPositionChange: () => void;
  23546. /**
  23547. * An event triggered when material is changed
  23548. */
  23549. onMaterialChangedObservable: Observable<AbstractMesh>;
  23550. /**
  23551. * Gets or sets the orientation for POV movement & rotation
  23552. */
  23553. definedFacingForward: boolean;
  23554. /** @hidden */ occlusionQuery: Nullable<WebGLQuery>;
  23555. private _visibility;
  23556. /**
  23557. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23558. */
  23559. /**
  23560. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23561. */
  23562. visibility: number;
  23563. /** Gets or sets the alpha index used to sort transparent meshes
  23564. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23565. */
  23566. alphaIndex: number;
  23567. /**
  23568. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23569. */
  23570. isVisible: boolean;
  23571. /**
  23572. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23573. */
  23574. isPickable: boolean;
  23575. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23576. showSubMeshesBoundingBox: boolean;
  23577. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  23578. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  23579. */
  23580. isBlocker: boolean;
  23581. /**
  23582. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  23583. */
  23584. enablePointerMoveEvents: boolean;
  23585. /**
  23586. * Specifies the rendering group id for this mesh (0 by default)
  23587. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  23588. */
  23589. renderingGroupId: number;
  23590. private _material;
  23591. /** Gets or sets current material */
  23592. material: Nullable<Material>;
  23593. private _receiveShadows;
  23594. /**
  23595. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  23596. * @see http://doc.babylonjs.com/babylon101/shadows
  23597. */
  23598. receiveShadows: boolean;
  23599. /** Defines color to use when rendering outline */
  23600. outlineColor: Color3;
  23601. /** Define width to use when rendering outline */
  23602. outlineWidth: number;
  23603. /** Defines color to use when rendering overlay */
  23604. overlayColor: Color3;
  23605. /** Defines alpha to use when rendering overlay */
  23606. overlayAlpha: number;
  23607. private _hasVertexAlpha;
  23608. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  23609. hasVertexAlpha: boolean;
  23610. private _useVertexColors;
  23611. /** 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) */
  23612. useVertexColors: boolean;
  23613. private _computeBonesUsingShaders;
  23614. /**
  23615. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  23616. */
  23617. computeBonesUsingShaders: boolean;
  23618. private _numBoneInfluencers;
  23619. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  23620. numBoneInfluencers: number;
  23621. private _applyFog;
  23622. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  23623. applyFog: boolean;
  23624. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  23625. useOctreeForRenderingSelection: boolean;
  23626. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  23627. useOctreeForPicking: boolean;
  23628. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  23629. useOctreeForCollisions: boolean;
  23630. private _layerMask;
  23631. /**
  23632. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  23633. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  23634. */
  23635. layerMask: number;
  23636. /**
  23637. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  23638. */
  23639. alwaysSelectAsActiveMesh: boolean;
  23640. /**
  23641. * Gets or sets the current action manager
  23642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  23643. */
  23644. actionManager: Nullable<AbstractActionManager>;
  23645. private _checkCollisions;
  23646. private _collisionMask;
  23647. private _collisionGroup;
  23648. /**
  23649. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  23650. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23651. */
  23652. ellipsoid: Vector3;
  23653. /**
  23654. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  23655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23656. */
  23657. ellipsoidOffset: Vector3;
  23658. private _collider;
  23659. private _oldPositionForCollisions;
  23660. private _diffPositionForCollisions;
  23661. /**
  23662. * Gets or sets a collision mask used to mask collisions (default is -1).
  23663. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23664. */
  23665. collisionMask: number;
  23666. /**
  23667. * Gets or sets the current collision group mask (-1 by default).
  23668. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  23669. */
  23670. collisionGroup: number;
  23671. /**
  23672. * Defines edge width used when edgesRenderer is enabled
  23673. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23674. */
  23675. edgesWidth: number;
  23676. /**
  23677. * Defines edge color used when edgesRenderer is enabled
  23678. * @see https://www.babylonjs-playground.com/#10OJSG#13
  23679. */
  23680. edgesColor: Color4;
  23681. /** @hidden */ edgesRenderer: Nullable<IEdgesRenderer>;
  23682. /** @hidden */ masterMesh: Nullable<AbstractMesh>;
  23683. /** @hidden */ boundingInfo: Nullable<BoundingInfo>;
  23684. /** @hidden */ renderId: number;
  23685. /**
  23686. * Gets or sets the list of subMeshes
  23687. * @see http://doc.babylonjs.com/how_to/multi_materials
  23688. */
  23689. subMeshes: SubMesh[];
  23690. /** @hidden */ intersectionsInProgress: AbstractMesh[];
  23691. /** @hidden */ unIndexed: boolean;
  23692. /** @hidden */ lightSources: Light[];
  23693. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23694. /** @hidden */ waitingActions: any;
  23695. /** @hidden */ waitingFreezeWorldMatrix: Nullable<boolean>;
  23696. private _skeleton;
  23697. /** @hidden */ bonesTransformMatrices: Nullable<Float32Array>;
  23698. /**
  23699. * Gets or sets a skeleton to apply skining transformations
  23700. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  23701. */
  23702. skeleton: Nullable<Skeleton>;
  23703. /**
  23704. * An event triggered when the mesh is rebuilt.
  23705. */
  23706. onRebuildObservable: Observable<AbstractMesh>;
  23707. /**
  23708. * Creates a new AbstractMesh
  23709. * @param name defines the name of the mesh
  23710. * @param scene defines the hosting scene
  23711. */
  23712. constructor(name: string, scene?: Nullable<Scene>);
  23713. /**
  23714. * Returns the string "AbstractMesh"
  23715. * @returns "AbstractMesh"
  23716. */
  23717. getClassName(): string;
  23718. /**
  23719. * Gets a string representation of the current mesh
  23720. * @param fullDetails defines a boolean indicating if full details must be included
  23721. * @returns a string representation of the current mesh
  23722. */
  23723. toString(fullDetails?: boolean): string;
  23724. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  23725. /** @hidden */ rebuild(): void;
  23726. /** @hidden */ resyncLightSources(): void;
  23727. /** @hidden */ resyncLighSource(light: Light): void;
  23728. /** @hidden */ unBindEffect(): void;
  23729. /** @hidden */ removeLightSource(light: Light): void;
  23730. private _markSubMeshesAsDirty;
  23731. /** @hidden */ markSubMeshesAsLightDirty(): void;
  23732. /** @hidden */ markSubMeshesAsAttributesDirty(): void;
  23733. /** @hidden */ markSubMeshesAsMiscDirty(): void;
  23734. /**
  23735. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  23736. */
  23737. scaling: Vector3;
  23738. /**
  23739. * Returns true if the mesh is blocked. Implemented by child classes
  23740. */
  23741. readonly isBlocked: boolean;
  23742. /**
  23743. * Returns the mesh itself by default. Implemented by child classes
  23744. * @param camera defines the camera to use to pick the right LOD level
  23745. * @returns the currentAbstractMesh
  23746. */
  23747. getLOD(camera: Camera): Nullable<AbstractMesh>;
  23748. /**
  23749. * Returns 0 by default. Implemented by child classes
  23750. * @returns an integer
  23751. */
  23752. getTotalVertices(): number;
  23753. /**
  23754. * Returns a positive integer : the total number of indices in this mesh geometry.
  23755. * @returns the numner of indices or zero if the mesh has no geometry.
  23756. */
  23757. getTotalIndices(): number;
  23758. /**
  23759. * Returns null by default. Implemented by child classes
  23760. * @returns null
  23761. */
  23762. getIndices(): Nullable<IndicesArray>;
  23763. /**
  23764. * Returns the array of the requested vertex data kind. Implemented by child classes
  23765. * @param kind defines the vertex data kind to use
  23766. * @returns null
  23767. */
  23768. getVerticesData(kind: string): Nullable<FloatArray>;
  23769. /**
  23770. * Sets the vertex data of the mesh geometry for the requested `kind`.
  23771. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  23772. * Note that a new underlying VertexBuffer object is created each call.
  23773. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  23774. * @param kind defines vertex data kind:
  23775. * * VertexBuffer.PositionKind
  23776. * * VertexBuffer.UVKind
  23777. * * VertexBuffer.UV2Kind
  23778. * * VertexBuffer.UV3Kind
  23779. * * VertexBuffer.UV4Kind
  23780. * * VertexBuffer.UV5Kind
  23781. * * VertexBuffer.UV6Kind
  23782. * * VertexBuffer.ColorKind
  23783. * * VertexBuffer.MatricesIndicesKind
  23784. * * VertexBuffer.MatricesIndicesExtraKind
  23785. * * VertexBuffer.MatricesWeightsKind
  23786. * * VertexBuffer.MatricesWeightsExtraKind
  23787. * @param data defines the data source
  23788. * @param updatable defines if the data must be flagged as updatable (or static)
  23789. * @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
  23790. * @returns the current mesh
  23791. */
  23792. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  23793. /**
  23794. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  23795. * If the mesh has no geometry, it is simply returned as it is.
  23796. * @param kind defines vertex data kind:
  23797. * * VertexBuffer.PositionKind
  23798. * * VertexBuffer.UVKind
  23799. * * VertexBuffer.UV2Kind
  23800. * * VertexBuffer.UV3Kind
  23801. * * VertexBuffer.UV4Kind
  23802. * * VertexBuffer.UV5Kind
  23803. * * VertexBuffer.UV6Kind
  23804. * * VertexBuffer.ColorKind
  23805. * * VertexBuffer.MatricesIndicesKind
  23806. * * VertexBuffer.MatricesIndicesExtraKind
  23807. * * VertexBuffer.MatricesWeightsKind
  23808. * * VertexBuffer.MatricesWeightsExtraKind
  23809. * @param data defines the data source
  23810. * @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
  23811. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  23812. * @returns the current mesh
  23813. */
  23814. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  23815. /**
  23816. * Sets the mesh indices,
  23817. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  23818. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  23819. * @param totalVertices Defines the total number of vertices
  23820. * @returns the current mesh
  23821. */
  23822. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  23823. /**
  23824. * Gets a boolean indicating if specific vertex data is present
  23825. * @param kind defines the vertex data kind to use
  23826. * @returns true is data kind is present
  23827. */
  23828. isVerticesDataPresent(kind: string): boolean;
  23829. /**
  23830. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  23831. * @returns a BoundingInfo
  23832. */
  23833. getBoundingInfo(): BoundingInfo;
  23834. /**
  23835. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  23836. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  23837. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  23838. * @returns the current mesh
  23839. */
  23840. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  23841. /**
  23842. * Overwrite the current bounding info
  23843. * @param boundingInfo defines the new bounding info
  23844. * @returns the current mesh
  23845. */
  23846. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  23847. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  23848. readonly useBones: boolean;
  23849. /** @hidden */ preActivate(): void;
  23850. /** @hidden */ preActivateForIntermediateRendering(renderId: number): void;
  23851. /** @hidden */ activate(renderId: number): void;
  23852. /**
  23853. * Gets the current world matrix
  23854. * @returns a Matrix
  23855. */
  23856. getWorldMatrix(): Matrix;
  23857. /** @hidden */ getWorldMatrixDeterminant(): number;
  23858. /**
  23859. * Perform relative position change from the point of view of behind the front of the mesh.
  23860. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23861. * Supports definition of mesh facing forward or backward
  23862. * @param amountRight defines the distance on the right axis
  23863. * @param amountUp defines the distance on the up axis
  23864. * @param amountForward defines the distance on the forward axis
  23865. * @returns the current mesh
  23866. */
  23867. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  23868. /**
  23869. * Calculate relative position change from the point of view of behind the front of the mesh.
  23870. * This is performed taking into account the meshes current rotation, so you do not have to care.
  23871. * Supports definition of mesh facing forward or backward
  23872. * @param amountRight defines the distance on the right axis
  23873. * @param amountUp defines the distance on the up axis
  23874. * @param amountForward defines the distance on the forward axis
  23875. * @returns the new displacement vector
  23876. */
  23877. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  23878. /**
  23879. * Perform relative rotation change from the point of view of behind the front of the mesh.
  23880. * Supports definition of mesh facing forward or backward
  23881. * @param flipBack defines the flip
  23882. * @param twirlClockwise defines the twirl
  23883. * @param tiltRight defines the tilt
  23884. * @returns the current mesh
  23885. */
  23886. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  23887. /**
  23888. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  23889. * Supports definition of mesh facing forward or backward.
  23890. * @param flipBack defines the flip
  23891. * @param twirlClockwise defines the twirl
  23892. * @param tiltRight defines the tilt
  23893. * @returns the new rotation vector
  23894. */
  23895. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  23896. /**
  23897. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  23898. * @param includeDescendants Include bounding info from descendants as well (true by default)
  23899. * @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
  23900. * @returns the new bounding vectors
  23901. */
  23902. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  23903. min: Vector3;
  23904. max: Vector3;
  23905. };
  23906. /**
  23907. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23908. * This means the mesh underlying bounding box and sphere are recomputed.
  23909. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23910. * @returns the current mesh
  23911. */
  23912. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  23913. /** @hidden */ refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  23914. /** @hidden */ getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  23915. /** @hidden */ updateBoundingInfo(): AbstractMesh;
  23916. /** @hidden */ updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  23917. /** @hidden */
  23918. protected _afterComputeWorldMatrix(): void;
  23919. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  23920. /**
  23921. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23922. * A mesh is in the frustum if its bounding box intersects the frustum
  23923. * @param frustumPlanes defines the frustum to test
  23924. * @returns true if the mesh is in the frustum planes
  23925. */
  23926. isInFrustum(frustumPlanes: Plane[]): boolean;
  23927. /**
  23928. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  23929. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  23930. * @param frustumPlanes defines the frustum to test
  23931. * @returns true if the mesh is completely in the frustum planes
  23932. */
  23933. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23934. /**
  23935. * True if the mesh intersects another mesh or a SolidParticle object
  23936. * @param mesh defines a target mesh or SolidParticle to test
  23937. * @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)
  23938. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  23939. * @returns true if there is an intersection
  23940. */
  23941. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  23942. /**
  23943. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  23944. * @param point defines the point to test
  23945. * @returns true if there is an intersection
  23946. */
  23947. intersectsPoint(point: Vector3): boolean;
  23948. /**
  23949. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  23950. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23951. */
  23952. checkCollisions: boolean;
  23953. /**
  23954. * Gets Collider object used to compute collisions (not physics)
  23955. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23956. */
  23957. readonly collider: Collider;
  23958. /**
  23959. * Move the mesh using collision engine
  23960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  23961. * @param displacement defines the requested displacement vector
  23962. * @returns the current mesh
  23963. */
  23964. moveWithCollisions(displacement: Vector3): AbstractMesh;
  23965. private _onCollisionPositionChange;
  23966. /** @hidden */ collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  23967. /** @hidden */ processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  23968. /** @hidden */ checkCollision(collider: Collider): AbstractMesh;
  23969. /** @hidden */ generatePointsArray(): boolean;
  23970. /**
  23971. * Checks if the passed Ray intersects with the mesh
  23972. * @param ray defines the ray to use
  23973. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  23974. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23975. * @returns the picking info
  23976. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  23977. */
  23978. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  23979. /**
  23980. * Clones the current mesh
  23981. * @param name defines the mesh name
  23982. * @param newParent defines the new mesh parent
  23983. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  23984. * @returns the new mesh
  23985. */
  23986. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  23987. /**
  23988. * Disposes all the submeshes of the current meshnp
  23989. * @returns the current mesh
  23990. */
  23991. releaseSubMeshes(): AbstractMesh;
  23992. /**
  23993. * Releases resources associated with this abstract mesh.
  23994. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23995. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23996. */
  23997. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23998. /**
  23999. * Adds the passed mesh as a child to the current mesh
  24000. * @param mesh defines the child mesh
  24001. * @returns the current mesh
  24002. */
  24003. addChild(mesh: AbstractMesh): AbstractMesh;
  24004. /**
  24005. * Removes the passed mesh from the current mesh children list
  24006. * @param mesh defines the child mesh
  24007. * @returns the current mesh
  24008. */
  24009. removeChild(mesh: AbstractMesh): AbstractMesh;
  24010. /** @hidden */
  24011. private _initFacetData;
  24012. /**
  24013. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24014. * This method can be called within the render loop.
  24015. * 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
  24016. * @returns the current mesh
  24017. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24018. */
  24019. updateFacetData(): AbstractMesh;
  24020. /**
  24021. * Returns the facetLocalNormals array.
  24022. * The normals are expressed in the mesh local spac
  24023. * @returns an array of Vector3
  24024. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24025. */
  24026. getFacetLocalNormals(): Vector3[];
  24027. /**
  24028. * Returns the facetLocalPositions array.
  24029. * The facet positions are expressed in the mesh local space
  24030. * @returns an array of Vector3
  24031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24032. */
  24033. getFacetLocalPositions(): Vector3[];
  24034. /**
  24035. * Returns the facetLocalPartioning array
  24036. * @returns an array of array of numbers
  24037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24038. */
  24039. getFacetLocalPartitioning(): number[][];
  24040. /**
  24041. * Returns the i-th facet position in the world system.
  24042. * This method allocates a new Vector3 per call
  24043. * @param i defines the facet index
  24044. * @returns a new Vector3
  24045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24046. */
  24047. getFacetPosition(i: number): Vector3;
  24048. /**
  24049. * Sets the reference Vector3 with the i-th facet position in the world system
  24050. * @param i defines the facet index
  24051. * @param ref defines the target vector
  24052. * @returns the current mesh
  24053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24054. */
  24055. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24056. /**
  24057. * Returns the i-th facet normal in the world system.
  24058. * This method allocates a new Vector3 per call
  24059. * @param i defines the facet index
  24060. * @returns a new Vector3
  24061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24062. */
  24063. getFacetNormal(i: number): Vector3;
  24064. /**
  24065. * Sets the reference Vector3 with the i-th facet normal in the world system
  24066. * @param i defines the facet index
  24067. * @param ref defines the target vector
  24068. * @returns the current mesh
  24069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24070. */
  24071. getFacetNormalToRef(i: number, ref: Vector3): this;
  24072. /**
  24073. * 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)
  24074. * @param x defines x coordinate
  24075. * @param y defines y coordinate
  24076. * @param z defines z coordinate
  24077. * @returns the array of facet indexes
  24078. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24079. */
  24080. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24081. /**
  24082. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24083. * @param projected sets as the (x,y,z) world projection on the facet
  24084. * @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
  24085. * @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
  24086. * @param x defines x coordinate
  24087. * @param y defines y coordinate
  24088. * @param z defines z coordinate
  24089. * @returns the face index if found (or null instead)
  24090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24091. */
  24092. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24093. /**
  24094. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24095. * @param projected sets as the (x,y,z) local projection on the facet
  24096. * @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
  24097. * @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
  24098. * @param x defines x coordinate
  24099. * @param y defines y coordinate
  24100. * @param z defines z coordinate
  24101. * @returns the face index if found (or null instead)
  24102. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24103. */
  24104. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24105. /**
  24106. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24107. * @returns the parameters
  24108. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24109. */
  24110. getFacetDataParameters(): any;
  24111. /**
  24112. * Disables the feature FacetData and frees the related memory
  24113. * @returns the current mesh
  24114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24115. */
  24116. disableFacetData(): AbstractMesh;
  24117. /**
  24118. * Updates the AbstractMesh indices array
  24119. * @param indices defines the data source
  24120. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24121. * @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)
  24122. * @returns the current mesh
  24123. */
  24124. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24125. /**
  24126. * Creates new normals data for the mesh
  24127. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24128. * @returns the current mesh
  24129. */
  24130. createNormals(updatable: boolean): AbstractMesh;
  24131. /**
  24132. * Align the mesh with a normal
  24133. * @param normal defines the normal to use
  24134. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24135. * @returns the current mesh
  24136. */
  24137. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24138. /** @hidden */ checkOcclusionQuery(): boolean;
  24139. }
  24140. }
  24141. declare module BABYLON {
  24142. /**
  24143. * Interface used to define ActionEvent
  24144. */
  24145. export interface IActionEvent {
  24146. /** The mesh or sprite that triggered the action */
  24147. source: any;
  24148. /** The X mouse cursor position at the time of the event */
  24149. pointerX: number;
  24150. /** The Y mouse cursor position at the time of the event */
  24151. pointerY: number;
  24152. /** The mesh that is currently pointed at (can be null) */
  24153. meshUnderPointer: Nullable<AbstractMesh>;
  24154. /** the original (browser) event that triggered the ActionEvent */
  24155. sourceEvent?: any;
  24156. /** additional data for the event */
  24157. additionalData?: any;
  24158. }
  24159. /**
  24160. * ActionEvent is the event being sent when an action is triggered.
  24161. */
  24162. export class ActionEvent implements IActionEvent {
  24163. /** The mesh or sprite that triggered the action */
  24164. source: any;
  24165. /** The X mouse cursor position at the time of the event */
  24166. pointerX: number;
  24167. /** The Y mouse cursor position at the time of the event */
  24168. pointerY: number;
  24169. /** The mesh that is currently pointed at (can be null) */
  24170. meshUnderPointer: Nullable<AbstractMesh>;
  24171. /** the original (browser) event that triggered the ActionEvent */
  24172. sourceEvent?: any;
  24173. /** additional data for the event */
  24174. additionalData?: any;
  24175. /**
  24176. * Creates a new ActionEvent
  24177. * @param source The mesh or sprite that triggered the action
  24178. * @param pointerX The X mouse cursor position at the time of the event
  24179. * @param pointerY The Y mouse cursor position at the time of the event
  24180. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24181. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24182. * @param additionalData additional data for the event
  24183. */
  24184. constructor(
  24185. /** The mesh or sprite that triggered the action */
  24186. source: any,
  24187. /** The X mouse cursor position at the time of the event */
  24188. pointerX: number,
  24189. /** The Y mouse cursor position at the time of the event */
  24190. pointerY: number,
  24191. /** The mesh that is currently pointed at (can be null) */
  24192. meshUnderPointer: Nullable<AbstractMesh>,
  24193. /** the original (browser) event that triggered the ActionEvent */
  24194. sourceEvent?: any,
  24195. /** additional data for the event */
  24196. additionalData?: any);
  24197. /**
  24198. * Helper function to auto-create an ActionEvent from a source mesh.
  24199. * @param source The source mesh that triggered the event
  24200. * @param evt The original (browser) event
  24201. * @param additionalData additional data for the event
  24202. * @returns the new ActionEvent
  24203. */
  24204. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24205. /**
  24206. * Helper function to auto-create an ActionEvent from a source sprite
  24207. * @param source The source sprite that triggered the event
  24208. * @param scene Scene associated with the sprite
  24209. * @param evt The original (browser) event
  24210. * @param additionalData additional data for the event
  24211. * @returns the new ActionEvent
  24212. */
  24213. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24214. /**
  24215. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24216. * @param scene the scene where the event occurred
  24217. * @param evt The original (browser) event
  24218. * @returns the new ActionEvent
  24219. */
  24220. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24221. /**
  24222. * Helper function to auto-create an ActionEvent from a primitive
  24223. * @param prim defines the target primitive
  24224. * @param pointerPos defines the pointer position
  24225. * @param evt The original (browser) event
  24226. * @param additionalData additional data for the event
  24227. * @returns the new ActionEvent
  24228. */
  24229. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24230. }
  24231. }
  24232. declare module BABYLON {
  24233. /**
  24234. * Abstract class used to decouple action Manager from scene and meshes.
  24235. * Do not instantiate.
  24236. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24237. */
  24238. export abstract class AbstractActionManager implements IDisposable {
  24239. /** Gets the list of active triggers */
  24240. static Triggers: {
  24241. [key: string]: number;
  24242. };
  24243. /** Gets the cursor to use when hovering items */
  24244. hoverCursor: string;
  24245. /** Gets the list of actions */
  24246. actions: IAction[];
  24247. /**
  24248. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24249. */
  24250. isRecursive: boolean;
  24251. /**
  24252. * Releases all associated resources
  24253. */
  24254. abstract dispose(): void;
  24255. /**
  24256. * Does this action manager has pointer triggers
  24257. */
  24258. abstract readonly hasPointerTriggers: boolean;
  24259. /**
  24260. * Does this action manager has pick triggers
  24261. */
  24262. abstract readonly hasPickTriggers: boolean;
  24263. /**
  24264. * Process a specific trigger
  24265. * @param trigger defines the trigger to process
  24266. * @param evt defines the event details to be processed
  24267. */
  24268. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24269. /**
  24270. * Does this action manager handles actions of any of the given triggers
  24271. * @param triggers defines the triggers to be tested
  24272. * @return a boolean indicating whether one (or more) of the triggers is handled
  24273. */
  24274. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24275. /**
  24276. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24277. * speed.
  24278. * @param triggerA defines the trigger to be tested
  24279. * @param triggerB defines the trigger to be tested
  24280. * @return a boolean indicating whether one (or more) of the triggers is handled
  24281. */
  24282. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24283. /**
  24284. * Does this action manager handles actions of a given trigger
  24285. * @param trigger defines the trigger to be tested
  24286. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24287. * @return whether the trigger is handled
  24288. */
  24289. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24290. /**
  24291. * Serialize this manager to a JSON object
  24292. * @param name defines the property name to store this manager
  24293. * @returns a JSON representation of this manager
  24294. */
  24295. abstract serialize(name: string): any;
  24296. /**
  24297. * Registers an action to this action manager
  24298. * @param action defines the action to be registered
  24299. * @return the action amended (prepared) after registration
  24300. */
  24301. abstract registerAction(action: IAction): Nullable<IAction>;
  24302. /**
  24303. * Unregisters an action to this action manager
  24304. * @param action defines the action to be unregistered
  24305. * @return a boolean indicating whether the action has been unregistered
  24306. */
  24307. abstract unregisterAction(action: IAction): Boolean;
  24308. /**
  24309. * Does exist one action manager with at least one trigger
  24310. **/
  24311. static readonly HasTriggers: boolean;
  24312. /**
  24313. * Does exist one action manager with at least one pick trigger
  24314. **/
  24315. static readonly HasPickTriggers: boolean;
  24316. /**
  24317. * Does exist one action manager that handles actions of a given trigger
  24318. * @param trigger defines the trigger to be tested
  24319. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24320. **/
  24321. static HasSpecificTrigger(trigger: number): boolean;
  24322. }
  24323. }
  24324. declare module BABYLON {
  24325. /**
  24326. * Defines how a node can be built from a string name.
  24327. */
  24328. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24329. /**
  24330. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24331. */
  24332. export class Node implements IBehaviorAware<Node> {
  24333. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24334. private static _NodeConstructors;
  24335. /**
  24336. * Add a new node constructor
  24337. * @param type defines the type name of the node to construct
  24338. * @param constructorFunc defines the constructor function
  24339. */
  24340. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24341. /**
  24342. * Returns a node constructor based on type name
  24343. * @param type defines the type name
  24344. * @param name defines the new node name
  24345. * @param scene defines the hosting scene
  24346. * @param options defines optional options to transmit to constructors
  24347. * @returns the new constructor or null
  24348. */
  24349. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24350. /**
  24351. * Gets or sets the name of the node
  24352. */
  24353. name: string;
  24354. /**
  24355. * Gets or sets the id of the node
  24356. */
  24357. id: string;
  24358. /**
  24359. * Gets or sets the unique id of the node
  24360. */
  24361. uniqueId: number;
  24362. /**
  24363. * Gets or sets a string used to store user defined state for the node
  24364. */
  24365. state: string;
  24366. /**
  24367. * Gets or sets an object used to store user defined information for the node
  24368. */
  24369. metadata: any;
  24370. /**
  24371. * For internal use only. Please do not use.
  24372. */
  24373. reservedDataStore: any;
  24374. /**
  24375. * List of inspectable custom properties (used by the Inspector)
  24376. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24377. */
  24378. inspectableCustomProperties: IInspectable[];
  24379. /**
  24380. * Gets or sets a boolean used to define if the node must be serialized
  24381. */
  24382. doNotSerialize: boolean;
  24383. /** @hidden */ isDisposed: boolean;
  24384. /**
  24385. * Gets a list of Animations associated with the node
  24386. */
  24387. animations: Animation[];
  24388. protected _ranges: {
  24389. [name: string]: Nullable<AnimationRange>;
  24390. };
  24391. /**
  24392. * Callback raised when the node is ready to be used
  24393. */
  24394. onReady: (node: Node) => void;
  24395. private _isEnabled;
  24396. private _isParentEnabled;
  24397. private _isReady;
  24398. /** @hidden */ currentRenderId: number;
  24399. private _parentUpdateId;
  24400. protected _childUpdateId: number;
  24401. /** @hidden */ waitingParentId: Nullable<string>;
  24402. /** @hidden */ scene: Scene;
  24403. /** @hidden */ cache: any;
  24404. private _parentNode;
  24405. private _children;
  24406. /** @hidden */ worldMatrix: Matrix;
  24407. /** @hidden */ worldMatrixDeterminant: number;
  24408. /** @hidden */
  24409. private _sceneRootNodesIndex;
  24410. /**
  24411. * Gets a boolean indicating if the node has been disposed
  24412. * @returns true if the node was disposed
  24413. */
  24414. isDisposed(): boolean;
  24415. /**
  24416. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24417. * @see https://doc.babylonjs.com/how_to/parenting
  24418. */
  24419. parent: Nullable<Node>;
  24420. private addToSceneRootNodes;
  24421. private removeFromSceneRootNodes;
  24422. private _animationPropertiesOverride;
  24423. /**
  24424. * Gets or sets the animation properties override
  24425. */
  24426. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24427. /**
  24428. * Gets a string idenfifying the name of the class
  24429. * @returns "Node" string
  24430. */
  24431. getClassName(): string;
  24432. /** @hidden */ protected readonly _isNode: boolean;
  24433. /**
  24434. * An event triggered when the mesh is disposed
  24435. */
  24436. onDisposeObservable: Observable<Node>;
  24437. private _onDisposeObserver;
  24438. /**
  24439. * Sets a callback that will be raised when the node will be disposed
  24440. */
  24441. onDispose: () => void;
  24442. /**
  24443. * Creates a new Node
  24444. * @param name the name and id to be given to this node
  24445. * @param scene the scene this node will be added to
  24446. * @param addToRootNodes the node will be added to scene.rootNodes
  24447. */
  24448. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24449. /**
  24450. * Gets the scene of the node
  24451. * @returns a scene
  24452. */
  24453. getScene(): Scene;
  24454. /**
  24455. * Gets the engine of the node
  24456. * @returns a Engine
  24457. */
  24458. getEngine(): Engine;
  24459. private _behaviors;
  24460. /**
  24461. * Attach a behavior to the node
  24462. * @see http://doc.babylonjs.com/features/behaviour
  24463. * @param behavior defines the behavior to attach
  24464. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24465. * @returns the current Node
  24466. */
  24467. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24468. /**
  24469. * Remove an attached behavior
  24470. * @see http://doc.babylonjs.com/features/behaviour
  24471. * @param behavior defines the behavior to attach
  24472. * @returns the current Node
  24473. */
  24474. removeBehavior(behavior: Behavior<Node>): Node;
  24475. /**
  24476. * Gets the list of attached behaviors
  24477. * @see http://doc.babylonjs.com/features/behaviour
  24478. */
  24479. readonly behaviors: Behavior<Node>[];
  24480. /**
  24481. * Gets an attached behavior by name
  24482. * @param name defines the name of the behavior to look for
  24483. * @see http://doc.babylonjs.com/features/behaviour
  24484. * @returns null if behavior was not found else the requested behavior
  24485. */
  24486. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24487. /**
  24488. * Returns the latest update of the World matrix
  24489. * @returns a Matrix
  24490. */
  24491. getWorldMatrix(): Matrix;
  24492. /** @hidden */ getWorldMatrixDeterminant(): number;
  24493. /**
  24494. * Returns directly the latest state of the mesh World matrix.
  24495. * A Matrix is returned.
  24496. */
  24497. readonly worldMatrixFromCache: Matrix;
  24498. /** @hidden */ initCache(): void;
  24499. /** @hidden */
  24500. updateCache(force?: boolean): void;
  24501. /** @hidden */ getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24502. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  24503. /** @hidden */ isSynchronized(): boolean;
  24504. /** @hidden */ markSyncedWithParent(): void;
  24505. /** @hidden */
  24506. isSynchronizedWithParent(): boolean;
  24507. /** @hidden */
  24508. isSynchronized(): boolean;
  24509. /**
  24510. * Is this node ready to be used/rendered
  24511. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24512. * @return true if the node is ready
  24513. */
  24514. isReady(completeCheck?: boolean): boolean;
  24515. /**
  24516. * Is this node enabled?
  24517. * 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
  24518. * @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
  24519. * @return whether this node (and its parent) is enabled
  24520. */
  24521. isEnabled(checkAncestors?: boolean): boolean;
  24522. /** @hidden */
  24523. protected _syncParentEnabledState(): void;
  24524. /**
  24525. * Set the enabled state of this node
  24526. * @param value defines the new enabled state
  24527. */
  24528. setEnabled(value: boolean): void;
  24529. /**
  24530. * Is this node a descendant of the given node?
  24531. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24532. * @param ancestor defines the parent node to inspect
  24533. * @returns a boolean indicating if this node is a descendant of the given node
  24534. */
  24535. isDescendantOf(ancestor: Node): boolean;
  24536. /** @hidden */ getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24537. /**
  24538. * Will return all nodes that have this node as ascendant
  24539. * @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
  24540. * @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
  24541. * @return all children nodes of all types
  24542. */
  24543. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24544. /**
  24545. * Get all child-meshes of this node
  24546. * @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)
  24547. * @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
  24548. * @returns an array of AbstractMesh
  24549. */
  24550. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24551. /**
  24552. * Get all direct children of this node
  24553. * @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
  24554. * @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)
  24555. * @returns an array of Node
  24556. */
  24557. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24558. /** @hidden */ setReady(state: boolean): void;
  24559. /**
  24560. * Get an animation by name
  24561. * @param name defines the name of the animation to look for
  24562. * @returns null if not found else the requested animation
  24563. */
  24564. getAnimationByName(name: string): Nullable<Animation>;
  24565. /**
  24566. * Creates an animation range for this node
  24567. * @param name defines the name of the range
  24568. * @param from defines the starting key
  24569. * @param to defines the end key
  24570. */
  24571. createAnimationRange(name: string, from: number, to: number): void;
  24572. /**
  24573. * Delete a specific animation range
  24574. * @param name defines the name of the range to delete
  24575. * @param deleteFrames defines if animation frames from the range must be deleted as well
  24576. */
  24577. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  24578. /**
  24579. * Get an animation range by name
  24580. * @param name defines the name of the animation range to look for
  24581. * @returns null if not found else the requested animation range
  24582. */
  24583. getAnimationRange(name: string): Nullable<AnimationRange>;
  24584. /**
  24585. * Gets the list of all animation ranges defined on this node
  24586. * @returns an array
  24587. */
  24588. getAnimationRanges(): Nullable<AnimationRange>[];
  24589. /**
  24590. * Will start the animation sequence
  24591. * @param name defines the range frames for animation sequence
  24592. * @param loop defines if the animation should loop (false by default)
  24593. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  24594. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  24595. * @returns the object created for this animation. If range does not exist, it will return null
  24596. */
  24597. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  24598. /**
  24599. * Serialize animation ranges into a JSON compatible object
  24600. * @returns serialization object
  24601. */
  24602. serializeAnimationRanges(): any;
  24603. /**
  24604. * Computes the world matrix of the node
  24605. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  24606. * @returns the world matrix
  24607. */
  24608. computeWorldMatrix(force?: boolean): Matrix;
  24609. /**
  24610. * Releases resources associated with this node.
  24611. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24612. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24613. */
  24614. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24615. /**
  24616. * Parse animation range data from a serialization object and store them into a given node
  24617. * @param node defines where to store the animation ranges
  24618. * @param parsedNode defines the serialization object to read data from
  24619. * @param scene defines the hosting scene
  24620. */
  24621. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  24622. }
  24623. }
  24624. declare module BABYLON {
  24625. /**
  24626. * Class used to store any kind of animation
  24627. */
  24628. export class Animation {
  24629. /**Name of the animation */
  24630. name: string;
  24631. /**Property to animate */
  24632. targetProperty: string;
  24633. /**The frames per second of the animation */
  24634. framePerSecond: number;
  24635. /**The data type of the animation */
  24636. dataType: number;
  24637. /**The loop mode of the animation */
  24638. loopMode?: number | undefined;
  24639. /**Specifies if blending should be enabled */
  24640. enableBlending?: boolean | undefined;
  24641. /**
  24642. * Use matrix interpolation instead of using direct key value when animating matrices
  24643. */
  24644. static AllowMatricesInterpolation: boolean;
  24645. /**
  24646. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  24647. */
  24648. static AllowMatrixDecomposeForInterpolation: boolean;
  24649. /**
  24650. * Stores the key frames of the animation
  24651. */
  24652. private _keys;
  24653. /**
  24654. * Stores the easing function of the animation
  24655. */
  24656. private _easingFunction;
  24657. /**
  24658. * @hidden Internal use only
  24659. */ runtimeAnimations: RuntimeAnimation[];
  24660. /**
  24661. * The set of event that will be linked to this animation
  24662. */
  24663. private _events;
  24664. /**
  24665. * Stores an array of target property paths
  24666. */
  24667. targetPropertyPath: string[];
  24668. /**
  24669. * Stores the blending speed of the animation
  24670. */
  24671. blendingSpeed: number;
  24672. /**
  24673. * Stores the animation ranges for the animation
  24674. */
  24675. private _ranges;
  24676. /**
  24677. * @hidden Internal use
  24678. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  24679. /**
  24680. * Sets up an animation
  24681. * @param property The property to animate
  24682. * @param animationType The animation type to apply
  24683. * @param framePerSecond The frames per second of the animation
  24684. * @param easingFunction The easing function used in the animation
  24685. * @returns The created animation
  24686. */
  24687. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  24688. /**
  24689. * Create and start an animation on a node
  24690. * @param name defines the name of the global animation that will be run on all nodes
  24691. * @param node defines the root node where the animation will take place
  24692. * @param targetProperty defines property to animate
  24693. * @param framePerSecond defines the number of frame per second yo use
  24694. * @param totalFrame defines the number of frames in total
  24695. * @param from defines the initial value
  24696. * @param to defines the final value
  24697. * @param loopMode defines which loop mode you want to use (off by default)
  24698. * @param easingFunction defines the easing function to use (linear by default)
  24699. * @param onAnimationEnd defines the callback to call when animation end
  24700. * @returns the animatable created for this animation
  24701. */
  24702. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24703. /**
  24704. * Create and start an animation on a node and its descendants
  24705. * @param name defines the name of the global animation that will be run on all nodes
  24706. * @param node defines the root node where the animation will take place
  24707. * @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
  24708. * @param targetProperty defines property to animate
  24709. * @param framePerSecond defines the number of frame per second to use
  24710. * @param totalFrame defines the number of frames in total
  24711. * @param from defines the initial value
  24712. * @param to defines the final value
  24713. * @param loopMode defines which loop mode you want to use (off by default)
  24714. * @param easingFunction defines the easing function to use (linear by default)
  24715. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  24716. * @returns the list of animatables created for all nodes
  24717. * @example https://www.babylonjs-playground.com/#MH0VLI
  24718. */
  24719. 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[]>;
  24720. /**
  24721. * Creates a new animation, merges it with the existing animations and starts it
  24722. * @param name Name of the animation
  24723. * @param node Node which contains the scene that begins the animations
  24724. * @param targetProperty Specifies which property to animate
  24725. * @param framePerSecond The frames per second of the animation
  24726. * @param totalFrame The total number of frames
  24727. * @param from The frame at the beginning of the animation
  24728. * @param to The frame at the end of the animation
  24729. * @param loopMode Specifies the loop mode of the animation
  24730. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  24731. * @param onAnimationEnd Callback to run once the animation is complete
  24732. * @returns Nullable animation
  24733. */
  24734. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  24735. /**
  24736. * Transition property of an host to the target Value
  24737. * @param property The property to transition
  24738. * @param targetValue The target Value of the property
  24739. * @param host The object where the property to animate belongs
  24740. * @param scene Scene used to run the animation
  24741. * @param frameRate Framerate (in frame/s) to use
  24742. * @param transition The transition type we want to use
  24743. * @param duration The duration of the animation, in milliseconds
  24744. * @param onAnimationEnd Callback trigger at the end of the animation
  24745. * @returns Nullable animation
  24746. */
  24747. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  24748. /**
  24749. * Return the array of runtime animations currently using this animation
  24750. */
  24751. readonly runtimeAnimations: RuntimeAnimation[];
  24752. /**
  24753. * Specifies if any of the runtime animations are currently running
  24754. */
  24755. readonly hasRunningRuntimeAnimations: boolean;
  24756. /**
  24757. * Initializes the animation
  24758. * @param name Name of the animation
  24759. * @param targetProperty Property to animate
  24760. * @param framePerSecond The frames per second of the animation
  24761. * @param dataType The data type of the animation
  24762. * @param loopMode The loop mode of the animation
  24763. * @param enableBlending Specifies if blending should be enabled
  24764. */
  24765. constructor(
  24766. /**Name of the animation */
  24767. name: string,
  24768. /**Property to animate */
  24769. targetProperty: string,
  24770. /**The frames per second of the animation */
  24771. framePerSecond: number,
  24772. /**The data type of the animation */
  24773. dataType: number,
  24774. /**The loop mode of the animation */
  24775. loopMode?: number | undefined,
  24776. /**Specifies if blending should be enabled */
  24777. enableBlending?: boolean | undefined);
  24778. /**
  24779. * Converts the animation to a string
  24780. * @param fullDetails support for multiple levels of logging within scene loading
  24781. * @returns String form of the animation
  24782. */
  24783. toString(fullDetails?: boolean): string;
  24784. /**
  24785. * Add an event to this animation
  24786. * @param event Event to add
  24787. */
  24788. addEvent(event: AnimationEvent): void;
  24789. /**
  24790. * Remove all events found at the given frame
  24791. * @param frame The frame to remove events from
  24792. */
  24793. removeEvents(frame: number): void;
  24794. /**
  24795. * Retrieves all the events from the animation
  24796. * @returns Events from the animation
  24797. */
  24798. getEvents(): AnimationEvent[];
  24799. /**
  24800. * Creates an animation range
  24801. * @param name Name of the animation range
  24802. * @param from Starting frame of the animation range
  24803. * @param to Ending frame of the animation
  24804. */
  24805. createRange(name: string, from: number, to: number): void;
  24806. /**
  24807. * Deletes an animation range by name
  24808. * @param name Name of the animation range to delete
  24809. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  24810. */
  24811. deleteRange(name: string, deleteFrames?: boolean): void;
  24812. /**
  24813. * Gets the animation range by name, or null if not defined
  24814. * @param name Name of the animation range
  24815. * @returns Nullable animation range
  24816. */
  24817. getRange(name: string): Nullable<AnimationRange>;
  24818. /**
  24819. * Gets the key frames from the animation
  24820. * @returns The key frames of the animation
  24821. */
  24822. getKeys(): Array<IAnimationKey>;
  24823. /**
  24824. * Gets the highest frame rate of the animation
  24825. * @returns Highest frame rate of the animation
  24826. */
  24827. getHighestFrame(): number;
  24828. /**
  24829. * Gets the easing function of the animation
  24830. * @returns Easing function of the animation
  24831. */
  24832. getEasingFunction(): IEasingFunction;
  24833. /**
  24834. * Sets the easing function of the animation
  24835. * @param easingFunction A custom mathematical formula for animation
  24836. */
  24837. setEasingFunction(easingFunction: EasingFunction): void;
  24838. /**
  24839. * Interpolates a scalar linearly
  24840. * @param startValue Start value of the animation curve
  24841. * @param endValue End value of the animation curve
  24842. * @param gradient Scalar amount to interpolate
  24843. * @returns Interpolated scalar value
  24844. */
  24845. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  24846. /**
  24847. * Interpolates a scalar cubically
  24848. * @param startValue Start value of the animation curve
  24849. * @param outTangent End tangent of the animation
  24850. * @param endValue End value of the animation curve
  24851. * @param inTangent Start tangent of the animation curve
  24852. * @param gradient Scalar amount to interpolate
  24853. * @returns Interpolated scalar value
  24854. */
  24855. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  24856. /**
  24857. * Interpolates a quaternion using a spherical linear interpolation
  24858. * @param startValue Start value of the animation curve
  24859. * @param endValue End value of the animation curve
  24860. * @param gradient Scalar amount to interpolate
  24861. * @returns Interpolated quaternion value
  24862. */
  24863. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  24864. /**
  24865. * Interpolates a quaternion cubically
  24866. * @param startValue Start value of the animation curve
  24867. * @param outTangent End tangent of the animation curve
  24868. * @param endValue End value of the animation curve
  24869. * @param inTangent Start tangent of the animation curve
  24870. * @param gradient Scalar amount to interpolate
  24871. * @returns Interpolated quaternion value
  24872. */
  24873. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  24874. /**
  24875. * Interpolates a Vector3 linearl
  24876. * @param startValue Start value of the animation curve
  24877. * @param endValue End value of the animation curve
  24878. * @param gradient Scalar amount to interpolate
  24879. * @returns Interpolated scalar value
  24880. */
  24881. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  24882. /**
  24883. * Interpolates a Vector3 cubically
  24884. * @param startValue Start value of the animation curve
  24885. * @param outTangent End tangent of the animation
  24886. * @param endValue End value of the animation curve
  24887. * @param inTangent Start tangent of the animation curve
  24888. * @param gradient Scalar amount to interpolate
  24889. * @returns InterpolatedVector3 value
  24890. */
  24891. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  24892. /**
  24893. * Interpolates a Vector2 linearly
  24894. * @param startValue Start value of the animation curve
  24895. * @param endValue End value of the animation curve
  24896. * @param gradient Scalar amount to interpolate
  24897. * @returns Interpolated Vector2 value
  24898. */
  24899. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  24900. /**
  24901. * Interpolates a Vector2 cubically
  24902. * @param startValue Start value of the animation curve
  24903. * @param outTangent End tangent of the animation
  24904. * @param endValue End value of the animation curve
  24905. * @param inTangent Start tangent of the animation curve
  24906. * @param gradient Scalar amount to interpolate
  24907. * @returns Interpolated Vector2 value
  24908. */
  24909. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  24910. /**
  24911. * Interpolates a size linearly
  24912. * @param startValue Start value of the animation curve
  24913. * @param endValue End value of the animation curve
  24914. * @param gradient Scalar amount to interpolate
  24915. * @returns Interpolated Size value
  24916. */
  24917. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  24918. /**
  24919. * Interpolates a Color3 linearly
  24920. * @param startValue Start value of the animation curve
  24921. * @param endValue End value of the animation curve
  24922. * @param gradient Scalar amount to interpolate
  24923. * @returns Interpolated Color3 value
  24924. */
  24925. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  24926. /**
  24927. * @hidden Internal use only
  24928. */ getKeyValue(value: any): any;
  24929. /**
  24930. * @hidden Internal use only
  24931. */ interpolate(currentFrame: number, repeatCount: number, workValue?: any, loopMode?: number, offsetValue?: any, highLimitValue?: any): any;
  24932. /**
  24933. * Defines the function to use to interpolate matrices
  24934. * @param startValue defines the start matrix
  24935. * @param endValue defines the end matrix
  24936. * @param gradient defines the gradient between both matrices
  24937. * @param result defines an optional target matrix where to store the interpolation
  24938. * @returns the interpolated matrix
  24939. */
  24940. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  24941. /**
  24942. * Makes a copy of the animation
  24943. * @returns Cloned animation
  24944. */
  24945. clone(): Animation;
  24946. /**
  24947. * Sets the key frames of the animation
  24948. * @param values The animation key frames to set
  24949. */
  24950. setKeys(values: Array<IAnimationKey>): void;
  24951. /**
  24952. * Serializes the animation to an object
  24953. * @returns Serialized object
  24954. */
  24955. serialize(): any;
  24956. /**
  24957. * Float animation type
  24958. */
  24959. private static _ANIMATIONTYPE_FLOAT;
  24960. /**
  24961. * Vector3 animation type
  24962. */
  24963. private static _ANIMATIONTYPE_VECTOR3;
  24964. /**
  24965. * Quaternion animation type
  24966. */
  24967. private static _ANIMATIONTYPE_QUATERNION;
  24968. /**
  24969. * Matrix animation type
  24970. */
  24971. private static _ANIMATIONTYPE_MATRIX;
  24972. /**
  24973. * Color3 animation type
  24974. */
  24975. private static _ANIMATIONTYPE_COLOR3;
  24976. /**
  24977. * Vector2 animation type
  24978. */
  24979. private static _ANIMATIONTYPE_VECTOR2;
  24980. /**
  24981. * Size animation type
  24982. */
  24983. private static _ANIMATIONTYPE_SIZE;
  24984. /**
  24985. * Relative Loop Mode
  24986. */
  24987. private static _ANIMATIONLOOPMODE_RELATIVE;
  24988. /**
  24989. * Cycle Loop Mode
  24990. */
  24991. private static _ANIMATIONLOOPMODE_CYCLE;
  24992. /**
  24993. * Constant Loop Mode
  24994. */
  24995. private static _ANIMATIONLOOPMODE_CONSTANT;
  24996. /**
  24997. * Get the float animation type
  24998. */
  24999. static readonly ANIMATIONTYPE_FLOAT: number;
  25000. /**
  25001. * Get the Vector3 animation type
  25002. */
  25003. static readonly ANIMATIONTYPE_VECTOR3: number;
  25004. /**
  25005. * Get the Vector2 animation type
  25006. */
  25007. static readonly ANIMATIONTYPE_VECTOR2: number;
  25008. /**
  25009. * Get the Size animation type
  25010. */
  25011. static readonly ANIMATIONTYPE_SIZE: number;
  25012. /**
  25013. * Get the Quaternion animation type
  25014. */
  25015. static readonly ANIMATIONTYPE_QUATERNION: number;
  25016. /**
  25017. * Get the Matrix animation type
  25018. */
  25019. static readonly ANIMATIONTYPE_MATRIX: number;
  25020. /**
  25021. * Get the Color3 animation type
  25022. */
  25023. static readonly ANIMATIONTYPE_COLOR3: number;
  25024. /**
  25025. * Get the Relative Loop Mode
  25026. */
  25027. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25028. /**
  25029. * Get the Cycle Loop Mode
  25030. */
  25031. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25032. /**
  25033. * Get the Constant Loop Mode
  25034. */
  25035. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25036. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25037. /**
  25038. * Parses an animation object and creates an animation
  25039. * @param parsedAnimation Parsed animation object
  25040. * @returns Animation object
  25041. */
  25042. static Parse(parsedAnimation: any): Animation;
  25043. /**
  25044. * Appends the serialized animations from the source animations
  25045. * @param source Source containing the animations
  25046. * @param destination Target to store the animations
  25047. */
  25048. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25049. }
  25050. }
  25051. declare module BABYLON {
  25052. /**
  25053. * Base class of all the textures in babylon.
  25054. * It groups all the common properties the materials, post process, lights... might need
  25055. * in order to make a correct use of the texture.
  25056. */
  25057. export class BaseTexture implements IAnimatable {
  25058. /**
  25059. * Default anisotropic filtering level for the application.
  25060. * It is set to 4 as a good tradeoff between perf and quality.
  25061. */
  25062. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25063. /**
  25064. * Gets or sets the unique id of the texture
  25065. */
  25066. uniqueId: number;
  25067. /**
  25068. * Define the name of the texture.
  25069. */
  25070. name: string;
  25071. /**
  25072. * Gets or sets an object used to store user defined information.
  25073. */
  25074. metadata: any;
  25075. /**
  25076. * For internal use only. Please do not use.
  25077. */
  25078. reservedDataStore: any;
  25079. private _hasAlpha;
  25080. /**
  25081. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25082. */
  25083. hasAlpha: boolean;
  25084. /**
  25085. * Defines if the alpha value should be determined via the rgb values.
  25086. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25087. */
  25088. getAlphaFromRGB: boolean;
  25089. /**
  25090. * Intensity or strength of the texture.
  25091. * It is commonly used by materials to fine tune the intensity of the texture
  25092. */
  25093. level: number;
  25094. /**
  25095. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25096. * This is part of the texture as textures usually maps to one uv set.
  25097. */
  25098. coordinatesIndex: number;
  25099. private _coordinatesMode;
  25100. /**
  25101. * How a texture is mapped.
  25102. *
  25103. * | Value | Type | Description |
  25104. * | ----- | ----------------------------------- | ----------- |
  25105. * | 0 | EXPLICIT_MODE | |
  25106. * | 1 | SPHERICAL_MODE | |
  25107. * | 2 | PLANAR_MODE | |
  25108. * | 3 | CUBIC_MODE | |
  25109. * | 4 | PROJECTION_MODE | |
  25110. * | 5 | SKYBOX_MODE | |
  25111. * | 6 | INVCUBIC_MODE | |
  25112. * | 7 | EQUIRECTANGULAR_MODE | |
  25113. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25114. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25115. */
  25116. coordinatesMode: number;
  25117. /**
  25118. * | Value | Type | Description |
  25119. * | ----- | ------------------ | ----------- |
  25120. * | 0 | CLAMP_ADDRESSMODE | |
  25121. * | 1 | WRAP_ADDRESSMODE | |
  25122. * | 2 | MIRROR_ADDRESSMODE | |
  25123. */
  25124. wrapU: number;
  25125. /**
  25126. * | Value | Type | Description |
  25127. * | ----- | ------------------ | ----------- |
  25128. * | 0 | CLAMP_ADDRESSMODE | |
  25129. * | 1 | WRAP_ADDRESSMODE | |
  25130. * | 2 | MIRROR_ADDRESSMODE | |
  25131. */
  25132. wrapV: number;
  25133. /**
  25134. * | Value | Type | Description |
  25135. * | ----- | ------------------ | ----------- |
  25136. * | 0 | CLAMP_ADDRESSMODE | |
  25137. * | 1 | WRAP_ADDRESSMODE | |
  25138. * | 2 | MIRROR_ADDRESSMODE | |
  25139. */
  25140. wrapR: number;
  25141. /**
  25142. * With compliant hardware and browser (supporting anisotropic filtering)
  25143. * this defines the level of anisotropic filtering in the texture.
  25144. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25145. */
  25146. anisotropicFilteringLevel: number;
  25147. /**
  25148. * Define if the texture is a cube texture or if false a 2d texture.
  25149. */
  25150. isCube: boolean;
  25151. /**
  25152. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25153. */
  25154. is3D: boolean;
  25155. /**
  25156. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25157. * HDR texture are usually stored in linear space.
  25158. * This only impacts the PBR and Background materials
  25159. */
  25160. gammaSpace: boolean;
  25161. /**
  25162. * Gets whether or not the texture contains RGBD data.
  25163. */
  25164. readonly isRGBD: boolean;
  25165. /**
  25166. * Is Z inverted in the texture (useful in a cube texture).
  25167. */
  25168. invertZ: boolean;
  25169. /**
  25170. * Are mip maps generated for this texture or not.
  25171. */
  25172. readonly noMipmap: boolean;
  25173. /**
  25174. * @hidden
  25175. */
  25176. lodLevelInAlpha: boolean;
  25177. /**
  25178. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25179. */
  25180. lodGenerationOffset: number;
  25181. /**
  25182. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25183. */
  25184. lodGenerationScale: number;
  25185. /**
  25186. * Define if the texture is a render target.
  25187. */
  25188. isRenderTarget: boolean;
  25189. /**
  25190. * Define the unique id of the texture in the scene.
  25191. */
  25192. readonly uid: string;
  25193. /**
  25194. * Return a string representation of the texture.
  25195. * @returns the texture as a string
  25196. */
  25197. toString(): string;
  25198. /**
  25199. * Get the class name of the texture.
  25200. * @returns "BaseTexture"
  25201. */
  25202. getClassName(): string;
  25203. /**
  25204. * Define the list of animation attached to the texture.
  25205. */
  25206. animations: Animation[];
  25207. /**
  25208. * An event triggered when the texture is disposed.
  25209. */
  25210. onDisposeObservable: Observable<BaseTexture>;
  25211. private _onDisposeObserver;
  25212. /**
  25213. * Callback triggered when the texture has been disposed.
  25214. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25215. */
  25216. onDispose: () => void;
  25217. /**
  25218. * Define the current state of the loading sequence when in delayed load mode.
  25219. */
  25220. delayLoadState: number;
  25221. private _scene;
  25222. /** @hidden */ texture: Nullable<InternalTexture>;
  25223. private _uid;
  25224. /**
  25225. * Define if the texture is preventinga material to render or not.
  25226. * If not and the texture is not ready, the engine will use a default black texture instead.
  25227. */
  25228. readonly isBlocking: boolean;
  25229. /**
  25230. * Instantiates a new BaseTexture.
  25231. * Base class of all the textures in babylon.
  25232. * It groups all the common properties the materials, post process, lights... might need
  25233. * in order to make a correct use of the texture.
  25234. * @param scene Define the scene the texture blongs to
  25235. */
  25236. constructor(scene: Nullable<Scene>);
  25237. /**
  25238. * Get the scene the texture belongs to.
  25239. * @returns the scene or null if undefined
  25240. */
  25241. getScene(): Nullable<Scene>;
  25242. /**
  25243. * Get the texture transform matrix used to offset tile the texture for istance.
  25244. * @returns the transformation matrix
  25245. */
  25246. getTextureMatrix(): Matrix;
  25247. /**
  25248. * Get the texture reflection matrix used to rotate/transform the reflection.
  25249. * @returns the reflection matrix
  25250. */
  25251. getReflectionTextureMatrix(): Matrix;
  25252. /**
  25253. * Get the underlying lower level texture from Babylon.
  25254. * @returns the insternal texture
  25255. */
  25256. getInternalTexture(): Nullable<InternalTexture>;
  25257. /**
  25258. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25259. * @returns true if ready or not blocking
  25260. */
  25261. isReadyOrNotBlocking(): boolean;
  25262. /**
  25263. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25264. * @returns true if fully ready
  25265. */
  25266. isReady(): boolean;
  25267. private _cachedSize;
  25268. /**
  25269. * Get the size of the texture.
  25270. * @returns the texture size.
  25271. */
  25272. getSize(): ISize;
  25273. /**
  25274. * Get the base size of the texture.
  25275. * It can be different from the size if the texture has been resized for POT for instance
  25276. * @returns the base size
  25277. */
  25278. getBaseSize(): ISize;
  25279. /**
  25280. * Update the sampling mode of the texture.
  25281. * Default is Trilinear mode.
  25282. *
  25283. * | Value | Type | Description |
  25284. * | ----- | ------------------ | ----------- |
  25285. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25286. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25287. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25288. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25289. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25290. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25291. * | 7 | NEAREST_LINEAR | |
  25292. * | 8 | NEAREST_NEAREST | |
  25293. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25294. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25295. * | 11 | LINEAR_LINEAR | |
  25296. * | 12 | LINEAR_NEAREST | |
  25297. *
  25298. * > _mag_: magnification filter (close to the viewer)
  25299. * > _min_: minification filter (far from the viewer)
  25300. * > _mip_: filter used between mip map levels
  25301. *@param samplingMode Define the new sampling mode of the texture
  25302. */
  25303. updateSamplingMode(samplingMode: number): void;
  25304. /**
  25305. * Scales the texture if is `canRescale()`
  25306. * @param ratio the resize factor we want to use to rescale
  25307. */
  25308. scale(ratio: number): void;
  25309. /**
  25310. * Get if the texture can rescale.
  25311. */
  25312. readonly canRescale: boolean;
  25313. /** @hidden */ getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25314. /** @hidden */ rebuild(): void;
  25315. /**
  25316. * Triggers the load sequence in delayed load mode.
  25317. */
  25318. delayLoad(): void;
  25319. /**
  25320. * Clones the texture.
  25321. * @returns the cloned texture
  25322. */
  25323. clone(): Nullable<BaseTexture>;
  25324. /**
  25325. * Get the texture underlying type (INT, FLOAT...)
  25326. */
  25327. readonly textureType: number;
  25328. /**
  25329. * Get the texture underlying format (RGB, RGBA...)
  25330. */
  25331. readonly textureFormat: number;
  25332. /**
  25333. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25334. * This will returns an RGBA array buffer containing either in values (0-255) or
  25335. * float values (0-1) depending of the underlying buffer type.
  25336. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25337. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25338. * @param buffer defines a user defined buffer to fill with data (can be null)
  25339. * @returns The Array buffer containing the pixels data.
  25340. */
  25341. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25342. /**
  25343. * Release and destroy the underlying lower level texture aka internalTexture.
  25344. */
  25345. releaseInternalTexture(): void;
  25346. /**
  25347. * Get the polynomial representation of the texture data.
  25348. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25349. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25350. */
  25351. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25352. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25353. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25354. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25355. /**
  25356. * Dispose the texture and release its associated resources.
  25357. */
  25358. dispose(): void;
  25359. /**
  25360. * Serialize the texture into a JSON representation that can be parsed later on.
  25361. * @returns the JSON representation of the texture
  25362. */
  25363. serialize(): any;
  25364. /**
  25365. * Helper function to be called back once a list of texture contains only ready textures.
  25366. * @param textures Define the list of textures to wait for
  25367. * @param callback Define the callback triggered once the entire list will be ready
  25368. */
  25369. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25370. }
  25371. }
  25372. declare module BABYLON {
  25373. /**
  25374. * Uniform buffer objects.
  25375. *
  25376. * Handles blocks of uniform on the GPU.
  25377. *
  25378. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25379. *
  25380. * For more information, please refer to :
  25381. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25382. */
  25383. export class UniformBuffer {
  25384. private _engine;
  25385. private _buffer;
  25386. private _data;
  25387. private _bufferData;
  25388. private _dynamic?;
  25389. private _uniformLocations;
  25390. private _uniformSizes;
  25391. private _uniformLocationPointer;
  25392. private _needSync;
  25393. private _noUBO;
  25394. private _currentEffect;
  25395. private static _MAX_UNIFORM_SIZE;
  25396. private static _tempBuffer;
  25397. /**
  25398. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25399. * This is dynamic to allow compat with webgl 1 and 2.
  25400. * You will need to pass the name of the uniform as well as the value.
  25401. */
  25402. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25403. /**
  25404. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25405. * This is dynamic to allow compat with webgl 1 and 2.
  25406. * You will need to pass the name of the uniform as well as the value.
  25407. */
  25408. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25409. /**
  25410. * Lambda to Update a single float in a uniform buffer.
  25411. * This is dynamic to allow compat with webgl 1 and 2.
  25412. * You will need to pass the name of the uniform as well as the value.
  25413. */
  25414. updateFloat: (name: string, x: number) => void;
  25415. /**
  25416. * Lambda to Update a vec2 of float in a uniform buffer.
  25417. * This is dynamic to allow compat with webgl 1 and 2.
  25418. * You will need to pass the name of the uniform as well as the value.
  25419. */
  25420. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25421. /**
  25422. * Lambda to Update a vec3 of float in a uniform buffer.
  25423. * This is dynamic to allow compat with webgl 1 and 2.
  25424. * You will need to pass the name of the uniform as well as the value.
  25425. */
  25426. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25427. /**
  25428. * Lambda to Update a vec4 of float in a uniform buffer.
  25429. * This is dynamic to allow compat with webgl 1 and 2.
  25430. * You will need to pass the name of the uniform as well as the value.
  25431. */
  25432. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25433. /**
  25434. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25435. * This is dynamic to allow compat with webgl 1 and 2.
  25436. * You will need to pass the name of the uniform as well as the value.
  25437. */
  25438. updateMatrix: (name: string, mat: Matrix) => void;
  25439. /**
  25440. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25441. * This is dynamic to allow compat with webgl 1 and 2.
  25442. * You will need to pass the name of the uniform as well as the value.
  25443. */
  25444. updateVector3: (name: string, vector: Vector3) => void;
  25445. /**
  25446. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25447. * This is dynamic to allow compat with webgl 1 and 2.
  25448. * You will need to pass the name of the uniform as well as the value.
  25449. */
  25450. updateVector4: (name: string, vector: Vector4) => void;
  25451. /**
  25452. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25453. * This is dynamic to allow compat with webgl 1 and 2.
  25454. * You will need to pass the name of the uniform as well as the value.
  25455. */
  25456. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25457. /**
  25458. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25459. * This is dynamic to allow compat with webgl 1 and 2.
  25460. * You will need to pass the name of the uniform as well as the value.
  25461. */
  25462. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25463. /**
  25464. * Instantiates a new Uniform buffer objects.
  25465. *
  25466. * Handles blocks of uniform on the GPU.
  25467. *
  25468. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25469. *
  25470. * For more information, please refer to :
  25471. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25472. * @param engine Define the engine the buffer is associated with
  25473. * @param data Define the data contained in the buffer
  25474. * @param dynamic Define if the buffer is updatable
  25475. */
  25476. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25477. /**
  25478. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25479. * or just falling back on setUniformXXX calls.
  25480. */
  25481. readonly useUbo: boolean;
  25482. /**
  25483. * Indicates if the WebGL underlying uniform buffer is in sync
  25484. * with the javascript cache data.
  25485. */
  25486. readonly isSync: boolean;
  25487. /**
  25488. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25489. * Also, a dynamic UniformBuffer will disable cache verification and always
  25490. * update the underlying WebGL uniform buffer to the GPU.
  25491. * @returns if Dynamic, otherwise false
  25492. */
  25493. isDynamic(): boolean;
  25494. /**
  25495. * The data cache on JS side.
  25496. * @returns the underlying data as a float array
  25497. */
  25498. getData(): Float32Array;
  25499. /**
  25500. * The underlying WebGL Uniform buffer.
  25501. * @returns the webgl buffer
  25502. */
  25503. getBuffer(): Nullable<WebGLBuffer>;
  25504. /**
  25505. * std140 layout specifies how to align data within an UBO structure.
  25506. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25507. * for specs.
  25508. */
  25509. private _fillAlignment;
  25510. /**
  25511. * Adds an uniform in the buffer.
  25512. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25513. * for the layout to be correct !
  25514. * @param name Name of the uniform, as used in the uniform block in the shader.
  25515. * @param size Data size, or data directly.
  25516. */
  25517. addUniform(name: string, size: number | number[]): void;
  25518. /**
  25519. * Adds a Matrix 4x4 to the uniform buffer.
  25520. * @param name Name of the uniform, as used in the uniform block in the shader.
  25521. * @param mat A 4x4 matrix.
  25522. */
  25523. addMatrix(name: string, mat: Matrix): void;
  25524. /**
  25525. * Adds a vec2 to the uniform buffer.
  25526. * @param name Name of the uniform, as used in the uniform block in the shader.
  25527. * @param x Define the x component value of the vec2
  25528. * @param y Define the y component value of the vec2
  25529. */
  25530. addFloat2(name: string, x: number, y: number): void;
  25531. /**
  25532. * Adds a vec3 to the uniform buffer.
  25533. * @param name Name of the uniform, as used in the uniform block in the shader.
  25534. * @param x Define the x component value of the vec3
  25535. * @param y Define the y component value of the vec3
  25536. * @param z Define the z component value of the vec3
  25537. */
  25538. addFloat3(name: string, x: number, y: number, z: number): void;
  25539. /**
  25540. * Adds a vec3 to the uniform buffer.
  25541. * @param name Name of the uniform, as used in the uniform block in the shader.
  25542. * @param color Define the vec3 from a Color
  25543. */
  25544. addColor3(name: string, color: Color3): void;
  25545. /**
  25546. * Adds a vec4 to the uniform buffer.
  25547. * @param name Name of the uniform, as used in the uniform block in the shader.
  25548. * @param color Define the rgb components from a Color
  25549. * @param alpha Define the a component of the vec4
  25550. */
  25551. addColor4(name: string, color: Color3, alpha: number): void;
  25552. /**
  25553. * Adds a vec3 to the uniform buffer.
  25554. * @param name Name of the uniform, as used in the uniform block in the shader.
  25555. * @param vector Define the vec3 components from a Vector
  25556. */
  25557. addVector3(name: string, vector: Vector3): void;
  25558. /**
  25559. * Adds a Matrix 3x3 to the uniform buffer.
  25560. * @param name Name of the uniform, as used in the uniform block in the shader.
  25561. */
  25562. addMatrix3x3(name: string): void;
  25563. /**
  25564. * Adds a Matrix 2x2 to the uniform buffer.
  25565. * @param name Name of the uniform, as used in the uniform block in the shader.
  25566. */
  25567. addMatrix2x2(name: string): void;
  25568. /**
  25569. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  25570. */
  25571. create(): void;
  25572. /** @hidden */ rebuild(): void;
  25573. /**
  25574. * Updates the WebGL Uniform Buffer on the GPU.
  25575. * If the `dynamic` flag is set to true, no cache comparison is done.
  25576. * Otherwise, the buffer will be updated only if the cache differs.
  25577. */
  25578. update(): void;
  25579. /**
  25580. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  25581. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25582. * @param data Define the flattened data
  25583. * @param size Define the size of the data.
  25584. */
  25585. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  25586. private _updateMatrix3x3ForUniform;
  25587. private _updateMatrix3x3ForEffect;
  25588. private _updateMatrix2x2ForEffect;
  25589. private _updateMatrix2x2ForUniform;
  25590. private _updateFloatForEffect;
  25591. private _updateFloatForUniform;
  25592. private _updateFloat2ForEffect;
  25593. private _updateFloat2ForUniform;
  25594. private _updateFloat3ForEffect;
  25595. private _updateFloat3ForUniform;
  25596. private _updateFloat4ForEffect;
  25597. private _updateFloat4ForUniform;
  25598. private _updateMatrixForEffect;
  25599. private _updateMatrixForUniform;
  25600. private _updateVector3ForEffect;
  25601. private _updateVector3ForUniform;
  25602. private _updateVector4ForEffect;
  25603. private _updateVector4ForUniform;
  25604. private _updateColor3ForEffect;
  25605. private _updateColor3ForUniform;
  25606. private _updateColor4ForEffect;
  25607. private _updateColor4ForUniform;
  25608. /**
  25609. * Sets a sampler uniform on the effect.
  25610. * @param name Define the name of the sampler.
  25611. * @param texture Define the texture to set in the sampler
  25612. */
  25613. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  25614. /**
  25615. * Directly updates the value of the uniform in the cache AND on the GPU.
  25616. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  25617. * @param data Define the flattened data
  25618. */
  25619. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  25620. /**
  25621. * Binds this uniform buffer to an effect.
  25622. * @param effect Define the effect to bind the buffer to
  25623. * @param name Name of the uniform block in the shader.
  25624. */
  25625. bindToEffect(effect: Effect, name: string): void;
  25626. /**
  25627. * Disposes the uniform buffer.
  25628. */
  25629. dispose(): void;
  25630. }
  25631. }
  25632. declare module BABYLON {
  25633. /**
  25634. * This represents the required contract to create a new type of texture loader.
  25635. */
  25636. export interface IInternalTextureLoader {
  25637. /**
  25638. * Defines wether the loader supports cascade loading the different faces.
  25639. */
  25640. supportCascades: boolean;
  25641. /**
  25642. * This returns if the loader support the current file information.
  25643. * @param extension defines the file extension of the file being loaded
  25644. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25645. * @param fallback defines the fallback internal texture if any
  25646. * @param isBase64 defines whether the texture is encoded as a base64
  25647. * @param isBuffer defines whether the texture data are stored as a buffer
  25648. * @returns true if the loader can load the specified file
  25649. */
  25650. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  25651. /**
  25652. * Transform the url before loading if required.
  25653. * @param rootUrl the url of the texture
  25654. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25655. * @returns the transformed texture
  25656. */
  25657. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  25658. /**
  25659. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  25660. * @param rootUrl the url of the texture
  25661. * @param textureFormatInUse defines the current compressed format in use iun the engine
  25662. * @returns the fallback texture
  25663. */
  25664. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  25665. /**
  25666. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  25667. * @param data contains the texture data
  25668. * @param texture defines the BabylonJS internal texture
  25669. * @param createPolynomials will be true if polynomials have been requested
  25670. * @param onLoad defines the callback to trigger once the texture is ready
  25671. * @param onError defines the callback to trigger in case of error
  25672. */
  25673. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  25674. /**
  25675. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  25676. * @param data contains the texture data
  25677. * @param texture defines the BabylonJS internal texture
  25678. * @param callback defines the method to call once ready to upload
  25679. */
  25680. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  25681. }
  25682. }
  25683. declare module BABYLON {
  25684. /**
  25685. * Creation options of the multi render target texture.
  25686. */
  25687. export interface IMultiRenderTargetOptions {
  25688. /**
  25689. * Define if the texture needs to create mip maps after render.
  25690. */
  25691. generateMipMaps?: boolean;
  25692. /**
  25693. * Define the types of all the draw buffers we want to create
  25694. */
  25695. types?: number[];
  25696. /**
  25697. * Define the sampling modes of all the draw buffers we want to create
  25698. */
  25699. samplingModes?: number[];
  25700. /**
  25701. * Define if a depth buffer is required
  25702. */
  25703. generateDepthBuffer?: boolean;
  25704. /**
  25705. * Define if a stencil buffer is required
  25706. */
  25707. generateStencilBuffer?: boolean;
  25708. /**
  25709. * Define if a depth texture is required instead of a depth buffer
  25710. */
  25711. generateDepthTexture?: boolean;
  25712. /**
  25713. * Define the number of desired draw buffers
  25714. */
  25715. textureCount?: number;
  25716. /**
  25717. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25718. */
  25719. doNotChangeAspectRatio?: boolean;
  25720. /**
  25721. * Define the default type of the buffers we are creating
  25722. */
  25723. defaultType?: number;
  25724. }
  25725. /**
  25726. * A multi render target, like a render target provides the ability to render to a texture.
  25727. * Unlike the render target, it can render to several draw buffers in one draw.
  25728. * This is specially interesting in deferred rendering or for any effects requiring more than
  25729. * just one color from a single pass.
  25730. */
  25731. export class MultiRenderTarget extends RenderTargetTexture {
  25732. private _internalTextures;
  25733. private _textures;
  25734. private _multiRenderTargetOptions;
  25735. /**
  25736. * Get if draw buffers are currently supported by the used hardware and browser.
  25737. */
  25738. readonly isSupported: boolean;
  25739. /**
  25740. * Get the list of textures generated by the multi render target.
  25741. */
  25742. readonly textures: Texture[];
  25743. /**
  25744. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25745. */
  25746. readonly depthTexture: Texture;
  25747. /**
  25748. * Set the wrapping mode on U of all the textures we are rendering to.
  25749. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25750. */
  25751. wrapU: number;
  25752. /**
  25753. * Set the wrapping mode on V of all the textures we are rendering to.
  25754. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25755. */
  25756. wrapV: number;
  25757. /**
  25758. * Instantiate a new multi render target texture.
  25759. * A multi render target, like a render target provides the ability to render to a texture.
  25760. * Unlike the render target, it can render to several draw buffers in one draw.
  25761. * This is specially interesting in deferred rendering or for any effects requiring more than
  25762. * just one color from a single pass.
  25763. * @param name Define the name of the texture
  25764. * @param size Define the size of the buffers to render to
  25765. * @param count Define the number of target we are rendering into
  25766. * @param scene Define the scene the texture belongs to
  25767. * @param options Define the options used to create the multi render target
  25768. */
  25769. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25770. /** @hidden */ rebuild(): void;
  25771. private _createInternalTextures;
  25772. private _createTextures;
  25773. /**
  25774. * Define the number of samples used if MSAA is enabled.
  25775. */
  25776. samples: number;
  25777. /**
  25778. * Resize all the textures in the multi render target.
  25779. * Be carrefull as it will recreate all the data in the new texture.
  25780. * @param size Define the new size
  25781. */
  25782. resize(size: any): void;
  25783. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25784. /**
  25785. * Dispose the render targets and their associated resources
  25786. */
  25787. dispose(): void;
  25788. /**
  25789. * Release all the underlying texture used as draw buffers.
  25790. */
  25791. releaseInternalTextures(): void;
  25792. }
  25793. }
  25794. declare module BABYLON {
  25795. /**
  25796. * Class used to work with sound analyzer using fast fourier transform (FFT)
  25797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25798. */
  25799. export class Analyser {
  25800. /**
  25801. * Gets or sets the smoothing
  25802. * @ignorenaming
  25803. */
  25804. SMOOTHING: number;
  25805. /**
  25806. * Gets or sets the FFT table size
  25807. * @ignorenaming
  25808. */
  25809. FFT_SIZE: number;
  25810. /**
  25811. * Gets or sets the bar graph amplitude
  25812. * @ignorenaming
  25813. */
  25814. BARGRAPHAMPLITUDE: number;
  25815. /**
  25816. * Gets or sets the position of the debug canvas
  25817. * @ignorenaming
  25818. */
  25819. DEBUGCANVASPOS: {
  25820. x: number;
  25821. y: number;
  25822. };
  25823. /**
  25824. * Gets or sets the debug canvas size
  25825. * @ignorenaming
  25826. */
  25827. DEBUGCANVASSIZE: {
  25828. width: number;
  25829. height: number;
  25830. };
  25831. private _byteFreqs;
  25832. private _byteTime;
  25833. private _floatFreqs;
  25834. private _webAudioAnalyser;
  25835. private _debugCanvas;
  25836. private _debugCanvasContext;
  25837. private _scene;
  25838. private _registerFunc;
  25839. private _audioEngine;
  25840. /**
  25841. * Creates a new analyser
  25842. * @param scene defines hosting scene
  25843. */
  25844. constructor(scene: Scene);
  25845. /**
  25846. * Get the number of data values you will have to play with for the visualization
  25847. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  25848. * @returns a number
  25849. */
  25850. getFrequencyBinCount(): number;
  25851. /**
  25852. * Gets the current frequency data as a byte array
  25853. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25854. * @returns a Uint8Array
  25855. */
  25856. getByteFrequencyData(): Uint8Array;
  25857. /**
  25858. * Gets the current waveform as a byte array
  25859. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  25860. * @returns a Uint8Array
  25861. */
  25862. getByteTimeDomainData(): Uint8Array;
  25863. /**
  25864. * Gets the current frequency data as a float array
  25865. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  25866. * @returns a Float32Array
  25867. */
  25868. getFloatFrequencyData(): Float32Array;
  25869. /**
  25870. * Renders the debug canvas
  25871. */
  25872. drawDebugCanvas(): void;
  25873. /**
  25874. * Stops rendering the debug canvas and removes it
  25875. */
  25876. stopDebugCanvas(): void;
  25877. /**
  25878. * Connects two audio nodes
  25879. * @param inputAudioNode defines first node to connect
  25880. * @param outputAudioNode defines second node to connect
  25881. */
  25882. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  25883. /**
  25884. * Releases all associated resources
  25885. */
  25886. dispose(): void;
  25887. }
  25888. }
  25889. declare module BABYLON {
  25890. /**
  25891. * This represents an audio engine and it is responsible
  25892. * to play, synchronize and analyse sounds throughout the application.
  25893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25894. */
  25895. export interface IAudioEngine extends IDisposable {
  25896. /**
  25897. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25898. */
  25899. readonly canUseWebAudio: boolean;
  25900. /**
  25901. * Gets the current AudioContext if available.
  25902. */
  25903. readonly audioContext: Nullable<AudioContext>;
  25904. /**
  25905. * The master gain node defines the global audio volume of your audio engine.
  25906. */
  25907. readonly masterGain: GainNode;
  25908. /**
  25909. * Gets whether or not mp3 are supported by your browser.
  25910. */
  25911. readonly isMP3supported: boolean;
  25912. /**
  25913. * Gets whether or not ogg are supported by your browser.
  25914. */
  25915. readonly isOGGsupported: boolean;
  25916. /**
  25917. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25918. * @ignoreNaming
  25919. */
  25920. WarnedWebAudioUnsupported: boolean;
  25921. /**
  25922. * Defines if the audio engine relies on a custom unlocked button.
  25923. * In this case, the embedded button will not be displayed.
  25924. */
  25925. useCustomUnlockedButton: boolean;
  25926. /**
  25927. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  25928. */
  25929. readonly unlocked: boolean;
  25930. /**
  25931. * Event raised when audio has been unlocked on the browser.
  25932. */
  25933. onAudioUnlockedObservable: Observable<AudioEngine>;
  25934. /**
  25935. * Event raised when audio has been locked on the browser.
  25936. */
  25937. onAudioLockedObservable: Observable<AudioEngine>;
  25938. /**
  25939. * Flags the audio engine in Locked state.
  25940. * This happens due to new browser policies preventing audio to autoplay.
  25941. */
  25942. lock(): void;
  25943. /**
  25944. * Unlocks the audio engine once a user action has been done on the dom.
  25945. * This is helpful to resume play once browser policies have been satisfied.
  25946. */
  25947. unlock(): void;
  25948. }
  25949. /**
  25950. * This represents the default audio engine used in babylon.
  25951. * It is responsible to play, synchronize and analyse sounds throughout the application.
  25952. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  25953. */
  25954. export class AudioEngine implements IAudioEngine {
  25955. private _audioContext;
  25956. private _audioContextInitialized;
  25957. private _muteButton;
  25958. private _hostElement;
  25959. /**
  25960. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  25961. */
  25962. canUseWebAudio: boolean;
  25963. /**
  25964. * The master gain node defines the global audio volume of your audio engine.
  25965. */
  25966. masterGain: GainNode;
  25967. /**
  25968. * Defines if Babylon should emit a warning if WebAudio is not supported.
  25969. * @ignoreNaming
  25970. */
  25971. WarnedWebAudioUnsupported: boolean;
  25972. /**
  25973. * Gets whether or not mp3 are supported by your browser.
  25974. */
  25975. isMP3supported: boolean;
  25976. /**
  25977. * Gets whether or not ogg are supported by your browser.
  25978. */
  25979. isOGGsupported: boolean;
  25980. /**
  25981. * Gets whether audio has been unlocked on the device.
  25982. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  25983. * a user interaction has happened.
  25984. */
  25985. unlocked: boolean;
  25986. /**
  25987. * Defines if the audio engine relies on a custom unlocked button.
  25988. * In this case, the embedded button will not be displayed.
  25989. */
  25990. useCustomUnlockedButton: boolean;
  25991. /**
  25992. * Event raised when audio has been unlocked on the browser.
  25993. */
  25994. onAudioUnlockedObservable: Observable<AudioEngine>;
  25995. /**
  25996. * Event raised when audio has been locked on the browser.
  25997. */
  25998. onAudioLockedObservable: Observable<AudioEngine>;
  25999. /**
  26000. * Gets the current AudioContext if available.
  26001. */
  26002. readonly audioContext: Nullable<AudioContext>;
  26003. private _connectedAnalyser;
  26004. /**
  26005. * Instantiates a new audio engine.
  26006. *
  26007. * There should be only one per page as some browsers restrict the number
  26008. * of audio contexts you can create.
  26009. * @param hostElement defines the host element where to display the mute icon if necessary
  26010. */
  26011. constructor(hostElement?: Nullable<HTMLElement>);
  26012. /**
  26013. * Flags the audio engine in Locked state.
  26014. * This happens due to new browser policies preventing audio to autoplay.
  26015. */
  26016. lock(): void;
  26017. /**
  26018. * Unlocks the audio engine once a user action has been done on the dom.
  26019. * This is helpful to resume play once browser policies have been satisfied.
  26020. */
  26021. unlock(): void;
  26022. private _resumeAudioContext;
  26023. private _initializeAudioContext;
  26024. private _tryToRun;
  26025. private _triggerRunningState;
  26026. private _triggerSuspendedState;
  26027. private _displayMuteButton;
  26028. private _moveButtonToTopLeft;
  26029. private _onResize;
  26030. private _hideMuteButton;
  26031. /**
  26032. * Destroy and release the resources associated with the audio ccontext.
  26033. */
  26034. dispose(): void;
  26035. /**
  26036. * Gets the global volume sets on the master gain.
  26037. * @returns the global volume if set or -1 otherwise
  26038. */
  26039. getGlobalVolume(): number;
  26040. /**
  26041. * Sets the global volume of your experience (sets on the master gain).
  26042. * @param newVolume Defines the new global volume of the application
  26043. */
  26044. setGlobalVolume(newVolume: number): void;
  26045. /**
  26046. * Connect the audio engine to an audio analyser allowing some amazing
  26047. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26048. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26049. * @param analyser The analyser to connect to the engine
  26050. */
  26051. connectToAnalyser(analyser: Analyser): void;
  26052. }
  26053. }
  26054. declare module BABYLON {
  26055. /**
  26056. * Interface used to present a loading screen while loading a scene
  26057. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26058. */
  26059. export interface ILoadingScreen {
  26060. /**
  26061. * Function called to display the loading screen
  26062. */
  26063. displayLoadingUI: () => void;
  26064. /**
  26065. * Function called to hide the loading screen
  26066. */
  26067. hideLoadingUI: () => void;
  26068. /**
  26069. * Gets or sets the color to use for the background
  26070. */
  26071. loadingUIBackgroundColor: string;
  26072. /**
  26073. * Gets or sets the text to display while loading
  26074. */
  26075. loadingUIText: string;
  26076. }
  26077. /**
  26078. * Class used for the default loading screen
  26079. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26080. */
  26081. export class DefaultLoadingScreen implements ILoadingScreen {
  26082. private _renderingCanvas;
  26083. private _loadingText;
  26084. private _loadingDivBackgroundColor;
  26085. private _loadingDiv;
  26086. private _loadingTextDiv;
  26087. /**
  26088. * Creates a new default loading screen
  26089. * @param _renderingCanvas defines the canvas used to render the scene
  26090. * @param _loadingText defines the default text to display
  26091. * @param _loadingDivBackgroundColor defines the default background color
  26092. */
  26093. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26094. /**
  26095. * Function called to display the loading screen
  26096. */
  26097. displayLoadingUI(): void;
  26098. /**
  26099. * Function called to hide the loading screen
  26100. */
  26101. hideLoadingUI(): void;
  26102. /**
  26103. * Gets or sets the text to display while loading
  26104. */
  26105. loadingUIText: string;
  26106. /**
  26107. * Gets or sets the color to use for the background
  26108. */
  26109. loadingUIBackgroundColor: string;
  26110. private _resizeLoadingUI;
  26111. }
  26112. }
  26113. declare module BABYLON {
  26114. /**
  26115. * Settings for finer control over video usage
  26116. */
  26117. export interface VideoTextureSettings {
  26118. /**
  26119. * Applies `autoplay` to video, if specified
  26120. */
  26121. autoPlay?: boolean;
  26122. /**
  26123. * Applies `loop` to video, if specified
  26124. */
  26125. loop?: boolean;
  26126. /**
  26127. * Automatically updates internal texture from video at every frame in the render loop
  26128. */
  26129. autoUpdateTexture: boolean;
  26130. /**
  26131. * Image src displayed during the video loading or until the user interacts with the video.
  26132. */
  26133. poster?: string;
  26134. }
  26135. /**
  26136. * If you want to display a video in your scene, this is the special texture for that.
  26137. * This special texture works similar to other textures, with the exception of a few parameters.
  26138. * @see https://doc.babylonjs.com/how_to/video_texture
  26139. */
  26140. export class VideoTexture extends Texture {
  26141. /**
  26142. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26143. */
  26144. readonly autoUpdateTexture: boolean;
  26145. /**
  26146. * The video instance used by the texture internally
  26147. */
  26148. readonly video: HTMLVideoElement;
  26149. private _onUserActionRequestedObservable;
  26150. /**
  26151. * Event triggerd when a dom action is required by the user to play the video.
  26152. * This happens due to recent changes in browser policies preventing video to auto start.
  26153. */
  26154. readonly onUserActionRequestedObservable: Observable<Texture>;
  26155. private _generateMipMaps;
  26156. private _engine;
  26157. private _stillImageCaptured;
  26158. private _displayingPosterTexture;
  26159. private _settings;
  26160. private _createInternalTextureOnEvent;
  26161. /**
  26162. * Creates a video texture.
  26163. * If you want to display a video in your scene, this is the special texture for that.
  26164. * This special texture works similar to other textures, with the exception of a few parameters.
  26165. * @see https://doc.babylonjs.com/how_to/video_texture
  26166. * @param name optional name, will detect from video source, if not defined
  26167. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26168. * @param scene is obviously the current scene.
  26169. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26170. * @param invertY is false by default but can be used to invert video on Y axis
  26171. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26172. * @param settings allows finer control over video usage
  26173. */
  26174. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26175. private _getName;
  26176. private _getVideo;
  26177. private _createInternalTexture;
  26178. private reset;
  26179. /**
  26180. * @hidden Internal method to initiate `update`.
  26181. */ rebuild(): void;
  26182. /**
  26183. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26184. */
  26185. update(): void;
  26186. /**
  26187. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26188. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26189. */
  26190. updateTexture(isVisible: boolean): void;
  26191. protected _updateInternalTexture: () => void;
  26192. /**
  26193. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26194. * @param url New url.
  26195. */
  26196. updateURL(url: string): void;
  26197. /**
  26198. * Dispose the texture and release its associated resources.
  26199. */
  26200. dispose(): void;
  26201. /**
  26202. * Creates a video texture straight from a stream.
  26203. * @param scene Define the scene the texture should be created in
  26204. * @param stream Define the stream the texture should be created from
  26205. * @returns The created video texture as a promise
  26206. */
  26207. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26208. /**
  26209. * Creates a video texture straight from your WebCam video feed.
  26210. * @param scene Define the scene the texture should be created in
  26211. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26212. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26213. * @returns The created video texture as a promise
  26214. */
  26215. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26216. minWidth: number;
  26217. maxWidth: number;
  26218. minHeight: number;
  26219. maxHeight: number;
  26220. deviceId: string;
  26221. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26222. /**
  26223. * Creates a video texture straight from your WebCam video feed.
  26224. * @param scene Define the scene the texture should be created in
  26225. * @param onReady Define a callback to triggered once the texture will be ready
  26226. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26227. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26228. */
  26229. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26230. minWidth: number;
  26231. maxWidth: number;
  26232. minHeight: number;
  26233. maxHeight: number;
  26234. deviceId: string;
  26235. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26236. }
  26237. }
  26238. declare module BABYLON {
  26239. /**
  26240. * Interface for attribute information associated with buffer instanciation
  26241. */
  26242. export class InstancingAttributeInfo {
  26243. /**
  26244. * Index/offset of the attribute in the vertex shader
  26245. */
  26246. index: number;
  26247. /**
  26248. * size of the attribute, 1, 2, 3 or 4
  26249. */
  26250. attributeSize: number;
  26251. /**
  26252. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26253. * default is FLOAT
  26254. */
  26255. attribyteType: number;
  26256. /**
  26257. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26258. */
  26259. normalized: boolean;
  26260. /**
  26261. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26262. */
  26263. offset: number;
  26264. /**
  26265. * Name of the GLSL attribute, for debugging purpose only
  26266. */
  26267. attributeName: string;
  26268. }
  26269. /**
  26270. * Define options used to create a depth texture
  26271. */
  26272. export class DepthTextureCreationOptions {
  26273. /** Specifies whether or not a stencil should be allocated in the texture */
  26274. generateStencil?: boolean;
  26275. /** Specifies whether or not bilinear filtering is enable on the texture */
  26276. bilinearFiltering?: boolean;
  26277. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26278. comparisonFunction?: number;
  26279. /** Specifies if the created texture is a cube texture */
  26280. isCube?: boolean;
  26281. }
  26282. /**
  26283. * Class used to describe the capabilities of the engine relatively to the current browser
  26284. */
  26285. export class EngineCapabilities {
  26286. /** Maximum textures units per fragment shader */
  26287. maxTexturesImageUnits: number;
  26288. /** Maximum texture units per vertex shader */
  26289. maxVertexTextureImageUnits: number;
  26290. /** Maximum textures units in the entire pipeline */
  26291. maxCombinedTexturesImageUnits: number;
  26292. /** Maximum texture size */
  26293. maxTextureSize: number;
  26294. /** Maximum cube texture size */
  26295. maxCubemapTextureSize: number;
  26296. /** Maximum render texture size */
  26297. maxRenderTextureSize: number;
  26298. /** Maximum number of vertex attributes */
  26299. maxVertexAttribs: number;
  26300. /** Maximum number of varyings */
  26301. maxVaryingVectors: number;
  26302. /** Maximum number of uniforms per vertex shader */
  26303. maxVertexUniformVectors: number;
  26304. /** Maximum number of uniforms per fragment shader */
  26305. maxFragmentUniformVectors: number;
  26306. /** Defines if standard derivates (dx/dy) are supported */
  26307. standardDerivatives: boolean;
  26308. /** Defines if s3tc texture compression is supported */
  26309. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26310. /** Defines if pvrtc texture compression is supported */
  26311. pvrtc: any;
  26312. /** Defines if etc1 texture compression is supported */
  26313. etc1: any;
  26314. /** Defines if etc2 texture compression is supported */
  26315. etc2: any;
  26316. /** Defines if astc texture compression is supported */
  26317. astc: any;
  26318. /** Defines if float textures are supported */
  26319. textureFloat: boolean;
  26320. /** Defines if vertex array objects are supported */
  26321. vertexArrayObject: boolean;
  26322. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26323. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26324. /** Gets the maximum level of anisotropy supported */
  26325. maxAnisotropy: number;
  26326. /** Defines if instancing is supported */
  26327. instancedArrays: boolean;
  26328. /** Defines if 32 bits indices are supported */
  26329. uintIndices: boolean;
  26330. /** Defines if high precision shaders are supported */
  26331. highPrecisionShaderSupported: boolean;
  26332. /** Defines if depth reading in the fragment shader is supported */
  26333. fragmentDepthSupported: boolean;
  26334. /** Defines if float texture linear filtering is supported*/
  26335. textureFloatLinearFiltering: boolean;
  26336. /** Defines if rendering to float textures is supported */
  26337. textureFloatRender: boolean;
  26338. /** Defines if half float textures are supported*/
  26339. textureHalfFloat: boolean;
  26340. /** Defines if half float texture linear filtering is supported*/
  26341. textureHalfFloatLinearFiltering: boolean;
  26342. /** Defines if rendering to half float textures is supported */
  26343. textureHalfFloatRender: boolean;
  26344. /** Defines if textureLOD shader command is supported */
  26345. textureLOD: boolean;
  26346. /** Defines if draw buffers extension is supported */
  26347. drawBuffersExtension: boolean;
  26348. /** Defines if depth textures are supported */
  26349. depthTextureExtension: boolean;
  26350. /** Defines if float color buffer are supported */
  26351. colorBufferFloat: boolean;
  26352. /** Gets disjoint timer query extension (null if not supported) */
  26353. timerQuery: EXT_disjoint_timer_query;
  26354. /** Defines if timestamp can be used with timer query */
  26355. canUseTimestampForTimerQuery: boolean;
  26356. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26357. multiview: any;
  26358. /** Function used to let the system compiles shaders in background */
  26359. parallelShaderCompile: {
  26360. COMPLETION_STATUS_KHR: number;
  26361. };
  26362. }
  26363. /** Interface defining initialization parameters for Engine class */
  26364. export interface EngineOptions extends WebGLContextAttributes {
  26365. /**
  26366. * Defines if the engine should no exceed a specified device ratio
  26367. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26368. */
  26369. limitDeviceRatio?: number;
  26370. /**
  26371. * Defines if webvr should be enabled automatically
  26372. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26373. */
  26374. autoEnableWebVR?: boolean;
  26375. /**
  26376. * Defines if webgl2 should be turned off even if supported
  26377. * @see http://doc.babylonjs.com/features/webgl2
  26378. */
  26379. disableWebGL2Support?: boolean;
  26380. /**
  26381. * Defines if webaudio should be initialized as well
  26382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26383. */
  26384. audioEngine?: boolean;
  26385. /**
  26386. * Defines if animations should run using a deterministic lock step
  26387. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26388. */
  26389. deterministicLockstep?: boolean;
  26390. /** Defines the maximum steps to use with deterministic lock step mode */
  26391. lockstepMaxSteps?: number;
  26392. /**
  26393. * Defines that engine should ignore context lost events
  26394. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26395. */
  26396. doNotHandleContextLost?: boolean;
  26397. /**
  26398. * Defines that engine should ignore modifying touch action attribute and style
  26399. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26400. */
  26401. doNotHandleTouchAction?: boolean;
  26402. /**
  26403. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26404. */
  26405. useHighPrecisionFloats?: boolean;
  26406. }
  26407. /**
  26408. * Defines the interface used by display changed events
  26409. */
  26410. export interface IDisplayChangedEventArgs {
  26411. /** Gets the vrDisplay object (if any) */
  26412. vrDisplay: Nullable<any>;
  26413. /** Gets a boolean indicating if webVR is supported */
  26414. vrSupported: boolean;
  26415. }
  26416. /**
  26417. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26418. */
  26419. export class Engine {
  26420. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26421. static ExceptionList: ({
  26422. key: string;
  26423. capture: string;
  26424. captureConstraint: number;
  26425. targets: string[];
  26426. } | {
  26427. key: string;
  26428. capture: null;
  26429. captureConstraint: null;
  26430. targets: string[];
  26431. })[];
  26432. /** Gets the list of created engines */
  26433. static readonly Instances: Engine[];
  26434. /**
  26435. * Gets the latest created engine
  26436. */
  26437. static readonly LastCreatedEngine: Nullable<Engine>;
  26438. /**
  26439. * Gets the latest created scene
  26440. */
  26441. static readonly LastCreatedScene: Nullable<Scene>;
  26442. /**
  26443. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26444. * @param flag defines which part of the materials must be marked as dirty
  26445. * @param predicate defines a predicate used to filter which materials should be affected
  26446. */
  26447. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26448. /**
  26449. * Hidden
  26450. */ private static _TextureLoaders: IInternalTextureLoader[];
  26451. /** Defines that alpha blending is disabled */
  26452. static readonly ALPHA_DISABLE: number;
  26453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26454. static readonly ALPHA_ADD: number;
  26455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26456. static readonly ALPHA_COMBINE: number;
  26457. /** Defines that alpha blending to DEST - SRC * DEST */
  26458. static readonly ALPHA_SUBTRACT: number;
  26459. /** Defines that alpha blending to SRC * DEST */
  26460. static readonly ALPHA_MULTIPLY: number;
  26461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26462. static readonly ALPHA_MAXIMIZED: number;
  26463. /** Defines that alpha blending to SRC + DEST */
  26464. static readonly ALPHA_ONEONE: number;
  26465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26466. static readonly ALPHA_PREMULTIPLIED: number;
  26467. /**
  26468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26470. */
  26471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26473. static readonly ALPHA_INTERPOLATE: number;
  26474. /**
  26475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26477. */
  26478. static readonly ALPHA_SCREENMODE: number;
  26479. /** Defines that the ressource is not delayed*/
  26480. static readonly DELAYLOADSTATE_NONE: number;
  26481. /** Defines that the ressource was successfully delay loaded */
  26482. static readonly DELAYLOADSTATE_LOADED: number;
  26483. /** Defines that the ressource is currently delay loading */
  26484. static readonly DELAYLOADSTATE_LOADING: number;
  26485. /** Defines that the ressource is delayed and has not started loading */
  26486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26488. static readonly NEVER: number;
  26489. /** 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 */
  26490. static readonly ALWAYS: number;
  26491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26492. static readonly LESS: number;
  26493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26494. static readonly EQUAL: number;
  26495. /** 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 */
  26496. static readonly LEQUAL: number;
  26497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26498. static readonly GREATER: number;
  26499. /** 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 */
  26500. static readonly GEQUAL: number;
  26501. /** 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 */
  26502. static readonly NOTEQUAL: number;
  26503. /** Passed to stencilOperation to specify that stencil value must be kept */
  26504. static readonly KEEP: number;
  26505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26506. static readonly REPLACE: number;
  26507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26508. static readonly INCR: number;
  26509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26510. static readonly DECR: number;
  26511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26512. static readonly INVERT: number;
  26513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26514. static readonly INCR_WRAP: number;
  26515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26516. static readonly DECR_WRAP: number;
  26517. /** Texture is not repeating outside of 0..1 UVs */
  26518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26519. /** Texture is repeating outside of 0..1 UVs */
  26520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26521. /** Texture is repeating and mirrored */
  26522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26523. /** ALPHA */
  26524. static readonly TEXTUREFORMAT_ALPHA: number;
  26525. /** LUMINANCE */
  26526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26527. /** LUMINANCE_ALPHA */
  26528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26529. /** RGB */
  26530. static readonly TEXTUREFORMAT_RGB: number;
  26531. /** RGBA */
  26532. static readonly TEXTUREFORMAT_RGBA: number;
  26533. /** RED */
  26534. static readonly TEXTUREFORMAT_RED: number;
  26535. /** RED (2nd reference) */
  26536. static readonly TEXTUREFORMAT_R: number;
  26537. /** RG */
  26538. static readonly TEXTUREFORMAT_RG: number;
  26539. /** RED_INTEGER */
  26540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26541. /** RED_INTEGER (2nd reference) */
  26542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26543. /** RG_INTEGER */
  26544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26545. /** RGB_INTEGER */
  26546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26547. /** RGBA_INTEGER */
  26548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26549. /** UNSIGNED_BYTE */
  26550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26551. /** UNSIGNED_BYTE (2nd reference) */
  26552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26553. /** FLOAT */
  26554. static readonly TEXTURETYPE_FLOAT: number;
  26555. /** HALF_FLOAT */
  26556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26557. /** BYTE */
  26558. static readonly TEXTURETYPE_BYTE: number;
  26559. /** SHORT */
  26560. static readonly TEXTURETYPE_SHORT: number;
  26561. /** UNSIGNED_SHORT */
  26562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26563. /** INT */
  26564. static readonly TEXTURETYPE_INT: number;
  26565. /** UNSIGNED_INT */
  26566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26567. /** UNSIGNED_SHORT_4_4_4_4 */
  26568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26569. /** UNSIGNED_SHORT_5_5_5_1 */
  26570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26571. /** UNSIGNED_SHORT_5_6_5 */
  26572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26573. /** UNSIGNED_INT_2_10_10_10_REV */
  26574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26575. /** UNSIGNED_INT_24_8 */
  26576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26577. /** UNSIGNED_INT_10F_11F_11F_REV */
  26578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26579. /** UNSIGNED_INT_5_9_9_9_REV */
  26580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26583. /** nearest is mag = nearest and min = nearest and mip = linear */
  26584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26587. /** Trilinear is mag = linear and min = linear and mip = linear */
  26588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26589. /** nearest is mag = nearest and min = nearest and mip = linear */
  26590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26593. /** Trilinear is mag = linear and min = linear and mip = linear */
  26594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26595. /** mag = nearest and min = nearest and mip = nearest */
  26596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26597. /** mag = nearest and min = linear and mip = nearest */
  26598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26599. /** mag = nearest and min = linear and mip = linear */
  26600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26601. /** mag = nearest and min = linear and mip = none */
  26602. static readonly TEXTURE_NEAREST_LINEAR: number;
  26603. /** mag = nearest and min = nearest and mip = none */
  26604. static readonly TEXTURE_NEAREST_NEAREST: number;
  26605. /** mag = linear and min = nearest and mip = nearest */
  26606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26607. /** mag = linear and min = nearest and mip = linear */
  26608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26609. /** mag = linear and min = linear and mip = none */
  26610. static readonly TEXTURE_LINEAR_LINEAR: number;
  26611. /** mag = linear and min = nearest and mip = none */
  26612. static readonly TEXTURE_LINEAR_NEAREST: number;
  26613. /** Explicit coordinates mode */
  26614. static readonly TEXTURE_EXPLICIT_MODE: number;
  26615. /** Spherical coordinates mode */
  26616. static readonly TEXTURE_SPHERICAL_MODE: number;
  26617. /** Planar coordinates mode */
  26618. static readonly TEXTURE_PLANAR_MODE: number;
  26619. /** Cubic coordinates mode */
  26620. static readonly TEXTURE_CUBIC_MODE: number;
  26621. /** Projection coordinates mode */
  26622. static readonly TEXTURE_PROJECTION_MODE: number;
  26623. /** Skybox coordinates mode */
  26624. static readonly TEXTURE_SKYBOX_MODE: number;
  26625. /** Inverse Cubic coordinates mode */
  26626. static readonly TEXTURE_INVCUBIC_MODE: number;
  26627. /** Equirectangular coordinates mode */
  26628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26629. /** Equirectangular Fixed coordinates mode */
  26630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26631. /** Equirectangular Fixed Mirrored coordinates mode */
  26632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26634. static readonly SCALEMODE_FLOOR: number;
  26635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26636. static readonly SCALEMODE_NEAREST: number;
  26637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26638. static readonly SCALEMODE_CEILING: number;
  26639. /**
  26640. * Returns the current npm package of the sdk
  26641. */
  26642. static readonly NpmPackage: string;
  26643. /**
  26644. * Returns the current version of the framework
  26645. */
  26646. static readonly Version: string;
  26647. /**
  26648. * Returns a string describing the current engine
  26649. */
  26650. readonly description: string;
  26651. /**
  26652. * Gets or sets the epsilon value used by collision engine
  26653. */
  26654. static CollisionsEpsilon: number;
  26655. /**
  26656. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26657. */
  26658. static ShadersRepository: string;
  26659. /**
  26660. * Method called to create the default loading screen.
  26661. * This can be overriden in your own app.
  26662. * @param canvas The rendering canvas element
  26663. * @returns The loading screen
  26664. */
  26665. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26666. /**
  26667. * Method called to create the default rescale post process on each engine.
  26668. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26669. /**
  26670. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26671. */
  26672. forcePOTTextures: boolean;
  26673. /**
  26674. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26675. */
  26676. isFullscreen: boolean;
  26677. /**
  26678. * Gets a boolean indicating if the pointer is currently locked
  26679. */
  26680. isPointerLock: boolean;
  26681. /**
  26682. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26683. */
  26684. cullBackFaces: boolean;
  26685. /**
  26686. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26687. */
  26688. renderEvenInBackground: boolean;
  26689. /**
  26690. * Gets or sets a boolean indicating that cache can be kept between frames
  26691. */
  26692. preventCacheWipeBetweenFrames: boolean;
  26693. /**
  26694. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  26695. **/
  26696. enableOfflineSupport: boolean;
  26697. /**
  26698. * 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)
  26699. **/
  26700. disableManifestCheck: boolean;
  26701. /**
  26702. * Gets the list of created scenes
  26703. */
  26704. scenes: Scene[];
  26705. /**
  26706. * Event raised when a new scene is created
  26707. */
  26708. onNewSceneAddedObservable: Observable<Scene>;
  26709. /**
  26710. * Gets the list of created postprocesses
  26711. */
  26712. postProcesses: PostProcess[];
  26713. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  26714. validateShaderPrograms: boolean;
  26715. /**
  26716. * Observable event triggered each time the rendering canvas is resized
  26717. */
  26718. onResizeObservable: Observable<Engine>;
  26719. /**
  26720. * Observable event triggered each time the canvas loses focus
  26721. */
  26722. onCanvasBlurObservable: Observable<Engine>;
  26723. /**
  26724. * Observable event triggered each time the canvas gains focus
  26725. */
  26726. onCanvasFocusObservable: Observable<Engine>;
  26727. /**
  26728. * Observable event triggered each time the canvas receives pointerout event
  26729. */
  26730. onCanvasPointerOutObservable: Observable<PointerEvent>;
  26731. /**
  26732. * Observable event triggered before each texture is initialized
  26733. */
  26734. onBeforeTextureInitObservable: Observable<Texture>;
  26735. private _vrDisplay;
  26736. private _vrSupported;
  26737. private _oldSize;
  26738. private _oldHardwareScaleFactor;
  26739. private _vrExclusivePointerMode;
  26740. private _webVRInitPromise;
  26741. /**
  26742. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  26743. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  26744. */
  26745. readonly isInVRExclusivePointerMode: boolean;
  26746. /**
  26747. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  26748. */
  26749. disableUniformBuffers: boolean;
  26750. /** @hidden */ uniformBuffers: UniformBuffer[];
  26751. /**
  26752. * Gets a boolean indicating that the engine supports uniform buffers
  26753. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  26754. */
  26755. readonly supportsUniformBuffers: boolean;
  26756. /**
  26757. * Observable raised when the engine begins a new frame
  26758. */
  26759. onBeginFrameObservable: Observable<Engine>;
  26760. /**
  26761. * If set, will be used to request the next animation frame for the render loop
  26762. */
  26763. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  26764. /**
  26765. * Observable raised when the engine ends the current frame
  26766. */
  26767. onEndFrameObservable: Observable<Engine>;
  26768. /**
  26769. * Observable raised when the engine is about to compile a shader
  26770. */
  26771. onBeforeShaderCompilationObservable: Observable<Engine>;
  26772. /**
  26773. * Observable raised when the engine has jsut compiled a shader
  26774. */
  26775. onAfterShaderCompilationObservable: Observable<Engine>;
  26776. /** @hidden */ gl: WebGLRenderingContext;
  26777. private _renderingCanvas;
  26778. private _windowIsBackground;
  26779. private _webGLVersion;
  26780. protected _highPrecisionShadersAllowed: boolean;
  26781. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  26782. /**
  26783. * Gets a boolean indicating that only power of 2 textures are supported
  26784. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  26785. */
  26786. readonly needPOTTextures: boolean;
  26787. /** @hidden */ badOS: boolean;
  26788. /** @hidden */ badDesktopOS: boolean;
  26789. /**
  26790. * Gets or sets a value indicating if we want to disable texture binding optimization.
  26791. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  26792. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  26793. */
  26794. disableTextureBindingOptimization: boolean;
  26795. /**
  26796. * Gets the audio engine
  26797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26798. * @ignorenaming
  26799. */
  26800. static audioEngine: IAudioEngine;
  26801. /**
  26802. * Default AudioEngine factory responsible of creating the Audio Engine.
  26803. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  26804. */
  26805. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  26806. /**
  26807. * Default offline support factory responsible of creating a tool used to store data locally.
  26808. * By default, this will create a Database object if the workload has been embedded.
  26809. */
  26810. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  26811. private _onFocus;
  26812. private _onBlur;
  26813. private _onCanvasPointerOut;
  26814. private _onCanvasBlur;
  26815. private _onCanvasFocus;
  26816. private _onFullscreenChange;
  26817. private _onPointerLockChange;
  26818. private _onVRDisplayPointerRestricted;
  26819. private _onVRDisplayPointerUnrestricted;
  26820. private _onVrDisplayConnect;
  26821. private _onVrDisplayDisconnect;
  26822. private _onVrDisplayPresentChange;
  26823. /**
  26824. * Observable signaled when VR display mode changes
  26825. */
  26826. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  26827. /**
  26828. * Observable signaled when VR request present is complete
  26829. */
  26830. onVRRequestPresentComplete: Observable<boolean>;
  26831. /**
  26832. * Observable signaled when VR request present starts
  26833. */
  26834. onVRRequestPresentStart: Observable<Engine>;
  26835. private _hardwareScalingLevel;
  26836. /** @hidden */
  26837. protected _caps: EngineCapabilities;
  26838. private _pointerLockRequested;
  26839. private _isStencilEnable;
  26840. private _colorWrite;
  26841. private _loadingScreen;
  26842. /** @hidden */ drawCalls: PerfCounter;
  26843. /** @hidden */ textureCollisions: PerfCounter;
  26844. private _glVersion;
  26845. private _glRenderer;
  26846. private _glVendor;
  26847. private _videoTextureSupported;
  26848. private _renderingQueueLaunched;
  26849. private _activeRenderLoops;
  26850. private _deterministicLockstep;
  26851. private _lockstepMaxSteps;
  26852. /**
  26853. * Observable signaled when a context lost event is raised
  26854. */
  26855. onContextLostObservable: Observable<Engine>;
  26856. /**
  26857. * Observable signaled when a context restored event is raised
  26858. */
  26859. onContextRestoredObservable: Observable<Engine>;
  26860. private _onContextLost;
  26861. private _onContextRestored;
  26862. private _contextWasLost;
  26863. private _doNotHandleContextLost;
  26864. /**
  26865. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  26866. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  26867. */
  26868. doNotHandleContextLost: boolean;
  26869. private _performanceMonitor;
  26870. private _fps;
  26871. private _deltaTime;
  26872. /**
  26873. * Turn this value on if you want to pause FPS computation when in background
  26874. */
  26875. disablePerformanceMonitorInBackground: boolean;
  26876. /**
  26877. * Gets the performance monitor attached to this engine
  26878. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  26879. */
  26880. readonly performanceMonitor: PerformanceMonitor;
  26881. /**
  26882. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  26883. */
  26884. disableVertexArrayObjects: boolean;
  26885. /** @hidden */
  26886. protected _depthCullingState: _DepthCullingState;
  26887. /** @hidden */
  26888. protected _stencilState: _StencilState;
  26889. /** @hidden */
  26890. protected _alphaState: _AlphaState;
  26891. /** @hidden */
  26892. protected _alphaMode: number;
  26893. protected _internalTexturesCache: InternalTexture[];
  26894. /** @hidden */
  26895. protected _activeChannel: number;
  26896. private _currentTextureChannel;
  26897. /** @hidden */
  26898. protected _boundTexturesCache: {
  26899. [key: string]: Nullable<InternalTexture>;
  26900. };
  26901. /** @hidden */
  26902. protected _currentEffect: Nullable<Effect>;
  26903. /** @hidden */
  26904. protected _currentProgram: Nullable<WebGLProgram>;
  26905. private _compiledEffects;
  26906. private _vertexAttribArraysEnabled;
  26907. /** @hidden */
  26908. protected _cachedViewport: Nullable<Viewport>;
  26909. private _cachedVertexArrayObject;
  26910. /** @hidden */
  26911. protected _cachedVertexBuffers: any;
  26912. /** @hidden */
  26913. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  26914. /** @hidden */
  26915. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  26916. /** @hidden */
  26917. protected _currentRenderTarget: Nullable<InternalTexture>;
  26918. private _uintIndicesCurrentlySet;
  26919. private _currentBoundBuffer;
  26920. /** @hidden */
  26921. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  26922. private _currentBufferPointers;
  26923. private _currentInstanceLocations;
  26924. private _currentInstanceBuffers;
  26925. private _textureUnits;
  26926. private _firstBoundInternalTextureTracker;
  26927. private _lastBoundInternalTextureTracker;
  26928. private _workingCanvas;
  26929. private _workingContext;
  26930. private _rescalePostProcess;
  26931. private _dummyFramebuffer;
  26932. private _externalData;
  26933. private _bindedRenderFunction;
  26934. private _vaoRecordInProgress;
  26935. private _mustWipeVertexAttributes;
  26936. private _emptyTexture;
  26937. private _emptyCubeTexture;
  26938. private _emptyTexture3D;
  26939. /** @hidden */ frameHandler: number;
  26940. private _nextFreeTextureSlots;
  26941. private _maxSimultaneousTextures;
  26942. private _activeRequests;
  26943. private _texturesSupported;
  26944. private _textureFormatInUse;
  26945. /**
  26946. * Gets the list of texture formats supported
  26947. */
  26948. readonly texturesSupported: Array<string>;
  26949. /**
  26950. * Gets the list of texture formats in use
  26951. */
  26952. readonly textureFormatInUse: Nullable<string>;
  26953. /**
  26954. * Gets the current viewport
  26955. */
  26956. readonly currentViewport: Nullable<Viewport>;
  26957. /**
  26958. * Gets the default empty texture
  26959. */
  26960. readonly emptyTexture: InternalTexture;
  26961. /**
  26962. * Gets the default empty 3D texture
  26963. */
  26964. readonly emptyTexture3D: InternalTexture;
  26965. /**
  26966. * Gets the default empty cube texture
  26967. */
  26968. readonly emptyCubeTexture: InternalTexture;
  26969. /**
  26970. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  26971. */
  26972. readonly premultipliedAlpha: boolean;
  26973. /**
  26974. * Creates a new engine
  26975. * @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
  26976. * @param antialias defines enable antialiasing (default: false)
  26977. * @param options defines further options to be sent to the getContext() function
  26978. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  26979. */
  26980. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  26981. private _disableTouchAction;
  26982. private _rebuildInternalTextures;
  26983. private _rebuildEffects;
  26984. /**
  26985. * Gets a boolean indicating if all created effects are ready
  26986. * @returns true if all effects are ready
  26987. */
  26988. areAllEffectsReady(): boolean;
  26989. private _rebuildBuffers;
  26990. private _initGLContext;
  26991. /**
  26992. * Gets version of the current webGL context
  26993. */
  26994. readonly webGLVersion: number;
  26995. /**
  26996. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  26997. */
  26998. readonly isStencilEnable: boolean;
  26999. private _prepareWorkingCanvas;
  27000. /**
  27001. * Reset the texture cache to empty state
  27002. */
  27003. resetTextureCache(): void;
  27004. /**
  27005. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27006. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27007. * @returns true if engine is in deterministic lock step mode
  27008. */
  27009. isDeterministicLockStep(): boolean;
  27010. /**
  27011. * Gets the max steps when engine is running in deterministic lock step
  27012. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27013. * @returns the max steps
  27014. */
  27015. getLockstepMaxSteps(): number;
  27016. /**
  27017. * Gets an object containing information about the current webGL context
  27018. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27019. */
  27020. getGlInfo(): {
  27021. vendor: string;
  27022. renderer: string;
  27023. version: string;
  27024. };
  27025. /**
  27026. * Gets current aspect ratio
  27027. * @param camera defines the camera to use to get the aspect ratio
  27028. * @param useScreen defines if screen size must be used (or the current render target if any)
  27029. * @returns a number defining the aspect ratio
  27030. */
  27031. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27032. /**
  27033. * Gets current screen aspect ratio
  27034. * @returns a number defining the aspect ratio
  27035. */
  27036. getScreenAspectRatio(): number;
  27037. /**
  27038. * Gets the current render width
  27039. * @param useScreen defines if screen size must be used (or the current render target if any)
  27040. * @returns a number defining the current render width
  27041. */
  27042. getRenderWidth(useScreen?: boolean): number;
  27043. /**
  27044. * Gets the current render height
  27045. * @param useScreen defines if screen size must be used (or the current render target if any)
  27046. * @returns a number defining the current render height
  27047. */
  27048. getRenderHeight(useScreen?: boolean): number;
  27049. /**
  27050. * Gets the HTML canvas attached with the current webGL context
  27051. * @returns a HTML canvas
  27052. */
  27053. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27054. /**
  27055. * Gets the client rect of the HTML canvas attached with the current webGL context
  27056. * @returns a client rectanglee
  27057. */
  27058. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27059. /**
  27060. * Defines the hardware scaling level.
  27061. * By default the hardware scaling level is computed from the window device ratio.
  27062. * 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.
  27063. * @param level defines the level to use
  27064. */
  27065. setHardwareScalingLevel(level: number): void;
  27066. /**
  27067. * Gets the current hardware scaling level.
  27068. * By default the hardware scaling level is computed from the window device ratio.
  27069. * 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.
  27070. * @returns a number indicating the current hardware scaling level
  27071. */
  27072. getHardwareScalingLevel(): number;
  27073. /**
  27074. * Gets the list of loaded textures
  27075. * @returns an array containing all loaded textures
  27076. */
  27077. getLoadedTexturesCache(): InternalTexture[];
  27078. /**
  27079. * Gets the object containing all engine capabilities
  27080. * @returns the EngineCapabilities object
  27081. */
  27082. getCaps(): EngineCapabilities;
  27083. /**
  27084. * Gets the current depth function
  27085. * @returns a number defining the depth function
  27086. */
  27087. getDepthFunction(): Nullable<number>;
  27088. /**
  27089. * Sets the current depth function
  27090. * @param depthFunc defines the function to use
  27091. */
  27092. setDepthFunction(depthFunc: number): void;
  27093. /**
  27094. * Sets the current depth function to GREATER
  27095. */
  27096. setDepthFunctionToGreater(): void;
  27097. /**
  27098. * Sets the current depth function to GEQUAL
  27099. */
  27100. setDepthFunctionToGreaterOrEqual(): void;
  27101. /**
  27102. * Sets the current depth function to LESS
  27103. */
  27104. setDepthFunctionToLess(): void;
  27105. private _cachedStencilBuffer;
  27106. private _cachedStencilFunction;
  27107. private _cachedStencilMask;
  27108. private _cachedStencilOperationPass;
  27109. private _cachedStencilOperationFail;
  27110. private _cachedStencilOperationDepthFail;
  27111. private _cachedStencilReference;
  27112. /**
  27113. * Caches the the state of the stencil buffer
  27114. */
  27115. cacheStencilState(): void;
  27116. /**
  27117. * Restores the state of the stencil buffer
  27118. */
  27119. restoreStencilState(): void;
  27120. /**
  27121. * Sets the current depth function to LEQUAL
  27122. */
  27123. setDepthFunctionToLessOrEqual(): void;
  27124. /**
  27125. * Gets a boolean indicating if stencil buffer is enabled
  27126. * @returns the current stencil buffer state
  27127. */
  27128. getStencilBuffer(): boolean;
  27129. /**
  27130. * Enable or disable the stencil buffer
  27131. * @param enable defines if the stencil buffer must be enabled or disabled
  27132. */
  27133. setStencilBuffer(enable: boolean): void;
  27134. /**
  27135. * Gets the current stencil mask
  27136. * @returns a number defining the new stencil mask to use
  27137. */
  27138. getStencilMask(): number;
  27139. /**
  27140. * Sets the current stencil mask
  27141. * @param mask defines the new stencil mask to use
  27142. */
  27143. setStencilMask(mask: number): void;
  27144. /**
  27145. * Gets the current stencil function
  27146. * @returns a number defining the stencil function to use
  27147. */
  27148. getStencilFunction(): number;
  27149. /**
  27150. * Gets the current stencil reference value
  27151. * @returns a number defining the stencil reference value to use
  27152. */
  27153. getStencilFunctionReference(): number;
  27154. /**
  27155. * Gets the current stencil mask
  27156. * @returns a number defining the stencil mask to use
  27157. */
  27158. getStencilFunctionMask(): number;
  27159. /**
  27160. * Sets the current stencil function
  27161. * @param stencilFunc defines the new stencil function to use
  27162. */
  27163. setStencilFunction(stencilFunc: number): void;
  27164. /**
  27165. * Sets the current stencil reference
  27166. * @param reference defines the new stencil reference to use
  27167. */
  27168. setStencilFunctionReference(reference: number): void;
  27169. /**
  27170. * Sets the current stencil mask
  27171. * @param mask defines the new stencil mask to use
  27172. */
  27173. setStencilFunctionMask(mask: number): void;
  27174. /**
  27175. * Gets the current stencil operation when stencil fails
  27176. * @returns a number defining stencil operation to use when stencil fails
  27177. */
  27178. getStencilOperationFail(): number;
  27179. /**
  27180. * Gets the current stencil operation when depth fails
  27181. * @returns a number defining stencil operation to use when depth fails
  27182. */
  27183. getStencilOperationDepthFail(): number;
  27184. /**
  27185. * Gets the current stencil operation when stencil passes
  27186. * @returns a number defining stencil operation to use when stencil passes
  27187. */
  27188. getStencilOperationPass(): number;
  27189. /**
  27190. * Sets the stencil operation to use when stencil fails
  27191. * @param operation defines the stencil operation to use when stencil fails
  27192. */
  27193. setStencilOperationFail(operation: number): void;
  27194. /**
  27195. * Sets the stencil operation to use when depth fails
  27196. * @param operation defines the stencil operation to use when depth fails
  27197. */
  27198. setStencilOperationDepthFail(operation: number): void;
  27199. /**
  27200. * Sets the stencil operation to use when stencil passes
  27201. * @param operation defines the stencil operation to use when stencil passes
  27202. */
  27203. setStencilOperationPass(operation: number): void;
  27204. /**
  27205. * Sets a boolean indicating if the dithering state is enabled or disabled
  27206. * @param value defines the dithering state
  27207. */
  27208. setDitheringState(value: boolean): void;
  27209. /**
  27210. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27211. * @param value defines the rasterizer state
  27212. */
  27213. setRasterizerState(value: boolean): void;
  27214. /**
  27215. * stop executing a render loop function and remove it from the execution array
  27216. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27217. */
  27218. stopRenderLoop(renderFunction?: () => void): void;
  27219. /** @hidden */ renderLoop(): void;
  27220. /**
  27221. * Register and execute a render loop. The engine can have more than one render function
  27222. * @param renderFunction defines the function to continuously execute
  27223. */
  27224. runRenderLoop(renderFunction: () => void): void;
  27225. /**
  27226. * Toggle full screen mode
  27227. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27228. */
  27229. switchFullscreen(requestPointerLock: boolean): void;
  27230. /**
  27231. * Enters full screen mode
  27232. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27233. */
  27234. enterFullscreen(requestPointerLock: boolean): void;
  27235. /**
  27236. * Exits full screen mode
  27237. */
  27238. exitFullscreen(): void;
  27239. /**
  27240. * Clear the current render buffer or the current render target (if any is set up)
  27241. * @param color defines the color to use
  27242. * @param backBuffer defines if the back buffer must be cleared
  27243. * @param depth defines if the depth buffer must be cleared
  27244. * @param stencil defines if the stencil buffer must be cleared
  27245. */
  27246. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27247. /**
  27248. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27249. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27250. * @param y defines the y-coordinate of the corner of the clear rectangle
  27251. * @param width defines the width of the clear rectangle
  27252. * @param height defines the height of the clear rectangle
  27253. * @param clearColor defines the clear color
  27254. */
  27255. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27256. /**
  27257. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27258. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27259. * @param y defines the y-coordinate of the corner of the clear rectangle
  27260. * @param width defines the width of the clear rectangle
  27261. * @param height defines the height of the clear rectangle
  27262. */
  27263. enableScissor(x: number, y: number, width: number, height: number): void;
  27264. /**
  27265. * Disable previously set scissor test rectangle
  27266. */
  27267. disableScissor(): void;
  27268. private _viewportCached;
  27269. /** @hidden */ viewport(x: number, y: number, width: number, height: number): void;
  27270. /**
  27271. * Set the WebGL's viewport
  27272. * @param viewport defines the viewport element to be used
  27273. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27274. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27275. */
  27276. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27277. /**
  27278. * Directly set the WebGL Viewport
  27279. * @param x defines the x coordinate of the viewport (in screen space)
  27280. * @param y defines the y coordinate of the viewport (in screen space)
  27281. * @param width defines the width of the viewport (in screen space)
  27282. * @param height defines the height of the viewport (in screen space)
  27283. * @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
  27284. */
  27285. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27286. /**
  27287. * Begin a new frame
  27288. */
  27289. beginFrame(): void;
  27290. /**
  27291. * Enf the current frame
  27292. */
  27293. endFrame(): void;
  27294. /**
  27295. * Resize the view according to the canvas' size
  27296. */
  27297. resize(): void;
  27298. /**
  27299. * Force a specific size of the canvas
  27300. * @param width defines the new canvas' width
  27301. * @param height defines the new canvas' height
  27302. */
  27303. setSize(width: number, height: number): void;
  27304. /**
  27305. * Gets a boolean indicating if a webVR device was detected
  27306. * @returns true if a webVR device was detected
  27307. */
  27308. isVRDevicePresent(): boolean;
  27309. /**
  27310. * Gets the current webVR device
  27311. * @returns the current webVR device (or null)
  27312. */
  27313. getVRDevice(): any;
  27314. /**
  27315. * Initializes a webVR display and starts listening to display change events
  27316. * The onVRDisplayChangedObservable will be notified upon these changes
  27317. * @returns The onVRDisplayChangedObservable
  27318. */
  27319. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27320. /**
  27321. * Initializes a webVR display and starts listening to display change events
  27322. * The onVRDisplayChangedObservable will be notified upon these changes
  27323. * @returns A promise containing a VRDisplay and if vr is supported
  27324. */
  27325. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27326. /**
  27327. * Call this function to switch to webVR mode
  27328. * Will do nothing if webVR is not supported or if there is no webVR device
  27329. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27330. */
  27331. enableVR(): void;
  27332. /**
  27333. * Call this function to leave webVR mode
  27334. * Will do nothing if webVR is not supported or if there is no webVR device
  27335. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27336. */
  27337. disableVR(): void;
  27338. private _onVRFullScreenTriggered;
  27339. private _getVRDisplaysAsync;
  27340. /**
  27341. * Binds the frame buffer to the specified texture.
  27342. * @param texture The texture to render to or null for the default canvas
  27343. * @param faceIndex The face of the texture to render to in case of cube texture
  27344. * @param requiredWidth The width of the target to render to
  27345. * @param requiredHeight The height of the target to render to
  27346. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27347. * @param depthStencilTexture The depth stencil texture to use to render
  27348. * @param lodLevel defines le lod level to bind to the frame buffer
  27349. */
  27350. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27351. private bindUnboundFramebuffer;
  27352. /**
  27353. * Unbind the current render target texture from the webGL context
  27354. * @param texture defines the render target texture to unbind
  27355. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27356. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27357. */
  27358. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27359. /**
  27360. * Unbind a list of render target textures from the webGL context
  27361. * This is used only when drawBuffer extension or webGL2 are active
  27362. * @param textures defines the render target textures to unbind
  27363. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27364. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27365. */
  27366. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27367. /**
  27368. * Force the mipmap generation for the given render target texture
  27369. * @param texture defines the render target texture to use
  27370. */
  27371. generateMipMapsForCubemap(texture: InternalTexture): void;
  27372. /**
  27373. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27374. */
  27375. flushFramebuffer(): void;
  27376. /**
  27377. * Unbind the current render target and bind the default framebuffer
  27378. */
  27379. restoreDefaultFramebuffer(): void;
  27380. /**
  27381. * Create an uniform buffer
  27382. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27383. * @param elements defines the content of the uniform buffer
  27384. * @returns the webGL uniform buffer
  27385. */
  27386. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  27387. /**
  27388. * Create a dynamic uniform buffer
  27389. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27390. * @param elements defines the content of the uniform buffer
  27391. * @returns the webGL uniform buffer
  27392. */
  27393. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  27394. /**
  27395. * Update an existing uniform buffer
  27396. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27397. * @param uniformBuffer defines the target uniform buffer
  27398. * @param elements defines the content to update
  27399. * @param offset defines the offset in the uniform buffer where update should start
  27400. * @param count defines the size of the data to update
  27401. */
  27402. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27403. private _resetVertexBufferBinding;
  27404. /**
  27405. * Creates a vertex buffer
  27406. * @param data the data for the vertex buffer
  27407. * @returns the new WebGL static buffer
  27408. */
  27409. createVertexBuffer(data: DataArray): WebGLBuffer;
  27410. /**
  27411. * Creates a dynamic vertex buffer
  27412. * @param data the data for the dynamic vertex buffer
  27413. * @returns the new WebGL dynamic buffer
  27414. */
  27415. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  27416. /**
  27417. * Update a dynamic index buffer
  27418. * @param indexBuffer defines the target index buffer
  27419. * @param indices defines the data to update
  27420. * @param offset defines the offset in the target index buffer where update should start
  27421. */
  27422. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  27423. /**
  27424. * Updates a dynamic vertex buffer.
  27425. * @param vertexBuffer the vertex buffer to update
  27426. * @param data the data used to update the vertex buffer
  27427. * @param byteOffset the byte offset of the data
  27428. * @param byteLength the byte length of the data
  27429. */
  27430. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27431. private _resetIndexBufferBinding;
  27432. /**
  27433. * Creates a new index buffer
  27434. * @param indices defines the content of the index buffer
  27435. * @param updatable defines if the index buffer must be updatable
  27436. * @returns a new webGL buffer
  27437. */
  27438. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  27439. /**
  27440. * Bind a webGL buffer to the webGL context
  27441. * @param buffer defines the buffer to bind
  27442. */
  27443. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  27444. /**
  27445. * Bind an uniform buffer to the current webGL context
  27446. * @param buffer defines the buffer to bind
  27447. */
  27448. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  27449. /**
  27450. * Bind a buffer to the current webGL context at a given location
  27451. * @param buffer defines the buffer to bind
  27452. * @param location defines the index where to bind the buffer
  27453. */
  27454. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  27455. /**
  27456. * Bind a specific block at a given index in a specific shader program
  27457. * @param shaderProgram defines the shader program
  27458. * @param blockName defines the block name
  27459. * @param index defines the index where to bind the block
  27460. */
  27461. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  27462. private bindIndexBuffer;
  27463. private bindBuffer;
  27464. /**
  27465. * update the bound buffer with the given data
  27466. * @param data defines the data to update
  27467. */
  27468. updateArrayBuffer(data: Float32Array): void;
  27469. private _vertexAttribPointer;
  27470. private _bindIndexBufferWithCache;
  27471. private _bindVertexBuffersAttributes;
  27472. /**
  27473. * Records a vertex array object
  27474. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27475. * @param vertexBuffers defines the list of vertex buffers to store
  27476. * @param indexBuffer defines the index buffer to store
  27477. * @param effect defines the effect to store
  27478. * @returns the new vertex array object
  27479. */
  27480. recordVertexArrayObject(vertexBuffers: {
  27481. [key: string]: VertexBuffer;
  27482. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  27483. /**
  27484. * Bind a specific vertex array object
  27485. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27486. * @param vertexArrayObject defines the vertex array object to bind
  27487. * @param indexBuffer defines the index buffer to bind
  27488. */
  27489. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  27490. /**
  27491. * Bind webGl buffers directly to the webGL context
  27492. * @param vertexBuffer defines the vertex buffer to bind
  27493. * @param indexBuffer defines the index buffer to bind
  27494. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27495. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27496. * @param effect defines the effect associated with the vertex buffer
  27497. */
  27498. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27499. private _unbindVertexArrayObject;
  27500. /**
  27501. * Bind a list of vertex buffers to the webGL context
  27502. * @param vertexBuffers defines the list of vertex buffers to bind
  27503. * @param indexBuffer defines the index buffer to bind
  27504. * @param effect defines the effect associated with the vertex buffers
  27505. */
  27506. bindBuffers(vertexBuffers: {
  27507. [key: string]: Nullable<VertexBuffer>;
  27508. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  27509. /**
  27510. * Unbind all instance attributes
  27511. */
  27512. unbindInstanceAttributes(): void;
  27513. /**
  27514. * Release and free the memory of a vertex array object
  27515. * @param vao defines the vertex array object to delete
  27516. */
  27517. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27518. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  27519. /**
  27520. * Creates a webGL buffer to use with instanciation
  27521. * @param capacity defines the size of the buffer
  27522. * @returns the webGL buffer
  27523. */
  27524. createInstancesBuffer(capacity: number): WebGLBuffer;
  27525. /**
  27526. * Delete a webGL buffer used with instanciation
  27527. * @param buffer defines the webGL buffer to delete
  27528. */
  27529. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27530. /**
  27531. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27532. * @param instancesBuffer defines the webGL buffer to update and bind
  27533. * @param data defines the data to store in the buffer
  27534. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27535. */
  27536. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27537. /**
  27538. * Apply all cached states (depth, culling, stencil and alpha)
  27539. */
  27540. applyStates(): void;
  27541. /**
  27542. * Send a draw order
  27543. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27544. * @param indexStart defines the starting index
  27545. * @param indexCount defines the number of index to draw
  27546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27547. */
  27548. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27549. /**
  27550. * Draw a list of points
  27551. * @param verticesStart defines the index of first vertex to draw
  27552. * @param verticesCount defines the count of vertices to draw
  27553. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27554. */
  27555. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27556. /**
  27557. * Draw a list of unindexed primitives
  27558. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27559. * @param verticesStart defines the index of first vertex to draw
  27560. * @param verticesCount defines the count of vertices to draw
  27561. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27562. */
  27563. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27564. /**
  27565. * Draw a list of indexed primitives
  27566. * @param fillMode defines the primitive to use
  27567. * @param indexStart defines the starting index
  27568. * @param indexCount defines the number of index to draw
  27569. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27570. */
  27571. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27572. /**
  27573. * Draw a list of unindexed primitives
  27574. * @param fillMode defines the primitive to use
  27575. * @param verticesStart defines the index of first vertex to draw
  27576. * @param verticesCount defines the count of vertices to draw
  27577. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27578. */
  27579. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27580. private _drawMode;
  27581. /** @hidden */ releaseEffect(effect: Effect): void;
  27582. /** @hidden */ deleteProgram(program: WebGLProgram): void;
  27583. /**
  27584. * Create a new effect (used to store vertex/fragment shaders)
  27585. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27586. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27587. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27588. * @param samplers defines an array of string used to represent textures
  27589. * @param defines defines the string containing the defines to use to compile the shaders
  27590. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27591. * @param onCompiled defines a function to call when the effect creation is successful
  27592. * @param onError defines a function to call when the effect creation has failed
  27593. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27594. * @returns the new Effect
  27595. */
  27596. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  27597. private _compileShader;
  27598. private _compileRawShader;
  27599. /**
  27600. * Directly creates a webGL program
  27601. * @param vertexCode defines the vertex shader code to use
  27602. * @param fragmentCode defines the fragment shader code to use
  27603. * @param context defines the webGL context to use (if not set, the current one will be used)
  27604. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27605. * @returns the new webGL program
  27606. */
  27607. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27608. /**
  27609. * Creates a webGL program
  27610. * @param vertexCode defines the vertex shader code to use
  27611. * @param fragmentCode defines the fragment shader code to use
  27612. * @param defines defines the string containing the defines to use to compile the shaders
  27613. * @param context defines the webGL context to use (if not set, the current one will be used)
  27614. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27615. * @returns the new webGL program
  27616. */
  27617. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27618. private _createShaderProgram;
  27619. private _finalizeProgram;
  27620. /** @hidden */ isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  27621. /** @hidden */ executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  27622. /**
  27623. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27624. * @param shaderProgram defines the webGL program to use
  27625. * @param uniformsNames defines the list of uniform names
  27626. * @returns an array of webGL uniform locations
  27627. */
  27628. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27629. /**
  27630. * Gets the lsit of active attributes for a given webGL program
  27631. * @param shaderProgram defines the webGL program to use
  27632. * @param attributesNames defines the list of attribute names to get
  27633. * @returns an array of indices indicating the offset of each attribute
  27634. */
  27635. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  27636. /**
  27637. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27638. * @param effect defines the effect to activate
  27639. */
  27640. enableEffect(effect: Nullable<Effect>): void;
  27641. /**
  27642. * Set the value of an uniform to an array of int32
  27643. * @param uniform defines the webGL uniform location where to store the value
  27644. * @param array defines the array of int32 to store
  27645. */
  27646. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27647. /**
  27648. * Set the value of an uniform to an array of int32 (stored as vec2)
  27649. * @param uniform defines the webGL uniform location where to store the value
  27650. * @param array defines the array of int32 to store
  27651. */
  27652. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27653. /**
  27654. * Set the value of an uniform to an array of int32 (stored as vec3)
  27655. * @param uniform defines the webGL uniform location where to store the value
  27656. * @param array defines the array of int32 to store
  27657. */
  27658. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27659. /**
  27660. * Set the value of an uniform to an array of int32 (stored as vec4)
  27661. * @param uniform defines the webGL uniform location where to store the value
  27662. * @param array defines the array of int32 to store
  27663. */
  27664. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27665. /**
  27666. * Set the value of an uniform to an array of float32
  27667. * @param uniform defines the webGL uniform location where to store the value
  27668. * @param array defines the array of float32 to store
  27669. */
  27670. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27671. /**
  27672. * Set the value of an uniform to an array of float32 (stored as vec2)
  27673. * @param uniform defines the webGL uniform location where to store the value
  27674. * @param array defines the array of float32 to store
  27675. */
  27676. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27677. /**
  27678. * Set the value of an uniform to an array of float32 (stored as vec3)
  27679. * @param uniform defines the webGL uniform location where to store the value
  27680. * @param array defines the array of float32 to store
  27681. */
  27682. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27683. /**
  27684. * Set the value of an uniform to an array of float32 (stored as vec4)
  27685. * @param uniform defines the webGL uniform location where to store the value
  27686. * @param array defines the array of float32 to store
  27687. */
  27688. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27689. /**
  27690. * Set the value of an uniform to an array of number
  27691. * @param uniform defines the webGL uniform location where to store the value
  27692. * @param array defines the array of number to store
  27693. */
  27694. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27695. /**
  27696. * Set the value of an uniform to an array of number (stored as vec2)
  27697. * @param uniform defines the webGL uniform location where to store the value
  27698. * @param array defines the array of number to store
  27699. */
  27700. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27701. /**
  27702. * Set the value of an uniform to an array of number (stored as vec3)
  27703. * @param uniform defines the webGL uniform location where to store the value
  27704. * @param array defines the array of number to store
  27705. */
  27706. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27707. /**
  27708. * Set the value of an uniform to an array of number (stored as vec4)
  27709. * @param uniform defines the webGL uniform location where to store the value
  27710. * @param array defines the array of number to store
  27711. */
  27712. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27713. /**
  27714. * Set the value of an uniform to an array of float32 (stored as matrices)
  27715. * @param uniform defines the webGL uniform location where to store the value
  27716. * @param matrices defines the array of float32 to store
  27717. */
  27718. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27719. /**
  27720. * Set the value of an uniform to a matrix
  27721. * @param uniform defines the webGL uniform location where to store the value
  27722. * @param matrix defines the matrix to store
  27723. */
  27724. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27725. /**
  27726. * Set the value of an uniform to a matrix (3x3)
  27727. * @param uniform defines the webGL uniform location where to store the value
  27728. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27729. */
  27730. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27731. /**
  27732. * Set the value of an uniform to a matrix (2x2)
  27733. * @param uniform defines the webGL uniform location where to store the value
  27734. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27735. */
  27736. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27737. /**
  27738. * Set the value of an uniform to a number (int)
  27739. * @param uniform defines the webGL uniform location where to store the value
  27740. * @param value defines the int number to store
  27741. */
  27742. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27743. /**
  27744. * Set the value of an uniform to a number (float)
  27745. * @param uniform defines the webGL uniform location where to store the value
  27746. * @param value defines the float number to store
  27747. */
  27748. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  27749. /**
  27750. * Set the value of an uniform to a vec2
  27751. * @param uniform defines the webGL uniform location where to store the value
  27752. * @param x defines the 1st component of the value
  27753. * @param y defines the 2nd component of the value
  27754. */
  27755. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  27756. /**
  27757. * Set the value of an uniform to a vec3
  27758. * @param uniform defines the webGL uniform location where to store the value
  27759. * @param x defines the 1st component of the value
  27760. * @param y defines the 2nd component of the value
  27761. * @param z defines the 3rd component of the value
  27762. */
  27763. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  27764. /**
  27765. * Set the value of an uniform to a boolean
  27766. * @param uniform defines the webGL uniform location where to store the value
  27767. * @param bool defines the boolean to store
  27768. */
  27769. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  27770. /**
  27771. * Set the value of an uniform to a vec4
  27772. * @param uniform defines the webGL uniform location where to store the value
  27773. * @param x defines the 1st component of the value
  27774. * @param y defines the 2nd component of the value
  27775. * @param z defines the 3rd component of the value
  27776. * @param w defines the 4th component of the value
  27777. */
  27778. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  27779. /**
  27780. * Set the value of an uniform to a Color3
  27781. * @param uniform defines the webGL uniform location where to store the value
  27782. * @param color3 defines the color to store
  27783. */
  27784. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  27785. /**
  27786. * Set the value of an uniform to a Color3 and an alpha value
  27787. * @param uniform defines the webGL uniform location where to store the value
  27788. * @param color3 defines the color to store
  27789. * @param alpha defines the alpha component to store
  27790. */
  27791. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  27792. /**
  27793. * Sets a Color4 on a uniform variable
  27794. * @param uniform defines the uniform location
  27795. * @param color4 defines the value to be set
  27796. */
  27797. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  27798. /**
  27799. * Set various states to the webGL context
  27800. * @param culling defines backface culling state
  27801. * @param zOffset defines the value to apply to zOffset (0 by default)
  27802. * @param force defines if states must be applied even if cache is up to date
  27803. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  27804. */
  27805. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  27806. /**
  27807. * Set the z offset to apply to current rendering
  27808. * @param value defines the offset to apply
  27809. */
  27810. setZOffset(value: number): void;
  27811. /**
  27812. * Gets the current value of the zOffset
  27813. * @returns the current zOffset state
  27814. */
  27815. getZOffset(): number;
  27816. /**
  27817. * Enable or disable depth buffering
  27818. * @param enable defines the state to set
  27819. */
  27820. setDepthBuffer(enable: boolean): void;
  27821. /**
  27822. * Gets a boolean indicating if depth writing is enabled
  27823. * @returns the current depth writing state
  27824. */
  27825. getDepthWrite(): boolean;
  27826. /**
  27827. * Enable or disable depth writing
  27828. * @param enable defines the state to set
  27829. */
  27830. setDepthWrite(enable: boolean): void;
  27831. /**
  27832. * Enable or disable color writing
  27833. * @param enable defines the state to set
  27834. */
  27835. setColorWrite(enable: boolean): void;
  27836. /**
  27837. * Gets a boolean indicating if color writing is enabled
  27838. * @returns the current color writing state
  27839. */
  27840. getColorWrite(): boolean;
  27841. /**
  27842. * Sets alpha constants used by some alpha blending modes
  27843. * @param r defines the red component
  27844. * @param g defines the green component
  27845. * @param b defines the blue component
  27846. * @param a defines the alpha component
  27847. */
  27848. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  27849. /**
  27850. * Sets the current alpha mode
  27851. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  27852. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  27853. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27854. */
  27855. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  27856. /**
  27857. * Gets the current alpha mode
  27858. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  27859. * @returns the current alpha mode
  27860. */
  27861. getAlphaMode(): number;
  27862. /**
  27863. * Clears the list of texture accessible through engine.
  27864. * This can help preventing texture load conflict due to name collision.
  27865. */
  27866. clearInternalTexturesCache(): void;
  27867. /**
  27868. * Force the entire cache to be cleared
  27869. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  27870. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  27871. */
  27872. wipeCaches(bruteForce?: boolean): void;
  27873. /**
  27874. * Set the compressed texture format to use, based on the formats you have, and the formats
  27875. * supported by the hardware / browser.
  27876. *
  27877. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  27878. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  27879. * to API arguments needed to compressed textures. This puts the burden on the container
  27880. * generator to house the arcane code for determining these for current & future formats.
  27881. *
  27882. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  27883. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  27884. *
  27885. * Note: The result of this call is not taken into account when a texture is base64.
  27886. *
  27887. * @param formatsAvailable defines the list of those format families you have created
  27888. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  27889. *
  27890. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  27891. * @returns The extension selected.
  27892. */
  27893. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  27894. private _getSamplingParameters;
  27895. private _partialLoadImg;
  27896. private _cascadeLoadImgs;
  27897. /** @hidden */ createTexture(): WebGLTexture;
  27898. /**
  27899. * Usually called from Texture.ts.
  27900. * Passed information to create a WebGLTexture
  27901. * @param urlArg defines a value which contains one of the following:
  27902. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  27903. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  27904. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  27905. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  27906. * @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)
  27907. * @param scene needed for loading to the correct scene
  27908. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  27909. * @param onLoad optional callback to be called upon successful completion
  27910. * @param onError optional callback to be called upon failure
  27911. * @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
  27912. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  27913. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  27914. * @param forcedExtension defines the extension to use to pick the right loader
  27915. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  27916. * @returns a InternalTexture for assignment back into BABYLON.Texture
  27917. */
  27918. 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;
  27919. private _rescaleTexture;
  27920. /**
  27921. * Update a raw texture
  27922. * @param texture defines the texture to update
  27923. * @param data defines the data to store in the texture
  27924. * @param format defines the format of the data
  27925. * @param invertY defines if data must be stored with Y axis inverted
  27926. * @param compression defines the compression used (null by default)
  27927. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27928. */
  27929. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  27930. /**
  27931. * Creates a raw texture
  27932. * @param data defines the data to store in the texture
  27933. * @param width defines the width of the texture
  27934. * @param height defines the height of the texture
  27935. * @param format defines the format of the data
  27936. * @param generateMipMaps defines if the engine should generate the mip levels
  27937. * @param invertY defines if data must be stored with Y axis inverted
  27938. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27939. * @param compression defines the compression used (null by default)
  27940. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  27941. * @returns the raw texture inside an InternalTexture
  27942. */
  27943. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  27944. private _unpackFlipYCached;
  27945. /**
  27946. * In case you are sharing the context with other applications, it might
  27947. * be interested to not cache the unpack flip y state to ensure a consistent
  27948. * value would be set.
  27949. */
  27950. enableUnpackFlipYCached: boolean;
  27951. /** @hidden */ unpackFlipY(value: boolean): void;
  27952. /** @hidden */ getUnpackAlignement(): number;
  27953. /**
  27954. * Creates a dynamic texture
  27955. * @param width defines the width of the texture
  27956. * @param height defines the height of the texture
  27957. * @param generateMipMaps defines if the engine should generate the mip levels
  27958. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  27959. * @returns the dynamic texture inside an InternalTexture
  27960. */
  27961. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  27962. /**
  27963. * Update the sampling mode of a given texture
  27964. * @param samplingMode defines the required sampling mode
  27965. * @param texture defines the texture to update
  27966. */
  27967. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  27968. /**
  27969. * Update the content of a dynamic texture
  27970. * @param texture defines the texture to update
  27971. * @param canvas defines the canvas containing the source
  27972. * @param invertY defines if data must be stored with Y axis inverted
  27973. * @param premulAlpha defines if alpha is stored as premultiplied
  27974. * @param format defines the format of the data
  27975. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  27976. */
  27977. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  27978. /**
  27979. * Update a video texture
  27980. * @param texture defines the texture to update
  27981. * @param video defines the video element to use
  27982. * @param invertY defines if data must be stored with Y axis inverted
  27983. */
  27984. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  27985. /**
  27986. * Updates a depth texture Comparison Mode and Function.
  27987. * If the comparison Function is equal to 0, the mode will be set to none.
  27988. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  27989. * @param texture The texture to set the comparison function for
  27990. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  27991. */
  27992. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  27993. private _setupDepthStencilTexture;
  27994. /**
  27995. * Creates a depth stencil texture.
  27996. * This is only available in WebGL 2 or with the depth texture extension available.
  27997. * @param size The size of face edge in the texture.
  27998. * @param options The options defining the texture.
  27999. * @returns The texture
  28000. */
  28001. createDepthStencilTexture(size: number | {
  28002. width: number;
  28003. height: number;
  28004. }, options: DepthTextureCreationOptions): InternalTexture;
  28005. /**
  28006. * Creates a depth stencil texture.
  28007. * This is only available in WebGL 2 or with the depth texture extension available.
  28008. * @param size The size of face edge in the texture.
  28009. * @param options The options defining the texture.
  28010. * @returns The texture
  28011. */
  28012. private _createDepthStencilTexture;
  28013. /**
  28014. * Creates a depth stencil cube texture.
  28015. * This is only available in WebGL 2.
  28016. * @param size The size of face edge in the cube texture.
  28017. * @param options The options defining the cube texture.
  28018. * @returns The cube texture
  28019. */
  28020. private _createDepthStencilCubeTexture;
  28021. /**
  28022. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28023. * @param renderTarget The render target to set the frame buffer for
  28024. */
  28025. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28026. /**
  28027. * Creates a new render target texture
  28028. * @param size defines the size of the texture
  28029. * @param options defines the options used to create the texture
  28030. * @returns a new render target texture stored in an InternalTexture
  28031. */
  28032. createRenderTargetTexture(size: number | {
  28033. width: number;
  28034. height: number;
  28035. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28036. /**
  28037. * Create a multi render target texture
  28038. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  28039. * @param size defines the size of the texture
  28040. * @param options defines the creation options
  28041. * @returns the cube texture as an InternalTexture
  28042. */
  28043. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  28044. private _setupFramebufferDepthAttachments;
  28045. /**
  28046. * Updates the sample count of a render target texture
  28047. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28048. * @param texture defines the texture to update
  28049. * @param samples defines the sample count to set
  28050. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28051. */
  28052. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28053. /**
  28054. * Update the sample count for a given multiple render target texture
  28055. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28056. * @param textures defines the textures to update
  28057. * @param samples defines the sample count to set
  28058. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28059. */
  28060. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  28061. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28062. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28063. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28064. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28065. /**
  28066. * Creates a new render target cube texture
  28067. * @param size defines the size of the texture
  28068. * @param options defines the options used to create the texture
  28069. * @returns a new render target cube texture stored in an InternalTexture
  28070. */
  28071. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  28072. /**
  28073. * Creates a cube texture
  28074. * @param rootUrl defines the url where the files to load is located
  28075. * @param scene defines the current scene
  28076. * @param files defines the list of files to load (1 per face)
  28077. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  28078. * @param onLoad defines an optional callback raised when the texture is loaded
  28079. * @param onError defines an optional callback raised if there is an issue to load the texture
  28080. * @param format defines the format of the data
  28081. * @param forcedExtension defines the extension to use to pick the right loader
  28082. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  28083. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  28084. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  28085. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  28086. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  28087. * @returns the cube texture as an InternalTexture
  28088. */
  28089. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number, fallback?: Nullable<InternalTexture>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  28090. /**
  28091. * @hidden
  28092. */ setCubeMapTextureParams(loadMipmap: boolean): void;
  28093. /**
  28094. * Update a raw cube texture
  28095. * @param texture defines the texture to udpdate
  28096. * @param data defines the data to store
  28097. * @param format defines the data format
  28098. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  28099. * @param invertY defines if data must be stored with Y axis inverted
  28100. * @param compression defines the compression used (null by default)
  28101. * @param level defines which level of the texture to update
  28102. */
  28103. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  28104. /**
  28105. * Creates a new raw cube texture
  28106. * @param data defines the array of data to use to create each face
  28107. * @param size defines the size of the textures
  28108. * @param format defines the format of the data
  28109. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28110. * @param generateMipMaps defines if the engine should generate the mip levels
  28111. * @param invertY defines if data must be stored with Y axis inverted
  28112. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28113. * @param compression defines the compression used (null by default)
  28114. * @returns the cube texture as an InternalTexture
  28115. */
  28116. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  28117. /**
  28118. * Creates a new raw cube texture from a specified url
  28119. * @param url defines the url where the data is located
  28120. * @param scene defines the current scene
  28121. * @param size defines the size of the textures
  28122. * @param format defines the format of the data
  28123. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  28124. * @param noMipmap defines if the engine should avoid generating the mip levels
  28125. * @param callback defines a callback used to extract texture data from loaded data
  28126. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  28127. * @param onLoad defines a callback called when texture is loaded
  28128. * @param onError defines a callback called if there is an error
  28129. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28130. * @param invertY defines if data must be stored with Y axis inverted
  28131. * @returns the cube texture as an InternalTexture
  28132. */
  28133. 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;
  28134. /**
  28135. * Update a raw 3D texture
  28136. * @param texture defines the texture to update
  28137. * @param data defines the data to store
  28138. * @param format defines the data format
  28139. * @param invertY defines if data must be stored with Y axis inverted
  28140. * @param compression defines the used compression (can be null)
  28141. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  28142. */
  28143. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  28144. /**
  28145. * Creates a new raw 3D texture
  28146. * @param data defines the data used to create the texture
  28147. * @param width defines the width of the texture
  28148. * @param height defines the height of the texture
  28149. * @param depth defines the depth of the texture
  28150. * @param format defines the format of the texture
  28151. * @param generateMipMaps defines if the engine must generate mip levels
  28152. * @param invertY defines if data must be stored with Y axis inverted
  28153. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  28154. * @param compression defines the compressed used (can be null)
  28155. * @param textureType defines the compressed used (can be null)
  28156. * @returns a new raw 3D texture (stored in an InternalTexture)
  28157. */
  28158. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  28159. private _prepareWebGLTextureContinuation;
  28160. private _prepareWebGLTexture;
  28161. private _convertRGBtoRGBATextureData;
  28162. /** @hidden */ releaseFramebufferObjects(texture: InternalTexture): void;
  28163. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  28164. private setProgram;
  28165. private _boundUniforms;
  28166. /**
  28167. * Binds an effect to the webGL context
  28168. * @param effect defines the effect to bind
  28169. */
  28170. bindSamplers(effect: Effect): void;
  28171. private _moveBoundTextureOnTop;
  28172. private _getCorrectTextureChannel;
  28173. private _linkTrackers;
  28174. private _removeDesignatedSlot;
  28175. private _activateCurrentTexture;
  28176. /** @hidden */ bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28177. /** @hidden */ bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28178. /**
  28179. * Sets a texture to the webGL context from a postprocess
  28180. * @param channel defines the channel to use
  28181. * @param postProcess defines the source postprocess
  28182. */
  28183. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28184. /**
  28185. * Binds the output of the passed in post process to the texture channel specified
  28186. * @param channel The channel the texture should be bound to
  28187. * @param postProcess The post process which's output should be bound
  28188. */
  28189. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28190. /**
  28191. * Unbind all textures from the webGL context
  28192. */
  28193. unbindAllTextures(): void;
  28194. /**
  28195. * Sets a texture to the according uniform.
  28196. * @param channel The texture channel
  28197. * @param uniform The uniform to set
  28198. * @param texture The texture to apply
  28199. */
  28200. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28201. /**
  28202. * Sets a depth stencil texture from a render target to the according uniform.
  28203. * @param channel The texture channel
  28204. * @param uniform The uniform to set
  28205. * @param texture The render target texture containing the depth stencil texture to apply
  28206. */
  28207. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28208. private _bindSamplerUniformToChannel;
  28209. private _getTextureWrapMode;
  28210. private _setTexture;
  28211. /**
  28212. * Sets an array of texture to the webGL context
  28213. * @param channel defines the channel where the texture array must be set
  28214. * @param uniform defines the associated uniform location
  28215. * @param textures defines the array of textures to bind
  28216. */
  28217. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28218. /** @hidden */ setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28219. private _setTextureParameterFloat;
  28220. private _setTextureParameterInteger;
  28221. /**
  28222. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28223. * @param x defines the x coordinate of the rectangle where pixels must be read
  28224. * @param y defines the y coordinate of the rectangle where pixels must be read
  28225. * @param width defines the width of the rectangle where pixels must be read
  28226. * @param height defines the height of the rectangle where pixels must be read
  28227. * @returns a Uint8Array containing RGBA colors
  28228. */
  28229. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28230. /**
  28231. * Add an externaly attached data from its key.
  28232. * This method call will fail and return false, if such key already exists.
  28233. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28234. * @param key the unique key that identifies the data
  28235. * @param data the data object to associate to the key for this Engine instance
  28236. * @return true if no such key were already present and the data was added successfully, false otherwise
  28237. */
  28238. addExternalData<T>(key: string, data: T): boolean;
  28239. /**
  28240. * Get an externaly attached data from its key
  28241. * @param key the unique key that identifies the data
  28242. * @return the associated data, if present (can be null), or undefined if not present
  28243. */
  28244. getExternalData<T>(key: string): T;
  28245. /**
  28246. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28247. * @param key the unique key that identifies the data
  28248. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28249. * @return the associated data, can be null if the factory returned null.
  28250. */
  28251. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28252. /**
  28253. * Remove an externaly attached data from the Engine instance
  28254. * @param key the unique key that identifies the data
  28255. * @return true if the data was successfully removed, false if it doesn't exist
  28256. */
  28257. removeExternalData(key: string): boolean;
  28258. /**
  28259. * Unbind all vertex attributes from the webGL context
  28260. */
  28261. unbindAllAttributes(): void;
  28262. /**
  28263. * 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
  28264. */
  28265. releaseEffects(): void;
  28266. /**
  28267. * Dispose and release all associated resources
  28268. */
  28269. dispose(): void;
  28270. /**
  28271. * Display the loading screen
  28272. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28273. */
  28274. displayLoadingUI(): void;
  28275. /**
  28276. * Hide the loading screen
  28277. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28278. */
  28279. hideLoadingUI(): void;
  28280. /**
  28281. * Gets the current loading screen object
  28282. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28283. */
  28284. /**
  28285. * Sets the current loading screen object
  28286. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28287. */
  28288. loadingScreen: ILoadingScreen;
  28289. /**
  28290. * Sets the current loading screen text
  28291. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28292. */
  28293. loadingUIText: string;
  28294. /**
  28295. * Sets the current loading screen background color
  28296. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28297. */
  28298. loadingUIBackgroundColor: string;
  28299. /**
  28300. * Attach a new callback raised when context lost event is fired
  28301. * @param callback defines the callback to call
  28302. */
  28303. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28304. /**
  28305. * Attach a new callback raised when context restored event is fired
  28306. * @param callback defines the callback to call
  28307. */
  28308. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28309. /**
  28310. * Gets the source code of the vertex shader associated with a specific webGL program
  28311. * @param program defines the program to use
  28312. * @returns a string containing the source code of the vertex shader associated with the program
  28313. */
  28314. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28315. /**
  28316. * Gets the source code of the fragment shader associated with a specific webGL program
  28317. * @param program defines the program to use
  28318. * @returns a string containing the source code of the fragment shader associated with the program
  28319. */
  28320. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28321. /**
  28322. * Get the current error code of the webGL context
  28323. * @returns the error code
  28324. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28325. */
  28326. getError(): number;
  28327. /**
  28328. * Gets the current framerate
  28329. * @returns a number representing the framerate
  28330. */
  28331. getFps(): number;
  28332. /**
  28333. * Gets the time spent between current and previous frame
  28334. * @returns a number representing the delta time in ms
  28335. */
  28336. getDeltaTime(): number;
  28337. private _measureFps;
  28338. /** @hidden */ readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28339. private _canRenderToFloatFramebuffer;
  28340. private _canRenderToHalfFloatFramebuffer;
  28341. private _canRenderToFramebuffer;
  28342. /** @hidden */ getWebGLTextureType(type: number): number;
  28343. private _getInternalFormat;
  28344. /** @hidden */ getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28345. /** @hidden */ getRGBAMultiSampleBufferFormat(type: number): number;
  28346. /** @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;
  28347. /** @hidden */ loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28348. private _partialLoadFile;
  28349. private _cascadeLoadFiles;
  28350. /**
  28351. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28352. * @returns true if the engine can be created
  28353. * @ignorenaming
  28354. */
  28355. static isSupported(): boolean;
  28356. }
  28357. }
  28358. declare module BABYLON {
  28359. /**
  28360. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28361. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28362. */
  28363. export class EffectFallbacks {
  28364. private _defines;
  28365. private _currentRank;
  28366. private _maxRank;
  28367. private _mesh;
  28368. /**
  28369. * Removes the fallback from the bound mesh.
  28370. */
  28371. unBindMesh(): void;
  28372. /**
  28373. * Adds a fallback on the specified property.
  28374. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28375. * @param define The name of the define in the shader
  28376. */
  28377. addFallback(rank: number, define: string): void;
  28378. /**
  28379. * Sets the mesh to use CPU skinning when needing to fallback.
  28380. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28381. * @param mesh The mesh to use the fallbacks.
  28382. */
  28383. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28384. /**
  28385. * Checks to see if more fallbacks are still availible.
  28386. */
  28387. readonly isMoreFallbacks: boolean;
  28388. /**
  28389. * Removes the defines that shoould be removed when falling back.
  28390. * @param currentDefines defines the current define statements for the shader.
  28391. * @param effect defines the current effect we try to compile
  28392. * @returns The resulting defines with defines of the current rank removed.
  28393. */
  28394. reduce(currentDefines: string, effect: Effect): string;
  28395. }
  28396. /**
  28397. * Options to be used when creating an effect.
  28398. */
  28399. export class EffectCreationOptions {
  28400. /**
  28401. * Atrributes that will be used in the shader.
  28402. */
  28403. attributes: string[];
  28404. /**
  28405. * Uniform varible names that will be set in the shader.
  28406. */
  28407. uniformsNames: string[];
  28408. /**
  28409. * Uniform buffer varible names that will be set in the shader.
  28410. */
  28411. uniformBuffersNames: string[];
  28412. /**
  28413. * Sampler texture variable names that will be set in the shader.
  28414. */
  28415. samplers: string[];
  28416. /**
  28417. * Define statements that will be set in the shader.
  28418. */
  28419. defines: any;
  28420. /**
  28421. * Possible fallbacks for this effect to improve performance when needed.
  28422. */
  28423. fallbacks: Nullable<EffectFallbacks>;
  28424. /**
  28425. * Callback that will be called when the shader is compiled.
  28426. */
  28427. onCompiled: Nullable<(effect: Effect) => void>;
  28428. /**
  28429. * Callback that will be called if an error occurs during shader compilation.
  28430. */
  28431. onError: Nullable<(effect: Effect, errors: string) => void>;
  28432. /**
  28433. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28434. */
  28435. indexParameters: any;
  28436. /**
  28437. * Max number of lights that can be used in the shader.
  28438. */
  28439. maxSimultaneousLights: number;
  28440. /**
  28441. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28442. */
  28443. transformFeedbackVaryings: Nullable<string[]>;
  28444. }
  28445. /**
  28446. * Effect containing vertex and fragment shader that can be executed on an object.
  28447. */
  28448. export class Effect {
  28449. /**
  28450. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28451. */
  28452. static ShadersRepository: string;
  28453. /**
  28454. * Name of the effect.
  28455. */
  28456. name: any;
  28457. /**
  28458. * String container all the define statements that should be set on the shader.
  28459. */
  28460. defines: string;
  28461. /**
  28462. * Callback that will be called when the shader is compiled.
  28463. */
  28464. onCompiled: Nullable<(effect: Effect) => void>;
  28465. /**
  28466. * Callback that will be called if an error occurs during shader compilation.
  28467. */
  28468. onError: Nullable<(effect: Effect, errors: string) => void>;
  28469. /**
  28470. * Callback that will be called when effect is bound.
  28471. */
  28472. onBind: Nullable<(effect: Effect) => void>;
  28473. /**
  28474. * Unique ID of the effect.
  28475. */
  28476. uniqueId: number;
  28477. /**
  28478. * Observable that will be called when the shader is compiled.
  28479. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28480. */
  28481. onCompileObservable: Observable<Effect>;
  28482. /**
  28483. * Observable that will be called if an error occurs during shader compilation.
  28484. */
  28485. onErrorObservable: Observable<Effect>;
  28486. /** @hidden */ onBindObservable: Nullable<Observable<Effect>>;
  28487. /**
  28488. * Observable that will be called when effect is bound.
  28489. */
  28490. readonly onBindObservable: Observable<Effect>;
  28491. /** @hidden */ bonesComputationForcedToCPU: boolean;
  28492. private static _uniqueIdSeed;
  28493. private _engine;
  28494. private _uniformBuffersNames;
  28495. private _uniformsNames;
  28496. private _samplers;
  28497. private _isReady;
  28498. private _compilationError;
  28499. private _attributesNames;
  28500. private _attributes;
  28501. private _uniforms;
  28502. /**
  28503. * Key for the effect.
  28504. * @hidden
  28505. */ key: string;
  28506. private _indexParameters;
  28507. private _fallbacks;
  28508. private _vertexSourceCode;
  28509. private _fragmentSourceCode;
  28510. private _vertexSourceCodeOverride;
  28511. private _fragmentSourceCodeOverride;
  28512. private _transformFeedbackVaryings;
  28513. /**
  28514. * Compiled shader to webGL program.
  28515. * @hidden
  28516. */ program: WebGLProgram;
  28517. private _valueCache;
  28518. private static _baseCache;
  28519. /**
  28520. * Instantiates an effect.
  28521. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28522. * @param baseName Name of the effect.
  28523. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28524. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28525. * @param samplers List of sampler variables that will be passed to the shader.
  28526. * @param engine Engine to be used to render the effect
  28527. * @param defines Define statements to be added to the shader.
  28528. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28529. * @param onCompiled Callback that will be called when the shader is compiled.
  28530. * @param onError Callback that will be called if an error occurs during shader compilation.
  28531. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28532. */
  28533. 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);
  28534. /**
  28535. * Unique key for this effect
  28536. */
  28537. readonly key: string;
  28538. /**
  28539. * If the effect has been compiled and prepared.
  28540. * @returns if the effect is compiled and prepared.
  28541. */
  28542. isReady(): boolean;
  28543. /**
  28544. * The engine the effect was initialized with.
  28545. * @returns the engine.
  28546. */
  28547. getEngine(): Engine;
  28548. /**
  28549. * The compiled webGL program for the effect
  28550. * @returns the webGL program.
  28551. */
  28552. getProgram(): WebGLProgram;
  28553. /**
  28554. * The set of names of attribute variables for the shader.
  28555. * @returns An array of attribute names.
  28556. */
  28557. getAttributesNames(): string[];
  28558. /**
  28559. * Returns the attribute at the given index.
  28560. * @param index The index of the attribute.
  28561. * @returns The location of the attribute.
  28562. */
  28563. getAttributeLocation(index: number): number;
  28564. /**
  28565. * Returns the attribute based on the name of the variable.
  28566. * @param name of the attribute to look up.
  28567. * @returns the attribute location.
  28568. */
  28569. getAttributeLocationByName(name: string): number;
  28570. /**
  28571. * The number of attributes.
  28572. * @returns the numnber of attributes.
  28573. */
  28574. getAttributesCount(): number;
  28575. /**
  28576. * Gets the index of a uniform variable.
  28577. * @param uniformName of the uniform to look up.
  28578. * @returns the index.
  28579. */
  28580. getUniformIndex(uniformName: string): number;
  28581. /**
  28582. * Returns the attribute based on the name of the variable.
  28583. * @param uniformName of the uniform to look up.
  28584. * @returns the location of the uniform.
  28585. */
  28586. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28587. /**
  28588. * Returns an array of sampler variable names
  28589. * @returns The array of sampler variable neames.
  28590. */
  28591. getSamplers(): string[];
  28592. /**
  28593. * The error from the last compilation.
  28594. * @returns the error string.
  28595. */
  28596. getCompilationError(): string;
  28597. /**
  28598. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28599. * @param func The callback to be used.
  28600. */
  28601. executeWhenCompiled(func: (effect: Effect) => void): void;
  28602. private _checkIsReady;
  28603. /** @hidden */ loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28604. /** @hidden */ loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28605. /** @hidden */ dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28606. private _processShaderConversion;
  28607. private _processIncludes;
  28608. private _processPrecision;
  28609. /**
  28610. * Recompiles the webGL program
  28611. * @param vertexSourceCode The source code for the vertex shader.
  28612. * @param fragmentSourceCode The source code for the fragment shader.
  28613. * @param onCompiled Callback called when completed.
  28614. * @param onError Callback called on error.
  28615. * @hidden
  28616. */ rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  28617. /**
  28618. * Gets the uniform locations of the the specified variable names
  28619. * @param names THe names of the variables to lookup.
  28620. * @returns Array of locations in the same order as variable names.
  28621. */
  28622. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  28623. /**
  28624. * Prepares the effect
  28625. * @hidden
  28626. */ prepareEffect(): void;
  28627. /**
  28628. * Checks if the effect is supported. (Must be called after compilation)
  28629. */
  28630. readonly isSupported: boolean;
  28631. /**
  28632. * Binds a texture to the engine to be used as output of the shader.
  28633. * @param channel Name of the output variable.
  28634. * @param texture Texture to bind.
  28635. * @hidden
  28636. */ bindTexture(channel: string, texture: InternalTexture): void;
  28637. /**
  28638. * Sets a texture on the engine to be used in the shader.
  28639. * @param channel Name of the sampler variable.
  28640. * @param texture Texture to set.
  28641. */
  28642. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28643. /**
  28644. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28645. * @param channel Name of the sampler variable.
  28646. * @param texture Texture to set.
  28647. */
  28648. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28649. /**
  28650. * Sets an array of textures on the engine to be used in the shader.
  28651. * @param channel Name of the variable.
  28652. * @param textures Textures to set.
  28653. */
  28654. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28655. /**
  28656. * 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)
  28657. * @param channel Name of the sampler variable.
  28658. * @param postProcess Post process to get the input texture from.
  28659. */
  28660. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28661. /**
  28662. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28663. * 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)
  28664. * @param channel Name of the sampler variable.
  28665. * @param postProcess Post process to get the output texture from.
  28666. */
  28667. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28668. /** @hidden */ cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28669. /** @hidden */ cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28670. /** @hidden */ cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28671. /** @hidden */ cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28672. /**
  28673. * Binds a buffer to a uniform.
  28674. * @param buffer Buffer to bind.
  28675. * @param name Name of the uniform variable to bind to.
  28676. */
  28677. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  28678. /**
  28679. * Binds block to a uniform.
  28680. * @param blockName Name of the block to bind.
  28681. * @param index Index to bind.
  28682. */
  28683. bindUniformBlock(blockName: string, index: number): void;
  28684. /**
  28685. * Sets an interger value on a uniform variable.
  28686. * @param uniformName Name of the variable.
  28687. * @param value Value to be set.
  28688. * @returns this effect.
  28689. */
  28690. setInt(uniformName: string, value: number): Effect;
  28691. /**
  28692. * Sets an int array on a uniform variable.
  28693. * @param uniformName Name of the variable.
  28694. * @param array array to be set.
  28695. * @returns this effect.
  28696. */
  28697. setIntArray(uniformName: string, array: Int32Array): Effect;
  28698. /**
  28699. * 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)
  28700. * @param uniformName Name of the variable.
  28701. * @param array array to be set.
  28702. * @returns this effect.
  28703. */
  28704. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28705. /**
  28706. * 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)
  28707. * @param uniformName Name of the variable.
  28708. * @param array array to be set.
  28709. * @returns this effect.
  28710. */
  28711. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28712. /**
  28713. * 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)
  28714. * @param uniformName Name of the variable.
  28715. * @param array array to be set.
  28716. * @returns this effect.
  28717. */
  28718. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28719. /**
  28720. * Sets an float array on a uniform variable.
  28721. * @param uniformName Name of the variable.
  28722. * @param array array to be set.
  28723. * @returns this effect.
  28724. */
  28725. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28726. /**
  28727. * 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)
  28728. * @param uniformName Name of the variable.
  28729. * @param array array to be set.
  28730. * @returns this effect.
  28731. */
  28732. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28733. /**
  28734. * 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)
  28735. * @param uniformName Name of the variable.
  28736. * @param array array to be set.
  28737. * @returns this effect.
  28738. */
  28739. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28740. /**
  28741. * 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)
  28742. * @param uniformName Name of the variable.
  28743. * @param array array to be set.
  28744. * @returns this effect.
  28745. */
  28746. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28747. /**
  28748. * Sets an array on a uniform variable.
  28749. * @param uniformName Name of the variable.
  28750. * @param array array to be set.
  28751. * @returns this effect.
  28752. */
  28753. setArray(uniformName: string, array: number[]): Effect;
  28754. /**
  28755. * 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)
  28756. * @param uniformName Name of the variable.
  28757. * @param array array to be set.
  28758. * @returns this effect.
  28759. */
  28760. setArray2(uniformName: string, array: number[]): Effect;
  28761. /**
  28762. * 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)
  28763. * @param uniformName Name of the variable.
  28764. * @param array array to be set.
  28765. * @returns this effect.
  28766. */
  28767. setArray3(uniformName: string, array: number[]): Effect;
  28768. /**
  28769. * 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)
  28770. * @param uniformName Name of the variable.
  28771. * @param array array to be set.
  28772. * @returns this effect.
  28773. */
  28774. setArray4(uniformName: string, array: number[]): Effect;
  28775. /**
  28776. * Sets matrices on a uniform variable.
  28777. * @param uniformName Name of the variable.
  28778. * @param matrices matrices to be set.
  28779. * @returns this effect.
  28780. */
  28781. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28782. /**
  28783. * Sets matrix on a uniform variable.
  28784. * @param uniformName Name of the variable.
  28785. * @param matrix matrix to be set.
  28786. * @returns this effect.
  28787. */
  28788. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28789. /**
  28790. * 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)
  28791. * @param uniformName Name of the variable.
  28792. * @param matrix matrix to be set.
  28793. * @returns this effect.
  28794. */
  28795. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28796. /**
  28797. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28798. * @param uniformName Name of the variable.
  28799. * @param matrix matrix to be set.
  28800. * @returns this effect.
  28801. */
  28802. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28803. /**
  28804. * Sets a float on a uniform variable.
  28805. * @param uniformName Name of the variable.
  28806. * @param value value to be set.
  28807. * @returns this effect.
  28808. */
  28809. setFloat(uniformName: string, value: number): Effect;
  28810. /**
  28811. * Sets a boolean on a uniform variable.
  28812. * @param uniformName Name of the variable.
  28813. * @param bool value to be set.
  28814. * @returns this effect.
  28815. */
  28816. setBool(uniformName: string, bool: boolean): Effect;
  28817. /**
  28818. * Sets a Vector2 on a uniform variable.
  28819. * @param uniformName Name of the variable.
  28820. * @param vector2 vector2 to be set.
  28821. * @returns this effect.
  28822. */
  28823. setVector2(uniformName: string, vector2: Vector2): Effect;
  28824. /**
  28825. * Sets a float2 on a uniform variable.
  28826. * @param uniformName Name of the variable.
  28827. * @param x First float in float2.
  28828. * @param y Second float in float2.
  28829. * @returns this effect.
  28830. */
  28831. setFloat2(uniformName: string, x: number, y: number): Effect;
  28832. /**
  28833. * Sets a Vector3 on a uniform variable.
  28834. * @param uniformName Name of the variable.
  28835. * @param vector3 Value to be set.
  28836. * @returns this effect.
  28837. */
  28838. setVector3(uniformName: string, vector3: Vector3): Effect;
  28839. /**
  28840. * Sets a float3 on a uniform variable.
  28841. * @param uniformName Name of the variable.
  28842. * @param x First float in float3.
  28843. * @param y Second float in float3.
  28844. * @param z Third float in float3.
  28845. * @returns this effect.
  28846. */
  28847. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28848. /**
  28849. * Sets a Vector4 on a uniform variable.
  28850. * @param uniformName Name of the variable.
  28851. * @param vector4 Value to be set.
  28852. * @returns this effect.
  28853. */
  28854. setVector4(uniformName: string, vector4: Vector4): Effect;
  28855. /**
  28856. * Sets a float4 on a uniform variable.
  28857. * @param uniformName Name of the variable.
  28858. * @param x First float in float4.
  28859. * @param y Second float in float4.
  28860. * @param z Third float in float4.
  28861. * @param w Fourth float in float4.
  28862. * @returns this effect.
  28863. */
  28864. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28865. /**
  28866. * Sets a Color3 on a uniform variable.
  28867. * @param uniformName Name of the variable.
  28868. * @param color3 Value to be set.
  28869. * @returns this effect.
  28870. */
  28871. setColor3(uniformName: string, color3: Color3): Effect;
  28872. /**
  28873. * Sets a Color4 on a uniform variable.
  28874. * @param uniformName Name of the variable.
  28875. * @param color3 Value to be set.
  28876. * @param alpha Alpha value to be set.
  28877. * @returns this effect.
  28878. */
  28879. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28880. /**
  28881. * Sets a Color4 on a uniform variable
  28882. * @param uniformName defines the name of the variable
  28883. * @param color4 defines the value to be set
  28884. * @returns this effect.
  28885. */
  28886. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28887. /**
  28888. * This function will add a new shader to the shader store
  28889. * @param name the name of the shader
  28890. * @param pixelShader optional pixel shader content
  28891. * @param vertexShader optional vertex shader content
  28892. */
  28893. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28894. /**
  28895. * Store of each shader (The can be looked up using effect.key)
  28896. */
  28897. static ShadersStore: {
  28898. [key: string]: string;
  28899. };
  28900. /**
  28901. * Store of each included file for a shader (The can be looked up using effect.key)
  28902. */
  28903. static IncludesShadersStore: {
  28904. [key: string]: string;
  28905. };
  28906. /**
  28907. * Resets the cache of effects.
  28908. */
  28909. static ResetCache(): void;
  28910. }
  28911. }
  28912. declare module BABYLON {
  28913. /**
  28914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28916. * 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;
  28917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28918. */
  28919. export class ColorCurves {
  28920. private _dirty;
  28921. private _tempColor;
  28922. private _globalCurve;
  28923. private _highlightsCurve;
  28924. private _midtonesCurve;
  28925. private _shadowsCurve;
  28926. private _positiveCurve;
  28927. private _negativeCurve;
  28928. private _globalHue;
  28929. private _globalDensity;
  28930. private _globalSaturation;
  28931. private _globalExposure;
  28932. /**
  28933. * Gets the global Hue value.
  28934. * 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).
  28935. */
  28936. /**
  28937. * Sets the global Hue value.
  28938. * 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).
  28939. */
  28940. globalHue: number;
  28941. /**
  28942. * Gets the global Density value.
  28943. * 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.
  28944. * Values less than zero provide a filter of opposite hue.
  28945. */
  28946. /**
  28947. * Sets the global Density value.
  28948. * 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.
  28949. * Values less than zero provide a filter of opposite hue.
  28950. */
  28951. globalDensity: number;
  28952. /**
  28953. * Gets the global Saturation value.
  28954. * 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.
  28955. */
  28956. /**
  28957. * Sets the global Saturation value.
  28958. * 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.
  28959. */
  28960. globalSaturation: number;
  28961. /**
  28962. * Gets the global Exposure value.
  28963. * 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.
  28964. */
  28965. /**
  28966. * Sets the global Exposure value.
  28967. * 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.
  28968. */
  28969. globalExposure: number;
  28970. private _highlightsHue;
  28971. private _highlightsDensity;
  28972. private _highlightsSaturation;
  28973. private _highlightsExposure;
  28974. /**
  28975. * Gets the highlights Hue value.
  28976. * 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).
  28977. */
  28978. /**
  28979. * Sets the highlights Hue value.
  28980. * 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).
  28981. */
  28982. highlightsHue: number;
  28983. /**
  28984. * Gets the highlights Density value.
  28985. * 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.
  28986. * Values less than zero provide a filter of opposite hue.
  28987. */
  28988. /**
  28989. * Sets the highlights Density value.
  28990. * 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.
  28991. * Values less than zero provide a filter of opposite hue.
  28992. */
  28993. highlightsDensity: number;
  28994. /**
  28995. * Gets the highlights Saturation value.
  28996. * 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.
  28997. */
  28998. /**
  28999. * Sets the highlights Saturation value.
  29000. * 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.
  29001. */
  29002. highlightsSaturation: number;
  29003. /**
  29004. * Gets the highlights Exposure value.
  29005. * 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.
  29006. */
  29007. /**
  29008. * Sets the highlights Exposure value.
  29009. * 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.
  29010. */
  29011. highlightsExposure: number;
  29012. private _midtonesHue;
  29013. private _midtonesDensity;
  29014. private _midtonesSaturation;
  29015. private _midtonesExposure;
  29016. /**
  29017. * Gets the midtones Hue value.
  29018. * 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).
  29019. */
  29020. /**
  29021. * Sets the midtones Hue value.
  29022. * 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).
  29023. */
  29024. midtonesHue: number;
  29025. /**
  29026. * Gets the midtones Density value.
  29027. * 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.
  29028. * Values less than zero provide a filter of opposite hue.
  29029. */
  29030. /**
  29031. * Sets the midtones Density value.
  29032. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29033. * Values less than zero provide a filter of opposite hue.
  29034. */
  29035. midtonesDensity: number;
  29036. /**
  29037. * Gets the midtones Saturation value.
  29038. * 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.
  29039. */
  29040. /**
  29041. * Sets the midtones Saturation value.
  29042. * 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.
  29043. */
  29044. midtonesSaturation: number;
  29045. /**
  29046. * Gets the midtones Exposure value.
  29047. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29048. */
  29049. /**
  29050. * Sets the midtones Exposure value.
  29051. * 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.
  29052. */
  29053. midtonesExposure: number;
  29054. private _shadowsHue;
  29055. private _shadowsDensity;
  29056. private _shadowsSaturation;
  29057. private _shadowsExposure;
  29058. /**
  29059. * Gets the shadows Hue value.
  29060. * 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).
  29061. */
  29062. /**
  29063. * Sets the shadows Hue value.
  29064. * 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).
  29065. */
  29066. shadowsHue: number;
  29067. /**
  29068. * Gets the shadows Density value.
  29069. * 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.
  29070. * Values less than zero provide a filter of opposite hue.
  29071. */
  29072. /**
  29073. * Sets the shadows Density value.
  29074. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  29075. * Values less than zero provide a filter of opposite hue.
  29076. */
  29077. shadowsDensity: number;
  29078. /**
  29079. * Gets the shadows Saturation value.
  29080. * 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.
  29081. */
  29082. /**
  29083. * Sets the shadows Saturation value.
  29084. * 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.
  29085. */
  29086. shadowsSaturation: number;
  29087. /**
  29088. * Gets the shadows Exposure value.
  29089. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  29090. */
  29091. /**
  29092. * Sets the shadows Exposure value.
  29093. * 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.
  29094. */
  29095. shadowsExposure: number;
  29096. /**
  29097. * Returns the class name
  29098. * @returns The class name
  29099. */
  29100. getClassName(): string;
  29101. /**
  29102. * Binds the color curves to the shader.
  29103. * @param colorCurves The color curve to bind
  29104. * @param effect The effect to bind to
  29105. * @param positiveUniform The positive uniform shader parameter
  29106. * @param neutralUniform The neutral uniform shader parameter
  29107. * @param negativeUniform The negative uniform shader parameter
  29108. */
  29109. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29110. /**
  29111. * Prepare the list of uniforms associated with the ColorCurves effects.
  29112. * @param uniformsList The list of uniforms used in the effect
  29113. */
  29114. static PrepareUniforms(uniformsList: string[]): void;
  29115. /**
  29116. * Returns color grading data based on a hue, density, saturation and exposure value.
  29117. * @param filterHue The hue of the color filter.
  29118. * @param filterDensity The density of the color filter.
  29119. * @param saturation The saturation.
  29120. * @param exposure The exposure.
  29121. * @param result The result data container.
  29122. */
  29123. private getColorGradingDataToRef;
  29124. /**
  29125. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29126. * @param value The input slider value in range [-100,100].
  29127. * @returns Adjusted value.
  29128. */
  29129. private static applyColorGradingSliderNonlinear;
  29130. /**
  29131. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29132. * @param hue The hue (H) input.
  29133. * @param saturation The saturation (S) input.
  29134. * @param brightness The brightness (B) input.
  29135. * @result An RGBA color represented as Vector4.
  29136. */
  29137. private static fromHSBToRef;
  29138. /**
  29139. * Returns a value clamped between min and max
  29140. * @param value The value to clamp
  29141. * @param min The minimum of value
  29142. * @param max The maximum of value
  29143. * @returns The clamped value.
  29144. */
  29145. private static clamp;
  29146. /**
  29147. * Clones the current color curve instance.
  29148. * @return The cloned curves
  29149. */
  29150. clone(): ColorCurves;
  29151. /**
  29152. * Serializes the current color curve instance to a json representation.
  29153. * @return a JSON representation
  29154. */
  29155. serialize(): any;
  29156. /**
  29157. * Parses the color curve from a json representation.
  29158. * @param source the JSON source to parse
  29159. * @return The parsed curves
  29160. */
  29161. static Parse(source: any): ColorCurves;
  29162. }
  29163. }
  29164. declare module BABYLON {
  29165. /**
  29166. * Interface to follow in your material defines to integrate easily the
  29167. * Image proccessing functions.
  29168. * @hidden
  29169. */
  29170. export interface IImageProcessingConfigurationDefines {
  29171. IMAGEPROCESSING: boolean;
  29172. VIGNETTE: boolean;
  29173. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29174. VIGNETTEBLENDMODEOPAQUE: boolean;
  29175. TONEMAPPING: boolean;
  29176. TONEMAPPING_ACES: boolean;
  29177. CONTRAST: boolean;
  29178. EXPOSURE: boolean;
  29179. COLORCURVES: boolean;
  29180. COLORGRADING: boolean;
  29181. COLORGRADING3D: boolean;
  29182. SAMPLER3DGREENDEPTH: boolean;
  29183. SAMPLER3DBGRMAP: boolean;
  29184. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29185. }
  29186. /**
  29187. * @hidden
  29188. */
  29189. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29190. IMAGEPROCESSING: boolean;
  29191. VIGNETTE: boolean;
  29192. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29193. VIGNETTEBLENDMODEOPAQUE: boolean;
  29194. TONEMAPPING: boolean;
  29195. TONEMAPPING_ACES: boolean;
  29196. CONTRAST: boolean;
  29197. COLORCURVES: boolean;
  29198. COLORGRADING: boolean;
  29199. COLORGRADING3D: boolean;
  29200. SAMPLER3DGREENDEPTH: boolean;
  29201. SAMPLER3DBGRMAP: boolean;
  29202. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29203. EXPOSURE: boolean;
  29204. constructor();
  29205. }
  29206. /**
  29207. * This groups together the common properties used for image processing either in direct forward pass
  29208. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29209. * or not.
  29210. */
  29211. export class ImageProcessingConfiguration {
  29212. /**
  29213. * Default tone mapping applied in BabylonJS.
  29214. */
  29215. static readonly TONEMAPPING_STANDARD: number;
  29216. /**
  29217. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29218. * to other engines rendering to increase portability.
  29219. */
  29220. static readonly TONEMAPPING_ACES: number;
  29221. /**
  29222. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29223. */
  29224. colorCurves: Nullable<ColorCurves>;
  29225. private _colorCurvesEnabled;
  29226. /**
  29227. * Gets wether the color curves effect is enabled.
  29228. */
  29229. /**
  29230. * Sets wether the color curves effect is enabled.
  29231. */
  29232. colorCurvesEnabled: boolean;
  29233. private _colorGradingTexture;
  29234. /**
  29235. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29236. */
  29237. /**
  29238. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29239. */
  29240. colorGradingTexture: Nullable<BaseTexture>;
  29241. private _colorGradingEnabled;
  29242. /**
  29243. * Gets wether the color grading effect is enabled.
  29244. */
  29245. /**
  29246. * Sets wether the color grading effect is enabled.
  29247. */
  29248. colorGradingEnabled: boolean;
  29249. private _colorGradingWithGreenDepth;
  29250. /**
  29251. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29252. */
  29253. /**
  29254. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29255. */
  29256. colorGradingWithGreenDepth: boolean;
  29257. private _colorGradingBGR;
  29258. /**
  29259. * Gets wether the color grading texture contains BGR values.
  29260. */
  29261. /**
  29262. * Sets wether the color grading texture contains BGR values.
  29263. */
  29264. colorGradingBGR: boolean;
  29265. /** @hidden */ exposure: number;
  29266. /**
  29267. * Gets the Exposure used in the effect.
  29268. */
  29269. /**
  29270. * Sets the Exposure used in the effect.
  29271. */
  29272. exposure: number;
  29273. private _toneMappingEnabled;
  29274. /**
  29275. * Gets wether the tone mapping effect is enabled.
  29276. */
  29277. /**
  29278. * Sets wether the tone mapping effect is enabled.
  29279. */
  29280. toneMappingEnabled: boolean;
  29281. private _toneMappingType;
  29282. /**
  29283. * Gets the type of tone mapping effect.
  29284. */
  29285. /**
  29286. * Sets the type of tone mapping effect used in BabylonJS.
  29287. */
  29288. toneMappingType: number;
  29289. protected _contrast: number;
  29290. /**
  29291. * Gets the contrast used in the effect.
  29292. */
  29293. /**
  29294. * Sets the contrast used in the effect.
  29295. */
  29296. contrast: number;
  29297. /**
  29298. * Vignette stretch size.
  29299. */
  29300. vignetteStretch: number;
  29301. /**
  29302. * Vignette centre X Offset.
  29303. */
  29304. vignetteCentreX: number;
  29305. /**
  29306. * Vignette centre Y Offset.
  29307. */
  29308. vignetteCentreY: number;
  29309. /**
  29310. * Vignette weight or intensity of the vignette effect.
  29311. */
  29312. vignetteWeight: number;
  29313. /**
  29314. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29315. * if vignetteEnabled is set to true.
  29316. */
  29317. vignetteColor: Color4;
  29318. /**
  29319. * Camera field of view used by the Vignette effect.
  29320. */
  29321. vignetteCameraFov: number;
  29322. private _vignetteBlendMode;
  29323. /**
  29324. * Gets the vignette blend mode allowing different kind of effect.
  29325. */
  29326. /**
  29327. * Sets the vignette blend mode allowing different kind of effect.
  29328. */
  29329. vignetteBlendMode: number;
  29330. private _vignetteEnabled;
  29331. /**
  29332. * Gets wether the vignette effect is enabled.
  29333. */
  29334. /**
  29335. * Sets wether the vignette effect is enabled.
  29336. */
  29337. vignetteEnabled: boolean;
  29338. private _applyByPostProcess;
  29339. /**
  29340. * Gets wether the image processing is applied through a post process or not.
  29341. */
  29342. /**
  29343. * Sets wether the image processing is applied through a post process or not.
  29344. */
  29345. applyByPostProcess: boolean;
  29346. private _isEnabled;
  29347. /**
  29348. * Gets wether the image processing is enabled or not.
  29349. */
  29350. /**
  29351. * Sets wether the image processing is enabled or not.
  29352. */
  29353. isEnabled: boolean;
  29354. /**
  29355. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29356. */
  29357. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29358. /**
  29359. * Method called each time the image processing information changes requires to recompile the effect.
  29360. */
  29361. protected _updateParameters(): void;
  29362. /**
  29363. * Gets the current class name.
  29364. * @return "ImageProcessingConfiguration"
  29365. */
  29366. getClassName(): string;
  29367. /**
  29368. * Prepare the list of uniforms associated with the Image Processing effects.
  29369. * @param uniforms The list of uniforms used in the effect
  29370. * @param defines the list of defines currently in use
  29371. */
  29372. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29373. /**
  29374. * Prepare the list of samplers associated with the Image Processing effects.
  29375. * @param samplersList The list of uniforms used in the effect
  29376. * @param defines the list of defines currently in use
  29377. */
  29378. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29379. /**
  29380. * Prepare the list of defines associated to the shader.
  29381. * @param defines the list of defines to complete
  29382. * @param forPostProcess Define if we are currently in post process mode or not
  29383. */
  29384. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29385. /**
  29386. * Returns true if all the image processing information are ready.
  29387. * @returns True if ready, otherwise, false
  29388. */
  29389. isReady(): boolean;
  29390. /**
  29391. * Binds the image processing to the shader.
  29392. * @param effect The effect to bind to
  29393. * @param aspectRatio Define the current aspect ratio of the effect
  29394. */
  29395. bind(effect: Effect, aspectRatio?: number): void;
  29396. /**
  29397. * Clones the current image processing instance.
  29398. * @return The cloned image processing
  29399. */
  29400. clone(): ImageProcessingConfiguration;
  29401. /**
  29402. * Serializes the current image processing instance to a json representation.
  29403. * @return a JSON representation
  29404. */
  29405. serialize(): any;
  29406. /**
  29407. * Parses the image processing from a json representation.
  29408. * @param source the JSON source to parse
  29409. * @return The parsed image processing
  29410. */
  29411. static Parse(source: any): ImageProcessingConfiguration;
  29412. private static _VIGNETTEMODE_MULTIPLY;
  29413. private static _VIGNETTEMODE_OPAQUE;
  29414. /**
  29415. * Used to apply the vignette as a mix with the pixel color.
  29416. */
  29417. static readonly VIGNETTEMODE_MULTIPLY: number;
  29418. /**
  29419. * Used to apply the vignette as a replacement of the pixel color.
  29420. */
  29421. static readonly VIGNETTEMODE_OPAQUE: number;
  29422. }
  29423. }
  29424. declare module BABYLON {
  29425. /**
  29426. * This represents all the required information to add a fresnel effect on a material:
  29427. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29428. */
  29429. export class FresnelParameters {
  29430. private _isEnabled;
  29431. /**
  29432. * Define if the fresnel effect is enable or not.
  29433. */
  29434. isEnabled: boolean;
  29435. /**
  29436. * Define the color used on edges (grazing angle)
  29437. */
  29438. leftColor: Color3;
  29439. /**
  29440. * Define the color used on center
  29441. */
  29442. rightColor: Color3;
  29443. /**
  29444. * Define bias applied to computed fresnel term
  29445. */
  29446. bias: number;
  29447. /**
  29448. * Defined the power exponent applied to fresnel term
  29449. */
  29450. power: number;
  29451. /**
  29452. * Clones the current fresnel and its valuues
  29453. * @returns a clone fresnel configuration
  29454. */
  29455. clone(): FresnelParameters;
  29456. /**
  29457. * Serializes the current fresnel parameters to a JSON representation.
  29458. * @return the JSON serialization
  29459. */
  29460. serialize(): any;
  29461. /**
  29462. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29463. * @param parsedFresnelParameters Define the JSON representation
  29464. * @returns the parsed parameters
  29465. */
  29466. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29467. }
  29468. }
  29469. declare module BABYLON {
  29470. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29471. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29472. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29473. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29474. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29475. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29476. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29477. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29478. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29479. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29480. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29481. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29482. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29483. /**
  29484. * Decorator used to define property that can be serialized as reference to a camera
  29485. * @param sourceName defines the name of the property to decorate
  29486. */
  29487. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29488. /**
  29489. * Class used to help serialization objects
  29490. */
  29491. export class SerializationHelper {
  29492. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29493. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29494. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29495. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29496. /**
  29497. * Appends the serialized animations from the source animations
  29498. * @param source Source containing the animations
  29499. * @param destination Target to store the animations
  29500. */
  29501. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29502. /**
  29503. * Static function used to serialized a specific entity
  29504. * @param entity defines the entity to serialize
  29505. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29506. * @returns a JSON compatible object representing the serialization of the entity
  29507. */
  29508. static Serialize<T>(entity: T, serializationObject?: any): any;
  29509. /**
  29510. * Creates a new entity from a serialization data object
  29511. * @param creationFunction defines a function used to instanciated the new entity
  29512. * @param source defines the source serialization data
  29513. * @param scene defines the hosting scene
  29514. * @param rootUrl defines the root url for resources
  29515. * @returns a new entity
  29516. */
  29517. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29518. /**
  29519. * Clones an object
  29520. * @param creationFunction defines the function used to instanciate the new object
  29521. * @param source defines the source object
  29522. * @returns the cloned object
  29523. */
  29524. static Clone<T>(creationFunction: () => T, source: T): T;
  29525. /**
  29526. * Instanciates a new object based on a source one (some data will be shared between both object)
  29527. * @param creationFunction defines the function used to instanciate the new object
  29528. * @param source defines the source object
  29529. * @returns the new object
  29530. */
  29531. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29532. }
  29533. }
  29534. declare module BABYLON {
  29535. /**
  29536. * This is the base class of all the camera used in the application.
  29537. * @see http://doc.babylonjs.com/features/cameras
  29538. */
  29539. export class Camera extends Node {
  29540. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29541. /**
  29542. * This is the default projection mode used by the cameras.
  29543. * It helps recreating a feeling of perspective and better appreciate depth.
  29544. * This is the best way to simulate real life cameras.
  29545. */
  29546. static readonly PERSPECTIVE_CAMERA: number;
  29547. /**
  29548. * This helps creating camera with an orthographic mode.
  29549. * 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.
  29550. */
  29551. static readonly ORTHOGRAPHIC_CAMERA: number;
  29552. /**
  29553. * This is the default FOV mode for perspective cameras.
  29554. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29555. */
  29556. static readonly FOVMODE_VERTICAL_FIXED: number;
  29557. /**
  29558. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29559. */
  29560. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29561. /**
  29562. * This specifies ther is no need for a camera rig.
  29563. * Basically only one eye is rendered corresponding to the camera.
  29564. */
  29565. static readonly RIG_MODE_NONE: number;
  29566. /**
  29567. * Simulates a camera Rig with one blue eye and one red eye.
  29568. * This can be use with 3d blue and red glasses.
  29569. */
  29570. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29571. /**
  29572. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29573. */
  29574. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29575. /**
  29576. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29577. */
  29578. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29579. /**
  29580. * Defines that both eyes of the camera will be rendered over under each other.
  29581. */
  29582. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29583. /**
  29584. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29585. */
  29586. static readonly RIG_MODE_VR: number;
  29587. /**
  29588. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29589. */
  29590. static readonly RIG_MODE_WEBVR: number;
  29591. /**
  29592. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29593. */
  29594. static readonly RIG_MODE_CUSTOM: number;
  29595. /**
  29596. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29597. */
  29598. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29599. /**
  29600. * Define the input manager associated with the camera.
  29601. */
  29602. inputs: CameraInputsManager<Camera>;
  29603. /** @hidden */ position: Vector3;
  29604. /**
  29605. * Define the current local position of the camera in the scene
  29606. */
  29607. position: Vector3;
  29608. /**
  29609. * The vector the camera should consider as up.
  29610. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29611. */
  29612. upVector: Vector3;
  29613. /**
  29614. * Define the current limit on the left side for an orthographic camera
  29615. * In scene unit
  29616. */
  29617. orthoLeft: Nullable<number>;
  29618. /**
  29619. * Define the current limit on the right side for an orthographic camera
  29620. * In scene unit
  29621. */
  29622. orthoRight: Nullable<number>;
  29623. /**
  29624. * Define the current limit on the bottom side for an orthographic camera
  29625. * In scene unit
  29626. */
  29627. orthoBottom: Nullable<number>;
  29628. /**
  29629. * Define the current limit on the top side for an orthographic camera
  29630. * In scene unit
  29631. */
  29632. orthoTop: Nullable<number>;
  29633. /**
  29634. * Field Of View is set in Radians. (default is 0.8)
  29635. */
  29636. fov: number;
  29637. /**
  29638. * Define the minimum distance the camera can see from.
  29639. * This is important to note that the depth buffer are not infinite and the closer it starts
  29640. * the more your scene might encounter depth fighting issue.
  29641. */
  29642. minZ: number;
  29643. /**
  29644. * Define the maximum distance the camera can see to.
  29645. * This is important to note that the depth buffer are not infinite and the further it end
  29646. * the more your scene might encounter depth fighting issue.
  29647. */
  29648. maxZ: number;
  29649. /**
  29650. * Define the default inertia of the camera.
  29651. * This helps giving a smooth feeling to the camera movement.
  29652. */
  29653. inertia: number;
  29654. /**
  29655. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29656. */
  29657. mode: number;
  29658. /**
  29659. * Define wether the camera is intermediate.
  29660. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29661. */
  29662. isIntermediate: boolean;
  29663. /**
  29664. * Define the viewport of the camera.
  29665. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29666. */
  29667. viewport: Viewport;
  29668. /**
  29669. * Restricts the camera to viewing objects with the same layerMask.
  29670. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29671. */
  29672. layerMask: number;
  29673. /**
  29674. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29675. */
  29676. fovMode: number;
  29677. /**
  29678. * Rig mode of the camera.
  29679. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29680. * This is normally controlled byt the camera themselves as internal use.
  29681. */
  29682. cameraRigMode: number;
  29683. /**
  29684. * Defines the distance between both "eyes" in case of a RIG
  29685. */
  29686. interaxialDistance: number;
  29687. /**
  29688. * Defines if stereoscopic rendering is done side by side or over under.
  29689. */
  29690. isStereoscopicSideBySide: boolean;
  29691. /**
  29692. * 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
  29693. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29694. * else in the scene.
  29695. */
  29696. customRenderTargets: RenderTargetTexture[];
  29697. /**
  29698. * When set, the camera will render to this render target instead of the default canvas
  29699. */
  29700. outputRenderTarget: Nullable<RenderTargetTexture>;
  29701. /**
  29702. * Observable triggered when the camera view matrix has changed.
  29703. */
  29704. onViewMatrixChangedObservable: Observable<Camera>;
  29705. /**
  29706. * Observable triggered when the camera Projection matrix has changed.
  29707. */
  29708. onProjectionMatrixChangedObservable: Observable<Camera>;
  29709. /**
  29710. * Observable triggered when the inputs have been processed.
  29711. */
  29712. onAfterCheckInputsObservable: Observable<Camera>;
  29713. /**
  29714. * Observable triggered when reset has been called and applied to the camera.
  29715. */
  29716. onRestoreStateObservable: Observable<Camera>;
  29717. /** @hidden */ cameraRigParams: any;
  29718. /** @hidden */ rigCameras: Camera[];
  29719. /** @hidden */ rigPostProcess: Nullable<PostProcess>;
  29720. protected _webvrViewMatrix: Matrix;
  29721. /** @hidden */ skipRendering: boolean;
  29722. /** @hidden */ projectionMatrix: Matrix;
  29723. /** @hidden */ postProcesses: Nullable<PostProcess>[];
  29724. /** @hidden */ activeMeshes: SmartArray<AbstractMesh>;
  29725. protected _globalPosition: Vector3;
  29726. /** hidden */ computedViewMatrix: Matrix;
  29727. private _doNotComputeProjectionMatrix;
  29728. private _transformMatrix;
  29729. private _frustumPlanes;
  29730. private _refreshFrustumPlanes;
  29731. private _storedFov;
  29732. private _stateStored;
  29733. /**
  29734. * Instantiates a new camera object.
  29735. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29736. * @see http://doc.babylonjs.com/features/cameras
  29737. * @param name Defines the name of the camera in the scene
  29738. * @param position Defines the position of the camera
  29739. * @param scene Defines the scene the camera belongs too
  29740. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29741. */
  29742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29743. /**
  29744. * Store current camera state (fov, position, etc..)
  29745. * @returns the camera
  29746. */
  29747. storeState(): Camera;
  29748. /**
  29749. * Restores the camera state values if it has been stored. You must call storeState() first
  29750. */
  29751. protected _restoreStateValues(): boolean;
  29752. /**
  29753. * Restored camera state. You must call storeState() first.
  29754. * @returns true if restored and false otherwise
  29755. */
  29756. restoreState(): boolean;
  29757. /**
  29758. * Gets the class name of the camera.
  29759. * @returns the class name
  29760. */
  29761. getClassName(): string;
  29762. /** @hidden */ protected readonly _isCamera: boolean;
  29763. /**
  29764. * Gets a string representation of the camera useful for debug purpose.
  29765. * @param fullDetails Defines that a more verboe level of logging is required
  29766. * @returns the string representation
  29767. */
  29768. toString(fullDetails?: boolean): string;
  29769. /**
  29770. * Gets the current world space position of the camera.
  29771. */
  29772. readonly globalPosition: Vector3;
  29773. /**
  29774. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29775. * @returns the active meshe list
  29776. */
  29777. getActiveMeshes(): SmartArray<AbstractMesh>;
  29778. /**
  29779. * Check wether a mesh is part of the current active mesh list of the camera
  29780. * @param mesh Defines the mesh to check
  29781. * @returns true if active, false otherwise
  29782. */
  29783. isActiveMesh(mesh: Mesh): boolean;
  29784. /**
  29785. * Is this camera ready to be used/rendered
  29786. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29787. * @return true if the camera is ready
  29788. */
  29789. isReady(completeCheck?: boolean): boolean;
  29790. /** @hidden */ initCache(): void;
  29791. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  29792. /** @hidden */ isSynchronized(): boolean;
  29793. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  29794. /** @hidden */ isSynchronizedProjectionMatrix(): boolean;
  29795. /**
  29796. * Attach the input controls to a specific dom element to get the input from.
  29797. * @param element Defines the element the controls should be listened from
  29798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29799. */
  29800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29801. /**
  29802. * Detach the current controls from the specified dom element.
  29803. * @param element Defines the element to stop listening the inputs from
  29804. */
  29805. detachControl(element: HTMLElement): void;
  29806. /**
  29807. * Update the camera state according to the different inputs gathered during the frame.
  29808. */
  29809. update(): void;
  29810. /** @hidden */ checkInputs(): void;
  29811. /** @hidden */
  29812. readonly rigCameras: Camera[];
  29813. /**
  29814. * Gets the post process used by the rig cameras
  29815. */
  29816. readonly rigPostProcess: Nullable<PostProcess>;
  29817. /**
  29818. * Internal, gets the first post proces.
  29819. * @returns the first post process to be run on this camera.
  29820. */ getFirstPostProcess(): Nullable<PostProcess>;
  29821. private _cascadePostProcessesToRigCams;
  29822. /**
  29823. * Attach a post process to the camera.
  29824. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29825. * @param postProcess The post process to attach to the camera
  29826. * @param insertAt The position of the post process in case several of them are in use in the scene
  29827. * @returns the position the post process has been inserted at
  29828. */
  29829. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29830. /**
  29831. * Detach a post process to the camera.
  29832. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29833. * @param postProcess The post process to detach from the camera
  29834. */
  29835. detachPostProcess(postProcess: PostProcess): void;
  29836. /**
  29837. * Gets the current world matrix of the camera
  29838. */
  29839. getWorldMatrix(): Matrix;
  29840. /** @hidden */ getViewMatrix(): Matrix;
  29841. /**
  29842. * Gets the current view matrix of the camera.
  29843. * @param force forces the camera to recompute the matrix without looking at the cached state
  29844. * @returns the view matrix
  29845. */
  29846. getViewMatrix(force?: boolean): Matrix;
  29847. /**
  29848. * Freeze the projection matrix.
  29849. * It will prevent the cache check of the camera projection compute and can speed up perf
  29850. * if no parameter of the camera are meant to change
  29851. * @param projection Defines manually a projection if necessary
  29852. */
  29853. freezeProjectionMatrix(projection?: Matrix): void;
  29854. /**
  29855. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29856. */
  29857. unfreezeProjectionMatrix(): void;
  29858. /**
  29859. * Gets the current projection matrix of the camera.
  29860. * @param force forces the camera to recompute the matrix without looking at the cached state
  29861. * @returns the projection matrix
  29862. */
  29863. getProjectionMatrix(force?: boolean): Matrix;
  29864. /**
  29865. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29866. * @returns a Matrix
  29867. */
  29868. getTransformationMatrix(): Matrix;
  29869. private _updateFrustumPlanes;
  29870. /**
  29871. * Checks if a cullable object (mesh...) is in the camera frustum
  29872. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29873. * @param target The object to check
  29874. * @returns true if the object is in frustum otherwise false
  29875. */
  29876. isInFrustum(target: ICullable): boolean;
  29877. /**
  29878. * Checks if a cullable object (mesh...) is in the camera frustum
  29879. * Unlike isInFrustum this cheks the full bounding box
  29880. * @param target The object to check
  29881. * @returns true if the object is in frustum otherwise false
  29882. */
  29883. isCompletelyInFrustum(target: ICullable): boolean;
  29884. /**
  29885. * Gets a ray in the forward direction from the camera.
  29886. * @param length Defines the length of the ray to create
  29887. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29888. * @param origin Defines the start point of the ray which defaults to the camera position
  29889. * @returns the forward ray
  29890. */
  29891. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29892. /**
  29893. * Releases resources associated with this node.
  29894. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29895. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29896. */
  29897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29898. /** @hidden */ isLeftCamera: boolean;
  29899. /**
  29900. * Gets the left camera of a rig setup in case of Rigged Camera
  29901. */
  29902. readonly isLeftCamera: boolean;
  29903. /** @hidden */ isRightCamera: boolean;
  29904. /**
  29905. * Gets the right camera of a rig setup in case of Rigged Camera
  29906. */
  29907. readonly isRightCamera: boolean;
  29908. /**
  29909. * Gets the left camera of a rig setup in case of Rigged Camera
  29910. */
  29911. readonly leftCamera: Nullable<FreeCamera>;
  29912. /**
  29913. * Gets the right camera of a rig setup in case of Rigged Camera
  29914. */
  29915. readonly rightCamera: Nullable<FreeCamera>;
  29916. /**
  29917. * Gets the left camera target of a rig setup in case of Rigged Camera
  29918. * @returns the target position
  29919. */
  29920. getLeftTarget(): Nullable<Vector3>;
  29921. /**
  29922. * Gets the right camera target of a rig setup in case of Rigged Camera
  29923. * @returns the target position
  29924. */
  29925. getRightTarget(): Nullable<Vector3>;
  29926. /**
  29927. * @hidden
  29928. */
  29929. setCameraRigMode(mode: number, rigParams: any): void;
  29930. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  29931. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29932. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  29933. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29934. /** @hidden */ getVRProjectionMatrix(): Matrix;
  29935. protected _updateCameraRotationMatrix(): void;
  29936. protected _updateWebVRCameraRotationMatrix(): void;
  29937. /**
  29938. * This function MUST be overwritten by the different WebVR cameras available.
  29939. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29940. * @hidden
  29941. */ getWebVRProjectionMatrix(): Matrix;
  29942. /**
  29943. * This function MUST be overwritten by the different WebVR cameras available.
  29944. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29945. * @hidden
  29946. */ getWebVRViewMatrix(): Matrix;
  29947. /** @hidden */
  29948. setCameraRigParameter(name: string, value: any): void;
  29949. /**
  29950. * needs to be overridden by children so sub has required properties to be copied
  29951. * @hidden
  29952. */
  29953. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29954. /**
  29955. * May need to be overridden by children
  29956. * @hidden
  29957. */ updateRigCameras(): void;
  29958. /** @hidden */ setupInputs(): void;
  29959. /**
  29960. * Serialiaze the camera setup to a json represention
  29961. * @returns the JSON representation
  29962. */
  29963. serialize(): any;
  29964. /**
  29965. * Clones the current camera.
  29966. * @param name The cloned camera name
  29967. * @returns the cloned camera
  29968. */
  29969. clone(name: string): Camera;
  29970. /**
  29971. * Gets the direction of the camera relative to a given local axis.
  29972. * @param localAxis Defines the reference axis to provide a relative direction.
  29973. * @return the direction
  29974. */
  29975. getDirection(localAxis: Vector3): Vector3;
  29976. /**
  29977. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29978. * @param localAxis Defines the reference axis to provide a relative direction.
  29979. * @param result Defines the vector to store the result in
  29980. */
  29981. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29982. /**
  29983. * Gets a camera constructor for a given camera type
  29984. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29985. * @param name The name of the camera the result will be able to instantiate
  29986. * @param scene The scene the result will construct the camera in
  29987. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29988. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29989. * @returns a factory method to construc the camera
  29990. */
  29991. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29992. /**
  29993. * Compute the world matrix of the camera.
  29994. * @returns the camera workd matrix
  29995. */
  29996. computeWorldMatrix(): Matrix;
  29997. /**
  29998. * Parse a JSON and creates the camera from the parsed information
  29999. * @param parsedCamera The JSON to parse
  30000. * @param scene The scene to instantiate the camera in
  30001. * @returns the newly constructed camera
  30002. */
  30003. static Parse(parsedCamera: any, scene: Scene): Camera;
  30004. }
  30005. }
  30006. declare module BABYLON {
  30007. /**
  30008. * Interface for any object that can request an animation frame
  30009. */
  30010. export interface ICustomAnimationFrameRequester {
  30011. /**
  30012. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30013. */
  30014. renderFunction?: Function;
  30015. /**
  30016. * Called to request the next frame to render to
  30017. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30018. */
  30019. requestAnimationFrame: Function;
  30020. /**
  30021. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30022. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30023. */
  30024. requestID?: number;
  30025. }
  30026. /**
  30027. * Interface containing an array of animations
  30028. */
  30029. export interface IAnimatable {
  30030. /**
  30031. * Array of animations
  30032. */
  30033. animations: Array<Animation>;
  30034. }
  30035. /** Interface used by value gradients (color, factor, ...) */
  30036. export interface IValueGradient {
  30037. /**
  30038. * Gets or sets the gradient value (between 0 and 1)
  30039. */
  30040. gradient: number;
  30041. }
  30042. /** Class used to store color4 gradient */
  30043. export class ColorGradient implements IValueGradient {
  30044. /**
  30045. * Gets or sets the gradient value (between 0 and 1)
  30046. */
  30047. gradient: number;
  30048. /**
  30049. * Gets or sets first associated color
  30050. */
  30051. color1: Color4;
  30052. /**
  30053. * Gets or sets second associated color
  30054. */
  30055. color2?: Color4;
  30056. /**
  30057. * Will get a color picked randomly between color1 and color2.
  30058. * If color2 is undefined then color1 will be used
  30059. * @param result defines the target Color4 to store the result in
  30060. */
  30061. getColorToRef(result: Color4): void;
  30062. }
  30063. /** Class used to store color 3 gradient */
  30064. export class Color3Gradient implements IValueGradient {
  30065. /**
  30066. * Gets or sets the gradient value (between 0 and 1)
  30067. */
  30068. gradient: number;
  30069. /**
  30070. * Gets or sets the associated color
  30071. */
  30072. color: Color3;
  30073. }
  30074. /** Class used to store factor gradient */
  30075. export class FactorGradient implements IValueGradient {
  30076. /**
  30077. * Gets or sets the gradient value (between 0 and 1)
  30078. */
  30079. gradient: number;
  30080. /**
  30081. * Gets or sets first associated factor
  30082. */
  30083. factor1: number;
  30084. /**
  30085. * Gets or sets second associated factor
  30086. */
  30087. factor2?: number;
  30088. /**
  30089. * Will get a number picked randomly between factor1 and factor2.
  30090. * If factor2 is undefined then factor1 will be used
  30091. * @returns the picked number
  30092. */
  30093. getFactor(): number;
  30094. }
  30095. /**
  30096. * @ignore
  30097. * Application error to support additional information when loading a file
  30098. */
  30099. export class LoadFileError extends Error {
  30100. /** defines the optional web request */
  30101. request?: WebRequest | undefined;
  30102. private static _setPrototypeOf;
  30103. /**
  30104. * Creates a new LoadFileError
  30105. * @param message defines the message of the error
  30106. * @param request defines the optional web request
  30107. */
  30108. constructor(message: string,
  30109. /** defines the optional web request */
  30110. request?: WebRequest | undefined);
  30111. }
  30112. /**
  30113. * Class used to define a retry strategy when error happens while loading assets
  30114. */
  30115. export class RetryStrategy {
  30116. /**
  30117. * Function used to defines an exponential back off strategy
  30118. * @param maxRetries defines the maximum number of retries (3 by default)
  30119. * @param baseInterval defines the interval between retries
  30120. * @returns the strategy function to use
  30121. */
  30122. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30123. }
  30124. /**
  30125. * File request interface
  30126. */
  30127. export interface IFileRequest {
  30128. /**
  30129. * Raised when the request is complete (success or error).
  30130. */
  30131. onCompleteObservable: Observable<IFileRequest>;
  30132. /**
  30133. * Aborts the request for a file.
  30134. */
  30135. abort: () => void;
  30136. }
  30137. /**
  30138. * Class containing a set of static utilities functions
  30139. */
  30140. export class Tools {
  30141. /**
  30142. * Gets or sets the base URL to use to load assets
  30143. */
  30144. static BaseUrl: string;
  30145. /**
  30146. * Enable/Disable Custom HTTP Request Headers globally.
  30147. * default = false
  30148. * @see CustomRequestHeaders
  30149. */
  30150. static UseCustomRequestHeaders: boolean;
  30151. /**
  30152. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30153. * i.e. when loading files, where the server/service expects an Authorization header
  30154. */
  30155. static CustomRequestHeaders: {
  30156. [key: string]: string;
  30157. };
  30158. /**
  30159. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30160. */
  30161. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30162. /**
  30163. * Default behaviour for cors in the application.
  30164. * It can be a string if the expected behavior is identical in the entire app.
  30165. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30166. */
  30167. static CorsBehavior: string | ((url: string | string[]) => string);
  30168. /**
  30169. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30170. * @ignorenaming
  30171. */
  30172. static UseFallbackTexture: boolean;
  30173. /**
  30174. * Use this object to register external classes like custom textures or material
  30175. * to allow the laoders to instantiate them
  30176. */
  30177. static RegisteredExternalClasses: {
  30178. [key: string]: Object;
  30179. };
  30180. /**
  30181. * Texture content used if a texture cannot loaded
  30182. * @ignorenaming
  30183. */
  30184. static fallbackTexture: string;
  30185. /**
  30186. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30187. * @param u defines the coordinate on X axis
  30188. * @param v defines the coordinate on Y axis
  30189. * @param width defines the width of the source data
  30190. * @param height defines the height of the source data
  30191. * @param pixels defines the source byte array
  30192. * @param color defines the output color
  30193. */
  30194. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30195. /**
  30196. * Interpolates between a and b via alpha
  30197. * @param a The lower value (returned when alpha = 0)
  30198. * @param b The upper value (returned when alpha = 1)
  30199. * @param alpha The interpolation-factor
  30200. * @return The mixed value
  30201. */
  30202. static Mix(a: number, b: number, alpha: number): number;
  30203. /**
  30204. * Tries to instantiate a new object from a given class name
  30205. * @param className defines the class name to instantiate
  30206. * @returns the new object or null if the system was not able to do the instantiation
  30207. */
  30208. static Instantiate(className: string): any;
  30209. /**
  30210. * Provides a slice function that will work even on IE
  30211. * @param data defines the array to slice
  30212. * @param start defines the start of the data (optional)
  30213. * @param end defines the end of the data (optional)
  30214. * @returns the new sliced array
  30215. */
  30216. static Slice<T>(data: T, start?: number, end?: number): T;
  30217. /**
  30218. * Polyfill for setImmediate
  30219. * @param action defines the action to execute after the current execution block
  30220. */
  30221. static SetImmediate(action: () => void): void;
  30222. /**
  30223. * Function indicating if a number is an exponent of 2
  30224. * @param value defines the value to test
  30225. * @returns true if the value is an exponent of 2
  30226. */
  30227. static IsExponentOfTwo(value: number): boolean;
  30228. private static _tmpFloatArray;
  30229. /**
  30230. * Returns the nearest 32-bit single precision float representation of a Number
  30231. * @param value A Number. If the parameter is of a different type, it will get converted
  30232. * to a number or to NaN if it cannot be converted
  30233. * @returns number
  30234. */
  30235. static FloatRound(value: number): number;
  30236. /**
  30237. * Find the next highest power of two.
  30238. * @param x Number to start search from.
  30239. * @return Next highest power of two.
  30240. */
  30241. static CeilingPOT(x: number): number;
  30242. /**
  30243. * Find the next lowest power of two.
  30244. * @param x Number to start search from.
  30245. * @return Next lowest power of two.
  30246. */
  30247. static FloorPOT(x: number): number;
  30248. /**
  30249. * Find the nearest power of two.
  30250. * @param x Number to start search from.
  30251. * @return Next nearest power of two.
  30252. */
  30253. static NearestPOT(x: number): number;
  30254. /**
  30255. * Get the closest exponent of two
  30256. * @param value defines the value to approximate
  30257. * @param max defines the maximum value to return
  30258. * @param mode defines how to define the closest value
  30259. * @returns closest exponent of two of the given value
  30260. */
  30261. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30262. /**
  30263. * Extracts the filename from a path
  30264. * @param path defines the path to use
  30265. * @returns the filename
  30266. */
  30267. static GetFilename(path: string): string;
  30268. /**
  30269. * Extracts the "folder" part of a path (everything before the filename).
  30270. * @param uri The URI to extract the info from
  30271. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30272. * @returns The "folder" part of the path
  30273. */
  30274. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30275. /**
  30276. * Extracts text content from a DOM element hierarchy
  30277. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30278. */
  30279. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30280. /**
  30281. * Convert an angle in radians to degrees
  30282. * @param angle defines the angle to convert
  30283. * @returns the angle in degrees
  30284. */
  30285. static ToDegrees(angle: number): number;
  30286. /**
  30287. * Convert an angle in degrees to radians
  30288. * @param angle defines the angle to convert
  30289. * @returns the angle in radians
  30290. */
  30291. static ToRadians(angle: number): number;
  30292. /**
  30293. * Encode a buffer to a base64 string
  30294. * @param buffer defines the buffer to encode
  30295. * @returns the encoded string
  30296. */
  30297. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30298. /**
  30299. * Extracts minimum and maximum values from a list of indexed positions
  30300. * @param positions defines the positions to use
  30301. * @param indices defines the indices to the positions
  30302. * @param indexStart defines the start index
  30303. * @param indexCount defines the end index
  30304. * @param bias defines bias value to add to the result
  30305. * @return minimum and maximum values
  30306. */
  30307. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30308. minimum: Vector3;
  30309. maximum: Vector3;
  30310. };
  30311. /**
  30312. * Extracts minimum and maximum values from a list of positions
  30313. * @param positions defines the positions to use
  30314. * @param start defines the start index in the positions array
  30315. * @param count defines the number of positions to handle
  30316. * @param bias defines bias value to add to the result
  30317. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30318. * @return minimum and maximum values
  30319. */
  30320. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30321. minimum: Vector3;
  30322. maximum: Vector3;
  30323. };
  30324. /**
  30325. * Returns an array if obj is not an array
  30326. * @param obj defines the object to evaluate as an array
  30327. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30328. * @returns either obj directly if obj is an array or a new array containing obj
  30329. */
  30330. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30331. /**
  30332. * Gets the pointer prefix to use
  30333. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30334. */
  30335. static GetPointerPrefix(): string;
  30336. /**
  30337. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30338. * @param func - the function to be called
  30339. * @param requester - the object that will request the next frame. Falls back to window.
  30340. * @returns frame number
  30341. */
  30342. static QueueNewFrame(func: () => void, requester?: any): number;
  30343. /**
  30344. * Ask the browser to promote the current element to fullscreen rendering mode
  30345. * @param element defines the DOM element to promote
  30346. */
  30347. static RequestFullscreen(element: HTMLElement): void;
  30348. /**
  30349. * Asks the browser to exit fullscreen mode
  30350. */
  30351. static ExitFullscreen(): void;
  30352. /**
  30353. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30354. * @param url define the url we are trying
  30355. * @param element define the dom element where to configure the cors policy
  30356. */
  30357. static SetCorsBehavior(url: string | string[], element: {
  30358. crossOrigin: string | null;
  30359. }): void;
  30360. /**
  30361. * Removes unwanted characters from an url
  30362. * @param url defines the url to clean
  30363. * @returns the cleaned url
  30364. */
  30365. static CleanUrl(url: string): string;
  30366. /**
  30367. * Gets or sets a function used to pre-process url before using them to load assets
  30368. */
  30369. static PreprocessUrl: (url: string) => string;
  30370. /**
  30371. * Loads an image as an HTMLImageElement.
  30372. * @param input url string, ArrayBuffer, or Blob to load
  30373. * @param onLoad callback called when the image successfully loads
  30374. * @param onError callback called when the image fails to load
  30375. * @param offlineProvider offline provider for caching
  30376. * @returns the HTMLImageElement of the loaded image
  30377. */
  30378. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30379. /**
  30380. * Loads a file
  30381. * @param url url string, ArrayBuffer, or Blob to load
  30382. * @param onSuccess callback called when the file successfully loads
  30383. * @param onProgress callback called while file is loading (if the server supports this mode)
  30384. * @param offlineProvider defines the offline provider for caching
  30385. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30386. * @param onError callback called when the file fails to load
  30387. * @returns a file request object
  30388. */
  30389. 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;
  30390. /**
  30391. * Load a script (identified by an url). When the url returns, the
  30392. * content of this file is added into a new script element, attached to the DOM (body element)
  30393. * @param scriptUrl defines the url of the script to laod
  30394. * @param onSuccess defines the callback called when the script is loaded
  30395. * @param onError defines the callback to call if an error occurs
  30396. * @param scriptId defines the id of the script element
  30397. */
  30398. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30399. /**
  30400. * Load an asynchronous script (identified by an url). When the url returns, the
  30401. * content of this file is added into a new script element, attached to the DOM (body element)
  30402. * @param scriptUrl defines the url of the script to laod
  30403. * @param scriptId defines the id of the script element
  30404. * @returns a promise request object
  30405. */
  30406. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30407. /**
  30408. * Loads a file from a blob
  30409. * @param fileToLoad defines the blob to use
  30410. * @param callback defines the callback to call when data is loaded
  30411. * @param progressCallback defines the callback to call during loading process
  30412. * @returns a file request object
  30413. */
  30414. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30415. /**
  30416. * Loads a file
  30417. * @param fileToLoad defines the file to load
  30418. * @param callback defines the callback to call when data is loaded
  30419. * @param progressCallBack defines the callback to call during loading process
  30420. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30421. * @returns a file request object
  30422. */
  30423. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30424. /**
  30425. * Creates a data url from a given string content
  30426. * @param content defines the content to convert
  30427. * @returns the new data url link
  30428. */
  30429. static FileAsURL(content: string): string;
  30430. /**
  30431. * Format the given number to a specific decimal format
  30432. * @param value defines the number to format
  30433. * @param decimals defines the number of decimals to use
  30434. * @returns the formatted string
  30435. */
  30436. static Format(value: number, decimals?: number): string;
  30437. /**
  30438. * Checks if a given vector is inside a specific range
  30439. * @param v defines the vector to test
  30440. * @param min defines the minimum range
  30441. * @param max defines the maximum range
  30442. */
  30443. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30444. /**
  30445. * Tries to copy an object by duplicating every property
  30446. * @param source defines the source object
  30447. * @param destination defines the target object
  30448. * @param doNotCopyList defines a list of properties to avoid
  30449. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30450. */
  30451. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30452. /**
  30453. * Gets a boolean indicating if the given object has no own property
  30454. * @param obj defines the object to test
  30455. * @returns true if object has no own property
  30456. */
  30457. static IsEmpty(obj: any): boolean;
  30458. /**
  30459. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30460. * @param str Source string
  30461. * @param suffix Suffix to search for in the source string
  30462. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30463. */
  30464. static EndsWith(str: string, suffix: string): boolean;
  30465. /**
  30466. * Function used to register events at window level
  30467. * @param events defines the events to register
  30468. */
  30469. static RegisterTopRootEvents(events: {
  30470. name: string;
  30471. handler: Nullable<(e: FocusEvent) => any>;
  30472. }[]): void;
  30473. /**
  30474. * Function used to unregister events from window level
  30475. * @param events defines the events to unregister
  30476. */
  30477. static UnregisterTopRootEvents(events: {
  30478. name: string;
  30479. handler: Nullable<(e: FocusEvent) => any>;
  30480. }[]): void;
  30481. /**
  30482. * @ignore
  30483. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30484. /**
  30485. * Dumps the current bound framebuffer
  30486. * @param width defines the rendering width
  30487. * @param height defines the rendering height
  30488. * @param engine defines the hosting engine
  30489. * @param successCallback defines the callback triggered once the data are available
  30490. * @param mimeType defines the mime type of the result
  30491. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30492. */
  30493. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30494. /**
  30495. * Converts the canvas data to blob.
  30496. * This acts as a polyfill for browsers not supporting the to blob function.
  30497. * @param canvas Defines the canvas to extract the data from
  30498. * @param successCallback Defines the callback triggered once the data are available
  30499. * @param mimeType Defines the mime type of the result
  30500. */
  30501. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30502. /**
  30503. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30504. * @param successCallback defines the callback triggered once the data are available
  30505. * @param mimeType defines the mime type of the result
  30506. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30507. */
  30508. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30509. /**
  30510. * Downloads a blob in the browser
  30511. * @param blob defines the blob to download
  30512. * @param fileName defines the name of the downloaded file
  30513. */
  30514. static Download(blob: Blob, fileName: string): void;
  30515. /**
  30516. * Captures a screenshot of the current rendering
  30517. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30518. * @param engine defines the rendering engine
  30519. * @param camera defines the source camera
  30520. * @param size This parameter can be set to a single number or to an object with the
  30521. * following (optional) properties: precision, width, height. If a single number is passed,
  30522. * it will be used for both width and height. If an object is passed, the screenshot size
  30523. * will be derived from the parameters. The precision property is a multiplier allowing
  30524. * rendering at a higher or lower resolution
  30525. * @param successCallback defines the callback receives a single parameter which contains the
  30526. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30527. * src parameter of an <img> to display it
  30528. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30529. * Check your browser for supported MIME types
  30530. */
  30531. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30532. /**
  30533. * Generates an image screenshot from the specified camera.
  30534. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30535. * @param engine The engine to use for rendering
  30536. * @param camera The camera to use for rendering
  30537. * @param size This parameter can be set to a single number or to an object with the
  30538. * following (optional) properties: precision, width, height. If a single number is passed,
  30539. * it will be used for both width and height. If an object is passed, the screenshot size
  30540. * will be derived from the parameters. The precision property is a multiplier allowing
  30541. * rendering at a higher or lower resolution
  30542. * @param successCallback The callback receives a single parameter which contains the
  30543. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30544. * src parameter of an <img> to display it
  30545. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30546. * Check your browser for supported MIME types
  30547. * @param samples Texture samples (default: 1)
  30548. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30549. * @param fileName A name for for the downloaded file.
  30550. */
  30551. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30552. /**
  30553. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30554. * Be aware Math.random() could cause collisions, but:
  30555. * "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"
  30556. * @returns a pseudo random id
  30557. */
  30558. static RandomId(): string;
  30559. /**
  30560. * Test if the given uri is a base64 string
  30561. * @param uri The uri to test
  30562. * @return True if the uri is a base64 string or false otherwise
  30563. */
  30564. static IsBase64(uri: string): boolean;
  30565. /**
  30566. * Decode the given base64 uri.
  30567. * @param uri The uri to decode
  30568. * @return The decoded base64 data.
  30569. */
  30570. static DecodeBase64(uri: string): ArrayBuffer;
  30571. /**
  30572. * No log
  30573. */
  30574. static readonly NoneLogLevel: number;
  30575. /**
  30576. * Only message logs
  30577. */
  30578. static readonly MessageLogLevel: number;
  30579. /**
  30580. * Only warning logs
  30581. */
  30582. static readonly WarningLogLevel: number;
  30583. /**
  30584. * Only error logs
  30585. */
  30586. static readonly ErrorLogLevel: number;
  30587. /**
  30588. * All logs
  30589. */
  30590. static readonly AllLogLevel: number;
  30591. /**
  30592. * Gets a value indicating the number of loading errors
  30593. * @ignorenaming
  30594. */
  30595. static readonly errorsCount: number;
  30596. /**
  30597. * Callback called when a new log is added
  30598. */
  30599. static OnNewCacheEntry: (entry: string) => void;
  30600. /**
  30601. * Log a message to the console
  30602. * @param message defines the message to log
  30603. */
  30604. static Log(message: string): void;
  30605. /**
  30606. * Write a warning message to the console
  30607. * @param message defines the message to log
  30608. */
  30609. static Warn(message: string): void;
  30610. /**
  30611. * Write an error message to the console
  30612. * @param message defines the message to log
  30613. */
  30614. static Error(message: string): void;
  30615. /**
  30616. * Gets current log cache (list of logs)
  30617. */
  30618. static readonly LogCache: string;
  30619. /**
  30620. * Clears the log cache
  30621. */
  30622. static ClearLogCache(): void;
  30623. /**
  30624. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30625. */
  30626. static LogLevels: number;
  30627. /**
  30628. * Checks if the loaded document was accessed via `file:`-Protocol.
  30629. * @returns boolean
  30630. */
  30631. static IsFileURL(): boolean;
  30632. /**
  30633. * Checks if the window object exists
  30634. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30635. */
  30636. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30637. /**
  30638. * No performance log
  30639. */
  30640. static readonly PerformanceNoneLogLevel: number;
  30641. /**
  30642. * Use user marks to log performance
  30643. */
  30644. static readonly PerformanceUserMarkLogLevel: number;
  30645. /**
  30646. * Log performance to the console
  30647. */
  30648. static readonly PerformanceConsoleLogLevel: number;
  30649. private static _performance;
  30650. /**
  30651. * Sets the current performance log level
  30652. */
  30653. static PerformanceLogLevel: number;
  30654. private static _StartPerformanceCounterDisabled;
  30655. private static _EndPerformanceCounterDisabled;
  30656. private static _StartUserMark;
  30657. private static _EndUserMark;
  30658. private static _StartPerformanceConsole;
  30659. private static _EndPerformanceConsole;
  30660. /**
  30661. * Starts a performance counter
  30662. */
  30663. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30664. /**
  30665. * Ends a specific performance coutner
  30666. */
  30667. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30668. /**
  30669. * Gets either window.performance.now() if supported or Date.now() else
  30670. */
  30671. static readonly Now: number;
  30672. /**
  30673. * This method will return the name of the class used to create the instance of the given object.
  30674. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30675. * @param object the object to get the class name from
  30676. * @param isType defines if the object is actually a type
  30677. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30678. */
  30679. static GetClassName(object: any, isType?: boolean): string;
  30680. /**
  30681. * Gets the first element of an array satisfying a given predicate
  30682. * @param array defines the array to browse
  30683. * @param predicate defines the predicate to use
  30684. * @returns null if not found or the element
  30685. */
  30686. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30687. /**
  30688. * This method will return the name of the full name of the class, including its owning module (if any).
  30689. * 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).
  30690. * @param object the object to get the class name from
  30691. * @param isType defines if the object is actually a type
  30692. * @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.
  30693. * @ignorenaming
  30694. */
  30695. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30696. /**
  30697. * Returns a promise that resolves after the given amount of time.
  30698. * @param delay Number of milliseconds to delay
  30699. * @returns Promise that resolves after the given amount of time
  30700. */
  30701. static DelayAsync(delay: number): Promise<void>;
  30702. /**
  30703. * Gets the current gradient from an array of IValueGradient
  30704. * @param ratio defines the current ratio to get
  30705. * @param gradients defines the array of IValueGradient
  30706. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30707. */
  30708. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30709. }
  30710. /**
  30711. * This class is used to track a performance counter which is number based.
  30712. * The user has access to many properties which give statistics of different nature.
  30713. *
  30714. * The implementer can track two kinds of Performance Counter: time and count.
  30715. * 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.
  30716. * 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.
  30717. */
  30718. export class PerfCounter {
  30719. /**
  30720. * Gets or sets a global boolean to turn on and off all the counters
  30721. */
  30722. static Enabled: boolean;
  30723. /**
  30724. * Returns the smallest value ever
  30725. */
  30726. readonly min: number;
  30727. /**
  30728. * Returns the biggest value ever
  30729. */
  30730. readonly max: number;
  30731. /**
  30732. * Returns the average value since the performance counter is running
  30733. */
  30734. readonly average: number;
  30735. /**
  30736. * Returns the average value of the last second the counter was monitored
  30737. */
  30738. readonly lastSecAverage: number;
  30739. /**
  30740. * Returns the current value
  30741. */
  30742. readonly current: number;
  30743. /**
  30744. * Gets the accumulated total
  30745. */
  30746. readonly total: number;
  30747. /**
  30748. * Gets the total value count
  30749. */
  30750. readonly count: number;
  30751. /**
  30752. * Creates a new counter
  30753. */
  30754. constructor();
  30755. /**
  30756. * Call this method to start monitoring a new frame.
  30757. * 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.
  30758. */
  30759. fetchNewFrame(): void;
  30760. /**
  30761. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30762. * @param newCount the count value to add to the monitored count
  30763. * @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.
  30764. */
  30765. addCount(newCount: number, fetchResult: boolean): void;
  30766. /**
  30767. * Start monitoring this performance counter
  30768. */
  30769. beginMonitoring(): void;
  30770. /**
  30771. * Compute the time lapsed since the previous beginMonitoring() call.
  30772. * @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
  30773. */
  30774. endMonitoring(newFrame?: boolean): void;
  30775. private _fetchResult;
  30776. private _startMonitoringTime;
  30777. private _min;
  30778. private _max;
  30779. private _average;
  30780. private _current;
  30781. private _totalValueCount;
  30782. private _totalAccumulated;
  30783. private _lastSecAverage;
  30784. private _lastSecAccumulated;
  30785. private _lastSecTime;
  30786. private _lastSecValueCount;
  30787. }
  30788. /**
  30789. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30790. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30791. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30792. * @param name The name of the class, case should be preserved
  30793. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30794. */
  30795. export function className(name: string, module?: string): (target: Object) => void;
  30796. /**
  30797. * An implementation of a loop for asynchronous functions.
  30798. */
  30799. export class AsyncLoop {
  30800. /**
  30801. * Defines the number of iterations for the loop
  30802. */
  30803. iterations: number;
  30804. /**
  30805. * Defines the current index of the loop.
  30806. */
  30807. index: number;
  30808. private _done;
  30809. private _fn;
  30810. private _successCallback;
  30811. /**
  30812. * Constructor.
  30813. * @param iterations the number of iterations.
  30814. * @param func the function to run each iteration
  30815. * @param successCallback the callback that will be called upon succesful execution
  30816. * @param offset starting offset.
  30817. */
  30818. constructor(
  30819. /**
  30820. * Defines the number of iterations for the loop
  30821. */
  30822. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30823. /**
  30824. * Execute the next iteration. Must be called after the last iteration was finished.
  30825. */
  30826. executeNext(): void;
  30827. /**
  30828. * Break the loop and run the success callback.
  30829. */
  30830. breakLoop(): void;
  30831. /**
  30832. * Create and run an async loop.
  30833. * @param iterations the number of iterations.
  30834. * @param fn the function to run each iteration
  30835. * @param successCallback the callback that will be called upon succesful execution
  30836. * @param offset starting offset.
  30837. * @returns the created async loop object
  30838. */
  30839. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30840. /**
  30841. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30842. * @param iterations total number of iterations
  30843. * @param syncedIterations number of synchronous iterations in each async iteration.
  30844. * @param fn the function to call each iteration.
  30845. * @param callback a success call back that will be called when iterating stops.
  30846. * @param breakFunction a break condition (optional)
  30847. * @param timeout timeout settings for the setTimeout function. default - 0.
  30848. * @returns the created async loop object
  30849. */
  30850. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30851. }
  30852. }
  30853. declare module BABYLON {
  30854. /** @hidden */
  30855. export interface ICollisionCoordinator {
  30856. createCollider(): Collider;
  30857. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30858. init(scene: Scene): void;
  30859. }
  30860. /** @hidden */
  30861. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30862. private _scene;
  30863. private _scaledPosition;
  30864. private _scaledVelocity;
  30865. private _finalPosition;
  30866. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30867. createCollider(): Collider;
  30868. init(scene: Scene): void;
  30869. private _collideWithWorld;
  30870. }
  30871. }
  30872. declare module BABYLON {
  30873. /**
  30874. * This class defines the direct association between an animation and a target
  30875. */
  30876. export class TargetedAnimation {
  30877. /**
  30878. * Animation to perform
  30879. */
  30880. animation: Animation;
  30881. /**
  30882. * Target to animate
  30883. */
  30884. target: any;
  30885. }
  30886. /**
  30887. * Use this class to create coordinated animations on multiple targets
  30888. */
  30889. export class AnimationGroup implements IDisposable {
  30890. /** The name of the animation group */
  30891. name: string;
  30892. private _scene;
  30893. private _targetedAnimations;
  30894. private _animatables;
  30895. private _from;
  30896. private _to;
  30897. private _isStarted;
  30898. private _isPaused;
  30899. private _speedRatio;
  30900. /**
  30901. * Gets or sets the unique id of the node
  30902. */
  30903. uniqueId: number;
  30904. /**
  30905. * This observable will notify when one animation have ended
  30906. */
  30907. onAnimationEndObservable: Observable<TargetedAnimation>;
  30908. /**
  30909. * Observer raised when one animation loops
  30910. */
  30911. onAnimationLoopObservable: Observable<TargetedAnimation>;
  30912. /**
  30913. * This observable will notify when all animations have ended.
  30914. */
  30915. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  30916. /**
  30917. * This observable will notify when all animations have paused.
  30918. */
  30919. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  30920. /**
  30921. * This observable will notify when all animations are playing.
  30922. */
  30923. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  30924. /**
  30925. * Gets the first frame
  30926. */
  30927. readonly from: number;
  30928. /**
  30929. * Gets the last frame
  30930. */
  30931. readonly to: number;
  30932. /**
  30933. * Define if the animations are started
  30934. */
  30935. readonly isStarted: boolean;
  30936. /**
  30937. * Gets a value indicating that the current group is playing
  30938. */
  30939. readonly isPlaying: boolean;
  30940. /**
  30941. * Gets or sets the speed ratio to use for all animations
  30942. */
  30943. /**
  30944. * Gets or sets the speed ratio to use for all animations
  30945. */
  30946. speedRatio: number;
  30947. /**
  30948. * Gets the targeted animations for this animation group
  30949. */
  30950. readonly targetedAnimations: Array<TargetedAnimation>;
  30951. /**
  30952. * returning the list of animatables controlled by this animation group.
  30953. */
  30954. readonly animatables: Array<Animatable>;
  30955. /**
  30956. * Instantiates a new Animation Group.
  30957. * This helps managing several animations at once.
  30958. * @see http://doc.babylonjs.com/how_to/group
  30959. * @param name Defines the name of the group
  30960. * @param scene Defines the scene the group belongs to
  30961. */
  30962. constructor(
  30963. /** The name of the animation group */
  30964. name: string, scene?: Nullable<Scene>);
  30965. /**
  30966. * Add an animation (with its target) in the group
  30967. * @param animation defines the animation we want to add
  30968. * @param target defines the target of the animation
  30969. * @returns the TargetedAnimation object
  30970. */
  30971. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  30972. /**
  30973. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  30974. * It can add constant keys at begin or end
  30975. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  30976. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  30977. * @returns the animation group
  30978. */
  30979. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  30980. /**
  30981. * Start all animations on given targets
  30982. * @param loop defines if animations must loop
  30983. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  30984. * @param from defines the from key (optional)
  30985. * @param to defines the to key (optional)
  30986. * @returns the current animation group
  30987. */
  30988. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  30989. /**
  30990. * Pause all animations
  30991. * @returns the animation group
  30992. */
  30993. pause(): AnimationGroup;
  30994. /**
  30995. * Play all animations to initial state
  30996. * This function will start() the animations if they were not started or will restart() them if they were paused
  30997. * @param loop defines if animations must loop
  30998. * @returns the animation group
  30999. */
  31000. play(loop?: boolean): AnimationGroup;
  31001. /**
  31002. * Reset all animations to initial state
  31003. * @returns the animation group
  31004. */
  31005. reset(): AnimationGroup;
  31006. /**
  31007. * Restart animations from key 0
  31008. * @returns the animation group
  31009. */
  31010. restart(): AnimationGroup;
  31011. /**
  31012. * Stop all animations
  31013. * @returns the animation group
  31014. */
  31015. stop(): AnimationGroup;
  31016. /**
  31017. * Set animation weight for all animatables
  31018. * @param weight defines the weight to use
  31019. * @return the animationGroup
  31020. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31021. */
  31022. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31023. /**
  31024. * Synchronize and normalize all animatables with a source animatable
  31025. * @param root defines the root animatable to synchronize with
  31026. * @return the animationGroup
  31027. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31028. */
  31029. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31030. /**
  31031. * Goes to a specific frame in this animation group
  31032. * @param frame the frame number to go to
  31033. * @return the animationGroup
  31034. */
  31035. goToFrame(frame: number): AnimationGroup;
  31036. /**
  31037. * Dispose all associated resources
  31038. */
  31039. dispose(): void;
  31040. private _checkAnimationGroupEnded;
  31041. /**
  31042. * Clone the current animation group and returns a copy
  31043. * @param newName defines the name of the new group
  31044. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31045. * @returns the new aniamtion group
  31046. */
  31047. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31048. /**
  31049. * Returns a new AnimationGroup object parsed from the source provided.
  31050. * @param parsedAnimationGroup defines the source
  31051. * @param scene defines the scene that will receive the animationGroup
  31052. * @returns a new AnimationGroup
  31053. */
  31054. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31055. /**
  31056. * Returns the string "AnimationGroup"
  31057. * @returns "AnimationGroup"
  31058. */
  31059. getClassName(): string;
  31060. /**
  31061. * Creates a detailled string about the object
  31062. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31063. * @returns a string representing the object
  31064. */
  31065. toString(fullDetails?: boolean): string;
  31066. }
  31067. }
  31068. declare module BABYLON {
  31069. /**
  31070. * Define an interface for all classes that will hold resources
  31071. */
  31072. export interface IDisposable {
  31073. /**
  31074. * Releases all held resources
  31075. */
  31076. dispose(): void;
  31077. }
  31078. /** Interface defining initialization parameters for Scene class */
  31079. export interface SceneOptions {
  31080. /**
  31081. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31082. * It will improve performance when the number of geometries becomes important.
  31083. */
  31084. useGeometryUniqueIdsMap?: boolean;
  31085. /**
  31086. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31087. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31088. */
  31089. useMaterialMeshMap?: boolean;
  31090. /**
  31091. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31092. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31093. */
  31094. useClonedMeshhMap?: boolean;
  31095. }
  31096. /**
  31097. * Represents a scene to be rendered by the engine.
  31098. * @see http://doc.babylonjs.com/features/scene
  31099. */
  31100. export class Scene extends AbstractScene implements IAnimatable {
  31101. private static _uniqueIdCounter;
  31102. /** The fog is deactivated */
  31103. static readonly FOGMODE_NONE: number;
  31104. /** The fog density is following an exponential function */
  31105. static readonly FOGMODE_EXP: number;
  31106. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31107. static readonly FOGMODE_EXP2: number;
  31108. /** The fog density is following a linear function. */
  31109. static readonly FOGMODE_LINEAR: number;
  31110. /**
  31111. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31112. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31113. */
  31114. static MinDeltaTime: number;
  31115. /**
  31116. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31117. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31118. */
  31119. static MaxDeltaTime: number;
  31120. /**
  31121. * Factory used to create the default material.
  31122. * @param name The name of the material to create
  31123. * @param scene The scene to create the material for
  31124. * @returns The default material
  31125. */
  31126. static DefaultMaterialFactory(scene: Scene): Material;
  31127. /**
  31128. * Factory used to create the a collision coordinator.
  31129. * @returns The collision coordinator
  31130. */
  31131. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31132. /** @hidden */ protected readonly _isScene: boolean;
  31133. /**
  31134. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31135. */
  31136. autoClear: boolean;
  31137. /**
  31138. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31139. */
  31140. autoClearDepthAndStencil: boolean;
  31141. /**
  31142. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31143. */
  31144. clearColor: Color4;
  31145. /**
  31146. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31147. */
  31148. ambientColor: Color3;
  31149. /**
  31150. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31151. * It should only be one of the following (if not the default embedded one):
  31152. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31153. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31154. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31155. * The material properties need to be setup according to the type of texture in use.
  31156. */
  31157. environmentBRDFTexture: BaseTexture;
  31158. /** @hidden */
  31159. protected _environmentTexture: Nullable<BaseTexture>;
  31160. /**
  31161. * Texture used in all pbr material as the reflection texture.
  31162. * As in the majority of the scene they are the same (exception for multi room and so on),
  31163. * this is easier to reference from here than from all the materials.
  31164. */
  31165. /**
  31166. * Texture used in all pbr material as the reflection texture.
  31167. * As in the majority of the scene they are the same (exception for multi room and so on),
  31168. * this is easier to set here than in all the materials.
  31169. */
  31170. environmentTexture: Nullable<BaseTexture>;
  31171. /** @hidden */
  31172. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31173. /**
  31174. * Default image processing configuration used either in the rendering
  31175. * Forward main pass or through the imageProcessingPostProcess if present.
  31176. * As in the majority of the scene they are the same (exception for multi camera),
  31177. * this is easier to reference from here than from all the materials and post process.
  31178. *
  31179. * No setter as we it is a shared configuration, you can set the values instead.
  31180. */
  31181. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31182. private _forceWireframe;
  31183. /**
  31184. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31185. */
  31186. forceWireframe: boolean;
  31187. private _forcePointsCloud;
  31188. /**
  31189. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31190. */
  31191. forcePointsCloud: boolean;
  31192. /**
  31193. * Gets or sets the active clipplane 1
  31194. */
  31195. clipPlane: Nullable<Plane>;
  31196. /**
  31197. * Gets or sets the active clipplane 2
  31198. */
  31199. clipPlane2: Nullable<Plane>;
  31200. /**
  31201. * Gets or sets the active clipplane 3
  31202. */
  31203. clipPlane3: Nullable<Plane>;
  31204. /**
  31205. * Gets or sets the active clipplane 4
  31206. */
  31207. clipPlane4: Nullable<Plane>;
  31208. /**
  31209. * Gets or sets a boolean indicating if animations are enabled
  31210. */
  31211. animationsEnabled: boolean;
  31212. private _animationPropertiesOverride;
  31213. /**
  31214. * Gets or sets the animation properties override
  31215. */
  31216. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31217. /**
  31218. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31219. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31220. */
  31221. useConstantAnimationDeltaTime: boolean;
  31222. /**
  31223. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31224. * Please note that it requires to run a ray cast through the scene on every frame
  31225. */
  31226. constantlyUpdateMeshUnderPointer: boolean;
  31227. /**
  31228. * Defines the HTML cursor to use when hovering over interactive elements
  31229. */
  31230. hoverCursor: string;
  31231. /**
  31232. * Defines the HTML default cursor to use (empty by default)
  31233. */
  31234. defaultCursor: string;
  31235. /**
  31236. * This is used to call preventDefault() on pointer down
  31237. * in order to block unwanted artifacts like system double clicks
  31238. */
  31239. preventDefaultOnPointerDown: boolean;
  31240. /**
  31241. * This is used to call preventDefault() on pointer up
  31242. * in order to block unwanted artifacts like system double clicks
  31243. */
  31244. preventDefaultOnPointerUp: boolean;
  31245. /**
  31246. * Gets or sets user defined metadata
  31247. */
  31248. metadata: any;
  31249. /**
  31250. * For internal use only. Please do not use.
  31251. */
  31252. reservedDataStore: any;
  31253. /**
  31254. * Gets the name of the plugin used to load this scene (null by default)
  31255. */
  31256. loadingPluginName: string;
  31257. /**
  31258. * Use this array to add regular expressions used to disable offline support for specific urls
  31259. */
  31260. disableOfflineSupportExceptionRules: RegExp[];
  31261. /**
  31262. * An event triggered when the scene is disposed.
  31263. */
  31264. onDisposeObservable: Observable<Scene>;
  31265. private _onDisposeObserver;
  31266. /** Sets a function to be executed when this scene is disposed. */
  31267. onDispose: () => void;
  31268. /**
  31269. * An event triggered before rendering the scene (right after animations and physics)
  31270. */
  31271. onBeforeRenderObservable: Observable<Scene>;
  31272. private _onBeforeRenderObserver;
  31273. /** Sets a function to be executed before rendering this scene */
  31274. beforeRender: Nullable<() => void>;
  31275. /**
  31276. * An event triggered after rendering the scene
  31277. */
  31278. onAfterRenderObservable: Observable<Scene>;
  31279. private _onAfterRenderObserver;
  31280. /** Sets a function to be executed after rendering this scene */
  31281. afterRender: Nullable<() => void>;
  31282. /**
  31283. * An event triggered before animating the scene
  31284. */
  31285. onBeforeAnimationsObservable: Observable<Scene>;
  31286. /**
  31287. * An event triggered after animations processing
  31288. */
  31289. onAfterAnimationsObservable: Observable<Scene>;
  31290. /**
  31291. * An event triggered before draw calls are ready to be sent
  31292. */
  31293. onBeforeDrawPhaseObservable: Observable<Scene>;
  31294. /**
  31295. * An event triggered after draw calls have been sent
  31296. */
  31297. onAfterDrawPhaseObservable: Observable<Scene>;
  31298. /**
  31299. * An event triggered when the scene is ready
  31300. */
  31301. onReadyObservable: Observable<Scene>;
  31302. /**
  31303. * An event triggered before rendering a camera
  31304. */
  31305. onBeforeCameraRenderObservable: Observable<Camera>;
  31306. private _onBeforeCameraRenderObserver;
  31307. /** Sets a function to be executed before rendering a camera*/
  31308. beforeCameraRender: () => void;
  31309. /**
  31310. * An event triggered after rendering a camera
  31311. */
  31312. onAfterCameraRenderObservable: Observable<Camera>;
  31313. private _onAfterCameraRenderObserver;
  31314. /** Sets a function to be executed after rendering a camera*/
  31315. afterCameraRender: () => void;
  31316. /**
  31317. * An event triggered when active meshes evaluation is about to start
  31318. */
  31319. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31320. /**
  31321. * An event triggered when active meshes evaluation is done
  31322. */
  31323. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31324. /**
  31325. * An event triggered when particles rendering is about to start
  31326. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31327. */
  31328. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31329. /**
  31330. * An event triggered when particles rendering is done
  31331. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31332. */
  31333. onAfterParticlesRenderingObservable: Observable<Scene>;
  31334. /**
  31335. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31336. */
  31337. onDataLoadedObservable: Observable<Scene>;
  31338. /**
  31339. * An event triggered when a camera is created
  31340. */
  31341. onNewCameraAddedObservable: Observable<Camera>;
  31342. /**
  31343. * An event triggered when a camera is removed
  31344. */
  31345. onCameraRemovedObservable: Observable<Camera>;
  31346. /**
  31347. * An event triggered when a light is created
  31348. */
  31349. onNewLightAddedObservable: Observable<Light>;
  31350. /**
  31351. * An event triggered when a light is removed
  31352. */
  31353. onLightRemovedObservable: Observable<Light>;
  31354. /**
  31355. * An event triggered when a geometry is created
  31356. */
  31357. onNewGeometryAddedObservable: Observable<Geometry>;
  31358. /**
  31359. * An event triggered when a geometry is removed
  31360. */
  31361. onGeometryRemovedObservable: Observable<Geometry>;
  31362. /**
  31363. * An event triggered when a transform node is created
  31364. */
  31365. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31366. /**
  31367. * An event triggered when a transform node is removed
  31368. */
  31369. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31370. /**
  31371. * An event triggered when a mesh is created
  31372. */
  31373. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31374. /**
  31375. * An event triggered when a mesh is removed
  31376. */
  31377. onMeshRemovedObservable: Observable<AbstractMesh>;
  31378. /**
  31379. * An event triggered when a skeleton is created
  31380. */
  31381. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31382. /**
  31383. * An event triggered when a skeleton is removed
  31384. */
  31385. onSkeletonRemovedObservable: Observable<Skeleton>;
  31386. /**
  31387. * An event triggered when a material is created
  31388. */
  31389. onNewMaterialAddedObservable: Observable<Material>;
  31390. /**
  31391. * An event triggered when a material is removed
  31392. */
  31393. onMaterialRemovedObservable: Observable<Material>;
  31394. /**
  31395. * An event triggered when a texture is created
  31396. */
  31397. onNewTextureAddedObservable: Observable<BaseTexture>;
  31398. /**
  31399. * An event triggered when a texture is removed
  31400. */
  31401. onTextureRemovedObservable: Observable<BaseTexture>;
  31402. /**
  31403. * An event triggered when render targets are about to be rendered
  31404. * Can happen multiple times per frame.
  31405. */
  31406. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31407. /**
  31408. * An event triggered when render targets were rendered.
  31409. * Can happen multiple times per frame.
  31410. */
  31411. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31412. /**
  31413. * An event triggered before calculating deterministic simulation step
  31414. */
  31415. onBeforeStepObservable: Observable<Scene>;
  31416. /**
  31417. * An event triggered after calculating deterministic simulation step
  31418. */
  31419. onAfterStepObservable: Observable<Scene>;
  31420. /**
  31421. * An event triggered when the activeCamera property is updated
  31422. */
  31423. onActiveCameraChanged: Observable<Scene>;
  31424. /**
  31425. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31426. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31427. * 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)
  31428. */
  31429. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31430. /**
  31431. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31432. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31433. * 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)
  31434. */
  31435. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31436. /**
  31437. * This Observable will when a mesh has been imported into the scene.
  31438. */
  31439. onMeshImportedObservable: Observable<AbstractMesh>;
  31440. /**
  31441. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31442. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31443. */
  31444. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31445. /** @hidden */ registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31446. /**
  31447. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31448. */
  31449. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31450. /**
  31451. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31452. */
  31453. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31454. /**
  31455. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31456. */
  31457. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31458. private _onPointerMove;
  31459. private _onPointerDown;
  31460. private _onPointerUp;
  31461. /** Callback called when a pointer move is detected */
  31462. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31463. /** Callback called when a pointer down is detected */
  31464. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31465. /** Callback called when a pointer up is detected */
  31466. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31467. /** Callback called when a pointer pick is detected */
  31468. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31469. /**
  31470. * 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).
  31471. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31472. */
  31473. onPrePointerObservable: Observable<PointerInfoPre>;
  31474. /**
  31475. * Observable event triggered each time an input event is received from the rendering canvas
  31476. */
  31477. onPointerObservable: Observable<PointerInfo>;
  31478. /**
  31479. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31480. */
  31481. readonly unTranslatedPointer: Vector2;
  31482. /** The distance in pixel that you have to move to prevent some events */
  31483. static DragMovementThreshold: number;
  31484. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31485. static LongPressDelay: number;
  31486. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31487. static DoubleClickDelay: number;
  31488. /** If you need to check double click without raising a single click at first click, enable this flag */
  31489. static ExclusiveDoubleClickMode: boolean;
  31490. private _initClickEvent;
  31491. private _initActionManager;
  31492. private _delayedSimpleClick;
  31493. private _delayedSimpleClickTimeout;
  31494. private _previousDelayedSimpleClickTimeout;
  31495. private _meshPickProceed;
  31496. private _previousButtonPressed;
  31497. private _currentPickResult;
  31498. private _previousPickResult;
  31499. private _totalPointersPressed;
  31500. private _doubleClickOccured;
  31501. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31502. cameraToUseForPointers: Nullable<Camera>;
  31503. private _pointerX;
  31504. private _pointerY;
  31505. private _unTranslatedPointerX;
  31506. private _unTranslatedPointerY;
  31507. private _startingPointerPosition;
  31508. private _previousStartingPointerPosition;
  31509. private _startingPointerTime;
  31510. private _previousStartingPointerTime;
  31511. private _pointerCaptures;
  31512. private _timeAccumulator;
  31513. private _currentStepId;
  31514. private _currentInternalStep;
  31515. /** @hidden */ mirroredCameraPosition: Nullable<Vector3>;
  31516. /**
  31517. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31518. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31519. */
  31520. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31521. /**
  31522. * Observable event triggered each time an keyboard event is received from the hosting window
  31523. */
  31524. onKeyboardObservable: Observable<KeyboardInfo>;
  31525. private _onKeyDown;
  31526. private _onKeyUp;
  31527. private _onCanvasFocusObserver;
  31528. private _onCanvasBlurObserver;
  31529. private _useRightHandedSystem;
  31530. /**
  31531. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31532. */
  31533. useRightHandedSystem: boolean;
  31534. /**
  31535. * Sets the step Id used by deterministic lock step
  31536. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31537. * @param newStepId defines the step Id
  31538. */
  31539. setStepId(newStepId: number): void;
  31540. /**
  31541. * Gets the step Id used by deterministic lock step
  31542. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31543. * @returns the step Id
  31544. */
  31545. getStepId(): number;
  31546. /**
  31547. * Gets the internal step used by deterministic lock step
  31548. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31549. * @returns the internal step
  31550. */
  31551. getInternalStep(): number;
  31552. private _fogEnabled;
  31553. /**
  31554. * Gets or sets a boolean indicating if fog is enabled on this scene
  31555. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31556. * (Default is true)
  31557. */
  31558. fogEnabled: boolean;
  31559. private _fogMode;
  31560. /**
  31561. * Gets or sets the fog mode to use
  31562. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31563. * | mode | value |
  31564. * | --- | --- |
  31565. * | FOGMODE_NONE | 0 |
  31566. * | FOGMODE_EXP | 1 |
  31567. * | FOGMODE_EXP2 | 2 |
  31568. * | FOGMODE_LINEAR | 3 |
  31569. */
  31570. fogMode: number;
  31571. /**
  31572. * Gets or sets the fog color to use
  31573. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31574. * (Default is Color3(0.2, 0.2, 0.3))
  31575. */
  31576. fogColor: Color3;
  31577. /**
  31578. * Gets or sets the fog density to use
  31579. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31580. * (Default is 0.1)
  31581. */
  31582. fogDensity: number;
  31583. /**
  31584. * Gets or sets the fog start distance to use
  31585. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31586. * (Default is 0)
  31587. */
  31588. fogStart: number;
  31589. /**
  31590. * Gets or sets the fog end distance to use
  31591. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31592. * (Default is 1000)
  31593. */
  31594. fogEnd: number;
  31595. private _shadowsEnabled;
  31596. /**
  31597. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31598. */
  31599. shadowsEnabled: boolean;
  31600. private _lightsEnabled;
  31601. /**
  31602. * Gets or sets a boolean indicating if lights are enabled on this scene
  31603. */
  31604. lightsEnabled: boolean;
  31605. /** All of the active cameras added to this scene. */
  31606. activeCameras: Camera[];
  31607. /** @hidden */ activeCamera: Nullable<Camera>;
  31608. /** Gets or sets the current active camera */
  31609. activeCamera: Nullable<Camera>;
  31610. private _defaultMaterial;
  31611. /** The default material used on meshes when no material is affected */
  31612. /** The default material used on meshes when no material is affected */
  31613. defaultMaterial: Material;
  31614. private _texturesEnabled;
  31615. /**
  31616. * Gets or sets a boolean indicating if textures are enabled on this scene
  31617. */
  31618. texturesEnabled: boolean;
  31619. /**
  31620. * Gets or sets a boolean indicating if particles are enabled on this scene
  31621. */
  31622. particlesEnabled: boolean;
  31623. /**
  31624. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31625. */
  31626. spritesEnabled: boolean;
  31627. private _skeletonsEnabled;
  31628. /**
  31629. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31630. */
  31631. skeletonsEnabled: boolean;
  31632. /**
  31633. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31634. */
  31635. lensFlaresEnabled: boolean;
  31636. /**
  31637. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31639. */
  31640. collisionsEnabled: boolean;
  31641. private _collisionCoordinator;
  31642. /** @hidden */
  31643. readonly collisionCoordinator: ICollisionCoordinator;
  31644. /**
  31645. * Defines the gravity applied to this scene (used only for collisions)
  31646. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31647. */
  31648. gravity: Vector3;
  31649. /**
  31650. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31651. */
  31652. postProcessesEnabled: boolean;
  31653. /**
  31654. * The list of postprocesses added to the scene
  31655. */
  31656. postProcesses: PostProcess[];
  31657. /**
  31658. * Gets the current postprocess manager
  31659. */
  31660. postProcessManager: PostProcessManager;
  31661. /**
  31662. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31663. */
  31664. renderTargetsEnabled: boolean;
  31665. /**
  31666. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31667. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31668. */
  31669. dumpNextRenderTargets: boolean;
  31670. /**
  31671. * The list of user defined render targets added to the scene
  31672. */
  31673. customRenderTargets: RenderTargetTexture[];
  31674. /**
  31675. * Defines if texture loading must be delayed
  31676. * If true, textures will only be loaded when they need to be rendered
  31677. */
  31678. useDelayedTextureLoading: boolean;
  31679. /**
  31680. * Gets the list of meshes imported to the scene through SceneLoader
  31681. */
  31682. importedMeshesFiles: String[];
  31683. /**
  31684. * Gets or sets a boolean indicating if probes are enabled on this scene
  31685. */
  31686. probesEnabled: boolean;
  31687. /**
  31688. * Gets or sets the current offline provider to use to store scene data
  31689. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31690. */
  31691. offlineProvider: IOfflineProvider;
  31692. /**
  31693. * Gets or sets the action manager associated with the scene
  31694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31695. */
  31696. actionManager: AbstractActionManager;
  31697. private _meshesForIntersections;
  31698. /**
  31699. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31700. */
  31701. proceduralTexturesEnabled: boolean;
  31702. private _engine;
  31703. private _totalVertices;
  31704. /** @hidden */ activeIndices: PerfCounter;
  31705. /** @hidden */ activeParticles: PerfCounter;
  31706. /** @hidden */ activeBones: PerfCounter;
  31707. private _animationRatio;
  31708. /** @hidden */ animationTimeLast: number;
  31709. /** @hidden */ animationTime: number;
  31710. /**
  31711. * Gets or sets a general scale for animation speed
  31712. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31713. */
  31714. animationTimeScale: number;
  31715. /** @hidden */ cachedMaterial: Nullable<Material>;
  31716. /** @hidden */ cachedEffect: Nullable<Effect>;
  31717. /** @hidden */ cachedVisibility: Nullable<number>;
  31718. private _renderId;
  31719. private _frameId;
  31720. private _executeWhenReadyTimeoutId;
  31721. private _intermediateRendering;
  31722. private _viewUpdateFlag;
  31723. private _projectionUpdateFlag;
  31724. /** @hidden */ toBeDisposed: Nullable<IDisposable>[];
  31725. private _activeRequests;
  31726. /** @hidden */ pendingData: any[];
  31727. private _isDisposed;
  31728. /**
  31729. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31730. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31731. */
  31732. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31733. private _activeMeshes;
  31734. private _processedMaterials;
  31735. private _renderTargets;
  31736. /** @hidden */ activeParticleSystems: SmartArray<IParticleSystem>;
  31737. private _activeSkeletons;
  31738. private _softwareSkinnedMeshes;
  31739. private _renderingManager;
  31740. /** @hidden */ activeAnimatables: Animatable[];
  31741. private _transformMatrix;
  31742. private _sceneUbo;
  31743. /** @hidden */ viewMatrix: Matrix;
  31744. private _projectionMatrix;
  31745. private _wheelEventName;
  31746. /** @hidden */ forcedViewPosition: Nullable<Vector3>;
  31747. /** @hidden */ frustumPlanes: Plane[];
  31748. /**
  31749. * Gets the list of frustum planes (built from the active camera)
  31750. */
  31751. readonly frustumPlanes: Plane[];
  31752. /**
  31753. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31754. * This is useful if there are more lights that the maximum simulteanous authorized
  31755. */
  31756. requireLightSorting: boolean;
  31757. /** @hidden */
  31758. readonly useMaterialMeshMap: boolean;
  31759. /** @hidden */
  31760. readonly useClonedMeshhMap: boolean;
  31761. private _pointerOverMesh;
  31762. private _pickedDownMesh;
  31763. private _pickedUpMesh;
  31764. private _externalData;
  31765. private _uid;
  31766. /**
  31767. * @hidden
  31768. * Backing store of defined scene components.
  31769. */ components: ISceneComponent[];
  31770. /**
  31771. * @hidden
  31772. * Backing store of defined scene components.
  31773. */ serializableComponents: ISceneSerializableComponent[];
  31774. /**
  31775. * List of components to register on the next registration step.
  31776. */
  31777. private _transientComponents;
  31778. /**
  31779. * Registers the transient components if needed.
  31780. */
  31781. private _registerTransientComponents;
  31782. /**
  31783. * @hidden
  31784. * Add a component to the scene.
  31785. * Note that the ccomponent could be registered on th next frame if this is called after
  31786. * the register component stage.
  31787. * @param component Defines the component to add to the scene
  31788. */ addComponent(component: ISceneComponent): void;
  31789. /**
  31790. * @hidden
  31791. * Gets a component from the scene.
  31792. * @param name defines the name of the component to retrieve
  31793. * @returns the component or null if not present
  31794. */ getComponent(name: string): Nullable<ISceneComponent>;
  31795. /**
  31796. * @hidden
  31797. * Defines the actions happening before camera updates.
  31798. */ beforeCameraUpdateStage: Stage<SimpleStageAction>;
  31799. /**
  31800. * @hidden
  31801. * Defines the actions happening before clear the canvas.
  31802. */ beforeClearStage: Stage<SimpleStageAction>;
  31803. /**
  31804. * @hidden
  31805. * Defines the actions when collecting render targets for the frame.
  31806. */ gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31807. /**
  31808. * @hidden
  31809. * Defines the actions happening for one camera in the frame.
  31810. */ gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  31811. /**
  31812. * @hidden
  31813. * Defines the actions happening during the per mesh ready checks.
  31814. */ isReadyForMeshStage: Stage<MeshStageAction>;
  31815. /**
  31816. * @hidden
  31817. * Defines the actions happening before evaluate active mesh checks.
  31818. */ beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  31819. /**
  31820. * @hidden
  31821. * Defines the actions happening during the evaluate sub mesh checks.
  31822. */ evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  31823. /**
  31824. * @hidden
  31825. * Defines the actions happening during the active mesh stage.
  31826. */ activeMeshStage: Stage<ActiveMeshStageAction>;
  31827. /**
  31828. * @hidden
  31829. * Defines the actions happening during the per camera render target step.
  31830. */ cameraDrawRenderTargetStage: Stage<CameraStageAction>;
  31831. /**
  31832. * @hidden
  31833. * Defines the actions happening just before the active camera is drawing.
  31834. */ beforeCameraDrawStage: Stage<CameraStageAction>;
  31835. /**
  31836. * @hidden
  31837. * Defines the actions happening just before a render target is drawing.
  31838. */ beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31839. /**
  31840. * @hidden
  31841. * Defines the actions happening just before a rendering group is drawing.
  31842. */ beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31843. /**
  31844. * @hidden
  31845. * Defines the actions happening just before a mesh is drawing.
  31846. */ beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31847. /**
  31848. * @hidden
  31849. * Defines the actions happening just after a mesh has been drawn.
  31850. */ afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  31851. /**
  31852. * @hidden
  31853. * Defines the actions happening just after a rendering group has been drawn.
  31854. */ afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  31855. /**
  31856. * @hidden
  31857. * Defines the actions happening just after the active camera has been drawn.
  31858. */ afterCameraDrawStage: Stage<CameraStageAction>;
  31859. /**
  31860. * @hidden
  31861. * Defines the actions happening just after a render target has been drawn.
  31862. */ afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  31863. /**
  31864. * @hidden
  31865. * Defines the actions happening just after rendering all cameras and computing intersections.
  31866. */ afterRenderStage: Stage<SimpleStageAction>;
  31867. /**
  31868. * @hidden
  31869. * Defines the actions happening when a pointer move event happens.
  31870. */ pointerMoveStage: Stage<PointerMoveStageAction>;
  31871. /**
  31872. * @hidden
  31873. * Defines the actions happening when a pointer down event happens.
  31874. */ pointerDownStage: Stage<PointerUpDownStageAction>;
  31875. /**
  31876. * @hidden
  31877. * Defines the actions happening when a pointer up event happens.
  31878. */ pointerUpStage: Stage<PointerUpDownStageAction>;
  31879. /**
  31880. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  31881. */
  31882. private geometriesByUniqueId;
  31883. /**
  31884. * Creates a new Scene
  31885. * @param engine defines the engine to use to render this scene
  31886. * @param options defines the scene options
  31887. */
  31888. constructor(engine: Engine, options?: SceneOptions);
  31889. /**
  31890. * Gets a string idenfifying the name of the class
  31891. * @returns "Scene" string
  31892. */
  31893. getClassName(): string;
  31894. private _defaultMeshCandidates;
  31895. /**
  31896. * @hidden
  31897. */ getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  31898. private _defaultSubMeshCandidates;
  31899. /**
  31900. * @hidden
  31901. */ getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  31902. /**
  31903. * Sets the default candidate providers for the scene.
  31904. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  31905. * and getCollidingSubMeshCandidates to their default function
  31906. */
  31907. setDefaultCandidateProviders(): void;
  31908. /**
  31909. * Gets the mesh that is currently under the pointer
  31910. */
  31911. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31912. /**
  31913. * Gets or sets the current on-screen X position of the pointer
  31914. */
  31915. pointerX: number;
  31916. /**
  31917. * Gets or sets the current on-screen Y position of the pointer
  31918. */
  31919. pointerY: number;
  31920. /**
  31921. * Gets the cached material (ie. the latest rendered one)
  31922. * @returns the cached material
  31923. */
  31924. getCachedMaterial(): Nullable<Material>;
  31925. /**
  31926. * Gets the cached effect (ie. the latest rendered one)
  31927. * @returns the cached effect
  31928. */
  31929. getCachedEffect(): Nullable<Effect>;
  31930. /**
  31931. * Gets the cached visibility state (ie. the latest rendered one)
  31932. * @returns the cached visibility state
  31933. */
  31934. getCachedVisibility(): Nullable<number>;
  31935. /**
  31936. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  31937. * @param material defines the current material
  31938. * @param effect defines the current effect
  31939. * @param visibility defines the current visibility state
  31940. * @returns true if one parameter is not cached
  31941. */
  31942. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  31943. /**
  31944. * Gets the engine associated with the scene
  31945. * @returns an Engine
  31946. */
  31947. getEngine(): Engine;
  31948. /**
  31949. * Gets the total number of vertices rendered per frame
  31950. * @returns the total number of vertices rendered per frame
  31951. */
  31952. getTotalVertices(): number;
  31953. /**
  31954. * Gets the performance counter for total vertices
  31955. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31956. */
  31957. readonly totalVerticesPerfCounter: PerfCounter;
  31958. /**
  31959. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  31960. * @returns the total number of active indices rendered per frame
  31961. */
  31962. getActiveIndices(): number;
  31963. /**
  31964. * Gets the performance counter for active indices
  31965. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31966. */
  31967. readonly totalActiveIndicesPerfCounter: PerfCounter;
  31968. /**
  31969. * Gets the total number of active particles rendered per frame
  31970. * @returns the total number of active particles rendered per frame
  31971. */
  31972. getActiveParticles(): number;
  31973. /**
  31974. * Gets the performance counter for active particles
  31975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31976. */
  31977. readonly activeParticlesPerfCounter: PerfCounter;
  31978. /**
  31979. * Gets the total number of active bones rendered per frame
  31980. * @returns the total number of active bones rendered per frame
  31981. */
  31982. getActiveBones(): number;
  31983. /**
  31984. * Gets the performance counter for active bones
  31985. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  31986. */
  31987. readonly activeBonesPerfCounter: PerfCounter;
  31988. /**
  31989. * Gets the array of active meshes
  31990. * @returns an array of AbstractMesh
  31991. */
  31992. getActiveMeshes(): SmartArray<AbstractMesh>;
  31993. /**
  31994. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  31995. * @returns a number
  31996. */
  31997. getAnimationRatio(): number;
  31998. /**
  31999. * Gets an unique Id for the current render phase
  32000. * @returns a number
  32001. */
  32002. getRenderId(): number;
  32003. /**
  32004. * Gets an unique Id for the current frame
  32005. * @returns a number
  32006. */
  32007. getFrameId(): number;
  32008. /** Call this function if you want to manually increment the render Id*/
  32009. incrementRenderId(): void;
  32010. private _updatePointerPosition;
  32011. private _createUbo;
  32012. private _setRayOnPointerInfo;
  32013. /**
  32014. * Use this method to simulate a pointer move on a mesh
  32015. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32016. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32017. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32018. * @returns the current scene
  32019. */
  32020. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32021. private _processPointerMove;
  32022. private _checkPrePointerObservable;
  32023. /**
  32024. * Use this method to simulate a pointer down on a mesh
  32025. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32026. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32027. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32028. * @returns the current scene
  32029. */
  32030. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32031. private _processPointerDown;
  32032. /**
  32033. * Use this method to simulate a pointer up on a mesh
  32034. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32035. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32036. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32037. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32038. * @returns the current scene
  32039. */
  32040. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32041. private _processPointerUp;
  32042. /**
  32043. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32044. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32045. * @returns true if the pointer was captured
  32046. */
  32047. isPointerCaptured(pointerId?: number): boolean;
  32048. /** @hidden */ isPointerSwiping(): boolean;
  32049. /**
  32050. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32051. * @param attachUp defines if you want to attach events to pointerup
  32052. * @param attachDown defines if you want to attach events to pointerdown
  32053. * @param attachMove defines if you want to attach events to pointermove
  32054. */
  32055. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32056. /** Detaches all event handlers*/
  32057. detachControl(): void;
  32058. /**
  32059. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32060. * Delay loaded resources are not taking in account
  32061. * @return true if all required resources are ready
  32062. */
  32063. isReady(): boolean;
  32064. /** Resets all cached information relative to material (including effect and visibility) */
  32065. resetCachedMaterial(): void;
  32066. /**
  32067. * Registers a function to be called before every frame render
  32068. * @param func defines the function to register
  32069. */
  32070. registerBeforeRender(func: () => void): void;
  32071. /**
  32072. * Unregisters a function called before every frame render
  32073. * @param func defines the function to unregister
  32074. */
  32075. unregisterBeforeRender(func: () => void): void;
  32076. /**
  32077. * Registers a function to be called after every frame render
  32078. * @param func defines the function to register
  32079. */
  32080. registerAfterRender(func: () => void): void;
  32081. /**
  32082. * Unregisters a function called after every frame render
  32083. * @param func defines the function to unregister
  32084. */
  32085. unregisterAfterRender(func: () => void): void;
  32086. private _executeOnceBeforeRender;
  32087. /**
  32088. * The provided function will run before render once and will be disposed afterwards.
  32089. * A timeout delay can be provided so that the function will be executed in N ms.
  32090. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32091. * @param func The function to be executed.
  32092. * @param timeout optional delay in ms
  32093. */
  32094. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32095. /** @hidden */ addPendingData(data: any): void;
  32096. /** @hidden */ removePendingData(data: any): void;
  32097. /**
  32098. * Returns the number of items waiting to be loaded
  32099. * @returns the number of items waiting to be loaded
  32100. */
  32101. getWaitingItemsCount(): number;
  32102. /**
  32103. * Returns a boolean indicating if the scene is still loading data
  32104. */
  32105. readonly isLoading: boolean;
  32106. /**
  32107. * Registers a function to be executed when the scene is ready
  32108. * @param {Function} func - the function to be executed
  32109. */
  32110. executeWhenReady(func: () => void): void;
  32111. /**
  32112. * Returns a promise that resolves when the scene is ready
  32113. * @returns A promise that resolves when the scene is ready
  32114. */
  32115. whenReadyAsync(): Promise<void>;
  32116. /** @hidden */ checkIsReady(): void;
  32117. /**
  32118. * Gets all animatable attached to the scene
  32119. */
  32120. readonly animatables: Animatable[];
  32121. /**
  32122. * Resets the last animation time frame.
  32123. * Useful to override when animations start running when loading a scene for the first time.
  32124. */
  32125. resetLastAnimationTimeFrame(): void;
  32126. /**
  32127. * Gets the current view matrix
  32128. * @returns a Matrix
  32129. */
  32130. getViewMatrix(): Matrix;
  32131. /**
  32132. * Gets the current projection matrix
  32133. * @returns a Matrix
  32134. */
  32135. getProjectionMatrix(): Matrix;
  32136. /**
  32137. * Gets the current transform matrix
  32138. * @returns a Matrix made of View * Projection
  32139. */
  32140. getTransformMatrix(): Matrix;
  32141. /**
  32142. * Sets the current transform matrix
  32143. * @param viewL defines the View matrix to use
  32144. * @param projectionL defines the Projection matrix to use
  32145. * @param viewR defines the right View matrix to use (if provided)
  32146. * @param projectionR defines the right Projection matrix to use (if provided)
  32147. */
  32148. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32149. /**
  32150. * Gets the uniform buffer used to store scene data
  32151. * @returns a UniformBuffer
  32152. */
  32153. getSceneUniformBuffer(): UniformBuffer;
  32154. /**
  32155. * Gets an unique (relatively to the current scene) Id
  32156. * @returns an unique number for the scene
  32157. */
  32158. getUniqueId(): number;
  32159. /**
  32160. * Add a mesh to the list of scene's meshes
  32161. * @param newMesh defines the mesh to add
  32162. * @param recursive if all child meshes should also be added to the scene
  32163. */
  32164. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32165. /**
  32166. * Remove a mesh for the list of scene's meshes
  32167. * @param toRemove defines the mesh to remove
  32168. * @param recursive if all child meshes should also be removed from the scene
  32169. * @returns the index where the mesh was in the mesh list
  32170. */
  32171. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32172. /**
  32173. * Add a transform node to the list of scene's transform nodes
  32174. * @param newTransformNode defines the transform node to add
  32175. */
  32176. addTransformNode(newTransformNode: TransformNode): void;
  32177. /**
  32178. * Remove a transform node for the list of scene's transform nodes
  32179. * @param toRemove defines the transform node to remove
  32180. * @returns the index where the transform node was in the transform node list
  32181. */
  32182. removeTransformNode(toRemove: TransformNode): number;
  32183. /**
  32184. * Remove a skeleton for the list of scene's skeletons
  32185. * @param toRemove defines the skeleton to remove
  32186. * @returns the index where the skeleton was in the skeleton list
  32187. */
  32188. removeSkeleton(toRemove: Skeleton): number;
  32189. /**
  32190. * Remove a morph target for the list of scene's morph targets
  32191. * @param toRemove defines the morph target to remove
  32192. * @returns the index where the morph target was in the morph target list
  32193. */
  32194. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32195. /**
  32196. * Remove a light for the list of scene's lights
  32197. * @param toRemove defines the light to remove
  32198. * @returns the index where the light was in the light list
  32199. */
  32200. removeLight(toRemove: Light): number;
  32201. /**
  32202. * Remove a camera for the list of scene's cameras
  32203. * @param toRemove defines the camera to remove
  32204. * @returns the index where the camera was in the camera list
  32205. */
  32206. removeCamera(toRemove: Camera): number;
  32207. /**
  32208. * Remove a particle system for the list of scene's particle systems
  32209. * @param toRemove defines the particle system to remove
  32210. * @returns the index where the particle system was in the particle system list
  32211. */
  32212. removeParticleSystem(toRemove: IParticleSystem): number;
  32213. /**
  32214. * Remove a animation for the list of scene's animations
  32215. * @param toRemove defines the animation to remove
  32216. * @returns the index where the animation was in the animation list
  32217. */
  32218. removeAnimation(toRemove: Animation): number;
  32219. /**
  32220. * Removes the given animation group from this scene.
  32221. * @param toRemove The animation group to remove
  32222. * @returns The index of the removed animation group
  32223. */
  32224. removeAnimationGroup(toRemove: AnimationGroup): number;
  32225. /**
  32226. * Removes the given multi-material from this scene.
  32227. * @param toRemove The multi-material to remove
  32228. * @returns The index of the removed multi-material
  32229. */
  32230. removeMultiMaterial(toRemove: MultiMaterial): number;
  32231. /**
  32232. * Removes the given material from this scene.
  32233. * @param toRemove The material to remove
  32234. * @returns The index of the removed material
  32235. */
  32236. removeMaterial(toRemove: Material): number;
  32237. /**
  32238. * Removes the given action manager from this scene.
  32239. * @param toRemove The action manager to remove
  32240. * @returns The index of the removed action manager
  32241. */
  32242. removeActionManager(toRemove: AbstractActionManager): number;
  32243. /**
  32244. * Removes the given texture from this scene.
  32245. * @param toRemove The texture to remove
  32246. * @returns The index of the removed texture
  32247. */
  32248. removeTexture(toRemove: BaseTexture): number;
  32249. /**
  32250. * Adds the given light to this scene
  32251. * @param newLight The light to add
  32252. */
  32253. addLight(newLight: Light): void;
  32254. /**
  32255. * Sorts the list list based on light priorities
  32256. */
  32257. sortLightsByPriority(): void;
  32258. /**
  32259. * Adds the given camera to this scene
  32260. * @param newCamera The camera to add
  32261. */
  32262. addCamera(newCamera: Camera): void;
  32263. /**
  32264. * Adds the given skeleton to this scene
  32265. * @param newSkeleton The skeleton to add
  32266. */
  32267. addSkeleton(newSkeleton: Skeleton): void;
  32268. /**
  32269. * Adds the given particle system to this scene
  32270. * @param newParticleSystem The particle system to add
  32271. */
  32272. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32273. /**
  32274. * Adds the given animation to this scene
  32275. * @param newAnimation The animation to add
  32276. */
  32277. addAnimation(newAnimation: Animation): void;
  32278. /**
  32279. * Adds the given animation group to this scene.
  32280. * @param newAnimationGroup The animation group to add
  32281. */
  32282. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32283. /**
  32284. * Adds the given multi-material to this scene
  32285. * @param newMultiMaterial The multi-material to add
  32286. */
  32287. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32288. /**
  32289. * Adds the given material to this scene
  32290. * @param newMaterial The material to add
  32291. */
  32292. addMaterial(newMaterial: Material): void;
  32293. /**
  32294. * Adds the given morph target to this scene
  32295. * @param newMorphTargetManager The morph target to add
  32296. */
  32297. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32298. /**
  32299. * Adds the given geometry to this scene
  32300. * @param newGeometry The geometry to add
  32301. */
  32302. addGeometry(newGeometry: Geometry): void;
  32303. /**
  32304. * Adds the given action manager to this scene
  32305. * @param newActionManager The action manager to add
  32306. */
  32307. addActionManager(newActionManager: AbstractActionManager): void;
  32308. /**
  32309. * Adds the given texture to this scene.
  32310. * @param newTexture The texture to add
  32311. */
  32312. addTexture(newTexture: BaseTexture): void;
  32313. /**
  32314. * Switch active camera
  32315. * @param newCamera defines the new active camera
  32316. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32317. */
  32318. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32319. /**
  32320. * sets the active camera of the scene using its ID
  32321. * @param id defines the camera's ID
  32322. * @return the new active camera or null if none found.
  32323. */
  32324. setActiveCameraByID(id: string): Nullable<Camera>;
  32325. /**
  32326. * sets the active camera of the scene using its name
  32327. * @param name defines the camera's name
  32328. * @returns the new active camera or null if none found.
  32329. */
  32330. setActiveCameraByName(name: string): Nullable<Camera>;
  32331. /**
  32332. * get an animation group using its name
  32333. * @param name defines the material's name
  32334. * @return the animation group or null if none found.
  32335. */
  32336. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32337. /**
  32338. * Get a material using its unique id
  32339. * @param uniqueId defines the material's unique id
  32340. * @return the material or null if none found.
  32341. */
  32342. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32343. /**
  32344. * get a material using its id
  32345. * @param id defines the material's ID
  32346. * @return the material or null if none found.
  32347. */
  32348. getMaterialByID(id: string): Nullable<Material>;
  32349. /**
  32350. * Gets a material using its name
  32351. * @param name defines the material's name
  32352. * @return the material or null if none found.
  32353. */
  32354. getMaterialByName(name: string): Nullable<Material>;
  32355. /**
  32356. * Gets a camera using its id
  32357. * @param id defines the id to look for
  32358. * @returns the camera or null if not found
  32359. */
  32360. getCameraByID(id: string): Nullable<Camera>;
  32361. /**
  32362. * Gets a camera using its unique id
  32363. * @param uniqueId defines the unique id to look for
  32364. * @returns the camera or null if not found
  32365. */
  32366. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32367. /**
  32368. * Gets a camera using its name
  32369. * @param name defines the camera's name
  32370. * @return the camera or null if none found.
  32371. */
  32372. getCameraByName(name: string): Nullable<Camera>;
  32373. /**
  32374. * Gets a bone using its id
  32375. * @param id defines the bone's id
  32376. * @return the bone or null if not found
  32377. */
  32378. getBoneByID(id: string): Nullable<Bone>;
  32379. /**
  32380. * Gets a bone using its id
  32381. * @param name defines the bone's name
  32382. * @return the bone or null if not found
  32383. */
  32384. getBoneByName(name: string): Nullable<Bone>;
  32385. /**
  32386. * Gets a light node using its name
  32387. * @param name defines the the light's name
  32388. * @return the light or null if none found.
  32389. */
  32390. getLightByName(name: string): Nullable<Light>;
  32391. /**
  32392. * Gets a light node using its id
  32393. * @param id defines the light's id
  32394. * @return the light or null if none found.
  32395. */
  32396. getLightByID(id: string): Nullable<Light>;
  32397. /**
  32398. * Gets a light node using its scene-generated unique ID
  32399. * @param uniqueId defines the light's unique id
  32400. * @return the light or null if none found.
  32401. */
  32402. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32403. /**
  32404. * Gets a particle system by id
  32405. * @param id defines the particle system id
  32406. * @return the corresponding system or null if none found
  32407. */
  32408. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32409. /**
  32410. * Gets a geometry using its ID
  32411. * @param id defines the geometry's id
  32412. * @return the geometry or null if none found.
  32413. */
  32414. getGeometryByID(id: string): Nullable<Geometry>;
  32415. private _getGeometryByUniqueID;
  32416. /**
  32417. * Add a new geometry to this scene
  32418. * @param geometry defines the geometry to be added to the scene.
  32419. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32420. * @return a boolean defining if the geometry was added or not
  32421. */
  32422. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32423. /**
  32424. * Removes an existing geometry
  32425. * @param geometry defines the geometry to be removed from the scene
  32426. * @return a boolean defining if the geometry was removed or not
  32427. */
  32428. removeGeometry(geometry: Geometry): boolean;
  32429. /**
  32430. * Gets the list of geometries attached to the scene
  32431. * @returns an array of Geometry
  32432. */
  32433. getGeometries(): Geometry[];
  32434. /**
  32435. * Gets the first added mesh found of a given ID
  32436. * @param id defines the id to search for
  32437. * @return the mesh found or null if not found at all
  32438. */
  32439. getMeshByID(id: string): Nullable<AbstractMesh>;
  32440. /**
  32441. * Gets a list of meshes using their id
  32442. * @param id defines the id to search for
  32443. * @returns a list of meshes
  32444. */
  32445. getMeshesByID(id: string): Array<AbstractMesh>;
  32446. /**
  32447. * Gets the first added transform node found of a given ID
  32448. * @param id defines the id to search for
  32449. * @return the found transform node or null if not found at all.
  32450. */
  32451. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32452. /**
  32453. * Gets a transform node with its auto-generated unique id
  32454. * @param uniqueId efines the unique id to search for
  32455. * @return the found transform node or null if not found at all.
  32456. */
  32457. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32458. /**
  32459. * Gets a list of transform nodes using their id
  32460. * @param id defines the id to search for
  32461. * @returns a list of transform nodes
  32462. */
  32463. getTransformNodesByID(id: string): Array<TransformNode>;
  32464. /**
  32465. * Gets a mesh with its auto-generated unique id
  32466. * @param uniqueId defines the unique id to search for
  32467. * @return the found mesh or null if not found at all.
  32468. */
  32469. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32470. /**
  32471. * Gets a the last added mesh using a given id
  32472. * @param id defines the id to search for
  32473. * @return the found mesh or null if not found at all.
  32474. */
  32475. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32476. /**
  32477. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32478. * @param id defines the id to search for
  32479. * @return the found node or null if not found at all
  32480. */
  32481. getLastEntryByID(id: string): Nullable<Node>;
  32482. /**
  32483. * Gets a node (Mesh, Camera, Light) using a given id
  32484. * @param id defines the id to search for
  32485. * @return the found node or null if not found at all
  32486. */
  32487. getNodeByID(id: string): Nullable<Node>;
  32488. /**
  32489. * Gets a node (Mesh, Camera, Light) using a given name
  32490. * @param name defines the name to search for
  32491. * @return the found node or null if not found at all.
  32492. */
  32493. getNodeByName(name: string): Nullable<Node>;
  32494. /**
  32495. * Gets a mesh using a given name
  32496. * @param name defines the name to search for
  32497. * @return the found mesh or null if not found at all.
  32498. */
  32499. getMeshByName(name: string): Nullable<AbstractMesh>;
  32500. /**
  32501. * Gets a transform node using a given name
  32502. * @param name defines the name to search for
  32503. * @return the found transform node or null if not found at all.
  32504. */
  32505. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32506. /**
  32507. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32508. * @param id defines the id to search for
  32509. * @return the found skeleton or null if not found at all.
  32510. */
  32511. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32512. /**
  32513. * Gets a skeleton using a given auto generated unique id
  32514. * @param uniqueId defines the unique id to search for
  32515. * @return the found skeleton or null if not found at all.
  32516. */
  32517. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32518. /**
  32519. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32520. * @param id defines the id to search for
  32521. * @return the found skeleton or null if not found at all.
  32522. */
  32523. getSkeletonById(id: string): Nullable<Skeleton>;
  32524. /**
  32525. * Gets a skeleton using a given name
  32526. * @param name defines the name to search for
  32527. * @return the found skeleton or null if not found at all.
  32528. */
  32529. getSkeletonByName(name: string): Nullable<Skeleton>;
  32530. /**
  32531. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32532. * @param id defines the id to search for
  32533. * @return the found morph target manager or null if not found at all.
  32534. */
  32535. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32536. /**
  32537. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32538. * @param id defines the id to search for
  32539. * @return the found morph target or null if not found at all.
  32540. */
  32541. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32542. /**
  32543. * Gets a boolean indicating if the given mesh is active
  32544. * @param mesh defines the mesh to look for
  32545. * @returns true if the mesh is in the active list
  32546. */
  32547. isActiveMesh(mesh: AbstractMesh): boolean;
  32548. /**
  32549. * Return a unique id as a string which can serve as an identifier for the scene
  32550. */
  32551. readonly uid: string;
  32552. /**
  32553. * Add an externaly attached data from its key.
  32554. * This method call will fail and return false, if such key already exists.
  32555. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32556. * @param key the unique key that identifies the data
  32557. * @param data the data object to associate to the key for this Engine instance
  32558. * @return true if no such key were already present and the data was added successfully, false otherwise
  32559. */
  32560. addExternalData<T>(key: string, data: T): boolean;
  32561. /**
  32562. * Get an externaly attached data from its key
  32563. * @param key the unique key that identifies the data
  32564. * @return the associated data, if present (can be null), or undefined if not present
  32565. */
  32566. getExternalData<T>(key: string): Nullable<T>;
  32567. /**
  32568. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32569. * @param key the unique key that identifies the data
  32570. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32571. * @return the associated data, can be null if the factory returned null.
  32572. */
  32573. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32574. /**
  32575. * Remove an externaly attached data from the Engine instance
  32576. * @param key the unique key that identifies the data
  32577. * @return true if the data was successfully removed, false if it doesn't exist
  32578. */
  32579. removeExternalData(key: string): boolean;
  32580. private _evaluateSubMesh;
  32581. /**
  32582. * Clear the processed materials smart array preventing retention point in material dispose.
  32583. */
  32584. freeProcessedMaterials(): void;
  32585. private _preventFreeActiveMeshesAndRenderingGroups;
  32586. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32587. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32588. * when disposing several meshes in a row or a hierarchy of meshes.
  32589. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32590. */
  32591. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32592. /**
  32593. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32594. */
  32595. freeActiveMeshes(): void;
  32596. /**
  32597. * Clear the info related to rendering groups preventing retention points during dispose.
  32598. */
  32599. freeRenderingGroups(): void;
  32600. /** @hidden */ isInIntermediateRendering(): boolean;
  32601. /**
  32602. * Lambda returning the list of potentially active meshes.
  32603. */
  32604. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32605. /**
  32606. * Lambda returning the list of potentially active sub meshes.
  32607. */
  32608. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32609. /**
  32610. * Lambda returning the list of potentially intersecting sub meshes.
  32611. */
  32612. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32613. /**
  32614. * Lambda returning the list of potentially colliding sub meshes.
  32615. */
  32616. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32617. private _activeMeshesFrozen;
  32618. /**
  32619. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32620. * @returns the current scene
  32621. */
  32622. freezeActiveMeshes(): Scene;
  32623. /**
  32624. * Use this function to restart evaluating active meshes on every frame
  32625. * @returns the current scene
  32626. */
  32627. unfreezeActiveMeshes(): Scene;
  32628. private _evaluateActiveMeshes;
  32629. private _activeMesh;
  32630. /**
  32631. * Update the transform matrix to update from the current active camera
  32632. * @param force defines a boolean used to force the update even if cache is up to date
  32633. */
  32634. updateTransformMatrix(force?: boolean): void;
  32635. private _bindFrameBuffer;
  32636. /** @hidden */ allowPostProcessClearColor: boolean;
  32637. /** @hidden */ renderForCamera(camera: Camera, rigParent?: Camera): void;
  32638. private _processSubCameras;
  32639. private _checkIntersections;
  32640. /** @hidden */ advancePhysicsEngineStep(step: number): void;
  32641. /**
  32642. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32643. */
  32644. getDeterministicFrameTime: () => number;
  32645. /** @hidden */ animate(): void;
  32646. /**
  32647. * Render the scene
  32648. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32649. */
  32650. render(updateCameras?: boolean): void;
  32651. /**
  32652. * Freeze all materials
  32653. * A frozen material will not be updatable but should be faster to render
  32654. */
  32655. freezeMaterials(): void;
  32656. /**
  32657. * Unfreeze all materials
  32658. * A frozen material will not be updatable but should be faster to render
  32659. */
  32660. unfreezeMaterials(): void;
  32661. /**
  32662. * Releases all held ressources
  32663. */
  32664. dispose(): void;
  32665. /**
  32666. * Gets if the scene is already disposed
  32667. */
  32668. readonly isDisposed: boolean;
  32669. /**
  32670. * Call this function to reduce memory footprint of the scene.
  32671. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32672. */
  32673. clearCachedVertexData(): void;
  32674. /**
  32675. * This function will remove the local cached buffer data from texture.
  32676. * It will save memory but will prevent the texture from being rebuilt
  32677. */
  32678. cleanCachedTextureBuffer(): void;
  32679. /**
  32680. * Get the world extend vectors with an optional filter
  32681. *
  32682. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32683. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32684. */
  32685. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32686. min: Vector3;
  32687. max: Vector3;
  32688. };
  32689. /**
  32690. * Creates a ray that can be used to pick in the scene
  32691. * @param x defines the x coordinate of the origin (on-screen)
  32692. * @param y defines the y coordinate of the origin (on-screen)
  32693. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32694. * @param camera defines the camera to use for the picking
  32695. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32696. * @returns a Ray
  32697. */
  32698. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32699. /**
  32700. * Creates a ray that can be used to pick in the scene
  32701. * @param x defines the x coordinate of the origin (on-screen)
  32702. * @param y defines the y coordinate of the origin (on-screen)
  32703. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32704. * @param result defines the ray where to store the picking ray
  32705. * @param camera defines the camera to use for the picking
  32706. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32707. * @returns the current scene
  32708. */
  32709. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32710. /**
  32711. * Creates a ray that can be used to pick in the scene
  32712. * @param x defines the x coordinate of the origin (on-screen)
  32713. * @param y defines the y coordinate of the origin (on-screen)
  32714. * @param camera defines the camera to use for the picking
  32715. * @returns a Ray
  32716. */
  32717. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32718. /**
  32719. * Creates a ray that can be used to pick in the scene
  32720. * @param x defines the x coordinate of the origin (on-screen)
  32721. * @param y defines the y coordinate of the origin (on-screen)
  32722. * @param result defines the ray where to store the picking ray
  32723. * @param camera defines the camera to use for the picking
  32724. * @returns the current scene
  32725. */
  32726. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32727. /** Launch a ray to try to pick a mesh in the scene
  32728. * @param x position on screen
  32729. * @param y position on screen
  32730. * @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
  32731. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32732. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32733. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32734. * @returns a PickingInfo
  32735. */
  32736. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32737. /** Use the given ray to pick a mesh in the scene
  32738. * @param ray The ray to use to pick meshes
  32739. * @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
  32740. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32741. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32742. * @returns a PickingInfo
  32743. */
  32744. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32745. /**
  32746. * Launch a ray to try to pick a mesh in the scene
  32747. * @param x X position on screen
  32748. * @param y Y position on screen
  32749. * @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
  32750. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32751. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32752. * @returns an array of PickingInfo
  32753. */
  32754. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32755. /**
  32756. * Launch a ray to try to pick a mesh in the scene
  32757. * @param ray Ray to use
  32758. * @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
  32759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32760. * @returns an array of PickingInfo
  32761. */
  32762. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32763. /**
  32764. * Force the value of meshUnderPointer
  32765. * @param mesh defines the mesh to use
  32766. */
  32767. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32768. /**
  32769. * Gets the mesh under the pointer
  32770. * @returns a Mesh or null if no mesh is under the pointer
  32771. */
  32772. getPointerOverMesh(): Nullable<AbstractMesh>;
  32773. /** @hidden */ rebuildGeometries(): void;
  32774. /** @hidden */ rebuildTextures(): void;
  32775. private _getByTags;
  32776. /**
  32777. * Get a list of meshes by tags
  32778. * @param tagsQuery defines the tags query to use
  32779. * @param forEach defines a predicate used to filter results
  32780. * @returns an array of Mesh
  32781. */
  32782. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  32783. /**
  32784. * Get a list of cameras by tags
  32785. * @param tagsQuery defines the tags query to use
  32786. * @param forEach defines a predicate used to filter results
  32787. * @returns an array of Camera
  32788. */
  32789. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  32790. /**
  32791. * Get a list of lights by tags
  32792. * @param tagsQuery defines the tags query to use
  32793. * @param forEach defines a predicate used to filter results
  32794. * @returns an array of Light
  32795. */
  32796. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  32797. /**
  32798. * Get a list of materials by tags
  32799. * @param tagsQuery defines the tags query to use
  32800. * @param forEach defines a predicate used to filter results
  32801. * @returns an array of Material
  32802. */
  32803. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  32804. /**
  32805. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  32806. * This allowed control for front to back rendering or reversly depending of the special needs.
  32807. *
  32808. * @param renderingGroupId The rendering group id corresponding to its index
  32809. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  32810. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  32811. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  32812. */
  32813. 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;
  32814. /**
  32815. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  32816. *
  32817. * @param renderingGroupId The rendering group id corresponding to its index
  32818. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  32819. * @param depth Automatically clears depth between groups if true and autoClear is true.
  32820. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  32821. */
  32822. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  32823. /**
  32824. * Gets the current auto clear configuration for one rendering group of the rendering
  32825. * manager.
  32826. * @param index the rendering group index to get the information for
  32827. * @returns The auto clear setup for the requested rendering group
  32828. */
  32829. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  32830. private _blockMaterialDirtyMechanism;
  32831. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  32832. blockMaterialDirtyMechanism: boolean;
  32833. /**
  32834. * Will flag all materials as dirty to trigger new shader compilation
  32835. * @param flag defines the flag used to specify which material part must be marked as dirty
  32836. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  32837. */
  32838. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32839. /** @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;
  32840. /** @hidden */ loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32841. }
  32842. }
  32843. declare module BABYLON {
  32844. /**
  32845. * Set of assets to keep when moving a scene into an asset container.
  32846. */
  32847. export class KeepAssets extends AbstractScene {
  32848. }
  32849. /**
  32850. * Container with a set of assets that can be added or removed from a scene.
  32851. */
  32852. export class AssetContainer extends AbstractScene {
  32853. /**
  32854. * The scene the AssetContainer belongs to.
  32855. */
  32856. scene: Scene;
  32857. /**
  32858. * Instantiates an AssetContainer.
  32859. * @param scene The scene the AssetContainer belongs to.
  32860. */
  32861. constructor(scene: Scene);
  32862. /**
  32863. * Adds all the assets from the container to the scene.
  32864. */
  32865. addAllToScene(): void;
  32866. /**
  32867. * Removes all the assets in the container from the scene
  32868. */
  32869. removeAllFromScene(): void;
  32870. /**
  32871. * Disposes all the assets in the container
  32872. */
  32873. dispose(): void;
  32874. private _moveAssets;
  32875. /**
  32876. * Removes all the assets contained in the scene and adds them to the container.
  32877. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  32878. */
  32879. moveAllFromScene(keepAssets?: KeepAssets): void;
  32880. /**
  32881. * 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.
  32882. * @returns the root mesh
  32883. */
  32884. createRootMesh(): Mesh;
  32885. }
  32886. }
  32887. declare module BABYLON {
  32888. /**
  32889. * Defines how the parser contract is defined.
  32890. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  32891. */
  32892. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  32893. /**
  32894. * Defines how the individual parser contract is defined.
  32895. * These parser can parse an individual asset
  32896. */
  32897. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  32898. /**
  32899. * Base class of the scene acting as a container for the different elements composing a scene.
  32900. * This class is dynamically extended by the different components of the scene increasing
  32901. * flexibility and reducing coupling
  32902. */
  32903. export abstract class AbstractScene {
  32904. /**
  32905. * Stores the list of available parsers in the application.
  32906. */
  32907. private static _BabylonFileParsers;
  32908. /**
  32909. * Stores the list of available individual parsers in the application.
  32910. */
  32911. private static _IndividualBabylonFileParsers;
  32912. /**
  32913. * Adds a parser in the list of available ones
  32914. * @param name Defines the name of the parser
  32915. * @param parser Defines the parser to add
  32916. */
  32917. static AddParser(name: string, parser: BabylonFileParser): void;
  32918. /**
  32919. * Gets a general parser from the list of avaialble ones
  32920. * @param name Defines the name of the parser
  32921. * @returns the requested parser or null
  32922. */
  32923. static GetParser(name: string): Nullable<BabylonFileParser>;
  32924. /**
  32925. * Adds n individual parser in the list of available ones
  32926. * @param name Defines the name of the parser
  32927. * @param parser Defines the parser to add
  32928. */
  32929. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  32930. /**
  32931. * Gets an individual parser from the list of avaialble ones
  32932. * @param name Defines the name of the parser
  32933. * @returns the requested parser or null
  32934. */
  32935. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  32936. /**
  32937. * Parser json data and populate both a scene and its associated container object
  32938. * @param jsonData Defines the data to parse
  32939. * @param scene Defines the scene to parse the data for
  32940. * @param container Defines the container attached to the parsing sequence
  32941. * @param rootUrl Defines the root url of the data
  32942. */
  32943. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  32944. /**
  32945. * Gets the list of root nodes (ie. nodes with no parent)
  32946. */
  32947. rootNodes: Node[];
  32948. /** All of the cameras added to this scene
  32949. * @see http://doc.babylonjs.com/babylon101/cameras
  32950. */
  32951. cameras: Camera[];
  32952. /**
  32953. * All of the lights added to this scene
  32954. * @see http://doc.babylonjs.com/babylon101/lights
  32955. */
  32956. lights: Light[];
  32957. /**
  32958. * All of the (abstract) meshes added to this scene
  32959. */
  32960. meshes: AbstractMesh[];
  32961. /**
  32962. * The list of skeletons added to the scene
  32963. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32964. */
  32965. skeletons: Skeleton[];
  32966. /**
  32967. * All of the particle systems added to this scene
  32968. * @see http://doc.babylonjs.com/babylon101/particles
  32969. */
  32970. particleSystems: IParticleSystem[];
  32971. /**
  32972. * Gets a list of Animations associated with the scene
  32973. */
  32974. animations: Animation[];
  32975. /**
  32976. * All of the animation groups added to this scene
  32977. * @see http://doc.babylonjs.com/how_to/group
  32978. */
  32979. animationGroups: AnimationGroup[];
  32980. /**
  32981. * All of the multi-materials added to this scene
  32982. * @see http://doc.babylonjs.com/how_to/multi_materials
  32983. */
  32984. multiMaterials: MultiMaterial[];
  32985. /**
  32986. * All of the materials added to this scene
  32987. * In the context of a Scene, it is not supposed to be modified manually.
  32988. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  32989. * Note also that the order of the Material wihin the array is not significant and might change.
  32990. * @see http://doc.babylonjs.com/babylon101/materials
  32991. */
  32992. materials: Material[];
  32993. /**
  32994. * The list of morph target managers added to the scene
  32995. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  32996. */
  32997. morphTargetManagers: MorphTargetManager[];
  32998. /**
  32999. * The list of geometries used in the scene.
  33000. */
  33001. geometries: Geometry[];
  33002. /**
  33003. * All of the tranform nodes added to this scene
  33004. * In the context of a Scene, it is not supposed to be modified manually.
  33005. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33006. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33007. * @see http://doc.babylonjs.com/how_to/transformnode
  33008. */
  33009. transformNodes: TransformNode[];
  33010. /**
  33011. * ActionManagers available on the scene.
  33012. */
  33013. actionManagers: AbstractActionManager[];
  33014. /**
  33015. * Textures to keep.
  33016. */
  33017. textures: BaseTexture[];
  33018. /**
  33019. * Environment texture for the scene
  33020. */
  33021. environmentTexture: Nullable<BaseTexture>;
  33022. }
  33023. }
  33024. declare module BABYLON {
  33025. /**
  33026. * Defines a sound that can be played in the application.
  33027. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33028. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33029. */
  33030. export class Sound {
  33031. /**
  33032. * The name of the sound in the scene.
  33033. */
  33034. name: string;
  33035. /**
  33036. * Does the sound autoplay once loaded.
  33037. */
  33038. autoplay: boolean;
  33039. /**
  33040. * Does the sound loop after it finishes playing once.
  33041. */
  33042. loop: boolean;
  33043. /**
  33044. * Does the sound use a custom attenuation curve to simulate the falloff
  33045. * happening when the source gets further away from the camera.
  33046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33047. */
  33048. useCustomAttenuation: boolean;
  33049. /**
  33050. * The sound track id this sound belongs to.
  33051. */
  33052. soundTrackId: number;
  33053. /**
  33054. * Is this sound currently played.
  33055. */
  33056. isPlaying: boolean;
  33057. /**
  33058. * Is this sound currently paused.
  33059. */
  33060. isPaused: boolean;
  33061. /**
  33062. * Does this sound enables spatial sound.
  33063. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33064. */
  33065. spatialSound: boolean;
  33066. /**
  33067. * Define the reference distance the sound should be heard perfectly.
  33068. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33069. */
  33070. refDistance: number;
  33071. /**
  33072. * Define the roll off factor of spatial sounds.
  33073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33074. */
  33075. rolloffFactor: number;
  33076. /**
  33077. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33079. */
  33080. maxDistance: number;
  33081. /**
  33082. * Define the distance attenuation model the sound will follow.
  33083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33084. */
  33085. distanceModel: string;
  33086. /**
  33087. * @hidden
  33088. * Back Compat
  33089. **/
  33090. onended: () => any;
  33091. /**
  33092. * Observable event when the current playing sound finishes.
  33093. */
  33094. onEndedObservable: Observable<Sound>;
  33095. private _panningModel;
  33096. private _playbackRate;
  33097. private _streaming;
  33098. private _startTime;
  33099. private _startOffset;
  33100. private _position;
  33101. /** @hidden */ positionInEmitterSpace: boolean;
  33102. private _localDirection;
  33103. private _volume;
  33104. private _isReadyToPlay;
  33105. private _isDirectional;
  33106. private _readyToPlayCallback;
  33107. private _audioBuffer;
  33108. private _soundSource;
  33109. private _streamingSource;
  33110. private _soundPanner;
  33111. private _soundGain;
  33112. private _inputAudioNode;
  33113. private _outputAudioNode;
  33114. private _coneInnerAngle;
  33115. private _coneOuterAngle;
  33116. private _coneOuterGain;
  33117. private _scene;
  33118. private _connectedTransformNode;
  33119. private _customAttenuationFunction;
  33120. private _registerFunc;
  33121. private _isOutputConnected;
  33122. private _htmlAudioElement;
  33123. private _urlType;
  33124. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33125. /**
  33126. * Create a sound and attach it to a scene
  33127. * @param name Name of your sound
  33128. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33129. * @param scene defines the scene the sound belongs to
  33130. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33131. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33132. */
  33133. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33134. /**
  33135. * Release the sound and its associated resources
  33136. */
  33137. dispose(): void;
  33138. /**
  33139. * Gets if the sounds is ready to be played or not.
  33140. * @returns true if ready, otherwise false
  33141. */
  33142. isReady(): boolean;
  33143. private _soundLoaded;
  33144. /**
  33145. * Sets the data of the sound from an audiobuffer
  33146. * @param audioBuffer The audioBuffer containing the data
  33147. */
  33148. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33149. /**
  33150. * Updates the current sounds options such as maxdistance, loop...
  33151. * @param options A JSON object containing values named as the object properties
  33152. */
  33153. updateOptions(options: any): void;
  33154. private _createSpatialParameters;
  33155. private _updateSpatialParameters;
  33156. /**
  33157. * Switch the panning model to HRTF:
  33158. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33159. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33160. */
  33161. switchPanningModelToHRTF(): void;
  33162. /**
  33163. * Switch the panning model to Equal Power:
  33164. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33165. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33166. */
  33167. switchPanningModelToEqualPower(): void;
  33168. private _switchPanningModel;
  33169. /**
  33170. * Connect this sound to a sound track audio node like gain...
  33171. * @param soundTrackAudioNode the sound track audio node to connect to
  33172. */
  33173. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33174. /**
  33175. * Transform this sound into a directional source
  33176. * @param coneInnerAngle Size of the inner cone in degree
  33177. * @param coneOuterAngle Size of the outer cone in degree
  33178. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33179. */
  33180. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33181. /**
  33182. * Gets or sets the inner angle for the directional cone.
  33183. */
  33184. /**
  33185. * Gets or sets the inner angle for the directional cone.
  33186. */
  33187. directionalConeInnerAngle: number;
  33188. /**
  33189. * Gets or sets the outer angle for the directional cone.
  33190. */
  33191. /**
  33192. * Gets or sets the outer angle for the directional cone.
  33193. */
  33194. directionalConeOuterAngle: number;
  33195. /**
  33196. * Sets the position of the emitter if spatial sound is enabled
  33197. * @param newPosition Defines the new posisiton
  33198. */
  33199. setPosition(newPosition: Vector3): void;
  33200. /**
  33201. * Sets the local direction of the emitter if spatial sound is enabled
  33202. * @param newLocalDirection Defines the new local direction
  33203. */
  33204. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33205. private _updateDirection;
  33206. /** @hidden */
  33207. updateDistanceFromListener(): void;
  33208. /**
  33209. * Sets a new custom attenuation function for the sound.
  33210. * @param callback Defines the function used for the attenuation
  33211. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33212. */
  33213. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33214. /**
  33215. * Play the sound
  33216. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33217. * @param offset (optional) Start the sound setting it at a specific time
  33218. */
  33219. play(time?: number, offset?: number): void;
  33220. private _onended;
  33221. /**
  33222. * Stop the sound
  33223. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33224. */
  33225. stop(time?: number): void;
  33226. /**
  33227. * Put the sound in pause
  33228. */
  33229. pause(): void;
  33230. /**
  33231. * Sets a dedicated volume for this sounds
  33232. * @param newVolume Define the new volume of the sound
  33233. * @param time Define in how long the sound should be at this value
  33234. */
  33235. setVolume(newVolume: number, time?: number): void;
  33236. /**
  33237. * Set the sound play back rate
  33238. * @param newPlaybackRate Define the playback rate the sound should be played at
  33239. */
  33240. setPlaybackRate(newPlaybackRate: number): void;
  33241. /**
  33242. * Gets the volume of the sound.
  33243. * @returns the volume of the sound
  33244. */
  33245. getVolume(): number;
  33246. /**
  33247. * Attach the sound to a dedicated mesh
  33248. * @param transformNode The transform node to connect the sound with
  33249. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33250. */
  33251. attachToMesh(transformNode: TransformNode): void;
  33252. /**
  33253. * Detach the sound from the previously attached mesh
  33254. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33255. */
  33256. detachFromMesh(): void;
  33257. private _onRegisterAfterWorldMatrixUpdate;
  33258. /**
  33259. * Clone the current sound in the scene.
  33260. * @returns the new sound clone
  33261. */
  33262. clone(): Nullable<Sound>;
  33263. /**
  33264. * Gets the current underlying audio buffer containing the data
  33265. * @returns the audio buffer
  33266. */
  33267. getAudioBuffer(): Nullable<AudioBuffer>;
  33268. /**
  33269. * Serializes the Sound in a JSON representation
  33270. * @returns the JSON representation of the sound
  33271. */
  33272. serialize(): any;
  33273. /**
  33274. * Parse a JSON representation of a sound to innstantiate in a given scene
  33275. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33276. * @param scene Define the scene the new parsed sound should be created in
  33277. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33278. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33279. * @returns the newly parsed sound
  33280. */
  33281. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33282. }
  33283. }
  33284. declare module BABYLON {
  33285. /**
  33286. * This defines an action helpful to play a defined sound on a triggered action.
  33287. */
  33288. export class PlaySoundAction extends Action {
  33289. private _sound;
  33290. /**
  33291. * Instantiate the action
  33292. * @param triggerOptions defines the trigger options
  33293. * @param sound defines the sound to play
  33294. * @param condition defines the trigger related conditions
  33295. */
  33296. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33297. /** @hidden */ prepare(): void;
  33298. /**
  33299. * Execute the action and play the sound.
  33300. */
  33301. execute(): void;
  33302. /**
  33303. * Serializes the actions and its related information.
  33304. * @param parent defines the object to serialize in
  33305. * @returns the serialized object
  33306. */
  33307. serialize(parent: any): any;
  33308. }
  33309. /**
  33310. * This defines an action helpful to stop a defined sound on a triggered action.
  33311. */
  33312. export class StopSoundAction extends Action {
  33313. private _sound;
  33314. /**
  33315. * Instantiate the action
  33316. * @param triggerOptions defines the trigger options
  33317. * @param sound defines the sound to stop
  33318. * @param condition defines the trigger related conditions
  33319. */
  33320. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33321. /** @hidden */ prepare(): void;
  33322. /**
  33323. * Execute the action and stop the sound.
  33324. */
  33325. execute(): void;
  33326. /**
  33327. * Serializes the actions and its related information.
  33328. * @param parent defines the object to serialize in
  33329. * @returns the serialized object
  33330. */
  33331. serialize(parent: any): any;
  33332. }
  33333. }
  33334. declare module BABYLON {
  33335. /**
  33336. * This defines an action responsible to change the value of a property
  33337. * by interpolating between its current value and the newly set one once triggered.
  33338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33339. */
  33340. export class InterpolateValueAction extends Action {
  33341. /**
  33342. * Defines the path of the property where the value should be interpolated
  33343. */
  33344. propertyPath: string;
  33345. /**
  33346. * Defines the target value at the end of the interpolation.
  33347. */
  33348. value: any;
  33349. /**
  33350. * Defines the time it will take for the property to interpolate to the value.
  33351. */
  33352. duration: number;
  33353. /**
  33354. * Defines if the other scene animations should be stopped when the action has been triggered
  33355. */
  33356. stopOtherAnimations?: boolean;
  33357. /**
  33358. * Defines a callback raised once the interpolation animation has been done.
  33359. */
  33360. onInterpolationDone?: () => void;
  33361. /**
  33362. * Observable triggered once the interpolation animation has been done.
  33363. */
  33364. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33365. private _target;
  33366. private _effectiveTarget;
  33367. private _property;
  33368. /**
  33369. * Instantiate the action
  33370. * @param triggerOptions defines the trigger options
  33371. * @param target defines the object containing the value to interpolate
  33372. * @param propertyPath defines the path to the property in the target object
  33373. * @param value defines the target value at the end of the interpolation
  33374. * @param duration deines the time it will take for the property to interpolate to the value.
  33375. * @param condition defines the trigger related conditions
  33376. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33377. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33378. */
  33379. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33380. /** @hidden */ prepare(): void;
  33381. /**
  33382. * Execute the action starts the value interpolation.
  33383. */
  33384. execute(): void;
  33385. /**
  33386. * Serializes the actions and its related information.
  33387. * @param parent defines the object to serialize in
  33388. * @returns the serialized object
  33389. */
  33390. serialize(parent: any): any;
  33391. }
  33392. }
  33393. declare module BABYLON {
  33394. /**
  33395. * Options allowed during the creation of a sound track.
  33396. */
  33397. export interface ISoundTrackOptions {
  33398. /**
  33399. * The volume the sound track should take during creation
  33400. */
  33401. volume?: number;
  33402. /**
  33403. * Define if the sound track is the main sound track of the scene
  33404. */
  33405. mainTrack?: boolean;
  33406. }
  33407. /**
  33408. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33409. * It will be also used in a future release to apply effects on a specific track.
  33410. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33411. */
  33412. export class SoundTrack {
  33413. /**
  33414. * The unique identifier of the sound track in the scene.
  33415. */
  33416. id: number;
  33417. /**
  33418. * The list of sounds included in the sound track.
  33419. */
  33420. soundCollection: Array<Sound>;
  33421. private _outputAudioNode;
  33422. private _scene;
  33423. private _isMainTrack;
  33424. private _connectedAnalyser;
  33425. private _options;
  33426. private _isInitialized;
  33427. /**
  33428. * Creates a new sound track.
  33429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33430. * @param scene Define the scene the sound track belongs to
  33431. * @param options
  33432. */
  33433. constructor(scene: Scene, options?: ISoundTrackOptions);
  33434. private _initializeSoundTrackAudioGraph;
  33435. /**
  33436. * Release the sound track and its associated resources
  33437. */
  33438. dispose(): void;
  33439. /**
  33440. * Adds a sound to this sound track
  33441. * @param sound define the cound to add
  33442. * @ignoreNaming
  33443. */
  33444. AddSound(sound: Sound): void;
  33445. /**
  33446. * Removes a sound to this sound track
  33447. * @param sound define the cound to remove
  33448. * @ignoreNaming
  33449. */
  33450. RemoveSound(sound: Sound): void;
  33451. /**
  33452. * Set a global volume for the full sound track.
  33453. * @param newVolume Define the new volume of the sound track
  33454. */
  33455. setVolume(newVolume: number): void;
  33456. /**
  33457. * Switch the panning model to HRTF:
  33458. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33459. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33460. */
  33461. switchPanningModelToHRTF(): void;
  33462. /**
  33463. * Switch the panning model to Equal Power:
  33464. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33465. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33466. */
  33467. switchPanningModelToEqualPower(): void;
  33468. /**
  33469. * Connect the sound track to an audio analyser allowing some amazing
  33470. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33472. * @param analyser The analyser to connect to the engine
  33473. */
  33474. connectToAnalyser(analyser: Analyser): void;
  33475. }
  33476. }
  33477. declare module BABYLON {
  33478. interface AbstractScene {
  33479. /**
  33480. * The list of sounds used in the scene.
  33481. */
  33482. sounds: Nullable<Array<Sound>>;
  33483. }
  33484. interface Scene {
  33485. /**
  33486. * @hidden
  33487. * Backing field
  33488. */ mainSoundTrack: SoundTrack;
  33489. /**
  33490. * The main sound track played by the scene.
  33491. * It cotains your primary collection of sounds.
  33492. */
  33493. mainSoundTrack: SoundTrack;
  33494. /**
  33495. * The list of sound tracks added to the scene
  33496. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33497. */
  33498. soundTracks: Nullable<Array<SoundTrack>>;
  33499. /**
  33500. * Gets a sound using a given name
  33501. * @param name defines the name to search for
  33502. * @return the found sound or null if not found at all.
  33503. */
  33504. getSoundByName(name: string): Nullable<Sound>;
  33505. /**
  33506. * Gets or sets if audio support is enabled
  33507. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33508. */
  33509. audioEnabled: boolean;
  33510. /**
  33511. * Gets or sets if audio will be output to headphones
  33512. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33513. */
  33514. headphone: boolean;
  33515. }
  33516. /**
  33517. * Defines the sound scene component responsible to manage any sounds
  33518. * in a given scene.
  33519. */
  33520. export class AudioSceneComponent implements ISceneSerializableComponent {
  33521. /**
  33522. * The component name helpfull to identify the component in the list of scene components.
  33523. */
  33524. readonly name: string;
  33525. /**
  33526. * The scene the component belongs to.
  33527. */
  33528. scene: Scene;
  33529. private _audioEnabled;
  33530. /**
  33531. * Gets whether audio is enabled or not.
  33532. * Please use related enable/disable method to switch state.
  33533. */
  33534. readonly audioEnabled: boolean;
  33535. private _headphone;
  33536. /**
  33537. * Gets whether audio is outputing to headphone or not.
  33538. * Please use the according Switch methods to change output.
  33539. */
  33540. readonly headphone: boolean;
  33541. /**
  33542. * Creates a new instance of the component for the given scene
  33543. * @param scene Defines the scene to register the component in
  33544. */
  33545. constructor(scene: Scene);
  33546. /**
  33547. * Registers the component in a given scene
  33548. */
  33549. register(): void;
  33550. /**
  33551. * Rebuilds the elements related to this component in case of
  33552. * context lost for instance.
  33553. */
  33554. rebuild(): void;
  33555. /**
  33556. * Serializes the component data to the specified json object
  33557. * @param serializationObject The object to serialize to
  33558. */
  33559. serialize(serializationObject: any): void;
  33560. /**
  33561. * Adds all the element from the container to the scene
  33562. * @param container the container holding the elements
  33563. */
  33564. addFromContainer(container: AbstractScene): void;
  33565. /**
  33566. * Removes all the elements in the container from the scene
  33567. * @param container contains the elements to remove
  33568. * @param dispose if the removed element should be disposed (default: false)
  33569. */
  33570. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33571. /**
  33572. * Disposes the component and the associated ressources.
  33573. */
  33574. dispose(): void;
  33575. /**
  33576. * Disables audio in the associated scene.
  33577. */
  33578. disableAudio(): void;
  33579. /**
  33580. * Enables audio in the associated scene.
  33581. */
  33582. enableAudio(): void;
  33583. /**
  33584. * Switch audio to headphone output.
  33585. */
  33586. switchAudioModeForHeadphones(): void;
  33587. /**
  33588. * Switch audio to normal speakers.
  33589. */
  33590. switchAudioModeForNormalSpeakers(): void;
  33591. private _afterRender;
  33592. }
  33593. }
  33594. declare module BABYLON {
  33595. /**
  33596. * Wraps one or more Sound objects and selects one with random weight for playback.
  33597. */
  33598. export class WeightedSound {
  33599. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33600. loop: boolean;
  33601. private _coneInnerAngle;
  33602. private _coneOuterAngle;
  33603. private _volume;
  33604. /** A Sound is currently playing. */
  33605. isPlaying: boolean;
  33606. /** A Sound is currently paused. */
  33607. isPaused: boolean;
  33608. private _sounds;
  33609. private _weights;
  33610. private _currentIndex?;
  33611. /**
  33612. * Creates a new WeightedSound from the list of sounds given.
  33613. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33614. * @param sounds Array of Sounds that will be selected from.
  33615. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33616. */
  33617. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33618. /**
  33619. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33620. */
  33621. /**
  33622. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33623. */
  33624. directionalConeInnerAngle: number;
  33625. /**
  33626. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33627. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33628. */
  33629. /**
  33630. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33631. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33632. */
  33633. directionalConeOuterAngle: number;
  33634. /**
  33635. * Playback volume.
  33636. */
  33637. /**
  33638. * Playback volume.
  33639. */
  33640. volume: number;
  33641. private _onended;
  33642. /**
  33643. * Suspend playback
  33644. */
  33645. pause(): void;
  33646. /**
  33647. * Stop playback
  33648. */
  33649. stop(): void;
  33650. /**
  33651. * Start playback.
  33652. * @param startOffset Position the clip head at a specific time in seconds.
  33653. */
  33654. play(startOffset?: number): void;
  33655. }
  33656. }
  33657. declare module BABYLON {
  33658. /**
  33659. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33660. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33661. */
  33662. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33663. /**
  33664. * Gets the name of the behavior.
  33665. */
  33666. readonly name: string;
  33667. /**
  33668. * The easing function used by animations
  33669. */
  33670. static EasingFunction: BackEase;
  33671. /**
  33672. * The easing mode used by animations
  33673. */
  33674. static EasingMode: number;
  33675. /**
  33676. * The duration of the animation, in milliseconds
  33677. */
  33678. transitionDuration: number;
  33679. /**
  33680. * Length of the distance animated by the transition when lower radius is reached
  33681. */
  33682. lowerRadiusTransitionRange: number;
  33683. /**
  33684. * Length of the distance animated by the transition when upper radius is reached
  33685. */
  33686. upperRadiusTransitionRange: number;
  33687. private _autoTransitionRange;
  33688. /**
  33689. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33690. */
  33691. /**
  33692. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33693. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33694. */
  33695. autoTransitionRange: boolean;
  33696. private _attachedCamera;
  33697. private _onAfterCheckInputsObserver;
  33698. private _onMeshTargetChangedObserver;
  33699. /**
  33700. * Initializes the behavior.
  33701. */
  33702. init(): void;
  33703. /**
  33704. * Attaches the behavior to its arc rotate camera.
  33705. * @param camera Defines the camera to attach the behavior to
  33706. */
  33707. attach(camera: ArcRotateCamera): void;
  33708. /**
  33709. * Detaches the behavior from its current arc rotate camera.
  33710. */
  33711. detach(): void;
  33712. private _radiusIsAnimating;
  33713. private _radiusBounceTransition;
  33714. private _animatables;
  33715. private _cachedWheelPrecision;
  33716. /**
  33717. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33718. * @param radiusLimit The limit to check against.
  33719. * @return Bool to indicate if at limit.
  33720. */
  33721. private _isRadiusAtLimit;
  33722. /**
  33723. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33724. * @param radiusDelta The delta by which to animate to. Can be negative.
  33725. */
  33726. private _applyBoundRadiusAnimation;
  33727. /**
  33728. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33729. */
  33730. protected _clearAnimationLocks(): void;
  33731. /**
  33732. * Stops and removes all animations that have been applied to the camera
  33733. */
  33734. stopAllAnimations(): void;
  33735. }
  33736. }
  33737. declare module BABYLON {
  33738. /**
  33739. * 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.
  33740. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33741. */
  33742. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33743. /**
  33744. * Gets the name of the behavior.
  33745. */
  33746. readonly name: string;
  33747. private _mode;
  33748. private _radiusScale;
  33749. private _positionScale;
  33750. private _defaultElevation;
  33751. private _elevationReturnTime;
  33752. private _elevationReturnWaitTime;
  33753. private _zoomStopsAnimation;
  33754. private _framingTime;
  33755. /**
  33756. * The easing function used by animations
  33757. */
  33758. static EasingFunction: ExponentialEase;
  33759. /**
  33760. * The easing mode used by animations
  33761. */
  33762. static EasingMode: number;
  33763. /**
  33764. * Sets the current mode used by the behavior
  33765. */
  33766. /**
  33767. * Gets current mode used by the behavior.
  33768. */
  33769. mode: number;
  33770. /**
  33771. * Sets the scale applied to the radius (1 by default)
  33772. */
  33773. /**
  33774. * Gets the scale applied to the radius
  33775. */
  33776. radiusScale: number;
  33777. /**
  33778. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33779. */
  33780. /**
  33781. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  33782. */
  33783. positionScale: number;
  33784. /**
  33785. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33786. * behaviour is triggered, in radians.
  33787. */
  33788. /**
  33789. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  33790. * behaviour is triggered, in radians.
  33791. */
  33792. defaultElevation: number;
  33793. /**
  33794. * Sets the time (in milliseconds) taken to return to the default beta position.
  33795. * Negative value indicates camera should not return to default.
  33796. */
  33797. /**
  33798. * Gets the time (in milliseconds) taken to return to the default beta position.
  33799. * Negative value indicates camera should not return to default.
  33800. */
  33801. elevationReturnTime: number;
  33802. /**
  33803. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33804. */
  33805. /**
  33806. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  33807. */
  33808. elevationReturnWaitTime: number;
  33809. /**
  33810. * Sets the flag that indicates if user zooming should stop animation.
  33811. */
  33812. /**
  33813. * Gets the flag that indicates if user zooming should stop animation.
  33814. */
  33815. zoomStopsAnimation: boolean;
  33816. /**
  33817. * Sets the transition time when framing the mesh, in milliseconds
  33818. */
  33819. /**
  33820. * Gets the transition time when framing the mesh, in milliseconds
  33821. */
  33822. framingTime: number;
  33823. /**
  33824. * Define if the behavior should automatically change the configured
  33825. * camera limits and sensibilities.
  33826. */
  33827. autoCorrectCameraLimitsAndSensibility: boolean;
  33828. private _onPrePointerObservableObserver;
  33829. private _onAfterCheckInputsObserver;
  33830. private _onMeshTargetChangedObserver;
  33831. private _attachedCamera;
  33832. private _isPointerDown;
  33833. private _lastInteractionTime;
  33834. /**
  33835. * Initializes the behavior.
  33836. */
  33837. init(): void;
  33838. /**
  33839. * Attaches the behavior to its arc rotate camera.
  33840. * @param camera Defines the camera to attach the behavior to
  33841. */
  33842. attach(camera: ArcRotateCamera): void;
  33843. /**
  33844. * Detaches the behavior from its current arc rotate camera.
  33845. */
  33846. detach(): void;
  33847. private _animatables;
  33848. private _betaIsAnimating;
  33849. private _betaTransition;
  33850. private _radiusTransition;
  33851. private _vectorTransition;
  33852. /**
  33853. * Targets the given mesh and updates zoom level accordingly.
  33854. * @param mesh The mesh to target.
  33855. * @param radius Optional. If a cached radius position already exists, overrides default.
  33856. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33857. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33858. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33859. */
  33860. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33861. /**
  33862. * Targets the given mesh with its children and updates zoom level accordingly.
  33863. * @param mesh The mesh to target.
  33864. * @param radius Optional. If a cached radius position already exists, overrides default.
  33865. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33866. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33867. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33868. */
  33869. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33870. /**
  33871. * Targets the given meshes with their children and updates zoom level accordingly.
  33872. * @param meshes The mesh to target.
  33873. * @param radius Optional. If a cached radius position already exists, overrides default.
  33874. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  33875. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33876. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33877. */
  33878. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33879. /**
  33880. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  33881. * @param minimumWorld Determines the smaller position of the bounding box extend
  33882. * @param maximumWorld Determines the bigger position of the bounding box extend
  33883. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  33884. * @param onAnimationEnd Callback triggered at the end of the framing animation
  33885. */
  33886. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  33887. /**
  33888. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  33889. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  33890. * frustum width.
  33891. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  33892. * to fully enclose the mesh in the viewing frustum.
  33893. */
  33894. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  33895. /**
  33896. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  33897. * is automatically returned to its default position (expected to be above ground plane).
  33898. */
  33899. private _maintainCameraAboveGround;
  33900. /**
  33901. * Returns the frustum slope based on the canvas ratio and camera FOV
  33902. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  33903. */
  33904. private _getFrustumSlope;
  33905. /**
  33906. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  33907. */
  33908. private _clearAnimationLocks;
  33909. /**
  33910. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  33911. */
  33912. private _applyUserInteraction;
  33913. /**
  33914. * Stops and removes all animations that have been applied to the camera
  33915. */
  33916. stopAllAnimations(): void;
  33917. /**
  33918. * Gets a value indicating if the user is moving the camera
  33919. */
  33920. readonly isUserIsMoving: boolean;
  33921. /**
  33922. * The camera can move all the way towards the mesh.
  33923. */
  33924. static IgnoreBoundsSizeMode: number;
  33925. /**
  33926. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  33927. */
  33928. static FitFrustumSidesMode: number;
  33929. }
  33930. }
  33931. declare module BABYLON {
  33932. /**
  33933. * Base class for Camera Pointer Inputs.
  33934. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  33935. * for example usage.
  33936. */
  33937. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  33938. /**
  33939. * Defines the camera the input is attached to.
  33940. */
  33941. abstract camera: Camera;
  33942. /**
  33943. * Whether keyboard modifier keys are pressed at time of last mouse event.
  33944. */
  33945. protected _altKey: boolean;
  33946. protected _ctrlKey: boolean;
  33947. protected _metaKey: boolean;
  33948. protected _shiftKey: boolean;
  33949. /**
  33950. * Which mouse buttons were pressed at time of last mouse event.
  33951. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  33952. */
  33953. protected _buttonsPressed: number;
  33954. /**
  33955. * Defines the buttons associated with the input to handle camera move.
  33956. */
  33957. buttons: number[];
  33958. /**
  33959. * Attach the input controls to a specific dom element to get the input from.
  33960. * @param element Defines the element the controls should be listened from
  33961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33962. */
  33963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33964. /**
  33965. * Detach the current controls from the specified dom element.
  33966. * @param element Defines the element to stop listening the inputs from
  33967. */
  33968. detachControl(element: Nullable<HTMLElement>): void;
  33969. /**
  33970. * Gets the class name of the current input.
  33971. * @returns the class name
  33972. */
  33973. getClassName(): string;
  33974. /**
  33975. * Get the friendly name associated with the input class.
  33976. * @returns the input friendly name
  33977. */
  33978. getSimpleName(): string;
  33979. /**
  33980. * Called on pointer POINTERDOUBLETAP event.
  33981. * Override this method to provide functionality on POINTERDOUBLETAP event.
  33982. */
  33983. protected onDoubleTap(type: string): void;
  33984. /**
  33985. * Called on pointer POINTERMOVE event if only a single touch is active.
  33986. * Override this method to provide functionality.
  33987. */
  33988. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  33989. /**
  33990. * Called on pointer POINTERMOVE event if multiple touches are active.
  33991. * Override this method to provide functionality.
  33992. */
  33993. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  33994. /**
  33995. * Called on JS contextmenu event.
  33996. * Override this method to provide functionality.
  33997. */
  33998. protected onContextMenu(evt: PointerEvent): void;
  33999. /**
  34000. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34001. * press.
  34002. * Override this method to provide functionality.
  34003. */
  34004. protected onButtonDown(evt: PointerEvent): void;
  34005. /**
  34006. * Called each time a new POINTERUP event occurs. Ie, for each button
  34007. * release.
  34008. * Override this method to provide functionality.
  34009. */
  34010. protected onButtonUp(evt: PointerEvent): void;
  34011. /**
  34012. * Called when window becomes inactive.
  34013. * Override this method to provide functionality.
  34014. */
  34015. protected onLostFocus(): void;
  34016. private _pointerInput;
  34017. private _observer;
  34018. private _onLostFocus;
  34019. private pointA;
  34020. private pointB;
  34021. }
  34022. }
  34023. declare module BABYLON {
  34024. /**
  34025. * Manage the pointers inputs to control an arc rotate camera.
  34026. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34027. */
  34028. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34029. /**
  34030. * Defines the camera the input is attached to.
  34031. */
  34032. camera: ArcRotateCamera;
  34033. /**
  34034. * Gets the class name of the current input.
  34035. * @returns the class name
  34036. */
  34037. getClassName(): string;
  34038. /**
  34039. * Defines the buttons associated with the input to handle camera move.
  34040. */
  34041. buttons: number[];
  34042. /**
  34043. * Defines the pointer angular sensibility along the X axis or how fast is
  34044. * the camera rotating.
  34045. */
  34046. angularSensibilityX: number;
  34047. /**
  34048. * Defines the pointer angular sensibility along the Y axis or how fast is
  34049. * the camera rotating.
  34050. */
  34051. angularSensibilityY: number;
  34052. /**
  34053. * Defines the pointer pinch precision or how fast is the camera zooming.
  34054. */
  34055. pinchPrecision: number;
  34056. /**
  34057. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34058. * from 0.
  34059. * It defines the percentage of current camera.radius to use as delta when
  34060. * pinch zoom is used.
  34061. */
  34062. pinchDeltaPercentage: number;
  34063. /**
  34064. * Defines the pointer panning sensibility or how fast is the camera moving.
  34065. */
  34066. panningSensibility: number;
  34067. /**
  34068. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34069. */
  34070. multiTouchPanning: boolean;
  34071. /**
  34072. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34073. * zoom (pinch) through multitouch.
  34074. */
  34075. multiTouchPanAndZoom: boolean;
  34076. /**
  34077. * Revers pinch action direction.
  34078. */
  34079. pinchInwards: boolean;
  34080. private _isPanClick;
  34081. private _twoFingerActivityCount;
  34082. private _isPinching;
  34083. /**
  34084. * Called on pointer POINTERMOVE event if only a single touch is active.
  34085. */
  34086. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34087. /**
  34088. * Called on pointer POINTERDOUBLETAP event.
  34089. */
  34090. protected onDoubleTap(type: string): void;
  34091. /**
  34092. * Called on pointer POINTERMOVE event if multiple touches are active.
  34093. */
  34094. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34095. /**
  34096. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34097. * press.
  34098. */
  34099. protected onButtonDown(evt: PointerEvent): void;
  34100. /**
  34101. * Called each time a new POINTERUP event occurs. Ie, for each button
  34102. * release.
  34103. */
  34104. protected onButtonUp(evt: PointerEvent): void;
  34105. /**
  34106. * Called when window becomes inactive.
  34107. */
  34108. protected onLostFocus(): void;
  34109. }
  34110. }
  34111. declare module BABYLON {
  34112. /**
  34113. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34115. */
  34116. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34117. /**
  34118. * Defines the camera the input is attached to.
  34119. */
  34120. camera: ArcRotateCamera;
  34121. /**
  34122. * Defines the list of key codes associated with the up action (increase alpha)
  34123. */
  34124. keysUp: number[];
  34125. /**
  34126. * Defines the list of key codes associated with the down action (decrease alpha)
  34127. */
  34128. keysDown: number[];
  34129. /**
  34130. * Defines the list of key codes associated with the left action (increase beta)
  34131. */
  34132. keysLeft: number[];
  34133. /**
  34134. * Defines the list of key codes associated with the right action (decrease beta)
  34135. */
  34136. keysRight: number[];
  34137. /**
  34138. * Defines the list of key codes associated with the reset action.
  34139. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34140. */
  34141. keysReset: number[];
  34142. /**
  34143. * Defines the panning sensibility of the inputs.
  34144. * (How fast is the camera paning)
  34145. */
  34146. panningSensibility: number;
  34147. /**
  34148. * Defines the zooming sensibility of the inputs.
  34149. * (How fast is the camera zooming)
  34150. */
  34151. zoomingSensibility: number;
  34152. /**
  34153. * Defines wether maintaining the alt key down switch the movement mode from
  34154. * orientation to zoom.
  34155. */
  34156. useAltToZoom: boolean;
  34157. /**
  34158. * Rotation speed of the camera
  34159. */
  34160. angularSpeed: number;
  34161. private _keys;
  34162. private _ctrlPressed;
  34163. private _altPressed;
  34164. private _onCanvasBlurObserver;
  34165. private _onKeyboardObserver;
  34166. private _engine;
  34167. private _scene;
  34168. /**
  34169. * Attach the input controls to a specific dom element to get the input from.
  34170. * @param element Defines the element the controls should be listened from
  34171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34172. */
  34173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34174. /**
  34175. * Detach the current controls from the specified dom element.
  34176. * @param element Defines the element to stop listening the inputs from
  34177. */
  34178. detachControl(element: Nullable<HTMLElement>): void;
  34179. /**
  34180. * Update the current camera state depending on the inputs that have been used this frame.
  34181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34182. */
  34183. checkInputs(): void;
  34184. /**
  34185. * Gets the class name of the current intput.
  34186. * @returns the class name
  34187. */
  34188. getClassName(): string;
  34189. /**
  34190. * Get the friendly name associated with the input class.
  34191. * @returns the input friendly name
  34192. */
  34193. getSimpleName(): string;
  34194. }
  34195. }
  34196. declare module BABYLON {
  34197. /**
  34198. * Manage the mouse wheel inputs to control an arc rotate camera.
  34199. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34200. */
  34201. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34202. /**
  34203. * Defines the camera the input is attached to.
  34204. */
  34205. camera: ArcRotateCamera;
  34206. /**
  34207. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34208. */
  34209. wheelPrecision: number;
  34210. /**
  34211. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34212. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34213. */
  34214. wheelDeltaPercentage: number;
  34215. private _wheel;
  34216. private _observer;
  34217. /**
  34218. * Attach the input controls to a specific dom element to get the input from.
  34219. * @param element Defines the element the controls should be listened from
  34220. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34221. */
  34222. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34223. /**
  34224. * Detach the current controls from the specified dom element.
  34225. * @param element Defines the element to stop listening the inputs from
  34226. */
  34227. detachControl(element: Nullable<HTMLElement>): void;
  34228. /**
  34229. * Gets the class name of the current intput.
  34230. * @returns the class name
  34231. */
  34232. getClassName(): string;
  34233. /**
  34234. * Get the friendly name associated with the input class.
  34235. * @returns the input friendly name
  34236. */
  34237. getSimpleName(): string;
  34238. }
  34239. }
  34240. declare module BABYLON {
  34241. /**
  34242. * Default Inputs manager for the ArcRotateCamera.
  34243. * It groups all the default supported inputs for ease of use.
  34244. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34245. */
  34246. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34247. /**
  34248. * Instantiates a new ArcRotateCameraInputsManager.
  34249. * @param camera Defines the camera the inputs belong to
  34250. */
  34251. constructor(camera: ArcRotateCamera);
  34252. /**
  34253. * Add mouse wheel input support to the input manager.
  34254. * @returns the current input manager
  34255. */
  34256. addMouseWheel(): ArcRotateCameraInputsManager;
  34257. /**
  34258. * Add pointers input support to the input manager.
  34259. * @returns the current input manager
  34260. */
  34261. addPointers(): ArcRotateCameraInputsManager;
  34262. /**
  34263. * Add keyboard input support to the input manager.
  34264. * @returns the current input manager
  34265. */
  34266. addKeyboard(): ArcRotateCameraInputsManager;
  34267. }
  34268. }
  34269. declare module BABYLON {
  34270. /**
  34271. * This represents an orbital type of camera.
  34272. *
  34273. * 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.
  34274. * 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.
  34275. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34276. */
  34277. export class ArcRotateCamera extends TargetCamera {
  34278. /**
  34279. * Defines the rotation angle of the camera along the longitudinal axis.
  34280. */
  34281. alpha: number;
  34282. /**
  34283. * Defines the rotation angle of the camera along the latitudinal axis.
  34284. */
  34285. beta: number;
  34286. /**
  34287. * Defines the radius of the camera from it s target point.
  34288. */
  34289. radius: number;
  34290. protected _target: Vector3;
  34291. protected _targetHost: Nullable<AbstractMesh>;
  34292. /**
  34293. * Defines the target point of the camera.
  34294. * The camera looks towards it form the radius distance.
  34295. */
  34296. target: Vector3;
  34297. /**
  34298. * Define the current local position of the camera in the scene
  34299. */
  34300. position: Vector3;
  34301. /**
  34302. * Current inertia value on the longitudinal axis.
  34303. * The bigger this number the longer it will take for the camera to stop.
  34304. */
  34305. inertialAlphaOffset: number;
  34306. /**
  34307. * Current inertia value on the latitudinal axis.
  34308. * The bigger this number the longer it will take for the camera to stop.
  34309. */
  34310. inertialBetaOffset: number;
  34311. /**
  34312. * Current inertia value on the radius axis.
  34313. * The bigger this number the longer it will take for the camera to stop.
  34314. */
  34315. inertialRadiusOffset: number;
  34316. /**
  34317. * Minimum allowed angle on the longitudinal axis.
  34318. * This can help limiting how the Camera is able to move in the scene.
  34319. */
  34320. lowerAlphaLimit: Nullable<number>;
  34321. /**
  34322. * Maximum allowed angle on the longitudinal axis.
  34323. * This can help limiting how the Camera is able to move in the scene.
  34324. */
  34325. upperAlphaLimit: Nullable<number>;
  34326. /**
  34327. * Minimum allowed angle on the latitudinal axis.
  34328. * This can help limiting how the Camera is able to move in the scene.
  34329. */
  34330. lowerBetaLimit: number;
  34331. /**
  34332. * Maximum allowed angle on the latitudinal axis.
  34333. * This can help limiting how the Camera is able to move in the scene.
  34334. */
  34335. upperBetaLimit: number;
  34336. /**
  34337. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34338. * This can help limiting how the Camera is able to move in the scene.
  34339. */
  34340. lowerRadiusLimit: Nullable<number>;
  34341. /**
  34342. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34343. * This can help limiting how the Camera is able to move in the scene.
  34344. */
  34345. upperRadiusLimit: Nullable<number>;
  34346. /**
  34347. * Defines the current inertia value used during panning of the camera along the X axis.
  34348. */
  34349. inertialPanningX: number;
  34350. /**
  34351. * Defines the current inertia value used during panning of the camera along the Y axis.
  34352. */
  34353. inertialPanningY: number;
  34354. /**
  34355. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34356. * Basically if your fingers moves away from more than this distance you will be considered
  34357. * in pinch mode.
  34358. */
  34359. pinchToPanMaxDistance: number;
  34360. /**
  34361. * Defines the maximum distance the camera can pan.
  34362. * This could help keeping the cammera always in your scene.
  34363. */
  34364. panningDistanceLimit: Nullable<number>;
  34365. /**
  34366. * Defines the target of the camera before paning.
  34367. */
  34368. panningOriginTarget: Vector3;
  34369. /**
  34370. * Defines the value of the inertia used during panning.
  34371. * 0 would mean stop inertia and one would mean no decelleration at all.
  34372. */
  34373. panningInertia: number;
  34374. /**
  34375. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34376. */
  34377. angularSensibilityX: number;
  34378. /**
  34379. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34380. */
  34381. angularSensibilityY: number;
  34382. /**
  34383. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34384. */
  34385. pinchPrecision: number;
  34386. /**
  34387. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34388. * It will be used instead of pinchDeltaPrecision if different from 0.
  34389. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34390. */
  34391. pinchDeltaPercentage: number;
  34392. /**
  34393. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34394. */
  34395. panningSensibility: number;
  34396. /**
  34397. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34398. */
  34399. keysUp: number[];
  34400. /**
  34401. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34402. */
  34403. keysDown: number[];
  34404. /**
  34405. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34406. */
  34407. keysLeft: number[];
  34408. /**
  34409. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34410. */
  34411. keysRight: number[];
  34412. /**
  34413. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34414. */
  34415. wheelPrecision: number;
  34416. /**
  34417. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34418. * It will be used instead of pinchDeltaPrecision if different from 0.
  34419. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34420. */
  34421. wheelDeltaPercentage: number;
  34422. /**
  34423. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34424. */
  34425. zoomOnFactor: number;
  34426. /**
  34427. * Defines a screen offset for the camera position.
  34428. */
  34429. targetScreenOffset: Vector2;
  34430. /**
  34431. * Allows the camera to be completely reversed.
  34432. * If false the camera can not arrive upside down.
  34433. */
  34434. allowUpsideDown: boolean;
  34435. /**
  34436. * Define if double tap/click is used to restore the previously saved state of the camera.
  34437. */
  34438. useInputToRestoreState: boolean;
  34439. /** @hidden */ viewMatrix: Matrix;
  34440. /** @hidden */ useCtrlForPanning: boolean;
  34441. /** @hidden */ panningMouseButton: number;
  34442. /**
  34443. * Defines the input associated to the camera.
  34444. */
  34445. inputs: ArcRotateCameraInputsManager;
  34446. /** @hidden */ reset: () => void;
  34447. /**
  34448. * Defines the allowed panning axis.
  34449. */
  34450. panningAxis: Vector3;
  34451. protected _localDirection: Vector3;
  34452. protected _transformedDirection: Vector3;
  34453. private _bouncingBehavior;
  34454. /**
  34455. * Gets the bouncing behavior of the camera if it has been enabled.
  34456. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34457. */
  34458. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34459. /**
  34460. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34461. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34462. */
  34463. useBouncingBehavior: boolean;
  34464. private _framingBehavior;
  34465. /**
  34466. * Gets the framing behavior of the camera if it has been enabled.
  34467. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34468. */
  34469. readonly framingBehavior: Nullable<FramingBehavior>;
  34470. /**
  34471. * Defines if the framing behavior of the camera is enabled on the camera.
  34472. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34473. */
  34474. useFramingBehavior: boolean;
  34475. private _autoRotationBehavior;
  34476. /**
  34477. * Gets the auto rotation behavior of the camera if it has been enabled.
  34478. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34479. */
  34480. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34481. /**
  34482. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34483. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34484. */
  34485. useAutoRotationBehavior: boolean;
  34486. /**
  34487. * Observable triggered when the mesh target has been changed on the camera.
  34488. */
  34489. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34490. /**
  34491. * Event raised when the camera is colliding with a mesh.
  34492. */
  34493. onCollide: (collidedMesh: AbstractMesh) => void;
  34494. /**
  34495. * Defines whether the camera should check collision with the objects oh the scene.
  34496. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34497. */
  34498. checkCollisions: boolean;
  34499. /**
  34500. * Defines the collision radius of the camera.
  34501. * This simulates a sphere around the camera.
  34502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34503. */
  34504. collisionRadius: Vector3;
  34505. protected _collider: Collider;
  34506. protected _previousPosition: Vector3;
  34507. protected _collisionVelocity: Vector3;
  34508. protected _newPosition: Vector3;
  34509. protected _previousAlpha: number;
  34510. protected _previousBeta: number;
  34511. protected _previousRadius: number;
  34512. protected _collisionTriggered: boolean;
  34513. protected _targetBoundingCenter: Nullable<Vector3>;
  34514. private _computationVector;
  34515. private _tempAxisVector;
  34516. private _tempAxisRotationMatrix;
  34517. /**
  34518. * Instantiates a new ArcRotateCamera in a given scene
  34519. * @param name Defines the name of the camera
  34520. * @param alpha Defines the camera rotation along the logitudinal axis
  34521. * @param beta Defines the camera rotation along the latitudinal axis
  34522. * @param radius Defines the camera distance from its target
  34523. * @param target Defines the camera target
  34524. * @param scene Defines the scene the camera belongs to
  34525. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34526. */
  34527. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34528. /** @hidden */ initCache(): void;
  34529. /** @hidden */ updateCache(ignoreParentClass?: boolean): void;
  34530. protected _getTargetPosition(): Vector3;
  34531. private _storedAlpha;
  34532. private _storedBeta;
  34533. private _storedRadius;
  34534. private _storedTarget;
  34535. /**
  34536. * Stores the current state of the camera (alpha, beta, radius and target)
  34537. * @returns the camera itself
  34538. */
  34539. storeState(): Camera;
  34540. /**
  34541. * @hidden
  34542. * Restored camera state. You must call storeState() first
  34543. */ restoreStateValues(): boolean;
  34544. /** @hidden */ isSynchronizedViewMatrix(): boolean;
  34545. /**
  34546. * Attached controls to the current camera.
  34547. * @param element Defines the element the controls should be listened from
  34548. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34549. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34550. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34551. */
  34552. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34553. /**
  34554. * Detach the current controls from the camera.
  34555. * The camera will stop reacting to inputs.
  34556. * @param element Defines the element to stop listening the inputs from
  34557. */
  34558. detachControl(element: HTMLElement): void;
  34559. /** @hidden */ checkInputs(): void;
  34560. protected _checkLimits(): void;
  34561. /**
  34562. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34563. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  34564. */
  34565. rebuildAnglesAndRadius(updateView?: boolean): void;
  34566. /**
  34567. * Use a position to define the current camera related information like aplha, beta and radius
  34568. * @param position Defines the position to set the camera at
  34569. */
  34570. setPosition(position: Vector3): void;
  34571. /**
  34572. * Defines the target the camera should look at.
  34573. * This will automatically adapt alpha beta and radius to fit within the new target.
  34574. * @param target Defines the new target as a Vector or a mesh
  34575. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34576. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34577. */
  34578. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34579. /** @hidden */ getViewMatrix(): Matrix;
  34580. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34581. /**
  34582. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34583. * @param meshes Defines the mesh to zoom on
  34584. * @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)
  34585. */
  34586. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34587. /**
  34588. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34589. * The target will be changed but the radius
  34590. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34591. * @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)
  34592. */
  34593. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34594. min: Vector3;
  34595. max: Vector3;
  34596. distance: number;
  34597. }, doNotUpdateMaxZ?: boolean): void;
  34598. /**
  34599. * @override
  34600. * Override Camera.createRigCamera
  34601. */
  34602. createRigCamera(name: string, cameraIndex: number): Camera;
  34603. /**
  34604. * @hidden
  34605. * @override
  34606. * Override Camera._updateRigCameras
  34607. */ updateRigCameras(): void;
  34608. /**
  34609. * Destroy the camera and release the current resources hold by it.
  34610. */
  34611. dispose(): void;
  34612. /**
  34613. * Gets the current object class name.
  34614. * @return the class name
  34615. */
  34616. getClassName(): string;
  34617. }
  34618. }
  34619. declare module BABYLON {
  34620. /**
  34621. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34622. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34623. */
  34624. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34625. /**
  34626. * Gets the name of the behavior.
  34627. */
  34628. readonly name: string;
  34629. private _zoomStopsAnimation;
  34630. private _idleRotationSpeed;
  34631. private _idleRotationWaitTime;
  34632. private _idleRotationSpinupTime;
  34633. /**
  34634. * Sets the flag that indicates if user zooming should stop animation.
  34635. */
  34636. /**
  34637. * Gets the flag that indicates if user zooming should stop animation.
  34638. */
  34639. zoomStopsAnimation: boolean;
  34640. /**
  34641. * Sets the default speed at which the camera rotates around the model.
  34642. */
  34643. /**
  34644. * Gets the default speed at which the camera rotates around the model.
  34645. */
  34646. idleRotationSpeed: number;
  34647. /**
  34648. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34649. */
  34650. /**
  34651. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34652. */
  34653. idleRotationWaitTime: number;
  34654. /**
  34655. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34656. */
  34657. /**
  34658. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34659. */
  34660. idleRotationSpinupTime: number;
  34661. /**
  34662. * Gets a value indicating if the camera is currently rotating because of this behavior
  34663. */
  34664. readonly rotationInProgress: boolean;
  34665. private _onPrePointerObservableObserver;
  34666. private _onAfterCheckInputsObserver;
  34667. private _attachedCamera;
  34668. private _isPointerDown;
  34669. private _lastFrameTime;
  34670. private _lastInteractionTime;
  34671. private _cameraRotationSpeed;
  34672. /**
  34673. * Initializes the behavior.
  34674. */
  34675. init(): void;
  34676. /**
  34677. * Attaches the behavior to its arc rotate camera.
  34678. * @param camera Defines the camera to attach the behavior to
  34679. */
  34680. attach(camera: ArcRotateCamera): void;
  34681. /**
  34682. * Detaches the behavior from its current arc rotate camera.
  34683. */
  34684. detach(): void;
  34685. /**
  34686. * Returns true if user is scrolling.
  34687. * @return true if user is scrolling.
  34688. */
  34689. private _userIsZooming;
  34690. private _lastFrameRadius;
  34691. private _shouldAnimationStopForInteraction;
  34692. /**
  34693. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34694. */
  34695. private _applyUserInteraction;
  34696. private _userIsMoving;
  34697. }
  34698. }
  34699. declare module BABYLON {
  34700. /**
  34701. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34702. */
  34703. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34704. private ui;
  34705. /**
  34706. * The name of the behavior
  34707. */
  34708. name: string;
  34709. /**
  34710. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34711. */
  34712. distanceAwayFromFace: number;
  34713. /**
  34714. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34715. */
  34716. distanceAwayFromBottomOfFace: number;
  34717. private _faceVectors;
  34718. private _target;
  34719. private _scene;
  34720. private _onRenderObserver;
  34721. private _tmpMatrix;
  34722. private _tmpVector;
  34723. /**
  34724. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34725. * @param ui The transform node that should be attched to the mesh
  34726. */
  34727. constructor(ui: TransformNode);
  34728. /**
  34729. * Initializes the behavior
  34730. */
  34731. init(): void;
  34732. private _closestFace;
  34733. private _zeroVector;
  34734. private _lookAtTmpMatrix;
  34735. private _lookAtToRef;
  34736. /**
  34737. * Attaches the AttachToBoxBehavior to the passed in mesh
  34738. * @param target The mesh that the specified node will be attached to
  34739. */
  34740. attach(target: Mesh): void;
  34741. /**
  34742. * Detaches the behavior from the mesh
  34743. */
  34744. detach(): void;
  34745. }
  34746. }
  34747. declare module BABYLON {
  34748. /**
  34749. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  34750. */
  34751. export class FadeInOutBehavior implements Behavior<Mesh> {
  34752. /**
  34753. * Time in milliseconds to delay before fading in (Default: 0)
  34754. */
  34755. delay: number;
  34756. /**
  34757. * Time in milliseconds for the mesh to fade in (Default: 300)
  34758. */
  34759. fadeInTime: number;
  34760. private _millisecondsPerFrame;
  34761. private _hovered;
  34762. private _hoverValue;
  34763. private _ownerNode;
  34764. /**
  34765. * Instatiates the FadeInOutBehavior
  34766. */
  34767. constructor();
  34768. /**
  34769. * The name of the behavior
  34770. */
  34771. readonly name: string;
  34772. /**
  34773. * Initializes the behavior
  34774. */
  34775. init(): void;
  34776. /**
  34777. * Attaches the fade behavior on the passed in mesh
  34778. * @param ownerNode The mesh that will be faded in/out once attached
  34779. */
  34780. attach(ownerNode: Mesh): void;
  34781. /**
  34782. * Detaches the behavior from the mesh
  34783. */
  34784. detach(): void;
  34785. /**
  34786. * Triggers the mesh to begin fading in or out
  34787. * @param value if the object should fade in or out (true to fade in)
  34788. */
  34789. fadeIn(value: boolean): void;
  34790. private _update;
  34791. private _setAllVisibility;
  34792. }
  34793. }
  34794. declare module BABYLON {
  34795. /**
  34796. * Class containing a set of static utilities functions for managing Pivots
  34797. * @hidden
  34798. */
  34799. export class PivotTools {
  34800. private static _PivotCached;
  34801. private static _OldPivotPoint;
  34802. private static _PivotTranslation;
  34803. private static _PivotTmpVector;
  34804. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  34805. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  34806. }
  34807. }
  34808. declare module BABYLON {
  34809. /**
  34810. * Class containing static functions to help procedurally build meshes
  34811. */
  34812. export class PlaneBuilder {
  34813. /**
  34814. * Creates a plane mesh
  34815. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  34816. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  34817. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  34818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34819. * * 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
  34820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34821. * @param name defines the name of the mesh
  34822. * @param options defines the options used to create the mesh
  34823. * @param scene defines the hosting scene
  34824. * @returns the plane mesh
  34825. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  34826. */
  34827. static CreatePlane(name: string, options: {
  34828. size?: number;
  34829. width?: number;
  34830. height?: number;
  34831. sideOrientation?: number;
  34832. frontUVs?: Vector4;
  34833. backUVs?: Vector4;
  34834. updatable?: boolean;
  34835. sourcePlane?: Plane;
  34836. }, scene: Scene): Mesh;
  34837. }
  34838. }
  34839. declare module BABYLON {
  34840. /**
  34841. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  34842. */
  34843. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  34844. private static _AnyMouseID;
  34845. private _attachedNode;
  34846. private _dragPlane;
  34847. private _scene;
  34848. private _pointerObserver;
  34849. private _beforeRenderObserver;
  34850. private static _planeScene;
  34851. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  34852. /**
  34853. * 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)
  34854. */
  34855. maxDragAngle: number;
  34856. /**
  34857. * @hidden
  34858. */ useAlternatePickedPointAboveMaxDragAngle: boolean;
  34859. /**
  34860. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  34861. */
  34862. currentDraggingPointerID: number;
  34863. /**
  34864. * The last position where the pointer hit the drag plane in world space
  34865. */
  34866. lastDragPosition: Vector3;
  34867. /**
  34868. * If the behavior is currently in a dragging state
  34869. */
  34870. dragging: boolean;
  34871. /**
  34872. * 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)
  34873. */
  34874. dragDeltaRatio: number;
  34875. /**
  34876. * If the drag plane orientation should be updated during the dragging (Default: true)
  34877. */
  34878. updateDragPlane: boolean;
  34879. private _debugMode;
  34880. private _moving;
  34881. /**
  34882. * Fires each time the attached mesh is dragged with the pointer
  34883. * * delta between last drag position and current drag position in world space
  34884. * * dragDistance along the drag axis
  34885. * * dragPlaneNormal normal of the current drag plane used during the drag
  34886. * * dragPlanePoint in world space where the drag intersects the drag plane
  34887. */
  34888. onDragObservable: Observable<{
  34889. delta: Vector3;
  34890. dragPlanePoint: Vector3;
  34891. dragPlaneNormal: Vector3;
  34892. dragDistance: number;
  34893. pointerId: number;
  34894. }>;
  34895. /**
  34896. * Fires each time a drag begins (eg. mouse down on mesh)
  34897. */
  34898. onDragStartObservable: Observable<{
  34899. dragPlanePoint: Vector3;
  34900. pointerId: number;
  34901. }>;
  34902. /**
  34903. * Fires each time a drag ends (eg. mouse release after drag)
  34904. */
  34905. onDragEndObservable: Observable<{
  34906. dragPlanePoint: Vector3;
  34907. pointerId: number;
  34908. }>;
  34909. /**
  34910. * If the attached mesh should be moved when dragged
  34911. */
  34912. moveAttached: boolean;
  34913. /**
  34914. * If the drag behavior will react to drag events (Default: true)
  34915. */
  34916. enabled: boolean;
  34917. /**
  34918. * If camera controls should be detached during the drag
  34919. */
  34920. detachCameraControls: boolean;
  34921. /**
  34922. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  34923. */
  34924. useObjectOrienationForDragging: boolean;
  34925. private _options;
  34926. /**
  34927. * Creates a pointer drag behavior that can be attached to a mesh
  34928. * @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)
  34929. */
  34930. constructor(options?: {
  34931. dragAxis?: Vector3;
  34932. dragPlaneNormal?: Vector3;
  34933. });
  34934. /**
  34935. * Predicate to determine if it is valid to move the object to a new position when it is moved
  34936. */
  34937. validateDrag: (targetPosition: Vector3) => boolean;
  34938. /**
  34939. * The name of the behavior
  34940. */
  34941. readonly name: string;
  34942. /**
  34943. * Initializes the behavior
  34944. */
  34945. init(): void;
  34946. private _tmpVector;
  34947. private _alternatePickedPoint;
  34948. private _worldDragAxis;
  34949. private _targetPosition;
  34950. private _attachedElement;
  34951. /**
  34952. * Attaches the drag behavior the passed in mesh
  34953. * @param ownerNode The mesh that will be dragged around once attached
  34954. */
  34955. attach(ownerNode: AbstractMesh): void;
  34956. /**
  34957. * Force relase the drag action by code.
  34958. */
  34959. releaseDrag(): void;
  34960. private _startDragRay;
  34961. private _lastPointerRay;
  34962. /**
  34963. * Simulates the start of a pointer drag event on the behavior
  34964. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  34965. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  34966. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  34967. */
  34968. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  34969. private _startDrag;
  34970. private _dragDelta;
  34971. private _moveDrag;
  34972. private _pickWithRayOnDragPlane;
  34973. private _pointA;
  34974. private _pointB;
  34975. private _pointC;
  34976. private _lineA;
  34977. private _lineB;
  34978. private _localAxis;
  34979. private _lookAt;
  34980. private _updateDragPlanePosition;
  34981. /**
  34982. * Detaches the behavior from the mesh
  34983. */
  34984. detach(): void;
  34985. }
  34986. }
  34987. declare module BABYLON {
  34988. /**
  34989. * A behavior that when attached to a mesh will allow the mesh to be scaled
  34990. */
  34991. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  34992. private _dragBehaviorA;
  34993. private _dragBehaviorB;
  34994. private _startDistance;
  34995. private _initialScale;
  34996. private _targetScale;
  34997. private _ownerNode;
  34998. private _sceneRenderObserver;
  34999. /**
  35000. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35001. */
  35002. constructor();
  35003. /**
  35004. * The name of the behavior
  35005. */
  35006. readonly name: string;
  35007. /**
  35008. * Initializes the behavior
  35009. */
  35010. init(): void;
  35011. private _getCurrentDistance;
  35012. /**
  35013. * Attaches the scale behavior the passed in mesh
  35014. * @param ownerNode The mesh that will be scaled around once attached
  35015. */
  35016. attach(ownerNode: Mesh): void;
  35017. /**
  35018. * Detaches the behavior from the mesh
  35019. */
  35020. detach(): void;
  35021. }
  35022. }
  35023. declare module BABYLON {
  35024. /**
  35025. * 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
  35026. */
  35027. export class SixDofDragBehavior implements Behavior<Mesh> {
  35028. private static _virtualScene;
  35029. private _ownerNode;
  35030. private _sceneRenderObserver;
  35031. private _scene;
  35032. private _targetPosition;
  35033. private _virtualOriginMesh;
  35034. private _virtualDragMesh;
  35035. private _pointerObserver;
  35036. private _moving;
  35037. private _startingOrientation;
  35038. /**
  35039. * 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)
  35040. */
  35041. private zDragFactor;
  35042. /**
  35043. * If the object should rotate to face the drag origin
  35044. */
  35045. rotateDraggedObject: boolean;
  35046. /**
  35047. * If the behavior is currently in a dragging state
  35048. */
  35049. dragging: boolean;
  35050. /**
  35051. * 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)
  35052. */
  35053. dragDeltaRatio: number;
  35054. /**
  35055. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35056. */
  35057. currentDraggingPointerID: number;
  35058. /**
  35059. * If camera controls should be detached during the drag
  35060. */
  35061. detachCameraControls: boolean;
  35062. /**
  35063. * Fires each time a drag starts
  35064. */
  35065. onDragStartObservable: Observable<{}>;
  35066. /**
  35067. * Fires each time a drag ends (eg. mouse release after drag)
  35068. */
  35069. onDragEndObservable: Observable<{}>;
  35070. /**
  35071. * 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
  35072. */
  35073. constructor();
  35074. /**
  35075. * The name of the behavior
  35076. */
  35077. readonly name: string;
  35078. /**
  35079. * Initializes the behavior
  35080. */
  35081. init(): void;
  35082. /**
  35083. * Attaches the scale behavior the passed in mesh
  35084. * @param ownerNode The mesh that will be scaled around once attached
  35085. */
  35086. attach(ownerNode: Mesh): void;
  35087. /**
  35088. * Detaches the behavior from the mesh
  35089. */
  35090. detach(): void;
  35091. }
  35092. }
  35093. declare module BABYLON {
  35094. /**
  35095. * Class used to apply inverse kinematics to bones
  35096. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35097. */
  35098. export class BoneIKController {
  35099. private static _tmpVecs;
  35100. private static _tmpQuat;
  35101. private static _tmpMats;
  35102. /**
  35103. * Gets or sets the target mesh
  35104. */
  35105. targetMesh: AbstractMesh;
  35106. /** Gets or sets the mesh used as pole */
  35107. poleTargetMesh: AbstractMesh;
  35108. /**
  35109. * Gets or sets the bone used as pole
  35110. */
  35111. poleTargetBone: Nullable<Bone>;
  35112. /**
  35113. * Gets or sets the target position
  35114. */
  35115. targetPosition: Vector3;
  35116. /**
  35117. * Gets or sets the pole target position
  35118. */
  35119. poleTargetPosition: Vector3;
  35120. /**
  35121. * Gets or sets the pole target local offset
  35122. */
  35123. poleTargetLocalOffset: Vector3;
  35124. /**
  35125. * Gets or sets the pole angle
  35126. */
  35127. poleAngle: number;
  35128. /**
  35129. * Gets or sets the mesh associated with the controller
  35130. */
  35131. mesh: AbstractMesh;
  35132. /**
  35133. * 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)
  35134. */
  35135. slerpAmount: number;
  35136. private _bone1Quat;
  35137. private _bone1Mat;
  35138. private _bone2Ang;
  35139. private _bone1;
  35140. private _bone2;
  35141. private _bone1Length;
  35142. private _bone2Length;
  35143. private _maxAngle;
  35144. private _maxReach;
  35145. private _rightHandedSystem;
  35146. private _bendAxis;
  35147. private _slerping;
  35148. private _adjustRoll;
  35149. /**
  35150. * Gets or sets maximum allowed angle
  35151. */
  35152. maxAngle: number;
  35153. /**
  35154. * Creates a new BoneIKController
  35155. * @param mesh defines the mesh to control
  35156. * @param bone defines the bone to control
  35157. * @param options defines options to set up the controller
  35158. */
  35159. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35160. targetMesh?: AbstractMesh;
  35161. poleTargetMesh?: AbstractMesh;
  35162. poleTargetBone?: Bone;
  35163. poleTargetLocalOffset?: Vector3;
  35164. poleAngle?: number;
  35165. bendAxis?: Vector3;
  35166. maxAngle?: number;
  35167. slerpAmount?: number;
  35168. });
  35169. private _setMaxAngle;
  35170. /**
  35171. * Force the controller to update the bones
  35172. */
  35173. update(): void;
  35174. }
  35175. }
  35176. declare module BABYLON {
  35177. /**
  35178. * Class used to make a bone look toward a point in space
  35179. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35180. */
  35181. export class BoneLookController {
  35182. private static _tmpVecs;
  35183. private static _tmpQuat;
  35184. private static _tmpMats;
  35185. /**
  35186. * The target Vector3 that the bone will look at
  35187. */
  35188. target: Vector3;
  35189. /**
  35190. * The mesh that the bone is attached to
  35191. */
  35192. mesh: AbstractMesh;
  35193. /**
  35194. * The bone that will be looking to the target
  35195. */
  35196. bone: Bone;
  35197. /**
  35198. * The up axis of the coordinate system that is used when the bone is rotated
  35199. */
  35200. upAxis: Vector3;
  35201. /**
  35202. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35203. */
  35204. upAxisSpace: Space;
  35205. /**
  35206. * Used to make an adjustment to the yaw of the bone
  35207. */
  35208. adjustYaw: number;
  35209. /**
  35210. * Used to make an adjustment to the pitch of the bone
  35211. */
  35212. adjustPitch: number;
  35213. /**
  35214. * Used to make an adjustment to the roll of the bone
  35215. */
  35216. adjustRoll: number;
  35217. /**
  35218. * 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)
  35219. */
  35220. slerpAmount: number;
  35221. private _minYaw;
  35222. private _maxYaw;
  35223. private _minPitch;
  35224. private _maxPitch;
  35225. private _minYawSin;
  35226. private _minYawCos;
  35227. private _maxYawSin;
  35228. private _maxYawCos;
  35229. private _midYawConstraint;
  35230. private _minPitchTan;
  35231. private _maxPitchTan;
  35232. private _boneQuat;
  35233. private _slerping;
  35234. private _transformYawPitch;
  35235. private _transformYawPitchInv;
  35236. private _firstFrameSkipped;
  35237. private _yawRange;
  35238. private _fowardAxis;
  35239. /**
  35240. * Gets or sets the minimum yaw angle that the bone can look to
  35241. */
  35242. minYaw: number;
  35243. /**
  35244. * Gets or sets the maximum yaw angle that the bone can look to
  35245. */
  35246. maxYaw: number;
  35247. /**
  35248. * Gets or sets the minimum pitch angle that the bone can look to
  35249. */
  35250. minPitch: number;
  35251. /**
  35252. * Gets or sets the maximum pitch angle that the bone can look to
  35253. */
  35254. maxPitch: number;
  35255. /**
  35256. * Create a BoneLookController
  35257. * @param mesh the mesh that the bone belongs to
  35258. * @param bone the bone that will be looking to the target
  35259. * @param target the target Vector3 to look at
  35260. * @param options optional settings:
  35261. * * maxYaw: the maximum angle the bone will yaw to
  35262. * * minYaw: the minimum angle the bone will yaw to
  35263. * * maxPitch: the maximum angle the bone will pitch to
  35264. * * minPitch: the minimum angle the bone will yaw to
  35265. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35266. * * upAxis: the up axis of the coordinate system
  35267. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35268. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35269. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35270. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35271. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35272. * * adjustRoll: used to make an adjustment to the roll of the bone
  35273. **/
  35274. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35275. maxYaw?: number;
  35276. minYaw?: number;
  35277. maxPitch?: number;
  35278. minPitch?: number;
  35279. slerpAmount?: number;
  35280. upAxis?: Vector3;
  35281. upAxisSpace?: Space;
  35282. yawAxis?: Vector3;
  35283. pitchAxis?: Vector3;
  35284. adjustYaw?: number;
  35285. adjustPitch?: number;
  35286. adjustRoll?: number;
  35287. });
  35288. /**
  35289. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35290. */
  35291. update(): void;
  35292. private _getAngleDiff;
  35293. private _getAngleBetween;
  35294. private _isAngleBetween;
  35295. }
  35296. }
  35297. declare module BABYLON {
  35298. /**
  35299. * Manage the gamepad inputs to control an arc rotate camera.
  35300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35301. */
  35302. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35303. /**
  35304. * Defines the camera the input is attached to.
  35305. */
  35306. camera: ArcRotateCamera;
  35307. /**
  35308. * Defines the gamepad the input is gathering event from.
  35309. */
  35310. gamepad: Nullable<Gamepad>;
  35311. /**
  35312. * Defines the gamepad rotation sensiblity.
  35313. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35314. */
  35315. gamepadRotationSensibility: number;
  35316. /**
  35317. * Defines the gamepad move sensiblity.
  35318. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35319. */
  35320. gamepadMoveSensibility: number;
  35321. private _onGamepadConnectedObserver;
  35322. private _onGamepadDisconnectedObserver;
  35323. /**
  35324. * Attach the input controls to a specific dom element to get the input from.
  35325. * @param element Defines the element the controls should be listened from
  35326. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35327. */
  35328. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35329. /**
  35330. * Detach the current controls from the specified dom element.
  35331. * @param element Defines the element to stop listening the inputs from
  35332. */
  35333. detachControl(element: Nullable<HTMLElement>): void;
  35334. /**
  35335. * Update the current camera state depending on the inputs that have been used this frame.
  35336. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35337. */
  35338. checkInputs(): void;
  35339. /**
  35340. * Gets the class name of the current intput.
  35341. * @returns the class name
  35342. */
  35343. getClassName(): string;
  35344. /**
  35345. * Get the friendly name associated with the input class.
  35346. * @returns the input friendly name
  35347. */
  35348. getSimpleName(): string;
  35349. }
  35350. }
  35351. declare module BABYLON {
  35352. interface ArcRotateCameraInputsManager {
  35353. /**
  35354. * Add orientation input support to the input manager.
  35355. * @returns the current input manager
  35356. */
  35357. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35358. }
  35359. /**
  35360. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35361. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35362. */
  35363. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35364. /**
  35365. * Defines the camera the input is attached to.
  35366. */
  35367. camera: ArcRotateCamera;
  35368. /**
  35369. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35370. */
  35371. alphaCorrection: number;
  35372. /**
  35373. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35374. */
  35375. gammaCorrection: number;
  35376. private _alpha;
  35377. private _gamma;
  35378. private _dirty;
  35379. private _deviceOrientationHandler;
  35380. /**
  35381. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35382. */
  35383. constructor();
  35384. /**
  35385. * Attach the input controls to a specific dom element to get the input from.
  35386. * @param element Defines the element the controls should be listened from
  35387. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35388. */
  35389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35390. /** @hidden */ onOrientationEvent(evt: DeviceOrientationEvent): void;
  35391. /**
  35392. * Update the current camera state depending on the inputs that have been used this frame.
  35393. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35394. */
  35395. checkInputs(): void;
  35396. /**
  35397. * Detach the current controls from the specified dom element.
  35398. * @param element Defines the element to stop listening the inputs from
  35399. */
  35400. detachControl(element: Nullable<HTMLElement>): void;
  35401. /**
  35402. * Gets the class name of the current intput.
  35403. * @returns the class name
  35404. */
  35405. getClassName(): string;
  35406. /**
  35407. * Get the friendly name associated with the input class.
  35408. * @returns the input friendly name
  35409. */
  35410. getSimpleName(): string;
  35411. }
  35412. }
  35413. declare module BABYLON {
  35414. /**
  35415. * Listen to mouse events to control the camera.
  35416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35417. */
  35418. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35419. /**
  35420. * Defines the camera the input is attached to.
  35421. */
  35422. camera: FlyCamera;
  35423. /**
  35424. * Defines if touch is enabled. (Default is true.)
  35425. */
  35426. touchEnabled: boolean;
  35427. /**
  35428. * Defines the buttons associated with the input to handle camera rotation.
  35429. */
  35430. buttons: number[];
  35431. /**
  35432. * Assign buttons for Yaw control.
  35433. */
  35434. buttonsYaw: number[];
  35435. /**
  35436. * Assign buttons for Pitch control.
  35437. */
  35438. buttonsPitch: number[];
  35439. /**
  35440. * Assign buttons for Roll control.
  35441. */
  35442. buttonsRoll: number[];
  35443. /**
  35444. * Detect if any button is being pressed while mouse is moved.
  35445. * -1 = Mouse locked.
  35446. * 0 = Left button.
  35447. * 1 = Middle Button.
  35448. * 2 = Right Button.
  35449. */
  35450. activeButton: number;
  35451. /**
  35452. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35453. * Higher values reduce its sensitivity.
  35454. */
  35455. angularSensibility: number;
  35456. private _mousemoveCallback;
  35457. private _observer;
  35458. private _rollObserver;
  35459. private previousPosition;
  35460. private noPreventDefault;
  35461. private element;
  35462. /**
  35463. * Listen to mouse events to control the camera.
  35464. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35465. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35466. */
  35467. constructor(touchEnabled?: boolean);
  35468. /**
  35469. * Attach the mouse control to the HTML DOM element.
  35470. * @param element Defines the element that listens to the input events.
  35471. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35472. */
  35473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35474. /**
  35475. * Detach the current controls from the specified dom element.
  35476. * @param element Defines the element to stop listening the inputs from
  35477. */
  35478. detachControl(element: Nullable<HTMLElement>): void;
  35479. /**
  35480. * Gets the class name of the current input.
  35481. * @returns the class name.
  35482. */
  35483. getClassName(): string;
  35484. /**
  35485. * Get the friendly name associated with the input class.
  35486. * @returns the input's friendly name.
  35487. */
  35488. getSimpleName(): string;
  35489. private _pointerInput;
  35490. private _onMouseMove;
  35491. /**
  35492. * Rotate camera by mouse offset.
  35493. */
  35494. private rotateCamera;
  35495. }
  35496. }
  35497. declare module BABYLON {
  35498. /**
  35499. * Default Inputs manager for the FlyCamera.
  35500. * It groups all the default supported inputs for ease of use.
  35501. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35502. */
  35503. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35504. /**
  35505. * Instantiates a new FlyCameraInputsManager.
  35506. * @param camera Defines the camera the inputs belong to.
  35507. */
  35508. constructor(camera: FlyCamera);
  35509. /**
  35510. * Add keyboard input support to the input manager.
  35511. * @returns the new FlyCameraKeyboardMoveInput().
  35512. */
  35513. addKeyboard(): FlyCameraInputsManager;
  35514. /**
  35515. * Add mouse input support to the input manager.
  35516. * @param touchEnabled Enable touch screen support.
  35517. * @returns the new FlyCameraMouseInput().
  35518. */
  35519. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35520. }
  35521. }
  35522. declare module BABYLON {
  35523. /**
  35524. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35525. * such as in a 3D Space Shooter or a Flight Simulator.
  35526. */
  35527. export class FlyCamera extends TargetCamera {
  35528. /**
  35529. * Define the collision ellipsoid of the camera.
  35530. * This is helpful for simulating a camera body, like a player's body.
  35531. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35532. */
  35533. ellipsoid: Vector3;
  35534. /**
  35535. * Define an offset for the position of the ellipsoid around the camera.
  35536. * This can be helpful if the camera is attached away from the player's body center,
  35537. * such as at its head.
  35538. */
  35539. ellipsoidOffset: Vector3;
  35540. /**
  35541. * Enable or disable collisions of the camera with the rest of the scene objects.
  35542. */
  35543. checkCollisions: boolean;
  35544. /**
  35545. * Enable or disable gravity on the camera.
  35546. */
  35547. applyGravity: boolean;
  35548. /**
  35549. * Define the current direction the camera is moving to.
  35550. */
  35551. cameraDirection: Vector3;
  35552. /**
  35553. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35554. * This overrides and empties cameraRotation.
  35555. */
  35556. rotationQuaternion: Quaternion;
  35557. /**
  35558. * Track Roll to maintain the wanted Rolling when looking around.
  35559. */ trackRoll: number;
  35560. /**
  35561. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35562. */
  35563. rollCorrect: number;
  35564. /**
  35565. * Mimic a banked turn, Rolling the camera when Yawing.
  35566. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35567. */
  35568. bankedTurn: boolean;
  35569. /**
  35570. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35571. */
  35572. bankedTurnLimit: number;
  35573. /**
  35574. * Value of 0 disables the banked Roll.
  35575. * Value of 1 is equal to the Yaw angle in radians.
  35576. */
  35577. bankedTurnMultiplier: number;
  35578. /**
  35579. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35580. */
  35581. inputs: FlyCameraInputsManager;
  35582. /**
  35583. * Gets the input sensibility for mouse input.
  35584. * Higher values reduce sensitivity.
  35585. */
  35586. /**
  35587. * Sets the input sensibility for a mouse input.
  35588. * Higher values reduce sensitivity.
  35589. */
  35590. angularSensibility: number;
  35591. /**
  35592. * Get the keys for camera movement forward.
  35593. */
  35594. /**
  35595. * Set the keys for camera movement forward.
  35596. */
  35597. keysForward: number[];
  35598. /**
  35599. * Get the keys for camera movement backward.
  35600. */
  35601. keysBackward: number[];
  35602. /**
  35603. * Get the keys for camera movement up.
  35604. */
  35605. /**
  35606. * Set the keys for camera movement up.
  35607. */
  35608. keysUp: number[];
  35609. /**
  35610. * Get the keys for camera movement down.
  35611. */
  35612. /**
  35613. * Set the keys for camera movement down.
  35614. */
  35615. keysDown: number[];
  35616. /**
  35617. * Get the keys for camera movement left.
  35618. */
  35619. /**
  35620. * Set the keys for camera movement left.
  35621. */
  35622. keysLeft: number[];
  35623. /**
  35624. * Set the keys for camera movement right.
  35625. */
  35626. /**
  35627. * Set the keys for camera movement right.
  35628. */
  35629. keysRight: number[];
  35630. /**
  35631. * Event raised when the camera collides with a mesh in the scene.
  35632. */
  35633. onCollide: (collidedMesh: AbstractMesh) => void;
  35634. private _collider;
  35635. private _needMoveForGravity;
  35636. private _oldPosition;
  35637. private _diffPosition;
  35638. private _newPosition;
  35639. /** @hidden */ localDirection: Vector3;
  35640. /** @hidden */ transformedDirection: Vector3;
  35641. /**
  35642. * Instantiates a FlyCamera.
  35643. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35644. * such as in a 3D Space Shooter or a Flight Simulator.
  35645. * @param name Define the name of the camera in the scene.
  35646. * @param position Define the starting position of the camera in the scene.
  35647. * @param scene Define the scene the camera belongs to.
  35648. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35649. */
  35650. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35651. /**
  35652. * Attach a control to the HTML DOM element.
  35653. * @param element Defines the element that listens to the input events.
  35654. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35655. */
  35656. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35657. /**
  35658. * Detach a control from the HTML DOM element.
  35659. * The camera will stop reacting to that input.
  35660. * @param element Defines the element that listens to the input events.
  35661. */
  35662. detachControl(element: HTMLElement): void;
  35663. private _collisionMask;
  35664. /**
  35665. * Get the mask that the camera ignores in collision events.
  35666. */
  35667. /**
  35668. * Set the mask that the camera ignores in collision events.
  35669. */
  35670. collisionMask: number;
  35671. /** @hidden */ collideWithWorld(displacement: Vector3): void;
  35672. /** @hidden */
  35673. private _onCollisionPositionChange;
  35674. /** @hidden */ checkInputs(): void;
  35675. /** @hidden */ decideIfNeedsToMove(): boolean;
  35676. /** @hidden */ updatePosition(): void;
  35677. /**
  35678. * Restore the Roll to its target value at the rate specified.
  35679. * @param rate - Higher means slower restoring.
  35680. * @hidden
  35681. */
  35682. restoreRoll(rate: number): void;
  35683. /**
  35684. * Destroy the camera and release the current resources held by it.
  35685. */
  35686. dispose(): void;
  35687. /**
  35688. * Get the current object class name.
  35689. * @returns the class name.
  35690. */
  35691. getClassName(): string;
  35692. }
  35693. }
  35694. declare module BABYLON {
  35695. /**
  35696. * Listen to keyboard events to control the camera.
  35697. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35698. */
  35699. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35700. /**
  35701. * Defines the camera the input is attached to.
  35702. */
  35703. camera: FlyCamera;
  35704. /**
  35705. * The list of keyboard keys used to control the forward move of the camera.
  35706. */
  35707. keysForward: number[];
  35708. /**
  35709. * The list of keyboard keys used to control the backward move of the camera.
  35710. */
  35711. keysBackward: number[];
  35712. /**
  35713. * The list of keyboard keys used to control the forward move of the camera.
  35714. */
  35715. keysUp: number[];
  35716. /**
  35717. * The list of keyboard keys used to control the backward move of the camera.
  35718. */
  35719. keysDown: number[];
  35720. /**
  35721. * The list of keyboard keys used to control the right strafe move of the camera.
  35722. */
  35723. keysRight: number[];
  35724. /**
  35725. * The list of keyboard keys used to control the left strafe move of the camera.
  35726. */
  35727. keysLeft: number[];
  35728. private _keys;
  35729. private _onCanvasBlurObserver;
  35730. private _onKeyboardObserver;
  35731. private _engine;
  35732. private _scene;
  35733. /**
  35734. * Attach the input controls to a specific dom element to get the input from.
  35735. * @param element Defines the element the controls should be listened from
  35736. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35737. */
  35738. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35739. /**
  35740. * Detach the current controls from the specified dom element.
  35741. * @param element Defines the element to stop listening the inputs from
  35742. */
  35743. detachControl(element: Nullable<HTMLElement>): void;
  35744. /**
  35745. * Gets the class name of the current intput.
  35746. * @returns the class name
  35747. */
  35748. getClassName(): string;
  35749. /** @hidden */ onLostFocus(e: FocusEvent): void;
  35750. /**
  35751. * Get the friendly name associated with the input class.
  35752. * @returns the input friendly name
  35753. */
  35754. getSimpleName(): string;
  35755. /**
  35756. * Update the current camera state depending on the inputs that have been used this frame.
  35757. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35758. */
  35759. checkInputs(): void;
  35760. }
  35761. }
  35762. declare module BABYLON {
  35763. /**
  35764. * Manage the mouse wheel inputs to control a follow camera.
  35765. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35766. */
  35767. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  35768. /**
  35769. * Defines the camera the input is attached to.
  35770. */
  35771. camera: FollowCamera;
  35772. /**
  35773. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  35774. */
  35775. axisControlRadius: boolean;
  35776. /**
  35777. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  35778. */
  35779. axisControlHeight: boolean;
  35780. /**
  35781. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  35782. */
  35783. axisControlRotation: boolean;
  35784. /**
  35785. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  35786. * relation to mouseWheel events.
  35787. */
  35788. wheelPrecision: number;
  35789. /**
  35790. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35791. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35792. */
  35793. wheelDeltaPercentage: number;
  35794. private _wheel;
  35795. private _observer;
  35796. /**
  35797. * Attach the input controls to a specific dom element to get the input from.
  35798. * @param element Defines the element the controls should be listened from
  35799. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35800. */
  35801. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35802. /**
  35803. * Detach the current controls from the specified dom element.
  35804. * @param element Defines the element to stop listening the inputs from
  35805. */
  35806. detachControl(element: Nullable<HTMLElement>): void;
  35807. /**
  35808. * Gets the class name of the current intput.
  35809. * @returns the class name
  35810. */
  35811. getClassName(): string;
  35812. /**
  35813. * Get the friendly name associated with the input class.
  35814. * @returns the input friendly name
  35815. */
  35816. getSimpleName(): string;
  35817. }
  35818. }
  35819. declare module BABYLON {
  35820. /**
  35821. * Manage the pointers inputs to control an follow camera.
  35822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35823. */
  35824. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  35825. /**
  35826. * Defines the camera the input is attached to.
  35827. */
  35828. camera: FollowCamera;
  35829. /**
  35830. * Gets the class name of the current input.
  35831. * @returns the class name
  35832. */
  35833. getClassName(): string;
  35834. /**
  35835. * Defines the pointer angular sensibility along the X axis or how fast is
  35836. * the camera rotating.
  35837. * A negative number will reverse the axis direction.
  35838. */
  35839. angularSensibilityX: number;
  35840. /**
  35841. * Defines the pointer angular sensibility along the Y axis or how fast is
  35842. * the camera rotating.
  35843. * A negative number will reverse the axis direction.
  35844. */
  35845. angularSensibilityY: number;
  35846. /**
  35847. * Defines the pointer pinch precision or how fast is the camera zooming.
  35848. * A negative number will reverse the axis direction.
  35849. */
  35850. pinchPrecision: number;
  35851. /**
  35852. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35853. * from 0.
  35854. * It defines the percentage of current camera.radius to use as delta when
  35855. * pinch zoom is used.
  35856. */
  35857. pinchDeltaPercentage: number;
  35858. /**
  35859. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  35860. */
  35861. axisXControlRadius: boolean;
  35862. /**
  35863. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  35864. */
  35865. axisXControlHeight: boolean;
  35866. /**
  35867. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  35868. */
  35869. axisXControlRotation: boolean;
  35870. /**
  35871. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  35872. */
  35873. axisYControlRadius: boolean;
  35874. /**
  35875. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  35876. */
  35877. axisYControlHeight: boolean;
  35878. /**
  35879. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  35880. */
  35881. axisYControlRotation: boolean;
  35882. /**
  35883. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  35884. */
  35885. axisPinchControlRadius: boolean;
  35886. /**
  35887. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  35888. */
  35889. axisPinchControlHeight: boolean;
  35890. /**
  35891. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  35892. */
  35893. axisPinchControlRotation: boolean;
  35894. /**
  35895. * Log error messages if basic misconfiguration has occurred.
  35896. */
  35897. warningEnable: boolean;
  35898. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35899. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35900. private _warningCounter;
  35901. private _warning;
  35902. }
  35903. }
  35904. declare module BABYLON {
  35905. /**
  35906. * Default Inputs manager for the FollowCamera.
  35907. * It groups all the default supported inputs for ease of use.
  35908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35909. */
  35910. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  35911. /**
  35912. * Instantiates a new FollowCameraInputsManager.
  35913. * @param camera Defines the camera the inputs belong to
  35914. */
  35915. constructor(camera: FollowCamera);
  35916. /**
  35917. * Add keyboard input support to the input manager.
  35918. * @returns the current input manager
  35919. */
  35920. addKeyboard(): FollowCameraInputsManager;
  35921. /**
  35922. * Add mouse wheel input support to the input manager.
  35923. * @returns the current input manager
  35924. */
  35925. addMouseWheel(): FollowCameraInputsManager;
  35926. /**
  35927. * Add pointers input support to the input manager.
  35928. * @returns the current input manager
  35929. */
  35930. addPointers(): FollowCameraInputsManager;
  35931. /**
  35932. * Add orientation input support to the input manager.
  35933. * @returns the current input manager
  35934. */
  35935. addVRDeviceOrientation(): FollowCameraInputsManager;
  35936. }
  35937. }
  35938. declare module BABYLON {
  35939. /**
  35940. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  35941. * an arc rotate version arcFollowCamera are available.
  35942. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  35943. */
  35944. export class FollowCamera extends TargetCamera {
  35945. /**
  35946. * Distance the follow camera should follow an object at
  35947. */
  35948. radius: number;
  35949. /**
  35950. * Minimum allowed distance of the camera to the axis of rotation
  35951. * (The camera can not get closer).
  35952. * This can help limiting how the Camera is able to move in the scene.
  35953. */
  35954. lowerRadiusLimit: Nullable<number>;
  35955. /**
  35956. * Maximum allowed distance of the camera to the axis of rotation
  35957. * (The camera can not get further).
  35958. * This can help limiting how the Camera is able to move in the scene.
  35959. */
  35960. upperRadiusLimit: Nullable<number>;
  35961. /**
  35962. * Define a rotation offset between the camera and the object it follows
  35963. */
  35964. rotationOffset: number;
  35965. /**
  35966. * Minimum allowed angle to camera position relative to target object.
  35967. * This can help limiting how the Camera is able to move in the scene.
  35968. */
  35969. lowerRotationOffsetLimit: Nullable<number>;
  35970. /**
  35971. * Maximum allowed angle to camera position relative to target object.
  35972. * This can help limiting how the Camera is able to move in the scene.
  35973. */
  35974. upperRotationOffsetLimit: Nullable<number>;
  35975. /**
  35976. * Define a height offset between the camera and the object it follows.
  35977. * It can help following an object from the top (like a car chaing a plane)
  35978. */
  35979. heightOffset: number;
  35980. /**
  35981. * Minimum allowed height of camera position relative to target object.
  35982. * This can help limiting how the Camera is able to move in the scene.
  35983. */
  35984. lowerHeightOffsetLimit: Nullable<number>;
  35985. /**
  35986. * Maximum allowed height of camera position relative to target object.
  35987. * This can help limiting how the Camera is able to move in the scene.
  35988. */
  35989. upperHeightOffsetLimit: Nullable<number>;
  35990. /**
  35991. * Define how fast the camera can accelerate to follow it s target.
  35992. */
  35993. cameraAcceleration: number;
  35994. /**
  35995. * Define the speed limit of the camera following an object.
  35996. */
  35997. maxCameraSpeed: number;
  35998. /**
  35999. * Define the target of the camera.
  36000. */
  36001. lockedTarget: Nullable<AbstractMesh>;
  36002. /**
  36003. * Defines the input associated with the camera.
  36004. */
  36005. inputs: FollowCameraInputsManager;
  36006. /**
  36007. * Instantiates the follow camera.
  36008. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36009. * @param name Define the name of the camera in the scene
  36010. * @param position Define the position of the camera
  36011. * @param scene Define the scene the camera belong to
  36012. * @param lockedTarget Define the target of the camera
  36013. */
  36014. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36015. private _follow;
  36016. /**
  36017. * Attached controls to the current camera.
  36018. * @param element Defines the element the controls should be listened from
  36019. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36020. */
  36021. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36022. /**
  36023. * Detach the current controls from the camera.
  36024. * The camera will stop reacting to inputs.
  36025. * @param element Defines the element to stop listening the inputs from
  36026. */
  36027. detachControl(element: HTMLElement): void;
  36028. /** @hidden */ checkInputs(): void;
  36029. private _checkLimits;
  36030. /**
  36031. * Gets the camera class name.
  36032. * @returns the class name
  36033. */
  36034. getClassName(): string;
  36035. }
  36036. /**
  36037. * Arc Rotate version of the follow camera.
  36038. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36039. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36040. */
  36041. export class ArcFollowCamera extends TargetCamera {
  36042. /** The longitudinal angle of the camera */
  36043. alpha: number;
  36044. /** The latitudinal angle of the camera */
  36045. beta: number;
  36046. /** The radius of the camera from its target */
  36047. radius: number;
  36048. /** Define the camera target (the messh it should follow) */
  36049. target: Nullable<AbstractMesh>;
  36050. private _cartesianCoordinates;
  36051. /**
  36052. * Instantiates a new ArcFollowCamera
  36053. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36054. * @param name Define the name of the camera
  36055. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36056. * @param beta Define the rotation angle of the camera around the elevation axis
  36057. * @param radius Define the radius of the camera from its target point
  36058. * @param target Define the target of the camera
  36059. * @param scene Define the scene the camera belongs to
  36060. */
  36061. constructor(name: string,
  36062. /** The longitudinal angle of the camera */
  36063. alpha: number,
  36064. /** The latitudinal angle of the camera */
  36065. beta: number,
  36066. /** The radius of the camera from its target */
  36067. radius: number,
  36068. /** Define the camera target (the messh it should follow) */
  36069. target: Nullable<AbstractMesh>, scene: Scene);
  36070. private _follow;
  36071. /** @hidden */ checkInputs(): void;
  36072. /**
  36073. * Returns the class name of the object.
  36074. * It is mostly used internally for serialization purposes.
  36075. */
  36076. getClassName(): string;
  36077. }
  36078. }
  36079. declare module BABYLON {
  36080. /**
  36081. * Manage the keyboard inputs to control the movement of a follow camera.
  36082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36083. */
  36084. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36085. /**
  36086. * Defines the camera the input is attached to.
  36087. */
  36088. camera: FollowCamera;
  36089. /**
  36090. * Defines the list of key codes associated with the up action (increase heightOffset)
  36091. */
  36092. keysHeightOffsetIncr: number[];
  36093. /**
  36094. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36095. */
  36096. keysHeightOffsetDecr: number[];
  36097. /**
  36098. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36099. */
  36100. keysHeightOffsetModifierAlt: boolean;
  36101. /**
  36102. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36103. */
  36104. keysHeightOffsetModifierCtrl: boolean;
  36105. /**
  36106. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36107. */
  36108. keysHeightOffsetModifierShift: boolean;
  36109. /**
  36110. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36111. */
  36112. keysRotationOffsetIncr: number[];
  36113. /**
  36114. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36115. */
  36116. keysRotationOffsetDecr: number[];
  36117. /**
  36118. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36119. */
  36120. keysRotationOffsetModifierAlt: boolean;
  36121. /**
  36122. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36123. */
  36124. keysRotationOffsetModifierCtrl: boolean;
  36125. /**
  36126. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36127. */
  36128. keysRotationOffsetModifierShift: boolean;
  36129. /**
  36130. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36131. */
  36132. keysRadiusIncr: number[];
  36133. /**
  36134. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36135. */
  36136. keysRadiusDecr: number[];
  36137. /**
  36138. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36139. */
  36140. keysRadiusModifierAlt: boolean;
  36141. /**
  36142. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36143. */
  36144. keysRadiusModifierCtrl: boolean;
  36145. /**
  36146. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36147. */
  36148. keysRadiusModifierShift: boolean;
  36149. /**
  36150. * Defines the rate of change of heightOffset.
  36151. */
  36152. heightSensibility: number;
  36153. /**
  36154. * Defines the rate of change of rotationOffset.
  36155. */
  36156. rotationSensibility: number;
  36157. /**
  36158. * Defines the rate of change of radius.
  36159. */
  36160. radiusSensibility: number;
  36161. private _keys;
  36162. private _ctrlPressed;
  36163. private _altPressed;
  36164. private _shiftPressed;
  36165. private _onCanvasBlurObserver;
  36166. private _onKeyboardObserver;
  36167. private _engine;
  36168. private _scene;
  36169. /**
  36170. * Attach the input controls to a specific dom element to get the input from.
  36171. * @param element Defines the element the controls should be listened from
  36172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36173. */
  36174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36175. /**
  36176. * Detach the current controls from the specified dom element.
  36177. * @param element Defines the element to stop listening the inputs from
  36178. */
  36179. detachControl(element: Nullable<HTMLElement>): void;
  36180. /**
  36181. * Update the current camera state depending on the inputs that have been used this frame.
  36182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36183. */
  36184. checkInputs(): void;
  36185. /**
  36186. * Gets the class name of the current input.
  36187. * @returns the class name
  36188. */
  36189. getClassName(): string;
  36190. /**
  36191. * Get the friendly name associated with the input class.
  36192. * @returns the input friendly name
  36193. */
  36194. getSimpleName(): string;
  36195. /**
  36196. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36197. * allow modification of the heightOffset value.
  36198. */
  36199. private _modifierHeightOffset;
  36200. /**
  36201. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36202. * allow modification of the rotationOffset value.
  36203. */
  36204. private _modifierRotationOffset;
  36205. /**
  36206. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36207. * allow modification of the radius value.
  36208. */
  36209. private _modifierRadius;
  36210. }
  36211. }
  36212. declare module BABYLON {
  36213. interface FreeCameraInputsManager {
  36214. /**
  36215. * @hidden
  36216. */ deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36217. /**
  36218. * Add orientation input support to the input manager.
  36219. * @returns the current input manager
  36220. */
  36221. addDeviceOrientation(): FreeCameraInputsManager;
  36222. }
  36223. /**
  36224. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36225. * Screen rotation is taken into account.
  36226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36227. */
  36228. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36229. private _camera;
  36230. private _screenOrientationAngle;
  36231. private _constantTranform;
  36232. private _screenQuaternion;
  36233. private _alpha;
  36234. private _beta;
  36235. private _gamma;
  36236. /**
  36237. * @hidden
  36238. */ onDeviceOrientationChangedObservable: Observable<void>;
  36239. /**
  36240. * Instantiates a new input
  36241. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36242. */
  36243. constructor();
  36244. /**
  36245. * Define the camera controlled by the input.
  36246. */
  36247. camera: FreeCamera;
  36248. /**
  36249. * Attach the input controls to a specific dom element to get the input from.
  36250. * @param element Defines the element the controls should be listened from
  36251. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36252. */
  36253. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36254. private _orientationChanged;
  36255. private _deviceOrientation;
  36256. /**
  36257. * Detach the current controls from the specified dom element.
  36258. * @param element Defines the element to stop listening the inputs from
  36259. */
  36260. detachControl(element: Nullable<HTMLElement>): void;
  36261. /**
  36262. * Update the current camera state depending on the inputs that have been used this frame.
  36263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36264. */
  36265. checkInputs(): void;
  36266. /**
  36267. * Gets the class name of the current intput.
  36268. * @returns the class name
  36269. */
  36270. getClassName(): string;
  36271. /**
  36272. * Get the friendly name associated with the input class.
  36273. * @returns the input friendly name
  36274. */
  36275. getSimpleName(): string;
  36276. }
  36277. }
  36278. declare module BABYLON {
  36279. /**
  36280. * Manage the gamepad inputs to control a free camera.
  36281. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36282. */
  36283. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36284. /**
  36285. * Define the camera the input is attached to.
  36286. */
  36287. camera: FreeCamera;
  36288. /**
  36289. * Define the Gamepad controlling the input
  36290. */
  36291. gamepad: Nullable<Gamepad>;
  36292. /**
  36293. * Defines the gamepad rotation sensiblity.
  36294. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36295. */
  36296. gamepadAngularSensibility: number;
  36297. /**
  36298. * Defines the gamepad move sensiblity.
  36299. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36300. */
  36301. gamepadMoveSensibility: number;
  36302. private _onGamepadConnectedObserver;
  36303. private _onGamepadDisconnectedObserver;
  36304. private _cameraTransform;
  36305. private _deltaTransform;
  36306. private _vector3;
  36307. private _vector2;
  36308. /**
  36309. * Attach the input controls to a specific dom element to get the input from.
  36310. * @param element Defines the element the controls should be listened from
  36311. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36312. */
  36313. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36314. /**
  36315. * Detach the current controls from the specified dom element.
  36316. * @param element Defines the element to stop listening the inputs from
  36317. */
  36318. detachControl(element: Nullable<HTMLElement>): void;
  36319. /**
  36320. * Update the current camera state depending on the inputs that have been used this frame.
  36321. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36322. */
  36323. checkInputs(): void;
  36324. /**
  36325. * Gets the class name of the current intput.
  36326. * @returns the class name
  36327. */
  36328. getClassName(): string;
  36329. /**
  36330. * Get the friendly name associated with the input class.
  36331. * @returns the input friendly name
  36332. */
  36333. getSimpleName(): string;
  36334. }
  36335. }
  36336. declare module BABYLON {
  36337. /**
  36338. * Defines the potential axis of a Joystick
  36339. */
  36340. export enum JoystickAxis {
  36341. /** X axis */
  36342. X = 0,
  36343. /** Y axis */
  36344. Y = 1,
  36345. /** Z axis */
  36346. Z = 2
  36347. }
  36348. /**
  36349. * Class used to define virtual joystick (used in touch mode)
  36350. */
  36351. export class VirtualJoystick {
  36352. /**
  36353. * Gets or sets a boolean indicating that left and right values must be inverted
  36354. */
  36355. reverseLeftRight: boolean;
  36356. /**
  36357. * Gets or sets a boolean indicating that up and down values must be inverted
  36358. */
  36359. reverseUpDown: boolean;
  36360. /**
  36361. * Gets the offset value for the position (ie. the change of the position value)
  36362. */
  36363. deltaPosition: Vector3;
  36364. /**
  36365. * Gets a boolean indicating if the virtual joystick was pressed
  36366. */
  36367. pressed: boolean;
  36368. /**
  36369. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36370. */
  36371. static Canvas: Nullable<HTMLCanvasElement>;
  36372. private static _globalJoystickIndex;
  36373. private static vjCanvasContext;
  36374. private static vjCanvasWidth;
  36375. private static vjCanvasHeight;
  36376. private static halfWidth;
  36377. private _action;
  36378. private _axisTargetedByLeftAndRight;
  36379. private _axisTargetedByUpAndDown;
  36380. private _joystickSensibility;
  36381. private _inversedSensibility;
  36382. private _joystickPointerID;
  36383. private _joystickColor;
  36384. private _joystickPointerPos;
  36385. private _joystickPreviousPointerPos;
  36386. private _joystickPointerStartPos;
  36387. private _deltaJoystickVector;
  36388. private _leftJoystick;
  36389. private _touches;
  36390. private _onPointerDownHandlerRef;
  36391. private _onPointerMoveHandlerRef;
  36392. private _onPointerUpHandlerRef;
  36393. private _onResize;
  36394. /**
  36395. * Creates a new virtual joystick
  36396. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36397. */
  36398. constructor(leftJoystick?: boolean);
  36399. /**
  36400. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36401. * @param newJoystickSensibility defines the new sensibility
  36402. */
  36403. setJoystickSensibility(newJoystickSensibility: number): void;
  36404. private _onPointerDown;
  36405. private _onPointerMove;
  36406. private _onPointerUp;
  36407. /**
  36408. * Change the color of the virtual joystick
  36409. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36410. */
  36411. setJoystickColor(newColor: string): void;
  36412. /**
  36413. * Defines a callback to call when the joystick is touched
  36414. * @param action defines the callback
  36415. */
  36416. setActionOnTouch(action: () => any): void;
  36417. /**
  36418. * Defines which axis you'd like to control for left & right
  36419. * @param axis defines the axis to use
  36420. */
  36421. setAxisForLeftRight(axis: JoystickAxis): void;
  36422. /**
  36423. * Defines which axis you'd like to control for up & down
  36424. * @param axis defines the axis to use
  36425. */
  36426. setAxisForUpDown(axis: JoystickAxis): void;
  36427. private _drawVirtualJoystick;
  36428. /**
  36429. * Release internal HTML canvas
  36430. */
  36431. releaseCanvas(): void;
  36432. }
  36433. }
  36434. declare module BABYLON {
  36435. interface FreeCameraInputsManager {
  36436. /**
  36437. * Add virtual joystick input support to the input manager.
  36438. * @returns the current input manager
  36439. */
  36440. addVirtualJoystick(): FreeCameraInputsManager;
  36441. }
  36442. /**
  36443. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36445. */
  36446. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36447. /**
  36448. * Defines the camera the input is attached to.
  36449. */
  36450. camera: FreeCamera;
  36451. private _leftjoystick;
  36452. private _rightjoystick;
  36453. /**
  36454. * Gets the left stick of the virtual joystick.
  36455. * @returns The virtual Joystick
  36456. */
  36457. getLeftJoystick(): VirtualJoystick;
  36458. /**
  36459. * Gets the right stick of the virtual joystick.
  36460. * @returns The virtual Joystick
  36461. */
  36462. getRightJoystick(): VirtualJoystick;
  36463. /**
  36464. * Update the current camera state depending on the inputs that have been used this frame.
  36465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36466. */
  36467. checkInputs(): void;
  36468. /**
  36469. * Attach the input controls to a specific dom element to get the input from.
  36470. * @param element Defines the element the controls should be listened from
  36471. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36472. */
  36473. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36474. /**
  36475. * Detach the current controls from the specified dom element.
  36476. * @param element Defines the element to stop listening the inputs from
  36477. */
  36478. detachControl(element: Nullable<HTMLElement>): void;
  36479. /**
  36480. * Gets the class name of the current intput.
  36481. * @returns the class name
  36482. */
  36483. getClassName(): string;
  36484. /**
  36485. * Get the friendly name associated with the input class.
  36486. * @returns the input friendly name
  36487. */
  36488. getSimpleName(): string;
  36489. }
  36490. }
  36491. declare module BABYLON {
  36492. /**
  36493. * This represents a FPS type of camera controlled by touch.
  36494. * This is like a universal camera minus the Gamepad controls.
  36495. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36496. */
  36497. export class TouchCamera extends FreeCamera {
  36498. /**
  36499. * Defines the touch sensibility for rotation.
  36500. * The higher the faster.
  36501. */
  36502. touchAngularSensibility: number;
  36503. /**
  36504. * Defines the touch sensibility for move.
  36505. * The higher the faster.
  36506. */
  36507. touchMoveSensibility: number;
  36508. /**
  36509. * Instantiates a new touch camera.
  36510. * This represents a FPS type of camera controlled by touch.
  36511. * This is like a universal camera minus the Gamepad controls.
  36512. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36513. * @param name Define the name of the camera in the scene
  36514. * @param position Define the start position of the camera in the scene
  36515. * @param scene Define the scene the camera belongs to
  36516. */
  36517. constructor(name: string, position: Vector3, scene: Scene);
  36518. /**
  36519. * Gets the current object class name.
  36520. * @return the class name
  36521. */
  36522. getClassName(): string;
  36523. /** @hidden */ setupInputs(): void;
  36524. }
  36525. }
  36526. declare module BABYLON {
  36527. /**
  36528. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36529. * being tilted forward or back and left or right.
  36530. */
  36531. export class DeviceOrientationCamera extends FreeCamera {
  36532. private _initialQuaternion;
  36533. private _quaternionCache;
  36534. private _tmpDragQuaternion;
  36535. /**
  36536. * Creates a new device orientation camera
  36537. * @param name The name of the camera
  36538. * @param position The start position camera
  36539. * @param scene The scene the camera belongs to
  36540. */
  36541. constructor(name: string, position: Vector3, scene: Scene);
  36542. /**
  36543. * Disabled pointer input on first orientation sensor update (Default: true)
  36544. */
  36545. disablePointerInputWhenUsingDeviceOrientation: boolean;
  36546. private _dragFactor;
  36547. /**
  36548. * Enabled turning on the y axis when the orientation sensor is active
  36549. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36550. */
  36551. enableHorizontalDragging(dragFactor?: number): void;
  36552. /**
  36553. * Gets the current instance class name ("DeviceOrientationCamera").
  36554. * This helps avoiding instanceof at run time.
  36555. * @returns the class name
  36556. */
  36557. getClassName(): string;
  36558. /**
  36559. * @hidden
  36560. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36561. */ checkInputs(): void;
  36562. /**
  36563. * Reset the camera to its default orientation on the specified axis only.
  36564. * @param axis The axis to reset
  36565. */
  36566. resetToCurrentRotation(axis?: Axis): void;
  36567. }
  36568. }
  36569. declare module BABYLON {
  36570. /**
  36571. * 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,
  36572. * which still works and will still be found in many Playgrounds.
  36573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36574. */
  36575. export class UniversalCamera extends TouchCamera {
  36576. /**
  36577. * Defines the gamepad rotation sensiblity.
  36578. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36579. */
  36580. gamepadAngularSensibility: number;
  36581. /**
  36582. * Defines the gamepad move sensiblity.
  36583. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36584. */
  36585. gamepadMoveSensibility: number;
  36586. /**
  36587. * 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,
  36588. * which still works and will still be found in many Playgrounds.
  36589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36590. * @param name Define the name of the camera in the scene
  36591. * @param position Define the start position of the camera in the scene
  36592. * @param scene Define the scene the camera belongs to
  36593. */
  36594. constructor(name: string, position: Vector3, scene: Scene);
  36595. /**
  36596. * Gets the current object class name.
  36597. * @return the class name
  36598. */
  36599. getClassName(): string;
  36600. }
  36601. }
  36602. declare module BABYLON {
  36603. /**
  36604. * This represents a FPS type of camera. This is only here for back compat purpose.
  36605. * Please use the UniversalCamera instead as both are identical.
  36606. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36607. */
  36608. export class GamepadCamera extends UniversalCamera {
  36609. /**
  36610. * Instantiates a new Gamepad Camera
  36611. * This represents a FPS type of camera. This is only here for back compat purpose.
  36612. * Please use the UniversalCamera instead as both are identical.
  36613. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36614. * @param name Define the name of the camera in the scene
  36615. * @param position Define the start position of the camera in the scene
  36616. * @param scene Define the scene the camera belongs to
  36617. */
  36618. constructor(name: string, position: Vector3, scene: Scene);
  36619. /**
  36620. * Gets the current object class name.
  36621. * @return the class name
  36622. */
  36623. getClassName(): string;
  36624. }
  36625. }
  36626. declare module BABYLON {
  36627. /** @hidden */
  36628. export var passPixelShader: {
  36629. name: string;
  36630. shader: string;
  36631. };
  36632. }
  36633. declare module BABYLON {
  36634. /** @hidden */
  36635. export var passCubePixelShader: {
  36636. name: string;
  36637. shader: string;
  36638. };
  36639. }
  36640. declare module BABYLON {
  36641. /**
  36642. * PassPostProcess which produces an output the same as it's input
  36643. */
  36644. export class PassPostProcess extends PostProcess {
  36645. /**
  36646. * Creates the PassPostProcess
  36647. * @param name The name of the effect.
  36648. * @param options The required width/height ratio to downsize to before computing the render pass.
  36649. * @param camera The camera to apply the render pass to.
  36650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36651. * @param engine The engine which the post process will be applied. (default: current engine)
  36652. * @param reusable If the post process can be reused on the same frame. (default: false)
  36653. * @param textureType The type of texture to be used when performing the post processing.
  36654. * @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)
  36655. */
  36656. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36657. }
  36658. /**
  36659. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  36660. */
  36661. export class PassCubePostProcess extends PostProcess {
  36662. private _face;
  36663. /**
  36664. * Gets or sets the cube face to display.
  36665. * * 0 is +X
  36666. * * 1 is -X
  36667. * * 2 is +Y
  36668. * * 3 is -Y
  36669. * * 4 is +Z
  36670. * * 5 is -Z
  36671. */
  36672. face: number;
  36673. /**
  36674. * Creates the PassCubePostProcess
  36675. * @param name The name of the effect.
  36676. * @param options The required width/height ratio to downsize to before computing the render pass.
  36677. * @param camera The camera to apply the render pass to.
  36678. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36679. * @param engine The engine which the post process will be applied. (default: current engine)
  36680. * @param reusable If the post process can be reused on the same frame. (default: false)
  36681. * @param textureType The type of texture to be used when performing the post processing.
  36682. * @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)
  36683. */
  36684. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  36685. }
  36686. }
  36687. declare module BABYLON {
  36688. /** @hidden */
  36689. export var anaglyphPixelShader: {
  36690. name: string;
  36691. shader: string;
  36692. };
  36693. }
  36694. declare module BABYLON {
  36695. /**
  36696. * Postprocess used to generate anaglyphic rendering
  36697. */
  36698. export class AnaglyphPostProcess extends PostProcess {
  36699. private _passedProcess;
  36700. /**
  36701. * Creates a new AnaglyphPostProcess
  36702. * @param name defines postprocess name
  36703. * @param options defines creation options or target ratio scale
  36704. * @param rigCameras defines cameras using this postprocess
  36705. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  36706. * @param engine defines hosting engine
  36707. * @param reusable defines if the postprocess will be reused multiple times per frame
  36708. */
  36709. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  36710. }
  36711. }
  36712. declare module BABYLON {
  36713. /**
  36714. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  36715. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36716. */
  36717. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  36718. /**
  36719. * Creates a new AnaglyphArcRotateCamera
  36720. * @param name defines camera name
  36721. * @param alpha defines alpha angle (in radians)
  36722. * @param beta defines beta angle (in radians)
  36723. * @param radius defines radius
  36724. * @param target defines camera target
  36725. * @param interaxialDistance defines distance between each color axis
  36726. * @param scene defines the hosting scene
  36727. */
  36728. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  36729. /**
  36730. * Gets camera class name
  36731. * @returns AnaglyphArcRotateCamera
  36732. */
  36733. getClassName(): string;
  36734. }
  36735. }
  36736. declare module BABYLON {
  36737. /**
  36738. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  36739. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36740. */
  36741. export class AnaglyphFreeCamera extends FreeCamera {
  36742. /**
  36743. * Creates a new AnaglyphFreeCamera
  36744. * @param name defines camera name
  36745. * @param position defines initial position
  36746. * @param interaxialDistance defines distance between each color axis
  36747. * @param scene defines the hosting scene
  36748. */
  36749. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36750. /**
  36751. * Gets camera class name
  36752. * @returns AnaglyphFreeCamera
  36753. */
  36754. getClassName(): string;
  36755. }
  36756. }
  36757. declare module BABYLON {
  36758. /**
  36759. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  36760. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36761. */
  36762. export class AnaglyphGamepadCamera extends GamepadCamera {
  36763. /**
  36764. * Creates a new AnaglyphGamepadCamera
  36765. * @param name defines camera name
  36766. * @param position defines initial position
  36767. * @param interaxialDistance defines distance between each color axis
  36768. * @param scene defines the hosting scene
  36769. */
  36770. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36771. /**
  36772. * Gets camera class name
  36773. * @returns AnaglyphGamepadCamera
  36774. */
  36775. getClassName(): string;
  36776. }
  36777. }
  36778. declare module BABYLON {
  36779. /**
  36780. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  36781. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  36782. */
  36783. export class AnaglyphUniversalCamera extends UniversalCamera {
  36784. /**
  36785. * Creates a new AnaglyphUniversalCamera
  36786. * @param name defines camera name
  36787. * @param position defines initial position
  36788. * @param interaxialDistance defines distance between each color axis
  36789. * @param scene defines the hosting scene
  36790. */
  36791. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  36792. /**
  36793. * Gets camera class name
  36794. * @returns AnaglyphUniversalCamera
  36795. */
  36796. getClassName(): string;
  36797. }
  36798. }
  36799. declare module BABYLON {
  36800. /** @hidden */
  36801. export var stereoscopicInterlacePixelShader: {
  36802. name: string;
  36803. shader: string;
  36804. };
  36805. }
  36806. declare module BABYLON {
  36807. /**
  36808. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  36809. */
  36810. export class StereoscopicInterlacePostProcess extends PostProcess {
  36811. private _stepSize;
  36812. private _passedProcess;
  36813. /**
  36814. * Initializes a StereoscopicInterlacePostProcess
  36815. * @param name The name of the effect.
  36816. * @param rigCameras The rig cameras to be appled to the post process
  36817. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  36818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  36819. * @param engine The engine which the post process will be applied. (default: current engine)
  36820. * @param reusable If the post process can be reused on the same frame. (default: false)
  36821. */
  36822. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  36823. }
  36824. }
  36825. declare module BABYLON {
  36826. /**
  36827. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  36828. * @see http://doc.babylonjs.com/features/cameras
  36829. */
  36830. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  36831. /**
  36832. * Creates a new StereoscopicArcRotateCamera
  36833. * @param name defines camera name
  36834. * @param alpha defines alpha angle (in radians)
  36835. * @param beta defines beta angle (in radians)
  36836. * @param radius defines radius
  36837. * @param target defines camera target
  36838. * @param interaxialDistance defines distance between each color axis
  36839. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36840. * @param scene defines the hosting scene
  36841. */
  36842. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36843. /**
  36844. * Gets camera class name
  36845. * @returns StereoscopicArcRotateCamera
  36846. */
  36847. getClassName(): string;
  36848. }
  36849. }
  36850. declare module BABYLON {
  36851. /**
  36852. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  36853. * @see http://doc.babylonjs.com/features/cameras
  36854. */
  36855. export class StereoscopicFreeCamera extends FreeCamera {
  36856. /**
  36857. * Creates a new StereoscopicFreeCamera
  36858. * @param name defines camera name
  36859. * @param position defines initial position
  36860. * @param interaxialDistance defines distance between each color axis
  36861. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36862. * @param scene defines the hosting scene
  36863. */
  36864. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36865. /**
  36866. * Gets camera class name
  36867. * @returns StereoscopicFreeCamera
  36868. */
  36869. getClassName(): string;
  36870. }
  36871. }
  36872. declare module BABYLON {
  36873. /**
  36874. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  36875. * @see http://doc.babylonjs.com/features/cameras
  36876. */
  36877. export class StereoscopicGamepadCamera extends GamepadCamera {
  36878. /**
  36879. * Creates a new StereoscopicGamepadCamera
  36880. * @param name defines camera name
  36881. * @param position defines initial position
  36882. * @param interaxialDistance defines distance between each color axis
  36883. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36884. * @param scene defines the hosting scene
  36885. */
  36886. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36887. /**
  36888. * Gets camera class name
  36889. * @returns StereoscopicGamepadCamera
  36890. */
  36891. getClassName(): string;
  36892. }
  36893. }
  36894. declare module BABYLON {
  36895. /**
  36896. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  36897. * @see http://doc.babylonjs.com/features/cameras
  36898. */
  36899. export class StereoscopicUniversalCamera extends UniversalCamera {
  36900. /**
  36901. * Creates a new StereoscopicUniversalCamera
  36902. * @param name defines camera name
  36903. * @param position defines initial position
  36904. * @param interaxialDistance defines distance between each color axis
  36905. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  36906. * @param scene defines the hosting scene
  36907. */
  36908. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  36909. /**
  36910. * Gets camera class name
  36911. * @returns StereoscopicUniversalCamera
  36912. */
  36913. getClassName(): string;
  36914. }
  36915. }
  36916. declare module BABYLON {
  36917. /**
  36918. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  36919. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36920. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36921. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36922. */
  36923. export class VirtualJoysticksCamera extends FreeCamera {
  36924. /**
  36925. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  36926. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  36927. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  36928. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  36929. * @param name Define the name of the camera in the scene
  36930. * @param position Define the start position of the camera in the scene
  36931. * @param scene Define the scene the camera belongs to
  36932. */
  36933. constructor(name: string, position: Vector3, scene: Scene);
  36934. /**
  36935. * Gets the current object class name.
  36936. * @return the class name
  36937. */
  36938. getClassName(): string;
  36939. }
  36940. }
  36941. declare module BABYLON {
  36942. /**
  36943. * This represents all the required metrics to create a VR camera.
  36944. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  36945. */
  36946. export class VRCameraMetrics {
  36947. /**
  36948. * Define the horizontal resolution off the screen.
  36949. */
  36950. hResolution: number;
  36951. /**
  36952. * Define the vertical resolution off the screen.
  36953. */
  36954. vResolution: number;
  36955. /**
  36956. * Define the horizontal screen size.
  36957. */
  36958. hScreenSize: number;
  36959. /**
  36960. * Define the vertical screen size.
  36961. */
  36962. vScreenSize: number;
  36963. /**
  36964. * Define the vertical screen center position.
  36965. */
  36966. vScreenCenter: number;
  36967. /**
  36968. * Define the distance of the eyes to the screen.
  36969. */
  36970. eyeToScreenDistance: number;
  36971. /**
  36972. * Define the distance between both lenses
  36973. */
  36974. lensSeparationDistance: number;
  36975. /**
  36976. * Define the distance between both viewer's eyes.
  36977. */
  36978. interpupillaryDistance: number;
  36979. /**
  36980. * Define the distortion factor of the VR postprocess.
  36981. * Please, touch with care.
  36982. */
  36983. distortionK: number[];
  36984. /**
  36985. * Define the chromatic aberration correction factors for the VR post process.
  36986. */
  36987. chromaAbCorrection: number[];
  36988. /**
  36989. * Define the scale factor of the post process.
  36990. * The smaller the better but the slower.
  36991. */
  36992. postProcessScaleFactor: number;
  36993. /**
  36994. * Define an offset for the lens center.
  36995. */
  36996. lensCenterOffset: number;
  36997. /**
  36998. * Define if the current vr camera should compensate the distortion of the lense or not.
  36999. */
  37000. compensateDistortion: boolean;
  37001. /**
  37002. * Defines if multiview should be enabled when rendering (Default: false)
  37003. */
  37004. multiviewEnabled: boolean;
  37005. /**
  37006. * Gets the rendering aspect ratio based on the provided resolutions.
  37007. */
  37008. readonly aspectRatio: number;
  37009. /**
  37010. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37011. */
  37012. readonly aspectRatioFov: number;
  37013. /**
  37014. * @hidden
  37015. */
  37016. readonly leftHMatrix: Matrix;
  37017. /**
  37018. * @hidden
  37019. */
  37020. readonly rightHMatrix: Matrix;
  37021. /**
  37022. * @hidden
  37023. */
  37024. readonly leftPreViewMatrix: Matrix;
  37025. /**
  37026. * @hidden
  37027. */
  37028. readonly rightPreViewMatrix: Matrix;
  37029. /**
  37030. * Get the default VRMetrics based on the most generic setup.
  37031. * @returns the default vr metrics
  37032. */
  37033. static GetDefault(): VRCameraMetrics;
  37034. }
  37035. }
  37036. declare module BABYLON {
  37037. /** @hidden */
  37038. export var vrDistortionCorrectionPixelShader: {
  37039. name: string;
  37040. shader: string;
  37041. };
  37042. }
  37043. declare module BABYLON {
  37044. /**
  37045. * VRDistortionCorrectionPostProcess used for mobile VR
  37046. */
  37047. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37048. private _isRightEye;
  37049. private _distortionFactors;
  37050. private _postProcessScaleFactor;
  37051. private _lensCenterOffset;
  37052. private _scaleIn;
  37053. private _scaleFactor;
  37054. private _lensCenter;
  37055. /**
  37056. * Initializes the VRDistortionCorrectionPostProcess
  37057. * @param name The name of the effect.
  37058. * @param camera The camera to apply the render pass to.
  37059. * @param isRightEye If this is for the right eye distortion
  37060. * @param vrMetrics All the required metrics for the VR camera
  37061. */
  37062. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37063. }
  37064. }
  37065. declare module BABYLON {
  37066. /**
  37067. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37068. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37069. */
  37070. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37071. /**
  37072. * Creates a new VRDeviceOrientationArcRotateCamera
  37073. * @param name defines camera name
  37074. * @param alpha defines the camera rotation along the logitudinal axis
  37075. * @param beta defines the camera rotation along the latitudinal axis
  37076. * @param radius defines the camera distance from its target
  37077. * @param target defines the camera target
  37078. * @param scene defines the scene the camera belongs to
  37079. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37080. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37081. */
  37082. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37083. /**
  37084. * Gets camera class name
  37085. * @returns VRDeviceOrientationArcRotateCamera
  37086. */
  37087. getClassName(): string;
  37088. }
  37089. }
  37090. declare module BABYLON {
  37091. /**
  37092. * Camera used to simulate VR rendering (based on FreeCamera)
  37093. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37094. */
  37095. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37096. /**
  37097. * Creates a new VRDeviceOrientationFreeCamera
  37098. * @param name defines camera name
  37099. * @param position defines the start position of the camera
  37100. * @param scene defines the scene the camera belongs to
  37101. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37102. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37103. */
  37104. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37105. /**
  37106. * Gets camera class name
  37107. * @returns VRDeviceOrientationFreeCamera
  37108. */
  37109. getClassName(): string;
  37110. }
  37111. }
  37112. declare module BABYLON {
  37113. /**
  37114. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37115. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37116. */
  37117. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37118. /**
  37119. * Creates a new VRDeviceOrientationGamepadCamera
  37120. * @param name defines camera name
  37121. * @param position defines the start position of the camera
  37122. * @param scene defines the scene the camera belongs to
  37123. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37124. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37125. */
  37126. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37127. /**
  37128. * Gets camera class name
  37129. * @returns VRDeviceOrientationGamepadCamera
  37130. */
  37131. getClassName(): string;
  37132. }
  37133. }
  37134. declare module BABYLON {
  37135. /**
  37136. * Defines supported buttons for XBox360 compatible gamepads
  37137. */
  37138. export enum Xbox360Button {
  37139. /** A */
  37140. A = 0,
  37141. /** B */
  37142. B = 1,
  37143. /** X */
  37144. X = 2,
  37145. /** Y */
  37146. Y = 3,
  37147. /** Start */
  37148. Start = 4,
  37149. /** Back */
  37150. Back = 5,
  37151. /** Left button */
  37152. LB = 6,
  37153. /** Right button */
  37154. RB = 7,
  37155. /** Left stick */
  37156. LeftStick = 8,
  37157. /** Right stick */
  37158. RightStick = 9
  37159. }
  37160. /** Defines values for XBox360 DPad */
  37161. export enum Xbox360Dpad {
  37162. /** Up */
  37163. Up = 0,
  37164. /** Down */
  37165. Down = 1,
  37166. /** Left */
  37167. Left = 2,
  37168. /** Right */
  37169. Right = 3
  37170. }
  37171. /**
  37172. * Defines a XBox360 gamepad
  37173. */
  37174. export class Xbox360Pad extends Gamepad {
  37175. private _leftTrigger;
  37176. private _rightTrigger;
  37177. private _onlefttriggerchanged;
  37178. private _onrighttriggerchanged;
  37179. private _onbuttondown;
  37180. private _onbuttonup;
  37181. private _ondpaddown;
  37182. private _ondpadup;
  37183. /** Observable raised when a button is pressed */
  37184. onButtonDownObservable: Observable<Xbox360Button>;
  37185. /** Observable raised when a button is released */
  37186. onButtonUpObservable: Observable<Xbox360Button>;
  37187. /** Observable raised when a pad is pressed */
  37188. onPadDownObservable: Observable<Xbox360Dpad>;
  37189. /** Observable raised when a pad is released */
  37190. onPadUpObservable: Observable<Xbox360Dpad>;
  37191. private _buttonA;
  37192. private _buttonB;
  37193. private _buttonX;
  37194. private _buttonY;
  37195. private _buttonBack;
  37196. private _buttonStart;
  37197. private _buttonLB;
  37198. private _buttonRB;
  37199. private _buttonLeftStick;
  37200. private _buttonRightStick;
  37201. private _dPadUp;
  37202. private _dPadDown;
  37203. private _dPadLeft;
  37204. private _dPadRight;
  37205. private _isXboxOnePad;
  37206. /**
  37207. * Creates a new XBox360 gamepad object
  37208. * @param id defines the id of this gamepad
  37209. * @param index defines its index
  37210. * @param gamepad defines the internal HTML gamepad object
  37211. * @param xboxOne defines if it is a XBox One gamepad
  37212. */
  37213. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37214. /**
  37215. * Defines the callback to call when left trigger is pressed
  37216. * @param callback defines the callback to use
  37217. */
  37218. onlefttriggerchanged(callback: (value: number) => void): void;
  37219. /**
  37220. * Defines the callback to call when right trigger is pressed
  37221. * @param callback defines the callback to use
  37222. */
  37223. onrighttriggerchanged(callback: (value: number) => void): void;
  37224. /**
  37225. * Gets the left trigger value
  37226. */
  37227. /**
  37228. * Sets the left trigger value
  37229. */
  37230. leftTrigger: number;
  37231. /**
  37232. * Gets the right trigger value
  37233. */
  37234. /**
  37235. * Sets the right trigger value
  37236. */
  37237. rightTrigger: number;
  37238. /**
  37239. * Defines the callback to call when a button is pressed
  37240. * @param callback defines the callback to use
  37241. */
  37242. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37243. /**
  37244. * Defines the callback to call when a button is released
  37245. * @param callback defines the callback to use
  37246. */
  37247. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37248. /**
  37249. * Defines the callback to call when a pad is pressed
  37250. * @param callback defines the callback to use
  37251. */
  37252. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37253. /**
  37254. * Defines the callback to call when a pad is released
  37255. * @param callback defines the callback to use
  37256. */
  37257. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37258. private _setButtonValue;
  37259. private _setDPadValue;
  37260. /**
  37261. * Gets the value of the `A` button
  37262. */
  37263. /**
  37264. * Sets the value of the `A` button
  37265. */
  37266. buttonA: number;
  37267. /**
  37268. * Gets the value of the `B` button
  37269. */
  37270. /**
  37271. * Sets the value of the `B` button
  37272. */
  37273. buttonB: number;
  37274. /**
  37275. * Gets the value of the `X` button
  37276. */
  37277. /**
  37278. * Sets the value of the `X` button
  37279. */
  37280. buttonX: number;
  37281. /**
  37282. * Gets the value of the `Y` button
  37283. */
  37284. /**
  37285. * Sets the value of the `Y` button
  37286. */
  37287. buttonY: number;
  37288. /**
  37289. * Gets the value of the `Start` button
  37290. */
  37291. /**
  37292. * Sets the value of the `Start` button
  37293. */
  37294. buttonStart: number;
  37295. /**
  37296. * Gets the value of the `Back` button
  37297. */
  37298. /**
  37299. * Sets the value of the `Back` button
  37300. */
  37301. buttonBack: number;
  37302. /**
  37303. * Gets the value of the `Left` button
  37304. */
  37305. /**
  37306. * Sets the value of the `Left` button
  37307. */
  37308. buttonLB: number;
  37309. /**
  37310. * Gets the value of the `Right` button
  37311. */
  37312. /**
  37313. * Sets the value of the `Right` button
  37314. */
  37315. buttonRB: number;
  37316. /**
  37317. * Gets the value of the Left joystick
  37318. */
  37319. /**
  37320. * Sets the value of the Left joystick
  37321. */
  37322. buttonLeftStick: number;
  37323. /**
  37324. * Gets the value of the Right joystick
  37325. */
  37326. /**
  37327. * Sets the value of the Right joystick
  37328. */
  37329. buttonRightStick: number;
  37330. /**
  37331. * Gets the value of D-pad up
  37332. */
  37333. /**
  37334. * Sets the value of D-pad up
  37335. */
  37336. dPadUp: number;
  37337. /**
  37338. * Gets the value of D-pad down
  37339. */
  37340. /**
  37341. * Sets the value of D-pad down
  37342. */
  37343. dPadDown: number;
  37344. /**
  37345. * Gets the value of D-pad left
  37346. */
  37347. /**
  37348. * Sets the value of D-pad left
  37349. */
  37350. dPadLeft: number;
  37351. /**
  37352. * Gets the value of D-pad right
  37353. */
  37354. /**
  37355. * Sets the value of D-pad right
  37356. */
  37357. dPadRight: number;
  37358. /**
  37359. * Force the gamepad to synchronize with device values
  37360. */
  37361. update(): void;
  37362. /**
  37363. * Disposes the gamepad
  37364. */
  37365. dispose(): void;
  37366. }
  37367. }
  37368. declare module BABYLON {
  37369. /**
  37370. * Base class of materials working in push mode in babylon JS
  37371. * @hidden
  37372. */
  37373. export class PushMaterial extends Material {
  37374. protected _activeEffect: Effect;
  37375. protected _normalMatrix: Matrix;
  37376. /**
  37377. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37378. * This means that the material can keep using a previous shader while a new one is being compiled.
  37379. * This is mostly used when shader parallel compilation is supported (true by default)
  37380. */
  37381. allowShaderHotSwapping: boolean;
  37382. constructor(name: string, scene: Scene);
  37383. getEffect(): Effect;
  37384. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37385. /**
  37386. * Binds the given world matrix to the active effect
  37387. *
  37388. * @param world the matrix to bind
  37389. */
  37390. bindOnlyWorldMatrix(world: Matrix): void;
  37391. /**
  37392. * Binds the given normal matrix to the active effect
  37393. *
  37394. * @param normalMatrix the matrix to bind
  37395. */
  37396. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37397. bind(world: Matrix, mesh?: Mesh): void;
  37398. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37399. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37400. }
  37401. }
  37402. declare module BABYLON {
  37403. /**
  37404. * This groups all the flags used to control the materials channel.
  37405. */
  37406. export class MaterialFlags {
  37407. private static _DiffuseTextureEnabled;
  37408. /**
  37409. * Are diffuse textures enabled in the application.
  37410. */
  37411. static DiffuseTextureEnabled: boolean;
  37412. private static _AmbientTextureEnabled;
  37413. /**
  37414. * Are ambient textures enabled in the application.
  37415. */
  37416. static AmbientTextureEnabled: boolean;
  37417. private static _OpacityTextureEnabled;
  37418. /**
  37419. * Are opacity textures enabled in the application.
  37420. */
  37421. static OpacityTextureEnabled: boolean;
  37422. private static _ReflectionTextureEnabled;
  37423. /**
  37424. * Are reflection textures enabled in the application.
  37425. */
  37426. static ReflectionTextureEnabled: boolean;
  37427. private static _EmissiveTextureEnabled;
  37428. /**
  37429. * Are emissive textures enabled in the application.
  37430. */
  37431. static EmissiveTextureEnabled: boolean;
  37432. private static _SpecularTextureEnabled;
  37433. /**
  37434. * Are specular textures enabled in the application.
  37435. */
  37436. static SpecularTextureEnabled: boolean;
  37437. private static _BumpTextureEnabled;
  37438. /**
  37439. * Are bump textures enabled in the application.
  37440. */
  37441. static BumpTextureEnabled: boolean;
  37442. private static _LightmapTextureEnabled;
  37443. /**
  37444. * Are lightmap textures enabled in the application.
  37445. */
  37446. static LightmapTextureEnabled: boolean;
  37447. private static _RefractionTextureEnabled;
  37448. /**
  37449. * Are refraction textures enabled in the application.
  37450. */
  37451. static RefractionTextureEnabled: boolean;
  37452. private static _ColorGradingTextureEnabled;
  37453. /**
  37454. * Are color grading textures enabled in the application.
  37455. */
  37456. static ColorGradingTextureEnabled: boolean;
  37457. private static _FresnelEnabled;
  37458. /**
  37459. * Are fresnels enabled in the application.
  37460. */
  37461. static FresnelEnabled: boolean;
  37462. private static _ClearCoatTextureEnabled;
  37463. /**
  37464. * Are clear coat textures enabled in the application.
  37465. */
  37466. static ClearCoatTextureEnabled: boolean;
  37467. private static _ClearCoatBumpTextureEnabled;
  37468. /**
  37469. * Are clear coat bump textures enabled in the application.
  37470. */
  37471. static ClearCoatBumpTextureEnabled: boolean;
  37472. private static _ClearCoatTintTextureEnabled;
  37473. /**
  37474. * Are clear coat tint textures enabled in the application.
  37475. */
  37476. static ClearCoatTintTextureEnabled: boolean;
  37477. private static _SheenTextureEnabled;
  37478. /**
  37479. * Are sheen textures enabled in the application.
  37480. */
  37481. static SheenTextureEnabled: boolean;
  37482. private static _AnisotropicTextureEnabled;
  37483. /**
  37484. * Are anisotropic textures enabled in the application.
  37485. */
  37486. static AnisotropicTextureEnabled: boolean;
  37487. }
  37488. }
  37489. declare module BABYLON {
  37490. /** @hidden */
  37491. export var defaultFragmentDeclaration: {
  37492. name: string;
  37493. shader: string;
  37494. };
  37495. }
  37496. declare module BABYLON {
  37497. /** @hidden */
  37498. export var defaultUboDeclaration: {
  37499. name: string;
  37500. shader: string;
  37501. };
  37502. }
  37503. declare module BABYLON {
  37504. /** @hidden */
  37505. export var lightFragmentDeclaration: {
  37506. name: string;
  37507. shader: string;
  37508. };
  37509. }
  37510. declare module BABYLON {
  37511. /** @hidden */
  37512. export var lightUboDeclaration: {
  37513. name: string;
  37514. shader: string;
  37515. };
  37516. }
  37517. declare module BABYLON {
  37518. /** @hidden */
  37519. export var lightsFragmentFunctions: {
  37520. name: string;
  37521. shader: string;
  37522. };
  37523. }
  37524. declare module BABYLON {
  37525. /** @hidden */
  37526. export var shadowsFragmentFunctions: {
  37527. name: string;
  37528. shader: string;
  37529. };
  37530. }
  37531. declare module BABYLON {
  37532. /** @hidden */
  37533. export var fresnelFunction: {
  37534. name: string;
  37535. shader: string;
  37536. };
  37537. }
  37538. declare module BABYLON {
  37539. /** @hidden */
  37540. export var reflectionFunction: {
  37541. name: string;
  37542. shader: string;
  37543. };
  37544. }
  37545. declare module BABYLON {
  37546. /** @hidden */
  37547. export var bumpFragmentFunctions: {
  37548. name: string;
  37549. shader: string;
  37550. };
  37551. }
  37552. declare module BABYLON {
  37553. /** @hidden */
  37554. export var logDepthDeclaration: {
  37555. name: string;
  37556. shader: string;
  37557. };
  37558. }
  37559. declare module BABYLON {
  37560. /** @hidden */
  37561. export var bumpFragment: {
  37562. name: string;
  37563. shader: string;
  37564. };
  37565. }
  37566. declare module BABYLON {
  37567. /** @hidden */
  37568. export var depthPrePass: {
  37569. name: string;
  37570. shader: string;
  37571. };
  37572. }
  37573. declare module BABYLON {
  37574. /** @hidden */
  37575. export var lightFragment: {
  37576. name: string;
  37577. shader: string;
  37578. };
  37579. }
  37580. declare module BABYLON {
  37581. /** @hidden */
  37582. export var logDepthFragment: {
  37583. name: string;
  37584. shader: string;
  37585. };
  37586. }
  37587. declare module BABYLON {
  37588. /** @hidden */
  37589. export var defaultPixelShader: {
  37590. name: string;
  37591. shader: string;
  37592. };
  37593. }
  37594. declare module BABYLON {
  37595. /** @hidden */
  37596. export var defaultVertexDeclaration: {
  37597. name: string;
  37598. shader: string;
  37599. };
  37600. }
  37601. declare module BABYLON {
  37602. /** @hidden */
  37603. export var bumpVertexDeclaration: {
  37604. name: string;
  37605. shader: string;
  37606. };
  37607. }
  37608. declare module BABYLON {
  37609. /** @hidden */
  37610. export var bumpVertex: {
  37611. name: string;
  37612. shader: string;
  37613. };
  37614. }
  37615. declare module BABYLON {
  37616. /** @hidden */
  37617. export var fogVertex: {
  37618. name: string;
  37619. shader: string;
  37620. };
  37621. }
  37622. declare module BABYLON {
  37623. /** @hidden */
  37624. export var shadowsVertex: {
  37625. name: string;
  37626. shader: string;
  37627. };
  37628. }
  37629. declare module BABYLON {
  37630. /** @hidden */
  37631. export var pointCloudVertex: {
  37632. name: string;
  37633. shader: string;
  37634. };
  37635. }
  37636. declare module BABYLON {
  37637. /** @hidden */
  37638. export var logDepthVertex: {
  37639. name: string;
  37640. shader: string;
  37641. };
  37642. }
  37643. declare module BABYLON {
  37644. /** @hidden */
  37645. export var defaultVertexShader: {
  37646. name: string;
  37647. shader: string;
  37648. };
  37649. }
  37650. declare module BABYLON {
  37651. /** @hidden */
  37652. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  37653. MAINUV1: boolean;
  37654. MAINUV2: boolean;
  37655. DIFFUSE: boolean;
  37656. DIFFUSEDIRECTUV: number;
  37657. AMBIENT: boolean;
  37658. AMBIENTDIRECTUV: number;
  37659. OPACITY: boolean;
  37660. OPACITYDIRECTUV: number;
  37661. OPACITYRGB: boolean;
  37662. REFLECTION: boolean;
  37663. EMISSIVE: boolean;
  37664. EMISSIVEDIRECTUV: number;
  37665. SPECULAR: boolean;
  37666. SPECULARDIRECTUV: number;
  37667. BUMP: boolean;
  37668. BUMPDIRECTUV: number;
  37669. PARALLAX: boolean;
  37670. PARALLAXOCCLUSION: boolean;
  37671. SPECULAROVERALPHA: boolean;
  37672. CLIPPLANE: boolean;
  37673. CLIPPLANE2: boolean;
  37674. CLIPPLANE3: boolean;
  37675. CLIPPLANE4: boolean;
  37676. ALPHATEST: boolean;
  37677. DEPTHPREPASS: boolean;
  37678. ALPHAFROMDIFFUSE: boolean;
  37679. POINTSIZE: boolean;
  37680. FOG: boolean;
  37681. SPECULARTERM: boolean;
  37682. DIFFUSEFRESNEL: boolean;
  37683. OPACITYFRESNEL: boolean;
  37684. REFLECTIONFRESNEL: boolean;
  37685. REFRACTIONFRESNEL: boolean;
  37686. EMISSIVEFRESNEL: boolean;
  37687. FRESNEL: boolean;
  37688. NORMAL: boolean;
  37689. UV1: boolean;
  37690. UV2: boolean;
  37691. VERTEXCOLOR: boolean;
  37692. VERTEXALPHA: boolean;
  37693. NUM_BONE_INFLUENCERS: number;
  37694. BonesPerMesh: number;
  37695. BONETEXTURE: boolean;
  37696. INSTANCES: boolean;
  37697. GLOSSINESS: boolean;
  37698. ROUGHNESS: boolean;
  37699. EMISSIVEASILLUMINATION: boolean;
  37700. LINKEMISSIVEWITHDIFFUSE: boolean;
  37701. REFLECTIONFRESNELFROMSPECULAR: boolean;
  37702. LIGHTMAP: boolean;
  37703. LIGHTMAPDIRECTUV: number;
  37704. OBJECTSPACE_NORMALMAP: boolean;
  37705. USELIGHTMAPASSHADOWMAP: boolean;
  37706. REFLECTIONMAP_3D: boolean;
  37707. REFLECTIONMAP_SPHERICAL: boolean;
  37708. REFLECTIONMAP_PLANAR: boolean;
  37709. REFLECTIONMAP_CUBIC: boolean;
  37710. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  37711. REFLECTIONMAP_PROJECTION: boolean;
  37712. REFLECTIONMAP_SKYBOX: boolean;
  37713. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  37714. REFLECTIONMAP_EXPLICIT: boolean;
  37715. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  37716. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  37717. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  37718. INVERTCUBICMAP: boolean;
  37719. LOGARITHMICDEPTH: boolean;
  37720. REFRACTION: boolean;
  37721. REFRACTIONMAP_3D: boolean;
  37722. REFLECTIONOVERALPHA: boolean;
  37723. TWOSIDEDLIGHTING: boolean;
  37724. SHADOWFLOAT: boolean;
  37725. MORPHTARGETS: boolean;
  37726. MORPHTARGETS_NORMAL: boolean;
  37727. MORPHTARGETS_TANGENT: boolean;
  37728. NUM_MORPH_INFLUENCERS: number;
  37729. NONUNIFORMSCALING: boolean;
  37730. PREMULTIPLYALPHA: boolean;
  37731. IMAGEPROCESSING: boolean;
  37732. VIGNETTE: boolean;
  37733. VIGNETTEBLENDMODEMULTIPLY: boolean;
  37734. VIGNETTEBLENDMODEOPAQUE: boolean;
  37735. TONEMAPPING: boolean;
  37736. TONEMAPPING_ACES: boolean;
  37737. CONTRAST: boolean;
  37738. COLORCURVES: boolean;
  37739. COLORGRADING: boolean;
  37740. COLORGRADING3D: boolean;
  37741. SAMPLER3DGREENDEPTH: boolean;
  37742. SAMPLER3DBGRMAP: boolean;
  37743. IMAGEPROCESSINGPOSTPROCESS: boolean;
  37744. MULTIVIEW: boolean;
  37745. /**
  37746. * If the reflection texture on this material is in linear color space
  37747. * @hidden
  37748. */
  37749. IS_REFLECTION_LINEAR: boolean;
  37750. /**
  37751. * If the refraction texture on this material is in linear color space
  37752. * @hidden
  37753. */
  37754. IS_REFRACTION_LINEAR: boolean;
  37755. EXPOSURE: boolean;
  37756. constructor();
  37757. setReflectionMode(modeToEnable: string): void;
  37758. }
  37759. /**
  37760. * This is the default material used in Babylon. It is the best trade off between quality
  37761. * and performances.
  37762. * @see http://doc.babylonjs.com/babylon101/materials
  37763. */
  37764. export class StandardMaterial extends PushMaterial {
  37765. private _diffuseTexture;
  37766. /**
  37767. * The basic texture of the material as viewed under a light.
  37768. */
  37769. diffuseTexture: Nullable<BaseTexture>;
  37770. private _ambientTexture;
  37771. /**
  37772. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  37773. */
  37774. ambientTexture: Nullable<BaseTexture>;
  37775. private _opacityTexture;
  37776. /**
  37777. * Define the transparency of the material from a texture.
  37778. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  37779. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  37780. */
  37781. opacityTexture: Nullable<BaseTexture>;
  37782. private _reflectionTexture;
  37783. /**
  37784. * Define the texture used to display the reflection.
  37785. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37786. */
  37787. reflectionTexture: Nullable<BaseTexture>;
  37788. private _emissiveTexture;
  37789. /**
  37790. * Define texture of the material as if self lit.
  37791. * This will be mixed in the final result even in the absence of light.
  37792. */
  37793. emissiveTexture: Nullable<BaseTexture>;
  37794. private _specularTexture;
  37795. /**
  37796. * Define how the color and intensity of the highlight given by the light in the material.
  37797. */
  37798. specularTexture: Nullable<BaseTexture>;
  37799. private _bumpTexture;
  37800. /**
  37801. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  37802. * 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.
  37803. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  37804. */
  37805. bumpTexture: Nullable<BaseTexture>;
  37806. private _lightmapTexture;
  37807. /**
  37808. * Complex lighting can be computationally expensive to compute at runtime.
  37809. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  37810. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  37811. */
  37812. lightmapTexture: Nullable<BaseTexture>;
  37813. private _refractionTexture;
  37814. /**
  37815. * Define the texture used to display the refraction.
  37816. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37817. */
  37818. refractionTexture: Nullable<BaseTexture>;
  37819. /**
  37820. * The color of the material lit by the environmental background lighting.
  37821. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  37822. */
  37823. ambientColor: Color3;
  37824. /**
  37825. * The basic color of the material as viewed under a light.
  37826. */
  37827. diffuseColor: Color3;
  37828. /**
  37829. * Define how the color and intensity of the highlight given by the light in the material.
  37830. */
  37831. specularColor: Color3;
  37832. /**
  37833. * Define the color of the material as if self lit.
  37834. * This will be mixed in the final result even in the absence of light.
  37835. */
  37836. emissiveColor: Color3;
  37837. /**
  37838. * Defines how sharp are the highlights in the material.
  37839. * The bigger the value the sharper giving a more glossy feeling to the result.
  37840. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  37841. */
  37842. specularPower: number;
  37843. private _useAlphaFromDiffuseTexture;
  37844. /**
  37845. * Does the transparency come from the diffuse texture alpha channel.
  37846. */
  37847. useAlphaFromDiffuseTexture: boolean;
  37848. private _useEmissiveAsIllumination;
  37849. /**
  37850. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  37851. */
  37852. useEmissiveAsIllumination: boolean;
  37853. private _linkEmissiveWithDiffuse;
  37854. /**
  37855. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  37856. * the emissive level when the final color is close to one.
  37857. */
  37858. linkEmissiveWithDiffuse: boolean;
  37859. private _useSpecularOverAlpha;
  37860. /**
  37861. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  37862. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  37863. */
  37864. useSpecularOverAlpha: boolean;
  37865. private _useReflectionOverAlpha;
  37866. /**
  37867. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  37868. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  37869. */
  37870. useReflectionOverAlpha: boolean;
  37871. private _disableLighting;
  37872. /**
  37873. * Does lights from the scene impacts this material.
  37874. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  37875. */
  37876. disableLighting: boolean;
  37877. private _useObjectSpaceNormalMap;
  37878. /**
  37879. * Allows using an object space normal map (instead of tangent space).
  37880. */
  37881. useObjectSpaceNormalMap: boolean;
  37882. private _useParallax;
  37883. /**
  37884. * Is parallax enabled or not.
  37885. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37886. */
  37887. useParallax: boolean;
  37888. private _useParallaxOcclusion;
  37889. /**
  37890. * Is parallax occlusion enabled or not.
  37891. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  37892. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  37893. */
  37894. useParallaxOcclusion: boolean;
  37895. /**
  37896. * 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.
  37897. */
  37898. parallaxScaleBias: number;
  37899. private _roughness;
  37900. /**
  37901. * Helps to define how blurry the reflections should appears in the material.
  37902. */
  37903. roughness: number;
  37904. /**
  37905. * In case of refraction, define the value of the indice of refraction.
  37906. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37907. */
  37908. indexOfRefraction: number;
  37909. /**
  37910. * Invert the refraction texture alongside the y axis.
  37911. * It can be useful with procedural textures or probe for instance.
  37912. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  37913. */
  37914. invertRefractionY: boolean;
  37915. /**
  37916. * Defines the alpha limits in alpha test mode.
  37917. */
  37918. alphaCutOff: number;
  37919. private _useLightmapAsShadowmap;
  37920. /**
  37921. * In case of light mapping, define whether the map contains light or shadow informations.
  37922. */
  37923. useLightmapAsShadowmap: boolean;
  37924. private _diffuseFresnelParameters;
  37925. /**
  37926. * Define the diffuse fresnel parameters of the material.
  37927. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37928. */
  37929. diffuseFresnelParameters: FresnelParameters;
  37930. private _opacityFresnelParameters;
  37931. /**
  37932. * Define the opacity fresnel parameters of the material.
  37933. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37934. */
  37935. opacityFresnelParameters: FresnelParameters;
  37936. private _reflectionFresnelParameters;
  37937. /**
  37938. * Define the reflection fresnel parameters of the material.
  37939. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37940. */
  37941. reflectionFresnelParameters: FresnelParameters;
  37942. private _refractionFresnelParameters;
  37943. /**
  37944. * Define the refraction fresnel parameters of the material.
  37945. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37946. */
  37947. refractionFresnelParameters: FresnelParameters;
  37948. private _emissiveFresnelParameters;
  37949. /**
  37950. * Define the emissive fresnel parameters of the material.
  37951. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37952. */
  37953. emissiveFresnelParameters: FresnelParameters;
  37954. private _useReflectionFresnelFromSpecular;
  37955. /**
  37956. * If true automatically deducts the fresnels values from the material specularity.
  37957. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  37958. */
  37959. useReflectionFresnelFromSpecular: boolean;
  37960. private _useGlossinessFromSpecularMapAlpha;
  37961. /**
  37962. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  37963. */
  37964. useGlossinessFromSpecularMapAlpha: boolean;
  37965. private _maxSimultaneousLights;
  37966. /**
  37967. * Defines the maximum number of lights that can be used in the material
  37968. */
  37969. maxSimultaneousLights: number;
  37970. private _invertNormalMapX;
  37971. /**
  37972. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  37973. */
  37974. invertNormalMapX: boolean;
  37975. private _invertNormalMapY;
  37976. /**
  37977. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  37978. */
  37979. invertNormalMapY: boolean;
  37980. private _twoSidedLighting;
  37981. /**
  37982. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  37983. */
  37984. twoSidedLighting: boolean;
  37985. /**
  37986. * Default configuration related to image processing available in the standard Material.
  37987. */
  37988. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  37989. /**
  37990. * Gets the image processing configuration used either in this material.
  37991. */
  37992. /**
  37993. * Sets the Default image processing configuration used either in the this material.
  37994. *
  37995. * If sets to null, the scene one is in use.
  37996. */
  37997. imageProcessingConfiguration: ImageProcessingConfiguration;
  37998. /**
  37999. * Keep track of the image processing observer to allow dispose and replace.
  38000. */
  38001. private _imageProcessingObserver;
  38002. /**
  38003. * Attaches a new image processing configuration to the Standard Material.
  38004. * @param configuration
  38005. */
  38006. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38007. /**
  38008. * Gets wether the color curves effect is enabled.
  38009. */
  38010. /**
  38011. * Sets wether the color curves effect is enabled.
  38012. */
  38013. cameraColorCurvesEnabled: boolean;
  38014. /**
  38015. * Gets wether the color grading effect is enabled.
  38016. */
  38017. /**
  38018. * Gets wether the color grading effect is enabled.
  38019. */
  38020. cameraColorGradingEnabled: boolean;
  38021. /**
  38022. * Gets wether tonemapping is enabled or not.
  38023. */
  38024. /**
  38025. * Sets wether tonemapping is enabled or not
  38026. */
  38027. cameraToneMappingEnabled: boolean;
  38028. /**
  38029. * The camera exposure used on this material.
  38030. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38031. * This corresponds to a photographic exposure.
  38032. */
  38033. /**
  38034. * The camera exposure used on this material.
  38035. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38036. * This corresponds to a photographic exposure.
  38037. */
  38038. cameraExposure: number;
  38039. /**
  38040. * Gets The camera contrast used on this material.
  38041. */
  38042. /**
  38043. * Sets The camera contrast used on this material.
  38044. */
  38045. cameraContrast: number;
  38046. /**
  38047. * Gets the Color Grading 2D Lookup Texture.
  38048. */
  38049. /**
  38050. * Sets the Color Grading 2D Lookup Texture.
  38051. */
  38052. cameraColorGradingTexture: Nullable<BaseTexture>;
  38053. /**
  38054. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38055. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38056. * 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;
  38057. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38058. */
  38059. /**
  38060. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38061. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38062. * 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;
  38063. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38064. */
  38065. cameraColorCurves: Nullable<ColorCurves>;
  38066. /**
  38067. * Custom callback helping to override the default shader used in the material.
  38068. */
  38069. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38070. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38071. protected _worldViewProjectionMatrix: Matrix;
  38072. protected _globalAmbientColor: Color3;
  38073. protected _useLogarithmicDepth: boolean;
  38074. /**
  38075. * Instantiates a new standard material.
  38076. * This is the default material used in Babylon. It is the best trade off between quality
  38077. * and performances.
  38078. * @see http://doc.babylonjs.com/babylon101/materials
  38079. * @param name Define the name of the material in the scene
  38080. * @param scene Define the scene the material belong to
  38081. */
  38082. constructor(name: string, scene: Scene);
  38083. /**
  38084. * Gets a boolean indicating that current material needs to register RTT
  38085. */
  38086. readonly hasRenderTargetTextures: boolean;
  38087. /**
  38088. * Gets the current class name of the material e.g. "StandardMaterial"
  38089. * Mainly use in serialization.
  38090. * @returns the class name
  38091. */
  38092. getClassName(): string;
  38093. /**
  38094. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38095. * You can try switching to logarithmic depth.
  38096. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38097. */
  38098. useLogarithmicDepth: boolean;
  38099. /**
  38100. * Specifies if the material will require alpha blending
  38101. * @returns a boolean specifying if alpha blending is needed
  38102. */
  38103. needAlphaBlending(): boolean;
  38104. /**
  38105. * Specifies if this material should be rendered in alpha test mode
  38106. * @returns a boolean specifying if an alpha test is needed.
  38107. */
  38108. needAlphaTesting(): boolean;
  38109. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38110. /**
  38111. * Get the texture used for alpha test purpose.
  38112. * @returns the diffuse texture in case of the standard material.
  38113. */
  38114. getAlphaTestTexture(): Nullable<BaseTexture>;
  38115. /**
  38116. * Get if the submesh is ready to be used and all its information available.
  38117. * Child classes can use it to update shaders
  38118. * @param mesh defines the mesh to check
  38119. * @param subMesh defines which submesh to check
  38120. * @param useInstances specifies that instances should be used
  38121. * @returns a boolean indicating that the submesh is ready or not
  38122. */
  38123. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38124. /**
  38125. * Builds the material UBO layouts.
  38126. * Used internally during the effect preparation.
  38127. */
  38128. buildUniformLayout(): void;
  38129. /**
  38130. * Unbinds the material from the mesh
  38131. */
  38132. unbind(): void;
  38133. /**
  38134. * Binds the submesh to this material by preparing the effect and shader to draw
  38135. * @param world defines the world transformation matrix
  38136. * @param mesh defines the mesh containing the submesh
  38137. * @param subMesh defines the submesh to bind the material to
  38138. */
  38139. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38140. /**
  38141. * Get the list of animatables in the material.
  38142. * @returns the list of animatables object used in the material
  38143. */
  38144. getAnimatables(): IAnimatable[];
  38145. /**
  38146. * Gets the active textures from the material
  38147. * @returns an array of textures
  38148. */
  38149. getActiveTextures(): BaseTexture[];
  38150. /**
  38151. * Specifies if the material uses a texture
  38152. * @param texture defines the texture to check against the material
  38153. * @returns a boolean specifying if the material uses the texture
  38154. */
  38155. hasTexture(texture: BaseTexture): boolean;
  38156. /**
  38157. * Disposes the material
  38158. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38159. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38160. */
  38161. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38162. /**
  38163. * Makes a duplicate of the material, and gives it a new name
  38164. * @param name defines the new name for the duplicated material
  38165. * @returns the cloned material
  38166. */
  38167. clone(name: string): StandardMaterial;
  38168. /**
  38169. * Serializes this material in a JSON representation
  38170. * @returns the serialized material object
  38171. */
  38172. serialize(): any;
  38173. /**
  38174. * Creates a standard material from parsed material data
  38175. * @param source defines the JSON representation of the material
  38176. * @param scene defines the hosting scene
  38177. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38178. * @returns a new standard material
  38179. */
  38180. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38181. /**
  38182. * Are diffuse textures enabled in the application.
  38183. */
  38184. static DiffuseTextureEnabled: boolean;
  38185. /**
  38186. * Are ambient textures enabled in the application.
  38187. */
  38188. static AmbientTextureEnabled: boolean;
  38189. /**
  38190. * Are opacity textures enabled in the application.
  38191. */
  38192. static OpacityTextureEnabled: boolean;
  38193. /**
  38194. * Are reflection textures enabled in the application.
  38195. */
  38196. static ReflectionTextureEnabled: boolean;
  38197. /**
  38198. * Are emissive textures enabled in the application.
  38199. */
  38200. static EmissiveTextureEnabled: boolean;
  38201. /**
  38202. * Are specular textures enabled in the application.
  38203. */
  38204. static SpecularTextureEnabled: boolean;
  38205. /**
  38206. * Are bump textures enabled in the application.
  38207. */
  38208. static BumpTextureEnabled: boolean;
  38209. /**
  38210. * Are lightmap textures enabled in the application.
  38211. */
  38212. static LightmapTextureEnabled: boolean;
  38213. /**
  38214. * Are refraction textures enabled in the application.
  38215. */
  38216. static RefractionTextureEnabled: boolean;
  38217. /**
  38218. * Are color grading textures enabled in the application.
  38219. */
  38220. static ColorGradingTextureEnabled: boolean;
  38221. /**
  38222. * Are fresnels enabled in the application.
  38223. */
  38224. static FresnelEnabled: boolean;
  38225. }
  38226. }
  38227. declare module BABYLON {
  38228. /**
  38229. * A class extending Texture allowing drawing on a texture
  38230. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38231. */
  38232. export class DynamicTexture extends Texture {
  38233. private _generateMipMaps;
  38234. private _canvas;
  38235. private _context;
  38236. private _engine;
  38237. /**
  38238. * Creates a DynamicTexture
  38239. * @param name defines the name of the texture
  38240. * @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
  38241. * @param scene defines the scene where you want the texture
  38242. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38243. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38244. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38245. */
  38246. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38247. /**
  38248. * Get the current class name of the texture useful for serialization or dynamic coding.
  38249. * @returns "DynamicTexture"
  38250. */
  38251. getClassName(): string;
  38252. /**
  38253. * Gets the current state of canRescale
  38254. */
  38255. readonly canRescale: boolean;
  38256. private _recreate;
  38257. /**
  38258. * Scales the texture
  38259. * @param ratio the scale factor to apply to both width and height
  38260. */
  38261. scale(ratio: number): void;
  38262. /**
  38263. * Resizes the texture
  38264. * @param width the new width
  38265. * @param height the new height
  38266. */
  38267. scaleTo(width: number, height: number): void;
  38268. /**
  38269. * Gets the context of the canvas used by the texture
  38270. * @returns the canvas context of the dynamic texture
  38271. */
  38272. getContext(): CanvasRenderingContext2D;
  38273. /**
  38274. * Clears the texture
  38275. */
  38276. clear(): void;
  38277. /**
  38278. * Updates the texture
  38279. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38280. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38281. */
  38282. update(invertY?: boolean, premulAlpha?: boolean): void;
  38283. /**
  38284. * Draws text onto the texture
  38285. * @param text defines the text to be drawn
  38286. * @param x defines the placement of the text from the left
  38287. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38288. * @param font defines the font to be used with font-style, font-size, font-name
  38289. * @param color defines the color used for the text
  38290. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38291. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38292. * @param update defines whether texture is immediately update (default is true)
  38293. */
  38294. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38295. /**
  38296. * Clones the texture
  38297. * @returns the clone of the texture.
  38298. */
  38299. clone(): DynamicTexture;
  38300. /**
  38301. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38302. * @returns a serialized dynamic texture object
  38303. */
  38304. serialize(): any;
  38305. /** @hidden */ rebuild(): void;
  38306. }
  38307. }
  38308. declare module BABYLON {
  38309. /** @hidden */
  38310. export var imageProcessingPixelShader: {
  38311. name: string;
  38312. shader: string;
  38313. };
  38314. }
  38315. declare module BABYLON {
  38316. /**
  38317. * ImageProcessingPostProcess
  38318. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38319. */
  38320. export class ImageProcessingPostProcess extends PostProcess {
  38321. /**
  38322. * Default configuration related to image processing available in the PBR Material.
  38323. */
  38324. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38325. /**
  38326. * Gets the image processing configuration used either in this material.
  38327. */
  38328. /**
  38329. * Sets the Default image processing configuration used either in the this material.
  38330. *
  38331. * If sets to null, the scene one is in use.
  38332. */
  38333. imageProcessingConfiguration: ImageProcessingConfiguration;
  38334. /**
  38335. * Keep track of the image processing observer to allow dispose and replace.
  38336. */
  38337. private _imageProcessingObserver;
  38338. /**
  38339. * Attaches a new image processing configuration to the PBR Material.
  38340. * @param configuration
  38341. */
  38342. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38343. /**
  38344. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38345. */
  38346. /**
  38347. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38348. */
  38349. colorCurves: Nullable<ColorCurves>;
  38350. /**
  38351. * Gets wether the color curves effect is enabled.
  38352. */
  38353. /**
  38354. * Sets wether the color curves effect is enabled.
  38355. */
  38356. colorCurvesEnabled: boolean;
  38357. /**
  38358. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38359. */
  38360. /**
  38361. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38362. */
  38363. colorGradingTexture: Nullable<BaseTexture>;
  38364. /**
  38365. * Gets wether the color grading effect is enabled.
  38366. */
  38367. /**
  38368. * Gets wether the color grading effect is enabled.
  38369. */
  38370. colorGradingEnabled: boolean;
  38371. /**
  38372. * Gets exposure used in the effect.
  38373. */
  38374. /**
  38375. * Sets exposure used in the effect.
  38376. */
  38377. exposure: number;
  38378. /**
  38379. * Gets wether tonemapping is enabled or not.
  38380. */
  38381. /**
  38382. * Sets wether tonemapping is enabled or not
  38383. */
  38384. toneMappingEnabled: boolean;
  38385. /**
  38386. * Gets the type of tone mapping effect.
  38387. */
  38388. /**
  38389. * Sets the type of tone mapping effect.
  38390. */
  38391. toneMappingType: number;
  38392. /**
  38393. * Gets contrast used in the effect.
  38394. */
  38395. /**
  38396. * Sets contrast used in the effect.
  38397. */
  38398. contrast: number;
  38399. /**
  38400. * Gets Vignette stretch size.
  38401. */
  38402. /**
  38403. * Sets Vignette stretch size.
  38404. */
  38405. vignetteStretch: number;
  38406. /**
  38407. * Gets Vignette centre X Offset.
  38408. */
  38409. /**
  38410. * Sets Vignette centre X Offset.
  38411. */
  38412. vignetteCentreX: number;
  38413. /**
  38414. * Gets Vignette centre Y Offset.
  38415. */
  38416. /**
  38417. * Sets Vignette centre Y Offset.
  38418. */
  38419. vignetteCentreY: number;
  38420. /**
  38421. * Gets Vignette weight or intensity of the vignette effect.
  38422. */
  38423. /**
  38424. * Sets Vignette weight or intensity of the vignette effect.
  38425. */
  38426. vignetteWeight: number;
  38427. /**
  38428. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38429. * if vignetteEnabled is set to true.
  38430. */
  38431. /**
  38432. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38433. * if vignetteEnabled is set to true.
  38434. */
  38435. vignetteColor: Color4;
  38436. /**
  38437. * Gets Camera field of view used by the Vignette effect.
  38438. */
  38439. /**
  38440. * Sets Camera field of view used by the Vignette effect.
  38441. */
  38442. vignetteCameraFov: number;
  38443. /**
  38444. * Gets the vignette blend mode allowing different kind of effect.
  38445. */
  38446. /**
  38447. * Sets the vignette blend mode allowing different kind of effect.
  38448. */
  38449. vignetteBlendMode: number;
  38450. /**
  38451. * Gets wether the vignette effect is enabled.
  38452. */
  38453. /**
  38454. * Sets wether the vignette effect is enabled.
  38455. */
  38456. vignetteEnabled: boolean;
  38457. private _fromLinearSpace;
  38458. /**
  38459. * Gets wether the input of the processing is in Gamma or Linear Space.
  38460. */
  38461. /**
  38462. * Sets wether the input of the processing is in Gamma or Linear Space.
  38463. */
  38464. fromLinearSpace: boolean;
  38465. /**
  38466. * Defines cache preventing GC.
  38467. */
  38468. private _defines;
  38469. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38470. /**
  38471. * "ImageProcessingPostProcess"
  38472. * @returns "ImageProcessingPostProcess"
  38473. */
  38474. getClassName(): string;
  38475. protected _updateParameters(): void;
  38476. dispose(camera?: Camera): void;
  38477. }
  38478. }
  38479. declare module BABYLON {
  38480. /**
  38481. * Class containing static functions to help procedurally build meshes
  38482. */
  38483. export class GroundBuilder {
  38484. /**
  38485. * Creates a ground mesh
  38486. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38487. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38489. * @param name defines the name of the mesh
  38490. * @param options defines the options used to create the mesh
  38491. * @param scene defines the hosting scene
  38492. * @returns the ground mesh
  38493. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38494. */
  38495. static CreateGround(name: string, options: {
  38496. width?: number;
  38497. height?: number;
  38498. subdivisions?: number;
  38499. subdivisionsX?: number;
  38500. subdivisionsY?: number;
  38501. updatable?: boolean;
  38502. }, scene: any): Mesh;
  38503. /**
  38504. * Creates a tiled ground mesh
  38505. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38506. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38507. * * 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
  38508. * * 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
  38509. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38510. * @param name defines the name of the mesh
  38511. * @param options defines the options used to create the mesh
  38512. * @param scene defines the hosting scene
  38513. * @returns the tiled ground mesh
  38514. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38515. */
  38516. static CreateTiledGround(name: string, options: {
  38517. xmin: number;
  38518. zmin: number;
  38519. xmax: number;
  38520. zmax: number;
  38521. subdivisions?: {
  38522. w: number;
  38523. h: number;
  38524. };
  38525. precision?: {
  38526. w: number;
  38527. h: number;
  38528. };
  38529. updatable?: boolean;
  38530. }, scene: Scene): Mesh;
  38531. /**
  38532. * Creates a ground mesh from a height map
  38533. * * The parameter `url` sets the URL of the height map image resource.
  38534. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38535. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38536. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38537. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38538. * * 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.
  38539. * * 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).
  38540. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38542. * @param name defines the name of the mesh
  38543. * @param url defines the url to the height map
  38544. * @param options defines the options used to create the mesh
  38545. * @param scene defines the hosting scene
  38546. * @returns the ground mesh
  38547. * @see https://doc.babylonjs.com/babylon101/height_map
  38548. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38549. */
  38550. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38551. width?: number;
  38552. height?: number;
  38553. subdivisions?: number;
  38554. minHeight?: number;
  38555. maxHeight?: number;
  38556. colorFilter?: Color3;
  38557. alphaFilter?: number;
  38558. updatable?: boolean;
  38559. onReady?: (mesh: GroundMesh) => void;
  38560. }, scene: Scene): GroundMesh;
  38561. }
  38562. }
  38563. declare module BABYLON {
  38564. /**
  38565. * Class containing static functions to help procedurally build meshes
  38566. */
  38567. export class TorusBuilder {
  38568. /**
  38569. * Creates a torus mesh
  38570. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38571. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38572. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38574. * * 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
  38575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38576. * @param name defines the name of the mesh
  38577. * @param options defines the options used to create the mesh
  38578. * @param scene defines the hosting scene
  38579. * @returns the torus mesh
  38580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38581. */
  38582. static CreateTorus(name: string, options: {
  38583. diameter?: number;
  38584. thickness?: number;
  38585. tessellation?: number;
  38586. updatable?: boolean;
  38587. sideOrientation?: number;
  38588. frontUVs?: Vector4;
  38589. backUVs?: Vector4;
  38590. }, scene: any): Mesh;
  38591. }
  38592. }
  38593. declare module BABYLON {
  38594. /**
  38595. * Class containing static functions to help procedurally build meshes
  38596. */
  38597. export class CylinderBuilder {
  38598. /**
  38599. * Creates a cylinder or a cone mesh
  38600. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38601. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38602. * * 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.
  38603. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38604. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38605. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38606. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38607. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38608. * * 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).
  38609. * * 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
  38610. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38611. * * 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
  38612. * * 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.
  38613. * * If `enclose` is false, a ring surface is one element.
  38614. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38615. * * 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
  38616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38617. * * 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
  38618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38619. * @param name defines the name of the mesh
  38620. * @param options defines the options used to create the mesh
  38621. * @param scene defines the hosting scene
  38622. * @returns the cylinder mesh
  38623. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38624. */
  38625. static CreateCylinder(name: string, options: {
  38626. height?: number;
  38627. diameterTop?: number;
  38628. diameterBottom?: number;
  38629. diameter?: number;
  38630. tessellation?: number;
  38631. subdivisions?: number;
  38632. arc?: number;
  38633. faceColors?: Color4[];
  38634. faceUV?: Vector4[];
  38635. updatable?: boolean;
  38636. hasRings?: boolean;
  38637. enclose?: boolean;
  38638. sideOrientation?: number;
  38639. frontUVs?: Vector4;
  38640. backUVs?: Vector4;
  38641. }, scene: any): Mesh;
  38642. }
  38643. }
  38644. declare module BABYLON {
  38645. /**
  38646. * Manager for handling gamepads
  38647. */
  38648. export class GamepadManager {
  38649. private _scene?;
  38650. private _babylonGamepads;
  38651. private _oneGamepadConnected;
  38652. /** @hidden */ isMonitoring: boolean;
  38653. private _gamepadEventSupported;
  38654. private _gamepadSupport;
  38655. /**
  38656. * observable to be triggered when the gamepad controller has been connected
  38657. */
  38658. onGamepadConnectedObservable: Observable<Gamepad>;
  38659. /**
  38660. * observable to be triggered when the gamepad controller has been disconnected
  38661. */
  38662. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38663. private _onGamepadConnectedEvent;
  38664. private _onGamepadDisconnectedEvent;
  38665. /**
  38666. * Initializes the gamepad manager
  38667. * @param _scene BabylonJS scene
  38668. */
  38669. constructor(_scene?: Scene | undefined);
  38670. /**
  38671. * The gamepads in the game pad manager
  38672. */
  38673. readonly gamepads: Gamepad[];
  38674. /**
  38675. * Get the gamepad controllers based on type
  38676. * @param type The type of gamepad controller
  38677. * @returns Nullable gamepad
  38678. */
  38679. getGamepadByType(type?: number): Nullable<Gamepad>;
  38680. /**
  38681. * Disposes the gamepad manager
  38682. */
  38683. dispose(): void;
  38684. private _addNewGamepad;
  38685. private _startMonitoringGamepads;
  38686. private _stopMonitoringGamepads;
  38687. /** @hidden */ checkGamepadsStatus(): void;
  38688. private _updateGamepadObjects;
  38689. }
  38690. }
  38691. declare module BABYLON {
  38692. interface Scene {
  38693. /** @hidden */ gamepadManager: Nullable<GamepadManager>;
  38694. /**
  38695. * Gets the gamepad manager associated with the scene
  38696. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38697. */
  38698. gamepadManager: GamepadManager;
  38699. }
  38700. /**
  38701. * Interface representing a free camera inputs manager
  38702. */
  38703. interface FreeCameraInputsManager {
  38704. /**
  38705. * Adds gamepad input support to the FreeCameraInputsManager.
  38706. * @returns the FreeCameraInputsManager
  38707. */
  38708. addGamepad(): FreeCameraInputsManager;
  38709. }
  38710. /**
  38711. * Interface representing an arc rotate camera inputs manager
  38712. */
  38713. interface ArcRotateCameraInputsManager {
  38714. /**
  38715. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38716. * @returns the camera inputs manager
  38717. */
  38718. addGamepad(): ArcRotateCameraInputsManager;
  38719. }
  38720. /**
  38721. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38722. */
  38723. export class GamepadSystemSceneComponent implements ISceneComponent {
  38724. /**
  38725. * The component name helpfull to identify the component in the list of scene components.
  38726. */
  38727. readonly name: string;
  38728. /**
  38729. * The scene the component belongs to.
  38730. */
  38731. scene: Scene;
  38732. /**
  38733. * Creates a new instance of the component for the given scene
  38734. * @param scene Defines the scene to register the component in
  38735. */
  38736. constructor(scene: Scene);
  38737. /**
  38738. * Registers the component in a given scene
  38739. */
  38740. register(): void;
  38741. /**
  38742. * Rebuilds the elements related to this component in case of
  38743. * context lost for instance.
  38744. */
  38745. rebuild(): void;
  38746. /**
  38747. * Disposes the component and the associated ressources
  38748. */
  38749. dispose(): void;
  38750. private _beforeCameraUpdate;
  38751. }
  38752. }
  38753. declare module BABYLON {
  38754. /**
  38755. * Options to modify the vr teleportation behavior.
  38756. */
  38757. export interface VRTeleportationOptions {
  38758. /**
  38759. * The name of the mesh which should be used as the teleportation floor. (default: null)
  38760. */
  38761. floorMeshName?: string;
  38762. /**
  38763. * A list of meshes to be used as the teleportation floor. (default: empty)
  38764. */
  38765. floorMeshes?: Mesh[];
  38766. }
  38767. /**
  38768. * Options to modify the vr experience helper's behavior.
  38769. */
  38770. export interface VRExperienceHelperOptions extends WebVROptions {
  38771. /**
  38772. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  38773. */
  38774. createDeviceOrientationCamera?: boolean;
  38775. /**
  38776. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  38777. */
  38778. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  38779. /**
  38780. * Uses the main button on the controller to toggle the laser casted. (default: true)
  38781. */
  38782. laserToggle?: boolean;
  38783. /**
  38784. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  38785. */
  38786. floorMeshes?: Mesh[];
  38787. /**
  38788. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  38789. */
  38790. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  38791. }
  38792. /**
  38793. * Event containing information after VR has been entered
  38794. */
  38795. export class OnAfterEnteringVRObservableEvent {
  38796. /**
  38797. * If entering vr was successful
  38798. */
  38799. success: boolean;
  38800. }
  38801. /**
  38802. * Helps to quickly add VR support to an existing scene.
  38803. * See http://doc.babylonjs.com/how_to/webvr_helper
  38804. */
  38805. export class VRExperienceHelper {
  38806. /** Options to modify the vr experience helper's behavior. */
  38807. webVROptions: VRExperienceHelperOptions;
  38808. private _scene;
  38809. private _position;
  38810. private _btnVR;
  38811. private _btnVRDisplayed;
  38812. private _webVRsupported;
  38813. private _webVRready;
  38814. private _webVRrequesting;
  38815. private _webVRpresenting;
  38816. private _hasEnteredVR;
  38817. private _fullscreenVRpresenting;
  38818. private _canvas;
  38819. private _webVRCamera;
  38820. private _vrDeviceOrientationCamera;
  38821. private _deviceOrientationCamera;
  38822. private _existingCamera;
  38823. private _onKeyDown;
  38824. private _onVrDisplayPresentChange;
  38825. private _onVRDisplayChanged;
  38826. private _onVRRequestPresentStart;
  38827. private _onVRRequestPresentComplete;
  38828. /**
  38829. * Observable raised right before entering VR.
  38830. */
  38831. onEnteringVRObservable: Observable<VRExperienceHelper>;
  38832. /**
  38833. * Observable raised when entering VR has completed.
  38834. */
  38835. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  38836. /**
  38837. * Observable raised when exiting VR.
  38838. */
  38839. onExitingVRObservable: Observable<VRExperienceHelper>;
  38840. /**
  38841. * Observable raised when controller mesh is loaded.
  38842. */
  38843. onControllerMeshLoadedObservable: Observable<WebVRController>;
  38844. /** Return this.onEnteringVRObservable
  38845. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  38846. */
  38847. readonly onEnteringVR: Observable<VRExperienceHelper>;
  38848. /** Return this.onExitingVRObservable
  38849. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  38850. */
  38851. readonly onExitingVR: Observable<VRExperienceHelper>;
  38852. /** Return this.onControllerMeshLoadedObservable
  38853. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  38854. */
  38855. readonly onControllerMeshLoaded: Observable<WebVRController>;
  38856. private _rayLength;
  38857. private _useCustomVRButton;
  38858. private _teleportationRequested;
  38859. private _teleportActive;
  38860. private _floorMeshName;
  38861. private _floorMeshesCollection;
  38862. private _rotationAllowed;
  38863. private _teleportBackwardsVector;
  38864. private _teleportationTarget;
  38865. private _isDefaultTeleportationTarget;
  38866. private _postProcessMove;
  38867. private _teleportationFillColor;
  38868. private _teleportationBorderColor;
  38869. private _rotationAngle;
  38870. private _haloCenter;
  38871. private _cameraGazer;
  38872. private _padSensibilityUp;
  38873. private _padSensibilityDown;
  38874. private _leftController;
  38875. private _rightController;
  38876. /**
  38877. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  38878. */
  38879. onNewMeshSelected: Observable<AbstractMesh>;
  38880. /**
  38881. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  38882. */
  38883. onNewMeshPicked: Observable<PickingInfo>;
  38884. private _circleEase;
  38885. /**
  38886. * Observable raised before camera teleportation
  38887. */
  38888. onBeforeCameraTeleport: Observable<Vector3>;
  38889. /**
  38890. * Observable raised after camera teleportation
  38891. */
  38892. onAfterCameraTeleport: Observable<Vector3>;
  38893. /**
  38894. * Observable raised when current selected mesh gets unselected
  38895. */
  38896. onSelectedMeshUnselected: Observable<AbstractMesh>;
  38897. private _raySelectionPredicate;
  38898. /**
  38899. * To be optionaly changed by user to define custom ray selection
  38900. */
  38901. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  38902. /**
  38903. * To be optionaly changed by user to define custom selection logic (after ray selection)
  38904. */
  38905. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  38906. /**
  38907. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  38908. */
  38909. teleportationEnabled: boolean;
  38910. private _defaultHeight;
  38911. private _teleportationInitialized;
  38912. private _interactionsEnabled;
  38913. private _interactionsRequested;
  38914. private _displayGaze;
  38915. private _displayLaserPointer;
  38916. /**
  38917. * The mesh used to display where the user is going to teleport.
  38918. */
  38919. /**
  38920. * Sets the mesh to be used to display where the user is going to teleport.
  38921. */
  38922. teleportationTarget: Mesh;
  38923. /**
  38924. * 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
  38925. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  38926. * See http://doc.babylonjs.com/resources/baking_transformations
  38927. */
  38928. gazeTrackerMesh: Mesh;
  38929. /**
  38930. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  38931. */
  38932. updateGazeTrackerScale: boolean;
  38933. /**
  38934. * If the gaze trackers color should be updated when selecting meshes
  38935. */
  38936. updateGazeTrackerColor: boolean;
  38937. /**
  38938. * The gaze tracking mesh corresponding to the left controller
  38939. */
  38940. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  38941. /**
  38942. * The gaze tracking mesh corresponding to the right controller
  38943. */
  38944. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  38945. /**
  38946. * If the ray of the gaze should be displayed.
  38947. */
  38948. /**
  38949. * Sets if the ray of the gaze should be displayed.
  38950. */
  38951. displayGaze: boolean;
  38952. /**
  38953. * If the ray of the LaserPointer should be displayed.
  38954. */
  38955. /**
  38956. * Sets if the ray of the LaserPointer should be displayed.
  38957. */
  38958. displayLaserPointer: boolean;
  38959. /**
  38960. * The deviceOrientationCamera used as the camera when not in VR.
  38961. */
  38962. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  38963. /**
  38964. * Based on the current WebVR support, returns the current VR camera used.
  38965. */
  38966. readonly currentVRCamera: Nullable<Camera>;
  38967. /**
  38968. * The webVRCamera which is used when in VR.
  38969. */
  38970. readonly webVRCamera: WebVRFreeCamera;
  38971. /**
  38972. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  38973. */
  38974. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  38975. private readonly _teleportationRequestInitiated;
  38976. /**
  38977. * Defines wether or not Pointer lock should be requested when switching to
  38978. * full screen.
  38979. */
  38980. requestPointerLockOnFullScreen: boolean;
  38981. /**
  38982. * Instantiates a VRExperienceHelper.
  38983. * Helps to quickly add VR support to an existing scene.
  38984. * @param scene The scene the VRExperienceHelper belongs to.
  38985. * @param webVROptions Options to modify the vr experience helper's behavior.
  38986. */
  38987. constructor(scene: Scene,
  38988. /** Options to modify the vr experience helper's behavior. */
  38989. webVROptions?: VRExperienceHelperOptions);
  38990. private _onDefaultMeshLoaded;
  38991. private _onResize;
  38992. private _onFullscreenChange;
  38993. /**
  38994. * Gets a value indicating if we are currently in VR mode.
  38995. */
  38996. readonly isInVRMode: boolean;
  38997. private onVrDisplayPresentChange;
  38998. private onVRDisplayChanged;
  38999. private moveButtonToBottomRight;
  39000. private displayVRButton;
  39001. private updateButtonVisibility;
  39002. private _cachedAngularSensibility;
  39003. /**
  39004. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39005. * Otherwise, will use the fullscreen API.
  39006. */
  39007. enterVR(): void;
  39008. /**
  39009. * Attempt to exit VR, or fullscreen.
  39010. */
  39011. exitVR(): void;
  39012. /**
  39013. * The position of the vr experience helper.
  39014. */
  39015. /**
  39016. * Sets the position of the vr experience helper.
  39017. */
  39018. position: Vector3;
  39019. /**
  39020. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39021. */
  39022. enableInteractions(): void;
  39023. private readonly _noControllerIsActive;
  39024. private beforeRender;
  39025. private _isTeleportationFloor;
  39026. /**
  39027. * Adds a floor mesh to be used for teleportation.
  39028. * @param floorMesh the mesh to be used for teleportation.
  39029. */
  39030. addFloorMesh(floorMesh: Mesh): void;
  39031. /**
  39032. * Removes a floor mesh from being used for teleportation.
  39033. * @param floorMesh the mesh to be removed.
  39034. */
  39035. removeFloorMesh(floorMesh: Mesh): void;
  39036. /**
  39037. * Enables interactions and teleportation using the VR controllers and gaze.
  39038. * @param vrTeleportationOptions options to modify teleportation behavior.
  39039. */
  39040. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39041. private _onNewGamepadConnected;
  39042. private _tryEnableInteractionOnController;
  39043. private _onNewGamepadDisconnected;
  39044. private _enableInteractionOnController;
  39045. private _checkTeleportWithRay;
  39046. private _checkRotate;
  39047. private _checkTeleportBackwards;
  39048. private _enableTeleportationOnController;
  39049. private _createTeleportationCircles;
  39050. private _displayTeleportationTarget;
  39051. private _hideTeleportationTarget;
  39052. private _rotateCamera;
  39053. private _moveTeleportationSelectorTo;
  39054. private _workingVector;
  39055. private _workingQuaternion;
  39056. private _workingMatrix;
  39057. /**
  39058. * Teleports the users feet to the desired location
  39059. * @param location The location where the user's feet should be placed
  39060. */
  39061. teleportCamera(location: Vector3): void;
  39062. private _convertNormalToDirectionOfRay;
  39063. private _castRayAndSelectObject;
  39064. private _notifySelectedMeshUnselected;
  39065. /**
  39066. * Sets the color of the laser ray from the vr controllers.
  39067. * @param color new color for the ray.
  39068. */
  39069. changeLaserColor(color: Color3): void;
  39070. /**
  39071. * Sets the color of the ray from the vr headsets gaze.
  39072. * @param color new color for the ray.
  39073. */
  39074. changeGazeColor(color: Color3): void;
  39075. /**
  39076. * Exits VR and disposes of the vr experience helper
  39077. */
  39078. dispose(): void;
  39079. /**
  39080. * Gets the name of the VRExperienceHelper class
  39081. * @returns "VRExperienceHelper"
  39082. */
  39083. getClassName(): string;
  39084. }
  39085. }
  39086. declare module BABYLON {
  39087. /**
  39088. * Manages an XRSession
  39089. * @see https://doc.babylonjs.com/how_to/webxr
  39090. */
  39091. export class WebXRSessionManager implements IDisposable {
  39092. private scene;
  39093. /**
  39094. * Fires every time a new xrFrame arrives which can be used to update the camera
  39095. */
  39096. onXRFrameObservable: Observable<any>;
  39097. /**
  39098. * Fires when the xr session is ended either by the device or manually done
  39099. */
  39100. onXRSessionEnded: Observable<any>;
  39101. /** @hidden */ xrSession: XRSession;
  39102. /** @hidden */ frameOfReference: XRFrameOfReference;
  39103. /** @hidden */ sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39104. /** @hidden */ currentXRFrame: Nullable<XRFrame>;
  39105. private _xrNavigator;
  39106. private _xrDevice;
  39107. private _tmpMatrix;
  39108. /**
  39109. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39110. * @param scene The scene which the session should be created for
  39111. */
  39112. constructor(scene: Scene);
  39113. /**
  39114. * Initializes the manager
  39115. * After initialization enterXR can be called to start an XR session
  39116. * @returns Promise which resolves after it is initialized
  39117. */
  39118. initializeAsync(): Promise<void>;
  39119. /**
  39120. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39121. * @param sessionCreationOptions xr options to create the session with
  39122. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39123. * @returns Promise which resolves after it enters XR
  39124. */
  39125. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39126. /**
  39127. * Stops the xrSession and restores the renderloop
  39128. * @returns Promise which resolves after it exits XR
  39129. */
  39130. exitXRAsync(): Promise<void>;
  39131. /**
  39132. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39133. * @param ray ray to cast into the environment
  39134. * @returns Promise which resolves with a collision point in the environment if it exists
  39135. */
  39136. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39137. /**
  39138. * Checks if a session would be supported for the creation options specified
  39139. * @param options creation options to check if they are supported
  39140. * @returns true if supported
  39141. */
  39142. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39143. /**
  39144. * @hidden
  39145. * Converts the render layer of xrSession to a render target
  39146. * @param session session to create render target for
  39147. * @param scene scene the new render target should be created for
  39148. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39149. /**
  39150. * Disposes of the session manager
  39151. */
  39152. dispose(): void;
  39153. }
  39154. }
  39155. declare module BABYLON {
  39156. /**
  39157. * WebXR Camera which holds the views for the xrSession
  39158. * @see https://doc.babylonjs.com/how_to/webxr
  39159. */
  39160. export class WebXRCamera extends FreeCamera {
  39161. private static _TmpMatrix;
  39162. /**
  39163. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39164. * @param name the name of the camera
  39165. * @param scene the scene to add the camera to
  39166. */
  39167. constructor(name: string, scene: Scene);
  39168. private _updateNumberOfRigCameras;
  39169. /** @hidden */ updateForDualEyeDebugging(pupilDistance?: number): void;
  39170. /**
  39171. * Updates the cameras position from the current pose information of the XR session
  39172. * @param xrSessionManager the session containing pose information
  39173. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39174. */
  39175. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39176. }
  39177. }
  39178. declare module BABYLON {
  39179. /**
  39180. * States of the webXR experience
  39181. */
  39182. export enum WebXRState {
  39183. /**
  39184. * Transitioning to being in XR mode
  39185. */
  39186. ENTERING_XR = 0,
  39187. /**
  39188. * Transitioning to non XR mode
  39189. */
  39190. EXITING_XR = 1,
  39191. /**
  39192. * In XR mode and presenting
  39193. */
  39194. IN_XR = 2,
  39195. /**
  39196. * Not entered XR mode
  39197. */
  39198. NOT_IN_XR = 3
  39199. }
  39200. /**
  39201. * Helper class used to enable XR
  39202. * @see https://doc.babylonjs.com/how_to/webxr
  39203. */
  39204. export class WebXRExperienceHelper implements IDisposable {
  39205. private scene;
  39206. /**
  39207. * 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
  39208. */
  39209. container: AbstractMesh;
  39210. /**
  39211. * Camera used to render xr content
  39212. */
  39213. camera: WebXRCamera;
  39214. /**
  39215. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39216. */
  39217. state: WebXRState;
  39218. private _setState;
  39219. private static _TmpVector;
  39220. /**
  39221. * Fires when the state of the experience helper has changed
  39222. */
  39223. onStateChangedObservable: Observable<WebXRState>;
  39224. /** @hidden */ sessionManager: WebXRSessionManager;
  39225. private _nonVRCamera;
  39226. private _originalSceneAutoClear;
  39227. private _supported;
  39228. /**
  39229. * Creates the experience helper
  39230. * @param scene the scene to attach the experience helper to
  39231. * @returns a promise for the experience helper
  39232. */
  39233. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39234. /**
  39235. * Creates a WebXRExperienceHelper
  39236. * @param scene The scene the helper should be created in
  39237. */
  39238. private constructor();
  39239. /**
  39240. * Exits XR mode and returns the scene to its original state
  39241. * @returns promise that resolves after xr mode has exited
  39242. */
  39243. exitXRAsync(): Promise<void>;
  39244. /**
  39245. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39246. * @param sessionCreationOptions options for the XR session
  39247. * @param frameOfReference frame of reference of the XR session
  39248. * @returns promise that resolves after xr mode has entered
  39249. */
  39250. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39251. /**
  39252. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39253. * @param ray ray to cast into the environment
  39254. * @returns Promise which resolves with a collision point in the environment if it exists
  39255. */
  39256. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39257. /**
  39258. * Updates the global position of the camera by moving the camera's container
  39259. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39260. * @param position The desired global position of the camera
  39261. */
  39262. setPositionOfCameraUsingContainer(position: Vector3): void;
  39263. /**
  39264. * Rotates the xr camera by rotating the camera's container around the camera's position
  39265. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39266. * @param rotation the desired quaternion rotation to apply to the camera
  39267. */
  39268. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39269. /**
  39270. * Checks if the creation options are supported by the xr session
  39271. * @param options creation options
  39272. * @returns true if supported
  39273. */
  39274. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39275. /**
  39276. * Disposes of the experience helper
  39277. */
  39278. dispose(): void;
  39279. }
  39280. }
  39281. declare module BABYLON {
  39282. /**
  39283. * Button which can be used to enter a different mode of XR
  39284. */
  39285. export class WebXREnterExitUIButton {
  39286. /** button element */
  39287. element: HTMLElement;
  39288. /** XR initialization options for the button */
  39289. initializationOptions: XRSessionCreationOptions;
  39290. /**
  39291. * Creates a WebXREnterExitUIButton
  39292. * @param element button element
  39293. * @param initializationOptions XR initialization options for the button
  39294. */
  39295. constructor(
  39296. /** button element */
  39297. element: HTMLElement,
  39298. /** XR initialization options for the button */
  39299. initializationOptions: XRSessionCreationOptions);
  39300. /**
  39301. * Overwritable function which can be used to update the button's visuals when the state changes
  39302. * @param activeButton the current active button in the UI
  39303. */
  39304. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39305. }
  39306. /**
  39307. * Options to create the webXR UI
  39308. */
  39309. export class WebXREnterExitUIOptions {
  39310. /**
  39311. * Context to enter xr with
  39312. */
  39313. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39314. /**
  39315. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39316. */
  39317. customButtons?: Array<WebXREnterExitUIButton>;
  39318. }
  39319. /**
  39320. * UI to allow the user to enter/exit XR mode
  39321. */
  39322. export class WebXREnterExitUI implements IDisposable {
  39323. private scene;
  39324. private _overlay;
  39325. private _buttons;
  39326. private _activeButton;
  39327. /**
  39328. * Fired every time the active button is changed.
  39329. *
  39330. * When xr is entered via a button that launches xr that button will be the callback parameter
  39331. *
  39332. * When exiting xr the callback parameter will be null)
  39333. */
  39334. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39335. /**
  39336. * Creates UI to allow the user to enter/exit XR mode
  39337. * @param scene the scene to add the ui to
  39338. * @param helper the xr experience helper to enter/exit xr with
  39339. * @param options options to configure the UI
  39340. * @returns the created ui
  39341. */
  39342. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39343. private constructor();
  39344. private _updateButtons;
  39345. /**
  39346. * Disposes of the object
  39347. */
  39348. dispose(): void;
  39349. }
  39350. }
  39351. declare module BABYLON {
  39352. /**
  39353. * Represents an XR input
  39354. */
  39355. export class WebXRController {
  39356. /**
  39357. * 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
  39358. */
  39359. grip?: AbstractMesh;
  39360. /**
  39361. * Pointer which can be used to select objects or attach a visible laser to
  39362. */
  39363. pointer: AbstractMesh;
  39364. /**
  39365. * Creates the controller
  39366. * @see https://doc.babylonjs.com/how_to/webxr
  39367. * @param scene the scene which the controller should be associated to
  39368. */
  39369. constructor(scene: Scene);
  39370. /**
  39371. * Disposes of the object
  39372. */
  39373. dispose(): void;
  39374. }
  39375. /**
  39376. * XR input used to track XR inputs such as controllers/rays
  39377. */
  39378. export class WebXRInput implements IDisposable {
  39379. private helper;
  39380. /**
  39381. * XR controllers being tracked
  39382. */
  39383. controllers: Array<WebXRController>;
  39384. private _tmpMatrix;
  39385. private _frameObserver;
  39386. /**
  39387. * Initializes the WebXRInput
  39388. * @param helper experience helper which the input should be created for
  39389. */
  39390. constructor(helper: WebXRExperienceHelper);
  39391. /**
  39392. * Disposes of the object
  39393. */
  39394. dispose(): void;
  39395. }
  39396. }
  39397. declare module BABYLON {
  39398. /**
  39399. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39400. */
  39401. export class WebXRManagedOutputCanvas implements IDisposable {
  39402. private _canvas;
  39403. /**
  39404. * xrpresent context of the canvas which can be used to display/mirror xr content
  39405. */
  39406. canvasContext: Nullable<WebGLRenderingContext>;
  39407. /**
  39408. * Initializes the canvas to be added/removed upon entering/exiting xr
  39409. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39410. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39411. */
  39412. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39413. /**
  39414. * Disposes of the object
  39415. */
  39416. dispose(): void;
  39417. private _setManagedOutputCanvas;
  39418. private _addCanvas;
  39419. private _removeCanvas;
  39420. }
  39421. }
  39422. declare module BABYLON {
  39423. /**
  39424. * Contains an array of blocks representing the octree
  39425. */
  39426. export interface IOctreeContainer<T> {
  39427. /**
  39428. * Blocks within the octree
  39429. */
  39430. blocks: Array<OctreeBlock<T>>;
  39431. }
  39432. /**
  39433. * Class used to store a cell in an octree
  39434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39435. */
  39436. export class OctreeBlock<T> {
  39437. /**
  39438. * Gets the content of the current block
  39439. */
  39440. entries: T[];
  39441. /**
  39442. * Gets the list of block children
  39443. */
  39444. blocks: Array<OctreeBlock<T>>;
  39445. private _depth;
  39446. private _maxDepth;
  39447. private _capacity;
  39448. private _minPoint;
  39449. private _maxPoint;
  39450. private _boundingVectors;
  39451. private _creationFunc;
  39452. /**
  39453. * Creates a new block
  39454. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39455. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39456. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39457. * @param depth defines the current depth of this block in the octree
  39458. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39459. * @param creationFunc defines a callback to call when an element is added to the block
  39460. */
  39461. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39462. /**
  39463. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39464. */
  39465. readonly capacity: number;
  39466. /**
  39467. * Gets the minimum vector (in world space) of the block's bounding box
  39468. */
  39469. readonly minPoint: Vector3;
  39470. /**
  39471. * Gets the maximum vector (in world space) of the block's bounding box
  39472. */
  39473. readonly maxPoint: Vector3;
  39474. /**
  39475. * Add a new element to this block
  39476. * @param entry defines the element to add
  39477. */
  39478. addEntry(entry: T): void;
  39479. /**
  39480. * Remove an element from this block
  39481. * @param entry defines the element to remove
  39482. */
  39483. removeEntry(entry: T): void;
  39484. /**
  39485. * Add an array of elements to this block
  39486. * @param entries defines the array of elements to add
  39487. */
  39488. addEntries(entries: T[]): void;
  39489. /**
  39490. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39491. * @param frustumPlanes defines the frustum planes to test
  39492. * @param selection defines the array to store current content if selection is positive
  39493. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39494. */
  39495. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39496. /**
  39497. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39498. * @param sphereCenter defines the bounding sphere center
  39499. * @param sphereRadius defines the bounding sphere radius
  39500. * @param selection defines the array to store current content if selection is positive
  39501. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39502. */
  39503. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39504. /**
  39505. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39506. * @param ray defines the ray to test with
  39507. * @param selection defines the array to store current content if selection is positive
  39508. */
  39509. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39510. /**
  39511. * Subdivide the content into child blocks (this block will then be empty)
  39512. */
  39513. createInnerBlocks(): void;
  39514. /**
  39515. * @hidden
  39516. */ 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;
  39517. }
  39518. }
  39519. declare module BABYLON {
  39520. /**
  39521. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39522. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39523. */
  39524. export class Octree<T> {
  39525. /** 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.) */
  39526. maxDepth: number;
  39527. /**
  39528. * Blocks within the octree containing objects
  39529. */
  39530. blocks: Array<OctreeBlock<T>>;
  39531. /**
  39532. * Content stored in the octree
  39533. */
  39534. dynamicContent: T[];
  39535. private _maxBlockCapacity;
  39536. private _selectionContent;
  39537. private _creationFunc;
  39538. /**
  39539. * Creates a octree
  39540. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39541. * @param creationFunc function to be used to instatiate the octree
  39542. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39543. * @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.)
  39544. */
  39545. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39546. /** 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.) */
  39547. maxDepth?: number);
  39548. /**
  39549. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39550. * @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);
  39551. * @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);
  39552. * @param entries meshes to be added to the octree blocks
  39553. */
  39554. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39555. /**
  39556. * Adds a mesh to the octree
  39557. * @param entry Mesh to add to the octree
  39558. */
  39559. addMesh(entry: T): void;
  39560. /**
  39561. * Remove an element from the octree
  39562. * @param entry defines the element to remove
  39563. */
  39564. removeMesh(entry: T): void;
  39565. /**
  39566. * Selects an array of meshes within the frustum
  39567. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39568. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39569. * @returns array of meshes within the frustum
  39570. */
  39571. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39572. /**
  39573. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39574. * @param sphereCenter defines the bounding sphere center
  39575. * @param sphereRadius defines the bounding sphere radius
  39576. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39577. * @returns an array of objects that intersect the sphere
  39578. */
  39579. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39580. /**
  39581. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39582. * @param ray defines the ray to test with
  39583. * @returns array of intersected objects
  39584. */
  39585. intersectsRay(ray: Ray): SmartArray<T>;
  39586. /**
  39587. * Adds a mesh into the octree block if it intersects the block
  39588. */
  39589. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39590. /**
  39591. * Adds a submesh into the octree block if it intersects the block
  39592. */
  39593. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39594. }
  39595. }
  39596. declare module BABYLON {
  39597. interface Scene {
  39598. /**
  39599. * @hidden
  39600. * Backing Filed
  39601. */ selectionOctree: Octree<AbstractMesh>;
  39602. /**
  39603. * Gets the octree used to boost mesh selection (picking)
  39604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39605. */
  39606. selectionOctree: Octree<AbstractMesh>;
  39607. /**
  39608. * Creates or updates the octree used to boost selection (picking)
  39609. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39610. * @param maxCapacity defines the maximum capacity per leaf
  39611. * @param maxDepth defines the maximum depth of the octree
  39612. * @returns an octree of AbstractMesh
  39613. */
  39614. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39615. }
  39616. interface AbstractMesh {
  39617. /**
  39618. * @hidden
  39619. * Backing Field
  39620. */ submeshesOctree: Octree<SubMesh>;
  39621. /**
  39622. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39623. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39624. * @param maxCapacity defines the maximum size of each block (64 by default)
  39625. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39626. * @returns the new octree
  39627. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39628. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39629. */
  39630. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39631. }
  39632. /**
  39633. * Defines the octree scene component responsible to manage any octrees
  39634. * in a given scene.
  39635. */
  39636. export class OctreeSceneComponent {
  39637. /**
  39638. * The component name helpfull to identify the component in the list of scene components.
  39639. */
  39640. readonly name: string;
  39641. /**
  39642. * The scene the component belongs to.
  39643. */
  39644. scene: Scene;
  39645. /**
  39646. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39647. */
  39648. readonly checksIsEnabled: boolean;
  39649. /**
  39650. * Creates a new instance of the component for the given scene
  39651. * @param scene Defines the scene to register the component in
  39652. */
  39653. constructor(scene: Scene);
  39654. /**
  39655. * Registers the component in a given scene
  39656. */
  39657. register(): void;
  39658. /**
  39659. * Return the list of active meshes
  39660. * @returns the list of active meshes
  39661. */
  39662. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39663. /**
  39664. * Return the list of active sub meshes
  39665. * @param mesh The mesh to get the candidates sub meshes from
  39666. * @returns the list of active sub meshes
  39667. */
  39668. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39669. private _tempRay;
  39670. /**
  39671. * Return the list of sub meshes intersecting with a given local ray
  39672. * @param mesh defines the mesh to find the submesh for
  39673. * @param localRay defines the ray in local space
  39674. * @returns the list of intersecting sub meshes
  39675. */
  39676. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39677. /**
  39678. * Return the list of sub meshes colliding with a collider
  39679. * @param mesh defines the mesh to find the submesh for
  39680. * @param collider defines the collider to evaluate the collision against
  39681. * @returns the list of colliding sub meshes
  39682. */
  39683. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39684. /**
  39685. * Rebuilds the elements related to this component in case of
  39686. * context lost for instance.
  39687. */
  39688. rebuild(): void;
  39689. /**
  39690. * Disposes the component and the associated ressources.
  39691. */
  39692. dispose(): void;
  39693. }
  39694. }
  39695. declare module BABYLON {
  39696. /**
  39697. * Renders a layer on top of an existing scene
  39698. */
  39699. export class UtilityLayerRenderer implements IDisposable {
  39700. /** the original scene that will be rendered on top of */
  39701. originalScene: Scene;
  39702. private _pointerCaptures;
  39703. private _lastPointerEvents;
  39704. private static _DefaultUtilityLayer;
  39705. private static _DefaultKeepDepthUtilityLayer;
  39706. private _sharedGizmoLight;
  39707. /**
  39708. * @hidden
  39709. * Light which used by gizmos to get light shading
  39710. */ getSharedGizmoLight(): HemisphericLight;
  39711. /**
  39712. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39713. */
  39714. pickUtilitySceneFirst: boolean;
  39715. /**
  39716. * 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)
  39717. */
  39718. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39719. /**
  39720. * 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)
  39721. */
  39722. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39723. /**
  39724. * The scene that is rendered on top of the original scene
  39725. */
  39726. utilityLayerScene: Scene;
  39727. /**
  39728. * If the utility layer should automatically be rendered on top of existing scene
  39729. */
  39730. shouldRender: boolean;
  39731. /**
  39732. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39733. */
  39734. onlyCheckPointerDownEvents: boolean;
  39735. /**
  39736. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39737. */
  39738. processAllEvents: boolean;
  39739. /**
  39740. * Observable raised when the pointer move from the utility layer scene to the main scene
  39741. */
  39742. onPointerOutObservable: Observable<number>;
  39743. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  39744. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  39745. private _afterRenderObserver;
  39746. private _sceneDisposeObserver;
  39747. private _originalPointerObserver;
  39748. /**
  39749. * Instantiates a UtilityLayerRenderer
  39750. * @param originalScene the original scene that will be rendered on top of
  39751. * @param handleEvents boolean indicating if the utility layer should handle events
  39752. */
  39753. constructor(
  39754. /** the original scene that will be rendered on top of */
  39755. originalScene: Scene, handleEvents?: boolean);
  39756. private _notifyObservers;
  39757. /**
  39758. * Renders the utility layers scene on top of the original scene
  39759. */
  39760. render(): void;
  39761. /**
  39762. * Disposes of the renderer
  39763. */
  39764. dispose(): void;
  39765. private _updateCamera;
  39766. }
  39767. }
  39768. declare module BABYLON {
  39769. /**
  39770. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  39771. */
  39772. export class Gizmo implements IDisposable {
  39773. /** The utility layer the gizmo will be added to */
  39774. gizmoLayer: UtilityLayerRenderer;
  39775. /**
  39776. * The root mesh of the gizmo
  39777. */ rootMesh: Mesh;
  39778. private _attachedMesh;
  39779. /**
  39780. * Ratio for the scale of the gizmo (Default: 1)
  39781. */
  39782. scaleRatio: number;
  39783. private _tmpMatrix;
  39784. /**
  39785. * If a custom mesh has been set (Default: false)
  39786. */
  39787. protected _customMeshSet: boolean;
  39788. /**
  39789. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  39790. * * When set, interactions will be enabled
  39791. */
  39792. attachedMesh: Nullable<AbstractMesh>;
  39793. /**
  39794. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  39795. * @param mesh The mesh to replace the default mesh of the gizmo
  39796. */
  39797. setCustomMesh(mesh: Mesh): void;
  39798. /**
  39799. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  39800. */
  39801. updateGizmoRotationToMatchAttachedMesh: boolean;
  39802. /**
  39803. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  39804. */
  39805. updateGizmoPositionToMatchAttachedMesh: boolean;
  39806. /**
  39807. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  39808. */
  39809. protected _updateScale: boolean;
  39810. protected _interactionsEnabled: boolean;
  39811. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39812. private _beforeRenderObserver;
  39813. /**
  39814. * Creates a gizmo
  39815. * @param gizmoLayer The utility layer the gizmo will be added to
  39816. */
  39817. constructor(
  39818. /** The utility layer the gizmo will be added to */
  39819. gizmoLayer?: UtilityLayerRenderer);
  39820. private _tempVector;
  39821. /**
  39822. * @hidden
  39823. * Updates the gizmo to match the attached mesh's position/rotation
  39824. */
  39825. protected _update(): void;
  39826. /**
  39827. * Disposes of the gizmo
  39828. */
  39829. dispose(): void;
  39830. }
  39831. }
  39832. declare module BABYLON {
  39833. /**
  39834. * Single axis drag gizmo
  39835. */
  39836. export class AxisDragGizmo extends Gizmo {
  39837. /**
  39838. * Drag behavior responsible for the gizmos dragging interactions
  39839. */
  39840. dragBehavior: PointerDragBehavior;
  39841. private _pointerObserver;
  39842. /**
  39843. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39844. */
  39845. snapDistance: number;
  39846. /**
  39847. * Event that fires each time the gizmo snaps to a new location.
  39848. * * snapDistance is the the change in distance
  39849. */
  39850. onSnapObservable: Observable<{
  39851. snapDistance: number;
  39852. }>;
  39853. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  39854. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  39855. /**
  39856. * Creates an AxisDragGizmo
  39857. * @param gizmoLayer The utility layer the gizmo will be added to
  39858. * @param dragAxis The axis which the gizmo will be able to drag on
  39859. * @param color The color of the gizmo
  39860. */
  39861. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  39862. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  39863. /**
  39864. * Disposes of the gizmo
  39865. */
  39866. dispose(): void;
  39867. }
  39868. }
  39869. declare module BABYLON.Debug {
  39870. /**
  39871. * The Axes viewer will show 3 axes in a specific point in space
  39872. */
  39873. export class AxesViewer {
  39874. private _xAxis;
  39875. private _yAxis;
  39876. private _zAxis;
  39877. private _scaleLinesFactor;
  39878. private _instanced;
  39879. /**
  39880. * Gets the hosting scene
  39881. */
  39882. scene: Scene;
  39883. /**
  39884. * Gets or sets a number used to scale line length
  39885. */
  39886. scaleLines: number;
  39887. /** Gets the node hierarchy used to render x-axis */
  39888. readonly xAxis: TransformNode;
  39889. /** Gets the node hierarchy used to render y-axis */
  39890. readonly yAxis: TransformNode;
  39891. /** Gets the node hierarchy used to render z-axis */
  39892. readonly zAxis: TransformNode;
  39893. /**
  39894. * Creates a new AxesViewer
  39895. * @param scene defines the hosting scene
  39896. * @param scaleLines defines a number used to scale line length (1 by default)
  39897. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  39898. * @param xAxis defines the node hierarchy used to render the x-axis
  39899. * @param yAxis defines the node hierarchy used to render the y-axis
  39900. * @param zAxis defines the node hierarchy used to render the z-axis
  39901. */
  39902. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  39903. /**
  39904. * Force the viewer to update
  39905. * @param position defines the position of the viewer
  39906. * @param xaxis defines the x axis of the viewer
  39907. * @param yaxis defines the y axis of the viewer
  39908. * @param zaxis defines the z axis of the viewer
  39909. */
  39910. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  39911. /**
  39912. * Creates an instance of this axes viewer.
  39913. * @returns a new axes viewer with instanced meshes
  39914. */
  39915. createInstance(): AxesViewer;
  39916. /** Releases resources */
  39917. dispose(): void;
  39918. private static _SetRenderingGroupId;
  39919. }
  39920. }
  39921. declare module BABYLON.Debug {
  39922. /**
  39923. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  39924. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  39925. */
  39926. export class BoneAxesViewer extends AxesViewer {
  39927. /**
  39928. * Gets or sets the target mesh where to display the axes viewer
  39929. */
  39930. mesh: Nullable<Mesh>;
  39931. /**
  39932. * Gets or sets the target bone where to display the axes viewer
  39933. */
  39934. bone: Nullable<Bone>;
  39935. /** Gets current position */
  39936. pos: Vector3;
  39937. /** Gets direction of X axis */
  39938. xaxis: Vector3;
  39939. /** Gets direction of Y axis */
  39940. yaxis: Vector3;
  39941. /** Gets direction of Z axis */
  39942. zaxis: Vector3;
  39943. /**
  39944. * Creates a new BoneAxesViewer
  39945. * @param scene defines the hosting scene
  39946. * @param bone defines the target bone
  39947. * @param mesh defines the target mesh
  39948. * @param scaleLines defines a scaling factor for line length (1 by default)
  39949. */
  39950. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  39951. /**
  39952. * Force the viewer to update
  39953. */
  39954. update(): void;
  39955. /** Releases resources */
  39956. dispose(): void;
  39957. }
  39958. }
  39959. declare module BABYLON {
  39960. /**
  39961. * Interface used to define scene explorer extensibility option
  39962. */
  39963. export interface IExplorerExtensibilityOption {
  39964. /**
  39965. * Define the option label
  39966. */
  39967. label: string;
  39968. /**
  39969. * Defines the action to execute on click
  39970. */
  39971. action: (entity: any) => void;
  39972. }
  39973. /**
  39974. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  39975. */
  39976. export interface IExplorerExtensibilityGroup {
  39977. /**
  39978. * Defines a predicate to test if a given type mut be extended
  39979. */
  39980. predicate: (entity: any) => boolean;
  39981. /**
  39982. * Gets the list of options added to a type
  39983. */
  39984. entries: IExplorerExtensibilityOption[];
  39985. }
  39986. /**
  39987. * Interface used to define the options to use to create the Inspector
  39988. */
  39989. export interface IInspectorOptions {
  39990. /**
  39991. * Display in overlay mode (default: false)
  39992. */
  39993. overlay?: boolean;
  39994. /**
  39995. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  39996. */
  39997. globalRoot?: HTMLElement;
  39998. /**
  39999. * Display the Scene explorer
  40000. */
  40001. showExplorer?: boolean;
  40002. /**
  40003. * Display the property inspector
  40004. */
  40005. showInspector?: boolean;
  40006. /**
  40007. * Display in embed mode (both panes on the right)
  40008. */
  40009. embedMode?: boolean;
  40010. /**
  40011. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40012. */
  40013. handleResize?: boolean;
  40014. /**
  40015. * Allow the panes to popup (default: true)
  40016. */
  40017. enablePopup?: boolean;
  40018. /**
  40019. * Allow the panes to be closed by users (default: true)
  40020. */
  40021. enableClose?: boolean;
  40022. /**
  40023. * Optional list of extensibility entries
  40024. */
  40025. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40026. /**
  40027. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40028. */
  40029. inspectorURL?: string;
  40030. }
  40031. interface Scene {
  40032. /**
  40033. * @hidden
  40034. * Backing field
  40035. */ debugLayer: DebugLayer;
  40036. /**
  40037. * Gets the debug layer (aka Inspector) associated with the scene
  40038. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40039. */
  40040. debugLayer: DebugLayer;
  40041. }
  40042. /**
  40043. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40044. * what is happening in your scene
  40045. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40046. */
  40047. export class DebugLayer {
  40048. /**
  40049. * Define the url to get the inspector script from.
  40050. * By default it uses the babylonjs CDN.
  40051. * @ignoreNaming
  40052. */
  40053. static InspectorURL: string;
  40054. private _scene;
  40055. private BJSINSPECTOR;
  40056. /**
  40057. * Observable triggered when a property is changed through the inspector.
  40058. */
  40059. onPropertyChangedObservable: Observable<{
  40060. object: any;
  40061. property: string;
  40062. value: any;
  40063. initialValue: any;
  40064. }>;
  40065. /**
  40066. * Instantiates a new debug layer.
  40067. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40068. * what is happening in your scene
  40069. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40070. * @param scene Defines the scene to inspect
  40071. */
  40072. constructor(scene: Scene);
  40073. /** Creates the inspector window. */
  40074. private _createInspector;
  40075. /**
  40076. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40077. * @param entity defines the entity to select
  40078. * @param lineContainerTitle defines the specific block to highlight
  40079. */
  40080. select(entity: any, lineContainerTitle?: string): void;
  40081. /** Get the inspector from bundle or global */
  40082. private _getGlobalInspector;
  40083. /**
  40084. * Get if the inspector is visible or not.
  40085. * @returns true if visible otherwise, false
  40086. */
  40087. isVisible(): boolean;
  40088. /**
  40089. * Hide the inspector and close its window.
  40090. */
  40091. hide(): void;
  40092. /**
  40093. * Launch the debugLayer.
  40094. * @param config Define the configuration of the inspector
  40095. * @return a promise fulfilled when the debug layer is visible
  40096. */
  40097. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40098. }
  40099. }
  40100. declare module BABYLON {
  40101. /**
  40102. * Class containing static functions to help procedurally build meshes
  40103. */
  40104. export class BoxBuilder {
  40105. /**
  40106. * Creates a box mesh
  40107. * * The parameter `size` sets the size (float) of each box side (default 1)
  40108. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40109. * * 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)
  40110. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40112. * * 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
  40113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40114. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40115. * @param name defines the name of the mesh
  40116. * @param options defines the options used to create the mesh
  40117. * @param scene defines the hosting scene
  40118. * @returns the box mesh
  40119. */
  40120. static CreateBox(name: string, options: {
  40121. size?: number;
  40122. width?: number;
  40123. height?: number;
  40124. depth?: number;
  40125. faceUV?: Vector4[];
  40126. faceColors?: Color4[];
  40127. sideOrientation?: number;
  40128. frontUVs?: Vector4;
  40129. backUVs?: Vector4;
  40130. updatable?: boolean;
  40131. }, scene?: Nullable<Scene>): Mesh;
  40132. }
  40133. }
  40134. declare module BABYLON {
  40135. /**
  40136. * Class containing static functions to help procedurally build meshes
  40137. */
  40138. export class SphereBuilder {
  40139. /**
  40140. * Creates a sphere mesh
  40141. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40142. * * 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`)
  40143. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40144. * * 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
  40145. * * 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)
  40146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40147. * * 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
  40148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40149. * @param name defines the name of the mesh
  40150. * @param options defines the options used to create the mesh
  40151. * @param scene defines the hosting scene
  40152. * @returns the sphere mesh
  40153. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40154. */
  40155. static CreateSphere(name: string, options: {
  40156. segments?: number;
  40157. diameter?: number;
  40158. diameterX?: number;
  40159. diameterY?: number;
  40160. diameterZ?: number;
  40161. arc?: number;
  40162. slice?: number;
  40163. sideOrientation?: number;
  40164. frontUVs?: Vector4;
  40165. backUVs?: Vector4;
  40166. updatable?: boolean;
  40167. }, scene: any): Mesh;
  40168. }
  40169. }
  40170. declare module BABYLON.Debug {
  40171. /**
  40172. * Used to show the physics impostor around the specific mesh
  40173. */
  40174. export class PhysicsViewer {
  40175. /** @hidden */
  40176. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40177. /** @hidden */
  40178. protected _meshes: Array<Nullable<AbstractMesh>>;
  40179. /** @hidden */
  40180. protected _scene: Nullable<Scene>;
  40181. /** @hidden */
  40182. protected _numMeshes: number;
  40183. /** @hidden */
  40184. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40185. private _renderFunction;
  40186. private _utilityLayer;
  40187. private _debugBoxMesh;
  40188. private _debugSphereMesh;
  40189. private _debugMaterial;
  40190. private _debugMeshMeshes;
  40191. /**
  40192. * Creates a new PhysicsViewer
  40193. * @param scene defines the hosting scene
  40194. */
  40195. constructor(scene: Scene);
  40196. /** @hidden */
  40197. protected _updateDebugMeshes(): void;
  40198. /**
  40199. * Renders a specified physic impostor
  40200. * @param impostor defines the impostor to render
  40201. * @param targetMesh defines the mesh represented by the impostor
  40202. * @returns the new debug mesh used to render the impostor
  40203. */
  40204. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40205. /**
  40206. * Hides a specified physic impostor
  40207. * @param impostor defines the impostor to hide
  40208. */
  40209. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40210. private _getDebugMaterial;
  40211. private _getDebugBoxMesh;
  40212. private _getDebugSphereMesh;
  40213. private _getDebugMeshMesh;
  40214. private _getDebugMesh;
  40215. /** Releases all resources */
  40216. dispose(): void;
  40217. }
  40218. }
  40219. declare module BABYLON {
  40220. /**
  40221. * Class containing static functions to help procedurally build meshes
  40222. */
  40223. export class LinesBuilder {
  40224. /**
  40225. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40226. * * 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
  40227. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40228. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40229. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40230. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40231. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40232. * * 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
  40233. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40235. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40236. * @param name defines the name of the new line system
  40237. * @param options defines the options used to create the line system
  40238. * @param scene defines the hosting scene
  40239. * @returns a new line system mesh
  40240. */
  40241. static CreateLineSystem(name: string, options: {
  40242. lines: Vector3[][];
  40243. updatable?: boolean;
  40244. instance?: Nullable<LinesMesh>;
  40245. colors?: Nullable<Color4[][]>;
  40246. useVertexAlpha?: boolean;
  40247. }, scene: Nullable<Scene>): LinesMesh;
  40248. /**
  40249. * Creates a line mesh
  40250. * 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
  40251. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40252. * * The parameter `points` is an array successive Vector3
  40253. * * 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
  40254. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40255. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40256. * * When updating an instance, remember that only point positions can change, not the number of points
  40257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40258. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40259. * @param name defines the name of the new line system
  40260. * @param options defines the options used to create the line system
  40261. * @param scene defines the hosting scene
  40262. * @returns a new line mesh
  40263. */
  40264. static CreateLines(name: string, options: {
  40265. points: Vector3[];
  40266. updatable?: boolean;
  40267. instance?: Nullable<LinesMesh>;
  40268. colors?: Color4[];
  40269. useVertexAlpha?: boolean;
  40270. }, scene?: Nullable<Scene>): LinesMesh;
  40271. /**
  40272. * Creates a dashed line mesh
  40273. * * 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
  40274. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40275. * * The parameter `points` is an array successive Vector3
  40276. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40277. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40278. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40279. * * 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
  40280. * * When updating an instance, remember that only point positions can change, not the number of points
  40281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40282. * @param name defines the name of the mesh
  40283. * @param options defines the options used to create the mesh
  40284. * @param scene defines the hosting scene
  40285. * @returns the dashed line mesh
  40286. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40287. */
  40288. static CreateDashedLines(name: string, options: {
  40289. points: Vector3[];
  40290. dashSize?: number;
  40291. gapSize?: number;
  40292. dashNb?: number;
  40293. updatable?: boolean;
  40294. instance?: LinesMesh;
  40295. }, scene?: Nullable<Scene>): LinesMesh;
  40296. }
  40297. }
  40298. declare module BABYLON {
  40299. /**
  40300. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40301. * in order to better appreciate the issue one might have.
  40302. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40303. */
  40304. export class RayHelper {
  40305. /**
  40306. * Defines the ray we are currently tryin to visualize.
  40307. */
  40308. ray: Nullable<Ray>;
  40309. private _renderPoints;
  40310. private _renderLine;
  40311. private _renderFunction;
  40312. private _scene;
  40313. private _updateToMeshFunction;
  40314. private _attachedToMesh;
  40315. private _meshSpaceDirection;
  40316. private _meshSpaceOrigin;
  40317. /**
  40318. * Helper function to create a colored helper in a scene in one line.
  40319. * @param ray Defines the ray we are currently tryin to visualize
  40320. * @param scene Defines the scene the ray is used in
  40321. * @param color Defines the color we want to see the ray in
  40322. * @returns The newly created ray helper.
  40323. */
  40324. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40325. /**
  40326. * Instantiate a new ray helper.
  40327. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40328. * in order to better appreciate the issue one might have.
  40329. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40330. * @param ray Defines the ray we are currently tryin to visualize
  40331. */
  40332. constructor(ray: Ray);
  40333. /**
  40334. * Shows the ray we are willing to debug.
  40335. * @param scene Defines the scene the ray needs to be rendered in
  40336. * @param color Defines the color the ray needs to be rendered in
  40337. */
  40338. show(scene: Scene, color?: Color3): void;
  40339. /**
  40340. * Hides the ray we are debugging.
  40341. */
  40342. hide(): void;
  40343. private _render;
  40344. /**
  40345. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40346. * @param mesh Defines the mesh we want the helper attached to
  40347. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40348. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40349. * @param length Defines the length of the ray
  40350. */
  40351. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40352. /**
  40353. * Detach the ray helper from the mesh it has previously been attached to.
  40354. */
  40355. detachFromMesh(): void;
  40356. private _updateToMesh;
  40357. /**
  40358. * Dispose the helper and release its associated resources.
  40359. */
  40360. dispose(): void;
  40361. }
  40362. }
  40363. declare module BABYLON.Debug {
  40364. /**
  40365. * Class used to render a debug view of a given skeleton
  40366. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40367. */
  40368. export class SkeletonViewer {
  40369. /** defines the skeleton to render */
  40370. skeleton: Skeleton;
  40371. /** defines the mesh attached to the skeleton */
  40372. mesh: AbstractMesh;
  40373. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40374. autoUpdateBonesMatrices: boolean;
  40375. /** defines the rendering group id to use with the viewer */
  40376. renderingGroupId: number;
  40377. /** Gets or sets the color used to render the skeleton */
  40378. color: Color3;
  40379. private _scene;
  40380. private _debugLines;
  40381. private _debugMesh;
  40382. private _isEnabled;
  40383. private _renderFunction;
  40384. private _utilityLayer;
  40385. /**
  40386. * Returns the mesh used to render the bones
  40387. */
  40388. readonly debugMesh: Nullable<LinesMesh>;
  40389. /**
  40390. * Creates a new SkeletonViewer
  40391. * @param skeleton defines the skeleton to render
  40392. * @param mesh defines the mesh attached to the skeleton
  40393. * @param scene defines the hosting scene
  40394. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40395. * @param renderingGroupId defines the rendering group id to use with the viewer
  40396. */
  40397. constructor(
  40398. /** defines the skeleton to render */
  40399. skeleton: Skeleton,
  40400. /** defines the mesh attached to the skeleton */
  40401. mesh: AbstractMesh, scene: Scene,
  40402. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40403. autoUpdateBonesMatrices?: boolean,
  40404. /** defines the rendering group id to use with the viewer */
  40405. renderingGroupId?: number);
  40406. /** Gets or sets a boolean indicating if the viewer is enabled */
  40407. isEnabled: boolean;
  40408. private _getBonePosition;
  40409. private _getLinesForBonesWithLength;
  40410. private _getLinesForBonesNoLength;
  40411. /** Update the viewer to sync with current skeleton state */
  40412. update(): void;
  40413. /** Release associated resources */
  40414. dispose(): void;
  40415. }
  40416. }
  40417. declare module BABYLON {
  40418. /**
  40419. * Options to create the null engine
  40420. */
  40421. export class NullEngineOptions {
  40422. /**
  40423. * Render width (Default: 512)
  40424. */
  40425. renderWidth: number;
  40426. /**
  40427. * Render height (Default: 256)
  40428. */
  40429. renderHeight: number;
  40430. /**
  40431. * Texture size (Default: 512)
  40432. */
  40433. textureSize: number;
  40434. /**
  40435. * If delta time between frames should be constant
  40436. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40437. */
  40438. deterministicLockstep: boolean;
  40439. /**
  40440. * Maximum about of steps between frames (Default: 4)
  40441. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40442. */
  40443. lockstepMaxSteps: number;
  40444. }
  40445. /**
  40446. * The null engine class provides support for headless version of babylon.js.
  40447. * This can be used in server side scenario or for testing purposes
  40448. */
  40449. export class NullEngine extends Engine {
  40450. private _options;
  40451. /**
  40452. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40453. */
  40454. isDeterministicLockStep(): boolean;
  40455. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40456. getLockstepMaxSteps(): number;
  40457. /**
  40458. * Sets hardware scaling, used to save performance if needed
  40459. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40460. */
  40461. getHardwareScalingLevel(): number;
  40462. constructor(options?: NullEngineOptions);
  40463. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40464. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  40465. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40466. getRenderWidth(useScreen?: boolean): number;
  40467. getRenderHeight(useScreen?: boolean): number;
  40468. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40469. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40470. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  40471. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  40472. bindSamplers(effect: Effect): void;
  40473. enableEffect(effect: Effect): void;
  40474. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40475. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40476. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40477. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40478. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40479. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40480. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40481. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40482. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40483. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40484. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40485. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40486. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40487. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40488. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40489. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40490. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40491. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40492. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40493. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40494. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40495. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40496. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40497. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40498. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40499. bindBuffers(vertexBuffers: {
  40500. [key: string]: VertexBuffer;
  40501. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  40502. wipeCaches(bruteForce?: boolean): void;
  40503. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40504. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40505. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40506. /** @hidden */ createTexture(): WebGLTexture;
  40507. /** @hidden */ releaseTexture(texture: InternalTexture): void;
  40508. 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;
  40509. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40510. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40511. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40512. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40513. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  40514. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40515. areAllEffectsReady(): boolean;
  40516. /**
  40517. * @hidden
  40518. * Get the current error code of the webGL context
  40519. * @returns the error code
  40520. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40521. */
  40522. getError(): number;
  40523. /** @hidden */ getUnpackAlignement(): number;
  40524. /** @hidden */ unpackFlipY(value: boolean): void;
  40525. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40526. /**
  40527. * Updates a dynamic vertex buffer.
  40528. * @param vertexBuffer the vertex buffer to update
  40529. * @param data the data used to update the vertex buffer
  40530. * @param byteOffset the byte offset of the data (optional)
  40531. * @param byteLength the byte length of the data (optional)
  40532. */
  40533. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40534. /** @hidden */ bindTexture(channel: number, texture: InternalTexture): void;
  40535. /** @hidden */ releaseBuffer(buffer: WebGLBuffer): boolean;
  40536. releaseEffects(): void;
  40537. displayLoadingUI(): void;
  40538. hideLoadingUI(): void;
  40539. /** @hidden */ uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40540. /** @hidden */ uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40541. /** @hidden */ uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40542. /** @hidden */ uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40543. }
  40544. }
  40545. declare module BABYLON {
  40546. /** @hidden */
  40547. export class _OcclusionDataStorage {
  40548. /** @hidden */
  40549. occlusionInternalRetryCounter: number;
  40550. /** @hidden */
  40551. isOcclusionQueryInProgress: boolean;
  40552. /** @hidden */
  40553. isOccluded: boolean;
  40554. /** @hidden */
  40555. occlusionRetryCount: number;
  40556. /** @hidden */
  40557. occlusionType: number;
  40558. /** @hidden */
  40559. occlusionQueryAlgorithmType: number;
  40560. }
  40561. interface Engine {
  40562. /**
  40563. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40564. * @return the new query
  40565. */
  40566. createQuery(): WebGLQuery;
  40567. /**
  40568. * Delete and release a webGL query
  40569. * @param query defines the query to delete
  40570. * @return the current engine
  40571. */
  40572. deleteQuery(query: WebGLQuery): Engine;
  40573. /**
  40574. * Check if a given query has resolved and got its value
  40575. * @param query defines the query to check
  40576. * @returns true if the query got its value
  40577. */
  40578. isQueryResultAvailable(query: WebGLQuery): boolean;
  40579. /**
  40580. * Gets the value of a given query
  40581. * @param query defines the query to check
  40582. * @returns the value of the query
  40583. */
  40584. getQueryResult(query: WebGLQuery): number;
  40585. /**
  40586. * Initiates an occlusion query
  40587. * @param algorithmType defines the algorithm to use
  40588. * @param query defines the query to use
  40589. * @returns the current engine
  40590. * @see http://doc.babylonjs.com/features/occlusionquery
  40591. */
  40592. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40593. /**
  40594. * Ends an occlusion query
  40595. * @see http://doc.babylonjs.com/features/occlusionquery
  40596. * @param algorithmType defines the algorithm to use
  40597. * @returns the current engine
  40598. */
  40599. endOcclusionQuery(algorithmType: number): Engine;
  40600. /**
  40601. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40602. * Please note that only one query can be issued at a time
  40603. * @returns a time token used to track the time span
  40604. */
  40605. startTimeQuery(): Nullable<_TimeToken>;
  40606. /**
  40607. * Ends a time query
  40608. * @param token defines the token used to measure the time span
  40609. * @returns the time spent (in ns)
  40610. */
  40611. endTimeQuery(token: _TimeToken): int;
  40612. /** @hidden */ currentNonTimestampToken: Nullable<_TimeToken>;
  40613. /** @hidden */ createTimeQuery(): WebGLQuery;
  40614. /** @hidden */ deleteTimeQuery(query: WebGLQuery): void;
  40615. /** @hidden */ getGlAlgorithmType(algorithmType: number): number;
  40616. /** @hidden */ getTimeQueryResult(query: WebGLQuery): any;
  40617. /** @hidden */ getTimeQueryAvailability(query: WebGLQuery): any;
  40618. }
  40619. interface AbstractMesh {
  40620. /**
  40621. * Backing filed
  40622. * @hidden
  40623. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40624. /**
  40625. * Access property
  40626. * @hidden
  40627. */ occlusionDataStorage: _OcclusionDataStorage;
  40628. /**
  40629. * 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.
  40630. * The default value is -1 which means don't break the query and wait till the result
  40631. * @see http://doc.babylonjs.com/features/occlusionquery
  40632. */
  40633. occlusionRetryCount: number;
  40634. /**
  40635. * 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:
  40636. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40637. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40638. * * 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.
  40639. * @see http://doc.babylonjs.com/features/occlusionquery
  40640. */
  40641. occlusionType: number;
  40642. /**
  40643. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40644. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40645. * * 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.
  40646. * @see http://doc.babylonjs.com/features/occlusionquery
  40647. */
  40648. occlusionQueryAlgorithmType: number;
  40649. /**
  40650. * 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
  40651. * @see http://doc.babylonjs.com/features/occlusionquery
  40652. */
  40653. isOccluded: boolean;
  40654. /**
  40655. * Flag to check the progress status of the query
  40656. * @see http://doc.babylonjs.com/features/occlusionquery
  40657. */
  40658. isOcclusionQueryInProgress: boolean;
  40659. }
  40660. }
  40661. declare module BABYLON {
  40662. /** @hidden */
  40663. export var _forceTransformFeedbackToBundle: boolean;
  40664. interface Engine {
  40665. /**
  40666. * Creates a webGL transform feedback object
  40667. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40668. * @returns the webGL transform feedback object
  40669. */
  40670. createTransformFeedback(): WebGLTransformFeedback;
  40671. /**
  40672. * Delete a webGL transform feedback object
  40673. * @param value defines the webGL transform feedback object to delete
  40674. */
  40675. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40676. /**
  40677. * Bind a webGL transform feedback object to the webgl context
  40678. * @param value defines the webGL transform feedback object to bind
  40679. */
  40680. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40681. /**
  40682. * Begins a transform feedback operation
  40683. * @param usePoints defines if points or triangles must be used
  40684. */
  40685. beginTransformFeedback(usePoints: boolean): void;
  40686. /**
  40687. * Ends a transform feedback operation
  40688. */
  40689. endTransformFeedback(): void;
  40690. /**
  40691. * Specify the varyings to use with transform feedback
  40692. * @param program defines the associated webGL program
  40693. * @param value defines the list of strings representing the varying names
  40694. */
  40695. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40696. /**
  40697. * Bind a webGL buffer for a transform feedback operation
  40698. * @param value defines the webGL buffer to bind
  40699. */
  40700. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  40701. }
  40702. }
  40703. declare module BABYLON {
  40704. /**
  40705. * Gather the list of clipboard event types as constants.
  40706. */
  40707. export class ClipboardEventTypes {
  40708. /**
  40709. * The clipboard event is fired when a copy command is active (pressed).
  40710. */
  40711. static readonly COPY: number;
  40712. /**
  40713. * The clipboard event is fired when a cut command is active (pressed).
  40714. */
  40715. static readonly CUT: number;
  40716. /**
  40717. * The clipboard event is fired when a paste command is active (pressed).
  40718. */
  40719. static readonly PASTE: number;
  40720. }
  40721. /**
  40722. * This class is used to store clipboard related info for the onClipboardObservable event.
  40723. */
  40724. export class ClipboardInfo {
  40725. /**
  40726. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40727. */
  40728. type: number;
  40729. /**
  40730. * Defines the related dom event
  40731. */
  40732. event: ClipboardEvent;
  40733. /**
  40734. *Creates an instance of ClipboardInfo.
  40735. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  40736. * @param event Defines the related dom event
  40737. */
  40738. constructor(
  40739. /**
  40740. * Defines the type of event (BABYLON.ClipboardEventTypes)
  40741. */
  40742. type: number,
  40743. /**
  40744. * Defines the related dom event
  40745. */
  40746. event: ClipboardEvent);
  40747. /**
  40748. * Get the clipboard event's type from the keycode.
  40749. * @param keyCode Defines the keyCode for the current keyboard event.
  40750. * @return {number}
  40751. */
  40752. static GetTypeFromCharacter(keyCode: number): number;
  40753. }
  40754. }
  40755. declare module BABYLON {
  40756. /**
  40757. * Class used to represent data loading progression
  40758. */
  40759. export class SceneLoaderProgressEvent {
  40760. /** defines if data length to load can be evaluated */
  40761. readonly lengthComputable: boolean;
  40762. /** defines the loaded data length */
  40763. readonly loaded: number;
  40764. /** defines the data length to load */
  40765. readonly total: number;
  40766. /**
  40767. * Create a new progress event
  40768. * @param lengthComputable defines if data length to load can be evaluated
  40769. * @param loaded defines the loaded data length
  40770. * @param total defines the data length to load
  40771. */
  40772. constructor(
  40773. /** defines if data length to load can be evaluated */
  40774. lengthComputable: boolean,
  40775. /** defines the loaded data length */
  40776. loaded: number,
  40777. /** defines the data length to load */
  40778. total: number);
  40779. /**
  40780. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40781. * @param event defines the source event
  40782. * @returns a new SceneLoaderProgressEvent
  40783. */
  40784. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40785. }
  40786. /**
  40787. * Interface used by SceneLoader plugins to define supported file extensions
  40788. */
  40789. export interface ISceneLoaderPluginExtensions {
  40790. /**
  40791. * Defines the list of supported extensions
  40792. */
  40793. [extension: string]: {
  40794. isBinary: boolean;
  40795. };
  40796. }
  40797. /**
  40798. * Interface used by SceneLoader plugin factory
  40799. */
  40800. export interface ISceneLoaderPluginFactory {
  40801. /**
  40802. * Defines the name of the factory
  40803. */
  40804. name: string;
  40805. /**
  40806. * Function called to create a new plugin
  40807. * @return the new plugin
  40808. */
  40809. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40810. /**
  40811. * Boolean indicating if the plugin can direct load specific data
  40812. */
  40813. canDirectLoad?: (data: string) => boolean;
  40814. }
  40815. /**
  40816. * Interface used to define a SceneLoader plugin
  40817. */
  40818. export interface ISceneLoaderPlugin {
  40819. /**
  40820. * The friendly name of this plugin.
  40821. */
  40822. name: string;
  40823. /**
  40824. * The file extensions supported by this plugin.
  40825. */
  40826. extensions: string | ISceneLoaderPluginExtensions;
  40827. /**
  40828. * Import meshes into a scene.
  40829. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40830. * @param scene The scene to import into
  40831. * @param data The data to import
  40832. * @param rootUrl The root url for scene and resources
  40833. * @param meshes The meshes array to import into
  40834. * @param particleSystems The particle systems array to import into
  40835. * @param skeletons The skeletons array to import into
  40836. * @param onError The callback when import fails
  40837. * @returns True if successful or false otherwise
  40838. */
  40839. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40840. /**
  40841. * Load into a scene.
  40842. * @param scene The scene to load into
  40843. * @param data The data to import
  40844. * @param rootUrl The root url for scene and resources
  40845. * @param onError The callback when import fails
  40846. * @returns true if successful or false otherwise
  40847. */
  40848. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40849. /**
  40850. * The callback that returns true if the data can be directly loaded.
  40851. */
  40852. canDirectLoad?: (data: string) => boolean;
  40853. /**
  40854. * The callback that allows custom handling of the root url based on the response url.
  40855. */
  40856. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40857. /**
  40858. * Load into an asset container.
  40859. * @param scene The scene to load into
  40860. * @param data The data to import
  40861. * @param rootUrl The root url for scene and resources
  40862. * @param onError The callback when import fails
  40863. * @returns The loaded asset container
  40864. */
  40865. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40866. }
  40867. /**
  40868. * Interface used to define an async SceneLoader plugin
  40869. */
  40870. export interface ISceneLoaderPluginAsync {
  40871. /**
  40872. * The friendly name of this plugin.
  40873. */
  40874. name: string;
  40875. /**
  40876. * The file extensions supported by this plugin.
  40877. */
  40878. extensions: string | ISceneLoaderPluginExtensions;
  40879. /**
  40880. * Import meshes into a scene.
  40881. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40882. * @param scene The scene to import into
  40883. * @param data The data to import
  40884. * @param rootUrl The root url for scene and resources
  40885. * @param onProgress The callback when the load progresses
  40886. * @param fileName Defines the name of the file to load
  40887. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40888. */
  40889. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40890. meshes: AbstractMesh[];
  40891. particleSystems: IParticleSystem[];
  40892. skeletons: Skeleton[];
  40893. animationGroups: AnimationGroup[];
  40894. }>;
  40895. /**
  40896. * Load into a scene.
  40897. * @param scene The scene to load into
  40898. * @param data The data to import
  40899. * @param rootUrl The root url for scene and resources
  40900. * @param onProgress The callback when the load progresses
  40901. * @param fileName Defines the name of the file to load
  40902. * @returns Nothing
  40903. */
  40904. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40905. /**
  40906. * The callback that returns true if the data can be directly loaded.
  40907. */
  40908. canDirectLoad?: (data: string) => boolean;
  40909. /**
  40910. * The callback that allows custom handling of the root url based on the response url.
  40911. */
  40912. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40913. /**
  40914. * Load into an asset container.
  40915. * @param scene The scene to load into
  40916. * @param data The data to import
  40917. * @param rootUrl The root url for scene and resources
  40918. * @param onProgress The callback when the load progresses
  40919. * @param fileName Defines the name of the file to load
  40920. * @returns The loaded asset container
  40921. */
  40922. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40923. }
  40924. /**
  40925. * Class used to load scene from various file formats using registered plugins
  40926. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40927. */
  40928. export class SceneLoader {
  40929. /**
  40930. * No logging while loading
  40931. */
  40932. static readonly NO_LOGGING: number;
  40933. /**
  40934. * Minimal logging while loading
  40935. */
  40936. static readonly MINIMAL_LOGGING: number;
  40937. /**
  40938. * Summary logging while loading
  40939. */
  40940. static readonly SUMMARY_LOGGING: number;
  40941. /**
  40942. * Detailled logging while loading
  40943. */
  40944. static readonly DETAILED_LOGGING: number;
  40945. /**
  40946. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  40947. */
  40948. static ForceFullSceneLoadingForIncremental: boolean;
  40949. /**
  40950. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  40951. */
  40952. static ShowLoadingScreen: boolean;
  40953. /**
  40954. * Defines the current logging level (while loading the scene)
  40955. * @ignorenaming
  40956. */
  40957. static loggingLevel: number;
  40958. /**
  40959. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  40960. */
  40961. static CleanBoneMatrixWeights: boolean;
  40962. /**
  40963. * Event raised when a plugin is used to load a scene
  40964. */
  40965. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  40966. private static _registeredPlugins;
  40967. private static _getDefaultPlugin;
  40968. private static _getPluginForExtension;
  40969. private static _getPluginForDirectLoad;
  40970. private static _getPluginForFilename;
  40971. private static _getDirectLoad;
  40972. private static _loadData;
  40973. private static _getFileInfo;
  40974. /**
  40975. * Gets a plugin that can load the given extension
  40976. * @param extension defines the extension to load
  40977. * @returns a plugin or null if none works
  40978. */
  40979. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  40980. /**
  40981. * Gets a boolean indicating that the given extension can be loaded
  40982. * @param extension defines the extension to load
  40983. * @returns true if the extension is supported
  40984. */
  40985. static IsPluginForExtensionAvailable(extension: string): boolean;
  40986. /**
  40987. * Adds a new plugin to the list of registered plugins
  40988. * @param plugin defines the plugin to add
  40989. */
  40990. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  40991. /**
  40992. * Import meshes into a scene
  40993. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40994. * @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)
  40995. * @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)
  40996. * @param scene the instance of BABYLON.Scene to append to
  40997. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  40998. * @param onProgress a callback with a progress event for each file being loaded
  40999. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41000. * @param pluginExtension the extension used to determine the plugin
  41001. * @returns The loaded plugin
  41002. */
  41003. 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>;
  41004. /**
  41005. * Import meshes into a scene
  41006. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41007. * @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)
  41008. * @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)
  41009. * @param scene the instance of BABYLON.Scene to append to
  41010. * @param onProgress a callback with a progress event for each file being loaded
  41011. * @param pluginExtension the extension used to determine the plugin
  41012. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41013. */
  41014. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41015. meshes: AbstractMesh[];
  41016. particleSystems: IParticleSystem[];
  41017. skeletons: Skeleton[];
  41018. animationGroups: AnimationGroup[];
  41019. }>;
  41020. /**
  41021. * Load a scene
  41022. * @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)
  41023. * @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)
  41024. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41025. * @param onSuccess a callback with the scene when import succeeds
  41026. * @param onProgress a callback with a progress event for each file being loaded
  41027. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41028. * @param pluginExtension the extension used to determine the plugin
  41029. * @returns The loaded plugin
  41030. */
  41031. 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>;
  41032. /**
  41033. * Load a scene
  41034. * @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)
  41035. * @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)
  41036. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41037. * @param onProgress a callback with a progress event for each file being loaded
  41038. * @param pluginExtension the extension used to determine the plugin
  41039. * @returns The loaded scene
  41040. */
  41041. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41042. /**
  41043. * Append a scene
  41044. * @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)
  41045. * @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)
  41046. * @param scene is the instance of BABYLON.Scene to append to
  41047. * @param onSuccess a callback with the scene when import succeeds
  41048. * @param onProgress a callback with a progress event for each file being loaded
  41049. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41050. * @param pluginExtension the extension used to determine the plugin
  41051. * @returns The loaded plugin
  41052. */
  41053. 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>;
  41054. /**
  41055. * Append a scene
  41056. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  41057. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  41058. * @param scene is the instance of BABYLON.Scene to append to
  41059. * @param onProgress a callback with a progress event for each file being loaded
  41060. * @param pluginExtension the extension used to determine the plugin
  41061. * @returns The given scene
  41062. */
  41063. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41064. /**
  41065. * Load a scene into an asset container
  41066. * @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)
  41067. * @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)
  41068. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41069. * @param onSuccess a callback with the scene when import succeeds
  41070. * @param onProgress a callback with a progress event for each file being loaded
  41071. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41072. * @param pluginExtension the extension used to determine the plugin
  41073. * @returns The loaded plugin
  41074. */
  41075. 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>;
  41076. /**
  41077. * Load a scene into an asset container
  41078. * @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)
  41079. * @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)
  41080. * @param scene is the instance of Scene to append to
  41081. * @param onProgress a callback with a progress event for each file being loaded
  41082. * @param pluginExtension the extension used to determine the plugin
  41083. * @returns The loaded asset container
  41084. */
  41085. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41086. }
  41087. }
  41088. declare module BABYLON {
  41089. /**
  41090. * Google Daydream controller
  41091. */
  41092. export class DaydreamController extends WebVRController {
  41093. /**
  41094. * Base Url for the controller model.
  41095. */
  41096. static MODEL_BASE_URL: string;
  41097. /**
  41098. * File name for the controller model.
  41099. */
  41100. static MODEL_FILENAME: string;
  41101. /**
  41102. * Gamepad Id prefix used to identify Daydream Controller.
  41103. */
  41104. static readonly GAMEPAD_ID_PREFIX: string;
  41105. /**
  41106. * Creates a new DaydreamController from a gamepad
  41107. * @param vrGamepad the gamepad that the controller should be created from
  41108. */
  41109. constructor(vrGamepad: any);
  41110. /**
  41111. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41112. * @param scene scene in which to add meshes
  41113. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41114. */
  41115. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41116. /**
  41117. * Called once for each button that changed state since the last frame
  41118. * @param buttonIdx Which button index changed
  41119. * @param state New state of the button
  41120. * @param changes Which properties on the state changed since last frame
  41121. */
  41122. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41123. }
  41124. }
  41125. declare module BABYLON {
  41126. /**
  41127. * Gear VR Controller
  41128. */
  41129. export class GearVRController extends WebVRController {
  41130. /**
  41131. * Base Url for the controller model.
  41132. */
  41133. static MODEL_BASE_URL: string;
  41134. /**
  41135. * File name for the controller model.
  41136. */
  41137. static MODEL_FILENAME: string;
  41138. /**
  41139. * Gamepad Id prefix used to identify this controller.
  41140. */
  41141. static readonly GAMEPAD_ID_PREFIX: string;
  41142. private readonly _buttonIndexToObservableNameMap;
  41143. /**
  41144. * Creates a new GearVRController from a gamepad
  41145. * @param vrGamepad the gamepad that the controller should be created from
  41146. */
  41147. constructor(vrGamepad: any);
  41148. /**
  41149. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41150. * @param scene scene in which to add meshes
  41151. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41152. */
  41153. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41154. /**
  41155. * Called once for each button that changed state since the last frame
  41156. * @param buttonIdx Which button index changed
  41157. * @param state New state of the button
  41158. * @param changes Which properties on the state changed since last frame
  41159. */
  41160. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41161. }
  41162. }
  41163. declare module BABYLON {
  41164. /**
  41165. * Generic Controller
  41166. */
  41167. export class GenericController extends WebVRController {
  41168. /**
  41169. * Base Url for the controller model.
  41170. */
  41171. static readonly MODEL_BASE_URL: string;
  41172. /**
  41173. * File name for the controller model.
  41174. */
  41175. static readonly MODEL_FILENAME: string;
  41176. /**
  41177. * Creates a new GenericController from a gamepad
  41178. * @param vrGamepad the gamepad that the controller should be created from
  41179. */
  41180. constructor(vrGamepad: any);
  41181. /**
  41182. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41183. * @param scene scene in which to add meshes
  41184. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41185. */
  41186. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41187. /**
  41188. * Called once for each button that changed state since the last frame
  41189. * @param buttonIdx Which button index changed
  41190. * @param state New state of the button
  41191. * @param changes Which properties on the state changed since last frame
  41192. */
  41193. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41194. }
  41195. }
  41196. declare module BABYLON {
  41197. /**
  41198. * Oculus Touch Controller
  41199. */
  41200. export class OculusTouchController extends WebVRController {
  41201. /**
  41202. * Base Url for the controller model.
  41203. */
  41204. static MODEL_BASE_URL: string;
  41205. /**
  41206. * File name for the left controller model.
  41207. */
  41208. static MODEL_LEFT_FILENAME: string;
  41209. /**
  41210. * File name for the right controller model.
  41211. */
  41212. static MODEL_RIGHT_FILENAME: string;
  41213. /**
  41214. * Fired when the secondary trigger on this controller is modified
  41215. */
  41216. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41217. /**
  41218. * Fired when the thumb rest on this controller is modified
  41219. */
  41220. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41221. /**
  41222. * Creates a new OculusTouchController from a gamepad
  41223. * @param vrGamepad the gamepad that the controller should be created from
  41224. */
  41225. constructor(vrGamepad: any);
  41226. /**
  41227. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41228. * @param scene scene in which to add meshes
  41229. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41230. */
  41231. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41232. /**
  41233. * Fired when the A button on this controller is modified
  41234. */
  41235. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41236. /**
  41237. * Fired when the B button on this controller is modified
  41238. */
  41239. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41240. /**
  41241. * Fired when the X button on this controller is modified
  41242. */
  41243. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41244. /**
  41245. * Fired when the Y button on this controller is modified
  41246. */
  41247. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41248. /**
  41249. * Called once for each button that changed state since the last frame
  41250. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41251. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41252. * 2) secondary trigger (same)
  41253. * 3) A (right) X (left), touch, pressed = value
  41254. * 4) B / Y
  41255. * 5) thumb rest
  41256. * @param buttonIdx Which button index changed
  41257. * @param state New state of the button
  41258. * @param changes Which properties on the state changed since last frame
  41259. */
  41260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41261. }
  41262. }
  41263. declare module BABYLON {
  41264. /**
  41265. * Vive Controller
  41266. */
  41267. export class ViveController extends WebVRController {
  41268. /**
  41269. * Base Url for the controller model.
  41270. */
  41271. static MODEL_BASE_URL: string;
  41272. /**
  41273. * File name for the controller model.
  41274. */
  41275. static MODEL_FILENAME: string;
  41276. /**
  41277. * Creates a new ViveController from a gamepad
  41278. * @param vrGamepad the gamepad that the controller should be created from
  41279. */
  41280. constructor(vrGamepad: any);
  41281. /**
  41282. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41283. * @param scene scene in which to add meshes
  41284. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41285. */
  41286. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41287. /**
  41288. * Fired when the left button on this controller is modified
  41289. */
  41290. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41291. /**
  41292. * Fired when the right button on this controller is modified
  41293. */
  41294. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41295. /**
  41296. * Fired when the menu button on this controller is modified
  41297. */
  41298. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41299. /**
  41300. * Called once for each button that changed state since the last frame
  41301. * Vive mapping:
  41302. * 0: touchpad
  41303. * 1: trigger
  41304. * 2: left AND right buttons
  41305. * 3: menu button
  41306. * @param buttonIdx Which button index changed
  41307. * @param state New state of the button
  41308. * @param changes Which properties on the state changed since last frame
  41309. */
  41310. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41311. }
  41312. }
  41313. declare module BABYLON {
  41314. /**
  41315. * Defines the WindowsMotionController object that the state of the windows motion controller
  41316. */
  41317. export class WindowsMotionController extends WebVRController {
  41318. /**
  41319. * The base url used to load the left and right controller models
  41320. */
  41321. static MODEL_BASE_URL: string;
  41322. /**
  41323. * The name of the left controller model file
  41324. */
  41325. static MODEL_LEFT_FILENAME: string;
  41326. /**
  41327. * The name of the right controller model file
  41328. */
  41329. static MODEL_RIGHT_FILENAME: string;
  41330. /**
  41331. * The controller name prefix for this controller type
  41332. */
  41333. static readonly GAMEPAD_ID_PREFIX: string;
  41334. /**
  41335. * The controller id pattern for this controller type
  41336. */
  41337. private static readonly GAMEPAD_ID_PATTERN;
  41338. private _loadedMeshInfo;
  41339. private readonly _mapping;
  41340. /**
  41341. * Fired when the trackpad on this controller is clicked
  41342. */
  41343. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41344. /**
  41345. * Fired when the trackpad on this controller is modified
  41346. */
  41347. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41348. /**
  41349. * The current x and y values of this controller's trackpad
  41350. */
  41351. trackpad: StickValues;
  41352. /**
  41353. * Creates a new WindowsMotionController from a gamepad
  41354. * @param vrGamepad the gamepad that the controller should be created from
  41355. */
  41356. constructor(vrGamepad: any);
  41357. /**
  41358. * Fired when the trigger on this controller is modified
  41359. */
  41360. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41361. /**
  41362. * Fired when the menu button on this controller is modified
  41363. */
  41364. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41365. /**
  41366. * Fired when the grip button on this controller is modified
  41367. */
  41368. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41369. /**
  41370. * Fired when the thumbstick button on this controller is modified
  41371. */
  41372. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41373. /**
  41374. * Fired when the touchpad button on this controller is modified
  41375. */
  41376. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41377. /**
  41378. * Fired when the touchpad values on this controller are modified
  41379. */
  41380. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41381. private _updateTrackpad;
  41382. /**
  41383. * Called once per frame by the engine.
  41384. */
  41385. update(): void;
  41386. /**
  41387. * Called once for each button that changed state since the last frame
  41388. * @param buttonIdx Which button index changed
  41389. * @param state New state of the button
  41390. * @param changes Which properties on the state changed since last frame
  41391. */
  41392. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41393. /**
  41394. * Moves the buttons on the controller mesh based on their current state
  41395. * @param buttonName the name of the button to move
  41396. * @param buttonValue the value of the button which determines the buttons new position
  41397. */
  41398. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41399. /**
  41400. * Moves the axis on the controller mesh based on its current state
  41401. * @param axis the index of the axis
  41402. * @param axisValue the value of the axis which determines the meshes new position
  41403. * @hidden
  41404. */
  41405. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41406. /**
  41407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41408. * @param scene scene in which to add meshes
  41409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41410. */
  41411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41412. /**
  41413. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41414. * can be transformed by button presses and axes values, based on this._mapping.
  41415. *
  41416. * @param scene scene in which the meshes exist
  41417. * @param meshes list of meshes that make up the controller model to process
  41418. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41419. */
  41420. private processModel;
  41421. private createMeshInfo;
  41422. /**
  41423. * Gets the ray of the controller in the direction the controller is pointing
  41424. * @param length the length the resulting ray should be
  41425. * @returns a ray in the direction the controller is pointing
  41426. */
  41427. getForwardRay(length?: number): Ray;
  41428. /**
  41429. * Disposes of the controller
  41430. */
  41431. dispose(): void;
  41432. }
  41433. }
  41434. declare module BABYLON {
  41435. /**
  41436. * Single axis scale gizmo
  41437. */
  41438. export class AxisScaleGizmo extends Gizmo {
  41439. private _coloredMaterial;
  41440. /**
  41441. * Drag behavior responsible for the gizmos dragging interactions
  41442. */
  41443. dragBehavior: PointerDragBehavior;
  41444. private _pointerObserver;
  41445. /**
  41446. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41447. */
  41448. snapDistance: number;
  41449. /**
  41450. * Event that fires each time the gizmo snaps to a new location.
  41451. * * snapDistance is the the change in distance
  41452. */
  41453. onSnapObservable: Observable<{
  41454. snapDistance: number;
  41455. }>;
  41456. /**
  41457. * If the scaling operation should be done on all axis (default: false)
  41458. */
  41459. uniformScaling: boolean;
  41460. /**
  41461. * Creates an AxisScaleGizmo
  41462. * @param gizmoLayer The utility layer the gizmo will be added to
  41463. * @param dragAxis The axis which the gizmo will be able to scale on
  41464. * @param color The color of the gizmo
  41465. */
  41466. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41467. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41468. /**
  41469. * Disposes of the gizmo
  41470. */
  41471. dispose(): void;
  41472. /**
  41473. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41474. * @param mesh The mesh to replace the default mesh of the gizmo
  41475. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41476. */
  41477. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41478. }
  41479. }
  41480. declare module BABYLON {
  41481. /**
  41482. * Bounding box gizmo
  41483. */
  41484. export class BoundingBoxGizmo extends Gizmo {
  41485. private _lineBoundingBox;
  41486. private _rotateSpheresParent;
  41487. private _scaleBoxesParent;
  41488. private _boundingDimensions;
  41489. private _renderObserver;
  41490. private _pointerObserver;
  41491. private _scaleDragSpeed;
  41492. private _tmpQuaternion;
  41493. private _tmpVector;
  41494. private _tmpRotationMatrix;
  41495. /**
  41496. * 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)
  41497. */
  41498. ignoreChildren: boolean;
  41499. /**
  41500. * 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)
  41501. */
  41502. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41503. /**
  41504. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41505. */
  41506. rotationSphereSize: number;
  41507. /**
  41508. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41509. */
  41510. scaleBoxSize: number;
  41511. /**
  41512. * 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)
  41513. */
  41514. fixedDragMeshScreenSize: boolean;
  41515. /**
  41516. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41517. */
  41518. fixedDragMeshScreenSizeDistanceFactor: number;
  41519. /**
  41520. * Fired when a rotation sphere or scale box is dragged
  41521. */
  41522. onDragStartObservable: Observable<{}>;
  41523. /**
  41524. * Fired when a scale box is dragged
  41525. */
  41526. onScaleBoxDragObservable: Observable<{}>;
  41527. /**
  41528. * Fired when a scale box drag is ended
  41529. */
  41530. onScaleBoxDragEndObservable: Observable<{}>;
  41531. /**
  41532. * Fired when a rotation sphere is dragged
  41533. */
  41534. onRotationSphereDragObservable: Observable<{}>;
  41535. /**
  41536. * Fired when a rotation sphere drag is ended
  41537. */
  41538. onRotationSphereDragEndObservable: Observable<{}>;
  41539. /**
  41540. * 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)
  41541. */
  41542. scalePivot: Nullable<Vector3>;
  41543. private _anchorMesh;
  41544. private _existingMeshScale;
  41545. private _dragMesh;
  41546. private pointerDragBehavior;
  41547. private coloredMaterial;
  41548. private hoverColoredMaterial;
  41549. /**
  41550. * Sets the color of the bounding box gizmo
  41551. * @param color the color to set
  41552. */
  41553. setColor(color: Color3): void;
  41554. /**
  41555. * Creates an BoundingBoxGizmo
  41556. * @param gizmoLayer The utility layer the gizmo will be added to
  41557. * @param color The color of the gizmo
  41558. */
  41559. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41560. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41561. private _selectNode;
  41562. /**
  41563. * Updates the bounding box information for the Gizmo
  41564. */
  41565. updateBoundingBox(): void;
  41566. private _updateRotationSpheres;
  41567. private _updateScaleBoxes;
  41568. /**
  41569. * Enables rotation on the specified axis and disables rotation on the others
  41570. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41571. */
  41572. setEnabledRotationAxis(axis: string): void;
  41573. /**
  41574. * Enables/disables scaling
  41575. * @param enable if scaling should be enabled
  41576. */
  41577. setEnabledScaling(enable: boolean): void;
  41578. private _updateDummy;
  41579. /**
  41580. * Enables a pointer drag behavior on the bounding box of the gizmo
  41581. */
  41582. enableDragBehavior(): void;
  41583. /**
  41584. * Disposes of the gizmo
  41585. */
  41586. dispose(): void;
  41587. /**
  41588. * 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)
  41589. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41590. * @returns the bounding box mesh with the passed in mesh as a child
  41591. */
  41592. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41593. /**
  41594. * CustomMeshes are not supported by this gizmo
  41595. * @param mesh The mesh to replace the default mesh of the gizmo
  41596. */
  41597. setCustomMesh(mesh: Mesh): void;
  41598. }
  41599. }
  41600. declare module BABYLON {
  41601. /**
  41602. * Single plane rotation gizmo
  41603. */
  41604. export class PlaneRotationGizmo extends Gizmo {
  41605. /**
  41606. * Drag behavior responsible for the gizmos dragging interactions
  41607. */
  41608. dragBehavior: PointerDragBehavior;
  41609. private _pointerObserver;
  41610. /**
  41611. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  41612. */
  41613. snapDistance: number;
  41614. /**
  41615. * Event that fires each time the gizmo snaps to a new location.
  41616. * * snapDistance is the the change in distance
  41617. */
  41618. onSnapObservable: Observable<{
  41619. snapDistance: number;
  41620. }>;
  41621. /**
  41622. * Creates a PlaneRotationGizmo
  41623. * @param gizmoLayer The utility layer the gizmo will be added to
  41624. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  41625. * @param color The color of the gizmo
  41626. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41627. */
  41628. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41629. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41630. /**
  41631. * Disposes of the gizmo
  41632. */
  41633. dispose(): void;
  41634. }
  41635. }
  41636. declare module BABYLON {
  41637. /**
  41638. * Gizmo that enables rotating a mesh along 3 axis
  41639. */
  41640. export class RotationGizmo extends Gizmo {
  41641. /**
  41642. * Internal gizmo used for interactions on the x axis
  41643. */
  41644. xGizmo: PlaneRotationGizmo;
  41645. /**
  41646. * Internal gizmo used for interactions on the y axis
  41647. */
  41648. yGizmo: PlaneRotationGizmo;
  41649. /**
  41650. * Internal gizmo used for interactions on the z axis
  41651. */
  41652. zGizmo: PlaneRotationGizmo;
  41653. /** Fires an event when any of it's sub gizmos are dragged */
  41654. onDragStartObservable: Observable<{}>;
  41655. /** Fires an event when any of it's sub gizmos are released from dragging */
  41656. onDragEndObservable: Observable<{}>;
  41657. attachedMesh: Nullable<AbstractMesh>;
  41658. /**
  41659. * Creates a RotationGizmo
  41660. * @param gizmoLayer The utility layer the gizmo will be added to
  41661. * @param tessellation Amount of tessellation to be used when creating rotation circles
  41662. */
  41663. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  41664. updateGizmoRotationToMatchAttachedMesh: boolean;
  41665. /**
  41666. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41667. */
  41668. snapDistance: number;
  41669. /**
  41670. * Ratio for the scale of the gizmo (Default: 1)
  41671. */
  41672. scaleRatio: number;
  41673. /**
  41674. * Disposes of the gizmo
  41675. */
  41676. dispose(): void;
  41677. /**
  41678. * CustomMeshes are not supported by this gizmo
  41679. * @param mesh The mesh to replace the default mesh of the gizmo
  41680. */
  41681. setCustomMesh(mesh: Mesh): void;
  41682. }
  41683. }
  41684. declare module BABYLON {
  41685. /**
  41686. * Gizmo that enables dragging a mesh along 3 axis
  41687. */
  41688. export class PositionGizmo extends Gizmo {
  41689. /**
  41690. * Internal gizmo used for interactions on the x axis
  41691. */
  41692. xGizmo: AxisDragGizmo;
  41693. /**
  41694. * Internal gizmo used for interactions on the y axis
  41695. */
  41696. yGizmo: AxisDragGizmo;
  41697. /**
  41698. * Internal gizmo used for interactions on the z axis
  41699. */
  41700. zGizmo: AxisDragGizmo;
  41701. /** Fires an event when any of it's sub gizmos are dragged */
  41702. onDragStartObservable: Observable<{}>;
  41703. /** Fires an event when any of it's sub gizmos are released from dragging */
  41704. onDragEndObservable: Observable<{}>;
  41705. attachedMesh: Nullable<AbstractMesh>;
  41706. /**
  41707. * Creates a PositionGizmo
  41708. * @param gizmoLayer The utility layer the gizmo will be added to
  41709. */
  41710. constructor(gizmoLayer?: UtilityLayerRenderer);
  41711. updateGizmoRotationToMatchAttachedMesh: boolean;
  41712. /**
  41713. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41714. */
  41715. snapDistance: number;
  41716. /**
  41717. * Ratio for the scale of the gizmo (Default: 1)
  41718. */
  41719. scaleRatio: number;
  41720. /**
  41721. * Disposes of the gizmo
  41722. */
  41723. dispose(): void;
  41724. /**
  41725. * CustomMeshes are not supported by this gizmo
  41726. * @param mesh The mesh to replace the default mesh of the gizmo
  41727. */
  41728. setCustomMesh(mesh: Mesh): void;
  41729. }
  41730. }
  41731. declare module BABYLON {
  41732. /**
  41733. * Class containing static functions to help procedurally build meshes
  41734. */
  41735. export class PolyhedronBuilder {
  41736. /**
  41737. * Creates a polyhedron mesh
  41738. * * 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
  41739. * * The parameter `size` (positive float, default 1) sets the polygon size
  41740. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  41741. * * 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`
  41742. * * 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
  41743. * * 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)`)
  41744. * * 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
  41745. * * 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
  41746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41747. * * 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
  41748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  41749. * @param name defines the name of the mesh
  41750. * @param options defines the options used to create the mesh
  41751. * @param scene defines the hosting scene
  41752. * @returns the polyhedron mesh
  41753. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  41754. */
  41755. static CreatePolyhedron(name: string, options: {
  41756. type?: number;
  41757. size?: number;
  41758. sizeX?: number;
  41759. sizeY?: number;
  41760. sizeZ?: number;
  41761. custom?: any;
  41762. faceUV?: Vector4[];
  41763. faceColors?: Color4[];
  41764. flat?: boolean;
  41765. updatable?: boolean;
  41766. sideOrientation?: number;
  41767. frontUVs?: Vector4;
  41768. backUVs?: Vector4;
  41769. }, scene: Scene): Mesh;
  41770. }
  41771. }
  41772. declare module BABYLON {
  41773. /**
  41774. * Gizmo that enables scaling a mesh along 3 axis
  41775. */
  41776. export class ScaleGizmo extends Gizmo {
  41777. /**
  41778. * Internal gizmo used for interactions on the x axis
  41779. */
  41780. xGizmo: AxisScaleGizmo;
  41781. /**
  41782. * Internal gizmo used for interactions on the y axis
  41783. */
  41784. yGizmo: AxisScaleGizmo;
  41785. /**
  41786. * Internal gizmo used for interactions on the z axis
  41787. */
  41788. zGizmo: AxisScaleGizmo;
  41789. /**
  41790. * Internal gizmo used to scale all axis equally
  41791. */
  41792. uniformScaleGizmo: AxisScaleGizmo;
  41793. /** Fires an event when any of it's sub gizmos are dragged */
  41794. onDragStartObservable: Observable<{}>;
  41795. /** Fires an event when any of it's sub gizmos are released from dragging */
  41796. onDragEndObservable: Observable<{}>;
  41797. attachedMesh: Nullable<AbstractMesh>;
  41798. /**
  41799. * Creates a ScaleGizmo
  41800. * @param gizmoLayer The utility layer the gizmo will be added to
  41801. */
  41802. constructor(gizmoLayer?: UtilityLayerRenderer);
  41803. updateGizmoRotationToMatchAttachedMesh: boolean;
  41804. /**
  41805. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41806. */
  41807. snapDistance: number;
  41808. /**
  41809. * Ratio for the scale of the gizmo (Default: 1)
  41810. */
  41811. scaleRatio: number;
  41812. /**
  41813. * Disposes of the gizmo
  41814. */
  41815. dispose(): void;
  41816. }
  41817. }
  41818. declare module BABYLON {
  41819. /**
  41820. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  41821. */
  41822. export class GizmoManager implements IDisposable {
  41823. private scene;
  41824. /**
  41825. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  41826. */
  41827. gizmos: {
  41828. positionGizmo: Nullable<PositionGizmo>;
  41829. rotationGizmo: Nullable<RotationGizmo>;
  41830. scaleGizmo: Nullable<ScaleGizmo>;
  41831. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  41832. };
  41833. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  41834. clearGizmoOnEmptyPointerEvent: boolean;
  41835. /** Fires an event when the manager is attached to a mesh */
  41836. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  41837. private _gizmosEnabled;
  41838. private _pointerObserver;
  41839. private _attachedMesh;
  41840. private _boundingBoxColor;
  41841. private _defaultUtilityLayer;
  41842. private _defaultKeepDepthUtilityLayer;
  41843. /**
  41844. * When bounding box gizmo is enabled, this can be used to track drag/end events
  41845. */
  41846. boundingBoxDragBehavior: SixDofDragBehavior;
  41847. /**
  41848. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  41849. */
  41850. attachableMeshes: Nullable<Array<AbstractMesh>>;
  41851. /**
  41852. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  41853. */
  41854. usePointerToAttachGizmos: boolean;
  41855. /**
  41856. * Instatiates a gizmo manager
  41857. * @param scene the scene to overlay the gizmos on top of
  41858. */
  41859. constructor(scene: Scene);
  41860. /**
  41861. * Attaches a set of gizmos to the specified mesh
  41862. * @param mesh The mesh the gizmo's should be attached to
  41863. */
  41864. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  41865. /**
  41866. * If the position gizmo is enabled
  41867. */
  41868. positionGizmoEnabled: boolean;
  41869. /**
  41870. * If the rotation gizmo is enabled
  41871. */
  41872. rotationGizmoEnabled: boolean;
  41873. /**
  41874. * If the scale gizmo is enabled
  41875. */
  41876. scaleGizmoEnabled: boolean;
  41877. /**
  41878. * If the boundingBox gizmo is enabled
  41879. */
  41880. boundingBoxGizmoEnabled: boolean;
  41881. /**
  41882. * Disposes of the gizmo manager
  41883. */
  41884. dispose(): void;
  41885. }
  41886. }
  41887. declare module BABYLON {
  41888. /**
  41889. * A directional light is defined by a direction (what a surprise!).
  41890. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  41891. * 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.
  41892. * Documentation: https://doc.babylonjs.com/babylon101/lights
  41893. */
  41894. export class DirectionalLight extends ShadowLight {
  41895. private _shadowFrustumSize;
  41896. /**
  41897. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  41898. */
  41899. /**
  41900. * Specifies a fix frustum size for the shadow generation.
  41901. */
  41902. shadowFrustumSize: number;
  41903. private _shadowOrthoScale;
  41904. /**
  41905. * Gets the shadow projection scale against the optimal computed one.
  41906. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41907. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41908. */
  41909. /**
  41910. * Sets the shadow projection scale against the optimal computed one.
  41911. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  41912. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  41913. */
  41914. shadowOrthoScale: number;
  41915. /**
  41916. * Automatically compute the projection matrix to best fit (including all the casters)
  41917. * on each frame.
  41918. */
  41919. autoUpdateExtends: boolean;
  41920. private _orthoLeft;
  41921. private _orthoRight;
  41922. private _orthoTop;
  41923. private _orthoBottom;
  41924. /**
  41925. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  41926. * The directional light is emitted from everywhere in the given direction.
  41927. * It can cast shadows.
  41928. * Documentation : https://doc.babylonjs.com/babylon101/lights
  41929. * @param name The friendly name of the light
  41930. * @param direction The direction of the light
  41931. * @param scene The scene the light belongs to
  41932. */
  41933. constructor(name: string, direction: Vector3, scene: Scene);
  41934. /**
  41935. * Returns the string "DirectionalLight".
  41936. * @return The class name
  41937. */
  41938. getClassName(): string;
  41939. /**
  41940. * Returns the integer 1.
  41941. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  41942. */
  41943. getTypeID(): number;
  41944. /**
  41945. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  41946. * Returns the DirectionalLight Shadow projection matrix.
  41947. */
  41948. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  41949. /**
  41950. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  41951. * Returns the DirectionalLight Shadow projection matrix.
  41952. */
  41953. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  41954. /**
  41955. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  41956. * Returns the DirectionalLight Shadow projection matrix.
  41957. */
  41958. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  41959. protected _buildUniformLayout(): void;
  41960. /**
  41961. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  41962. * @param effect The effect to update
  41963. * @param lightIndex The index of the light in the effect to update
  41964. * @returns The directional light
  41965. */
  41966. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  41967. /**
  41968. * Gets the minZ used for shadow according to both the scene and the light.
  41969. *
  41970. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  41971. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  41972. * @param activeCamera The camera we are returning the min for
  41973. * @returns the depth min z
  41974. */
  41975. getDepthMinZ(activeCamera: Camera): number;
  41976. /**
  41977. * Gets the maxZ used for shadow according to both the scene and the light.
  41978. *
  41979. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  41980. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  41981. * @param activeCamera The camera we are returning the max for
  41982. * @returns the depth max z
  41983. */
  41984. getDepthMaxZ(activeCamera: Camera): number;
  41985. /**
  41986. * Prepares the list of defines specific to the light type.
  41987. * @param defines the list of defines
  41988. * @param lightIndex defines the index of the light for the effect
  41989. */
  41990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  41991. }
  41992. }
  41993. declare module BABYLON {
  41994. /**
  41995. * Class containing static functions to help procedurally build meshes
  41996. */
  41997. export class HemisphereBuilder {
  41998. /**
  41999. * Creates a hemisphere mesh
  42000. * @param name defines the name of the mesh
  42001. * @param options defines the options used to create the mesh
  42002. * @param scene defines the hosting scene
  42003. * @returns the hemisphere mesh
  42004. */
  42005. static CreateHemisphere(name: string, options: {
  42006. segments?: number;
  42007. diameter?: number;
  42008. sideOrientation?: number;
  42009. }, scene: any): Mesh;
  42010. }
  42011. }
  42012. declare module BABYLON {
  42013. /**
  42014. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42015. * These values define a cone of light starting from the position, emitting toward the direction.
  42016. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42017. * and the exponent defines the speed of the decay of the light with distance (reach).
  42018. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42019. */
  42020. export class SpotLight extends ShadowLight {
  42021. private _angle;
  42022. private _innerAngle;
  42023. private _cosHalfAngle;
  42024. private _lightAngleScale;
  42025. private _lightAngleOffset;
  42026. /**
  42027. * Gets the cone angle of the spot light in Radians.
  42028. */
  42029. /**
  42030. * Sets the cone angle of the spot light in Radians.
  42031. */
  42032. angle: number;
  42033. /**
  42034. * Only used in gltf falloff mode, this defines the angle where
  42035. * the directional falloff will start before cutting at angle which could be seen
  42036. * as outer angle.
  42037. */
  42038. /**
  42039. * Only used in gltf falloff mode, this defines the angle where
  42040. * the directional falloff will start before cutting at angle which could be seen
  42041. * as outer angle.
  42042. */
  42043. innerAngle: number;
  42044. private _shadowAngleScale;
  42045. /**
  42046. * Allows scaling the angle of the light for shadow generation only.
  42047. */
  42048. /**
  42049. * Allows scaling the angle of the light for shadow generation only.
  42050. */
  42051. shadowAngleScale: number;
  42052. /**
  42053. * The light decay speed with the distance from the emission spot.
  42054. */
  42055. exponent: number;
  42056. private _projectionTextureMatrix;
  42057. /**
  42058. * Allows reading the projecton texture
  42059. */
  42060. readonly projectionTextureMatrix: Matrix;
  42061. protected _projectionTextureLightNear: number;
  42062. /**
  42063. * Gets the near clip of the Spotlight for texture projection.
  42064. */
  42065. /**
  42066. * Sets the near clip of the Spotlight for texture projection.
  42067. */
  42068. projectionTextureLightNear: number;
  42069. protected _projectionTextureLightFar: number;
  42070. /**
  42071. * Gets the far clip of the Spotlight for texture projection.
  42072. */
  42073. /**
  42074. * Sets the far clip of the Spotlight for texture projection.
  42075. */
  42076. projectionTextureLightFar: number;
  42077. protected _projectionTextureUpDirection: Vector3;
  42078. /**
  42079. * Gets the Up vector of the Spotlight for texture projection.
  42080. */
  42081. /**
  42082. * Sets the Up vector of the Spotlight for texture projection.
  42083. */
  42084. projectionTextureUpDirection: Vector3;
  42085. private _projectionTexture;
  42086. /**
  42087. * Gets the projection texture of the light.
  42088. */
  42089. /**
  42090. * Sets the projection texture of the light.
  42091. */
  42092. projectionTexture: Nullable<BaseTexture>;
  42093. private _projectionTextureViewLightDirty;
  42094. private _projectionTextureProjectionLightDirty;
  42095. private _projectionTextureDirty;
  42096. private _projectionTextureViewTargetVector;
  42097. private _projectionTextureViewLightMatrix;
  42098. private _projectionTextureProjectionLightMatrix;
  42099. private _projectionTextureScalingMatrix;
  42100. /**
  42101. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42102. * It can cast shadows.
  42103. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42104. * @param name The light friendly name
  42105. * @param position The position of the spot light in the scene
  42106. * @param direction The direction of the light in the scene
  42107. * @param angle The cone angle of the light in Radians
  42108. * @param exponent The light decay speed with the distance from the emission spot
  42109. * @param scene The scene the lights belongs to
  42110. */
  42111. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42112. /**
  42113. * Returns the string "SpotLight".
  42114. * @returns the class name
  42115. */
  42116. getClassName(): string;
  42117. /**
  42118. * Returns the integer 2.
  42119. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42120. */
  42121. getTypeID(): number;
  42122. /**
  42123. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42124. */
  42125. protected _setDirection(value: Vector3): void;
  42126. /**
  42127. * Overrides the position setter to recompute the projection texture view light Matrix.
  42128. */
  42129. protected _setPosition(value: Vector3): void;
  42130. /**
  42131. * 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.
  42132. * Returns the SpotLight.
  42133. */
  42134. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42135. protected _computeProjectionTextureViewLightMatrix(): void;
  42136. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42137. /**
  42138. * Main function for light texture projection matrix computing.
  42139. */
  42140. protected _computeProjectionTextureMatrix(): void;
  42141. protected _buildUniformLayout(): void;
  42142. private _computeAngleValues;
  42143. /**
  42144. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42145. * @param effect The effect to update
  42146. * @param lightIndex The index of the light in the effect to update
  42147. * @returns The spot light
  42148. */
  42149. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42150. /**
  42151. * Disposes the light and the associated resources.
  42152. */
  42153. dispose(): void;
  42154. /**
  42155. * Prepares the list of defines specific to the light type.
  42156. * @param defines the list of defines
  42157. * @param lightIndex defines the index of the light for the effect
  42158. */
  42159. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42160. }
  42161. }
  42162. declare module BABYLON {
  42163. /**
  42164. * Gizmo that enables viewing a light
  42165. */
  42166. export class LightGizmo extends Gizmo {
  42167. private _lightMesh;
  42168. private _material;
  42169. /**
  42170. * Creates a LightGizmo
  42171. * @param gizmoLayer The utility layer the gizmo will be added to
  42172. */
  42173. constructor(gizmoLayer?: UtilityLayerRenderer);
  42174. private _light;
  42175. /**
  42176. * The light that the gizmo is attached to
  42177. */
  42178. light: Nullable<Light>;
  42179. /**
  42180. * @hidden
  42181. * Updates the gizmo to match the attached mesh's position/rotation
  42182. */
  42183. protected _update(): void;
  42184. private static _Scale;
  42185. /**
  42186. * Creates the lines for a light mesh
  42187. */
  42188. private static _createLightLines;
  42189. private static _CreateHemisphericLightMesh;
  42190. private static _CreatePointLightMesh;
  42191. private static _CreateSpotLightMesh;
  42192. private static _CreateDirectionalLightMesh;
  42193. }
  42194. }
  42195. declare module BABYLON {
  42196. /** @hidden */
  42197. export var backgroundFragmentDeclaration: {
  42198. name: string;
  42199. shader: string;
  42200. };
  42201. }
  42202. declare module BABYLON {
  42203. /** @hidden */
  42204. export var backgroundUboDeclaration: {
  42205. name: string;
  42206. shader: string;
  42207. };
  42208. }
  42209. declare module BABYLON {
  42210. /** @hidden */
  42211. export var backgroundPixelShader: {
  42212. name: string;
  42213. shader: string;
  42214. };
  42215. }
  42216. declare module BABYLON {
  42217. /** @hidden */
  42218. export var backgroundVertexDeclaration: {
  42219. name: string;
  42220. shader: string;
  42221. };
  42222. }
  42223. declare module BABYLON {
  42224. /** @hidden */
  42225. export var backgroundVertexShader: {
  42226. name: string;
  42227. shader: string;
  42228. };
  42229. }
  42230. declare module BABYLON {
  42231. /**
  42232. * Background material used to create an efficient environement around your scene.
  42233. */
  42234. export class BackgroundMaterial extends PushMaterial {
  42235. /**
  42236. * Standard reflectance value at parallel view angle.
  42237. */
  42238. static StandardReflectance0: number;
  42239. /**
  42240. * Standard reflectance value at grazing angle.
  42241. */
  42242. static StandardReflectance90: number;
  42243. protected _primaryColor: Color3;
  42244. /**
  42245. * Key light Color (multiply against the environement texture)
  42246. */
  42247. primaryColor: Color3;
  42248. protected __perceptualColor: Nullable<Color3>;
  42249. /**
  42250. * Experimental Internal Use Only.
  42251. *
  42252. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42253. * This acts as a helper to set the primary color to a more "human friendly" value.
  42254. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42255. * output color as close as possible from the chosen value.
  42256. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42257. * part of lighting setup.)
  42258. */ perceptualColor: Nullable<Color3>;
  42259. protected _primaryColorShadowLevel: float;
  42260. /**
  42261. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42262. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42263. */
  42264. primaryColorShadowLevel: float;
  42265. protected _primaryColorHighlightLevel: float;
  42266. /**
  42267. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42268. * The primary color is used at the level chosen to define what the white area would look.
  42269. */
  42270. primaryColorHighlightLevel: float;
  42271. protected _reflectionTexture: Nullable<BaseTexture>;
  42272. /**
  42273. * Reflection Texture used in the material.
  42274. * Should be author in a specific way for the best result (refer to the documentation).
  42275. */
  42276. reflectionTexture: Nullable<BaseTexture>;
  42277. protected _reflectionBlur: float;
  42278. /**
  42279. * Reflection Texture level of blur.
  42280. *
  42281. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42282. * texture twice.
  42283. */
  42284. reflectionBlur: float;
  42285. protected _diffuseTexture: Nullable<BaseTexture>;
  42286. /**
  42287. * Diffuse Texture used in the material.
  42288. * Should be author in a specific way for the best result (refer to the documentation).
  42289. */
  42290. diffuseTexture: Nullable<BaseTexture>;
  42291. protected _shadowLights: Nullable<IShadowLight[]>;
  42292. /**
  42293. * Specify the list of lights casting shadow on the material.
  42294. * All scene shadow lights will be included if null.
  42295. */
  42296. shadowLights: Nullable<IShadowLight[]>;
  42297. protected _shadowLevel: float;
  42298. /**
  42299. * Helps adjusting the shadow to a softer level if required.
  42300. * 0 means black shadows and 1 means no shadows.
  42301. */
  42302. shadowLevel: float;
  42303. protected _sceneCenter: Vector3;
  42304. /**
  42305. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42306. * It is usually zero but might be interesting to modify according to your setup.
  42307. */
  42308. sceneCenter: Vector3;
  42309. protected _opacityFresnel: boolean;
  42310. /**
  42311. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42312. * This helps ensuring a nice transition when the camera goes under the ground.
  42313. */
  42314. opacityFresnel: boolean;
  42315. protected _reflectionFresnel: boolean;
  42316. /**
  42317. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42318. * This helps adding a mirror texture on the ground.
  42319. */
  42320. reflectionFresnel: boolean;
  42321. protected _reflectionFalloffDistance: number;
  42322. /**
  42323. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42324. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42325. */
  42326. reflectionFalloffDistance: number;
  42327. protected _reflectionAmount: number;
  42328. /**
  42329. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42330. */
  42331. reflectionAmount: number;
  42332. protected _reflectionReflectance0: number;
  42333. /**
  42334. * This specifies the weight of the reflection at grazing angle.
  42335. */
  42336. reflectionReflectance0: number;
  42337. protected _reflectionReflectance90: number;
  42338. /**
  42339. * This specifies the weight of the reflection at a perpendicular point of view.
  42340. */
  42341. reflectionReflectance90: number;
  42342. /**
  42343. * Sets the reflection reflectance fresnel values according to the default standard
  42344. * empirically know to work well :-)
  42345. */
  42346. reflectionStandardFresnelWeight: number;
  42347. protected _useRGBColor: boolean;
  42348. /**
  42349. * Helps to directly use the maps channels instead of their level.
  42350. */
  42351. useRGBColor: boolean;
  42352. protected _enableNoise: boolean;
  42353. /**
  42354. * This helps reducing the banding effect that could occur on the background.
  42355. */
  42356. enableNoise: boolean;
  42357. /**
  42358. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42359. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42360. * Recommended to be keep at 1.0 except for special cases.
  42361. */
  42362. fovMultiplier: number;
  42363. private _fovMultiplier;
  42364. /**
  42365. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42366. */
  42367. useEquirectangularFOV: boolean;
  42368. private _maxSimultaneousLights;
  42369. /**
  42370. * Number of Simultaneous lights allowed on the material.
  42371. */
  42372. maxSimultaneousLights: int;
  42373. /**
  42374. * Default configuration related to image processing available in the Background Material.
  42375. */
  42376. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42377. /**
  42378. * Keep track of the image processing observer to allow dispose and replace.
  42379. */
  42380. private _imageProcessingObserver;
  42381. /**
  42382. * Attaches a new image processing configuration to the PBR Material.
  42383. * @param configuration (if null the scene configuration will be use)
  42384. */
  42385. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42386. /**
  42387. * Gets the image processing configuration used either in this material.
  42388. */
  42389. /**
  42390. * Sets the Default image processing configuration used either in the this material.
  42391. *
  42392. * If sets to null, the scene one is in use.
  42393. */
  42394. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42395. /**
  42396. * Gets wether the color curves effect is enabled.
  42397. */
  42398. /**
  42399. * Sets wether the color curves effect is enabled.
  42400. */
  42401. cameraColorCurvesEnabled: boolean;
  42402. /**
  42403. * Gets wether the color grading effect is enabled.
  42404. */
  42405. /**
  42406. * Gets wether the color grading effect is enabled.
  42407. */
  42408. cameraColorGradingEnabled: boolean;
  42409. /**
  42410. * Gets wether tonemapping is enabled or not.
  42411. */
  42412. /**
  42413. * Sets wether tonemapping is enabled or not
  42414. */
  42415. cameraToneMappingEnabled: boolean;
  42416. /**
  42417. * The camera exposure used on this material.
  42418. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42419. * This corresponds to a photographic exposure.
  42420. */
  42421. /**
  42422. * The camera exposure used on this material.
  42423. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42424. * This corresponds to a photographic exposure.
  42425. */
  42426. cameraExposure: float;
  42427. /**
  42428. * Gets The camera contrast used on this material.
  42429. */
  42430. /**
  42431. * Sets The camera contrast used on this material.
  42432. */
  42433. cameraContrast: float;
  42434. /**
  42435. * Gets the Color Grading 2D Lookup Texture.
  42436. */
  42437. /**
  42438. * Sets the Color Grading 2D Lookup Texture.
  42439. */
  42440. cameraColorGradingTexture: Nullable<BaseTexture>;
  42441. /**
  42442. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42443. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42444. * 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;
  42445. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42446. */
  42447. /**
  42448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42450. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  42451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42452. */
  42453. cameraColorCurves: Nullable<ColorCurves>;
  42454. /**
  42455. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42456. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42457. */
  42458. switchToBGR: boolean;
  42459. private _renderTargets;
  42460. private _reflectionControls;
  42461. private _white;
  42462. private _primaryShadowColor;
  42463. private _primaryHighlightColor;
  42464. /**
  42465. * Instantiates a Background Material in the given scene
  42466. * @param name The friendly name of the material
  42467. * @param scene The scene to add the material to
  42468. */
  42469. constructor(name: string, scene: Scene);
  42470. /**
  42471. * Gets a boolean indicating that current material needs to register RTT
  42472. */
  42473. readonly hasRenderTargetTextures: boolean;
  42474. /**
  42475. * The entire material has been created in order to prevent overdraw.
  42476. * @returns false
  42477. */
  42478. needAlphaTesting(): boolean;
  42479. /**
  42480. * The entire material has been created in order to prevent overdraw.
  42481. * @returns true if blending is enable
  42482. */
  42483. needAlphaBlending(): boolean;
  42484. /**
  42485. * Checks wether the material is ready to be rendered for a given mesh.
  42486. * @param mesh The mesh to render
  42487. * @param subMesh The submesh to check against
  42488. * @param useInstances Specify wether or not the material is used with instances
  42489. * @returns true if all the dependencies are ready (Textures, Effects...)
  42490. */
  42491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42492. /**
  42493. * Compute the primary color according to the chosen perceptual color.
  42494. */
  42495. private _computePrimaryColorFromPerceptualColor;
  42496. /**
  42497. * Compute the highlights and shadow colors according to their chosen levels.
  42498. */
  42499. private _computePrimaryColors;
  42500. /**
  42501. * Build the uniform buffer used in the material.
  42502. */
  42503. buildUniformLayout(): void;
  42504. /**
  42505. * Unbind the material.
  42506. */
  42507. unbind(): void;
  42508. /**
  42509. * Bind only the world matrix to the material.
  42510. * @param world The world matrix to bind.
  42511. */
  42512. bindOnlyWorldMatrix(world: Matrix): void;
  42513. /**
  42514. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42515. * @param world The world matrix to bind.
  42516. * @param subMesh The submesh to bind for.
  42517. */
  42518. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42519. /**
  42520. * Dispose the material.
  42521. * @param forceDisposeEffect Force disposal of the associated effect.
  42522. * @param forceDisposeTextures Force disposal of the associated textures.
  42523. */
  42524. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42525. /**
  42526. * Clones the material.
  42527. * @param name The cloned name.
  42528. * @returns The cloned material.
  42529. */
  42530. clone(name: string): BackgroundMaterial;
  42531. /**
  42532. * Serializes the current material to its JSON representation.
  42533. * @returns The JSON representation.
  42534. */
  42535. serialize(): any;
  42536. /**
  42537. * Gets the class name of the material
  42538. * @returns "BackgroundMaterial"
  42539. */
  42540. getClassName(): string;
  42541. /**
  42542. * Parse a JSON input to create back a background material.
  42543. * @param source The JSON data to parse
  42544. * @param scene The scene to create the parsed material in
  42545. * @param rootUrl The root url of the assets the material depends upon
  42546. * @returns the instantiated BackgroundMaterial.
  42547. */
  42548. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42549. }
  42550. }
  42551. declare module BABYLON {
  42552. /**
  42553. * Represents the different options available during the creation of
  42554. * a Environment helper.
  42555. *
  42556. * This can control the default ground, skybox and image processing setup of your scene.
  42557. */
  42558. export interface IEnvironmentHelperOptions {
  42559. /**
  42560. * Specifies wether or not to create a ground.
  42561. * True by default.
  42562. */
  42563. createGround: boolean;
  42564. /**
  42565. * Specifies the ground size.
  42566. * 15 by default.
  42567. */
  42568. groundSize: number;
  42569. /**
  42570. * The texture used on the ground for the main color.
  42571. * Comes from the BabylonJS CDN by default.
  42572. *
  42573. * Remarks: Can be either a texture or a url.
  42574. */
  42575. groundTexture: string | BaseTexture;
  42576. /**
  42577. * The color mixed in the ground texture by default.
  42578. * BabylonJS clearColor by default.
  42579. */
  42580. groundColor: Color3;
  42581. /**
  42582. * Specifies the ground opacity.
  42583. * 1 by default.
  42584. */
  42585. groundOpacity: number;
  42586. /**
  42587. * Enables the ground to receive shadows.
  42588. * True by default.
  42589. */
  42590. enableGroundShadow: boolean;
  42591. /**
  42592. * Helps preventing the shadow to be fully black on the ground.
  42593. * 0.5 by default.
  42594. */
  42595. groundShadowLevel: number;
  42596. /**
  42597. * Creates a mirror texture attach to the ground.
  42598. * false by default.
  42599. */
  42600. enableGroundMirror: boolean;
  42601. /**
  42602. * Specifies the ground mirror size ratio.
  42603. * 0.3 by default as the default kernel is 64.
  42604. */
  42605. groundMirrorSizeRatio: number;
  42606. /**
  42607. * Specifies the ground mirror blur kernel size.
  42608. * 64 by default.
  42609. */
  42610. groundMirrorBlurKernel: number;
  42611. /**
  42612. * Specifies the ground mirror visibility amount.
  42613. * 1 by default
  42614. */
  42615. groundMirrorAmount: number;
  42616. /**
  42617. * Specifies the ground mirror reflectance weight.
  42618. * This uses the standard weight of the background material to setup the fresnel effect
  42619. * of the mirror.
  42620. * 1 by default.
  42621. */
  42622. groundMirrorFresnelWeight: number;
  42623. /**
  42624. * Specifies the ground mirror Falloff distance.
  42625. * This can helps reducing the size of the reflection.
  42626. * 0 by Default.
  42627. */
  42628. groundMirrorFallOffDistance: number;
  42629. /**
  42630. * Specifies the ground mirror texture type.
  42631. * Unsigned Int by Default.
  42632. */
  42633. groundMirrorTextureType: number;
  42634. /**
  42635. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  42636. * the shown objects.
  42637. */
  42638. groundYBias: number;
  42639. /**
  42640. * Specifies wether or not to create a skybox.
  42641. * True by default.
  42642. */
  42643. createSkybox: boolean;
  42644. /**
  42645. * Specifies the skybox size.
  42646. * 20 by default.
  42647. */
  42648. skyboxSize: number;
  42649. /**
  42650. * The texture used on the skybox for the main color.
  42651. * Comes from the BabylonJS CDN by default.
  42652. *
  42653. * Remarks: Can be either a texture or a url.
  42654. */
  42655. skyboxTexture: string | BaseTexture;
  42656. /**
  42657. * The color mixed in the skybox texture by default.
  42658. * BabylonJS clearColor by default.
  42659. */
  42660. skyboxColor: Color3;
  42661. /**
  42662. * The background rotation around the Y axis of the scene.
  42663. * This helps aligning the key lights of your scene with the background.
  42664. * 0 by default.
  42665. */
  42666. backgroundYRotation: number;
  42667. /**
  42668. * Compute automatically the size of the elements to best fit with the scene.
  42669. */
  42670. sizeAuto: boolean;
  42671. /**
  42672. * Default position of the rootMesh if autoSize is not true.
  42673. */
  42674. rootPosition: Vector3;
  42675. /**
  42676. * Sets up the image processing in the scene.
  42677. * true by default.
  42678. */
  42679. setupImageProcessing: boolean;
  42680. /**
  42681. * The texture used as your environment texture in the scene.
  42682. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  42683. *
  42684. * Remarks: Can be either a texture or a url.
  42685. */
  42686. environmentTexture: string | BaseTexture;
  42687. /**
  42688. * The value of the exposure to apply to the scene.
  42689. * 0.6 by default if setupImageProcessing is true.
  42690. */
  42691. cameraExposure: number;
  42692. /**
  42693. * The value of the contrast to apply to the scene.
  42694. * 1.6 by default if setupImageProcessing is true.
  42695. */
  42696. cameraContrast: number;
  42697. /**
  42698. * Specifies wether or not tonemapping should be enabled in the scene.
  42699. * true by default if setupImageProcessing is true.
  42700. */
  42701. toneMappingEnabled: boolean;
  42702. }
  42703. /**
  42704. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  42705. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  42706. * It also helps with the default setup of your imageProcessing configuration.
  42707. */
  42708. export class EnvironmentHelper {
  42709. /**
  42710. * Default ground texture URL.
  42711. */
  42712. private static _groundTextureCDNUrl;
  42713. /**
  42714. * Default skybox texture URL.
  42715. */
  42716. private static _skyboxTextureCDNUrl;
  42717. /**
  42718. * Default environment texture URL.
  42719. */
  42720. private static _environmentTextureCDNUrl;
  42721. /**
  42722. * Creates the default options for the helper.
  42723. */
  42724. private static _getDefaultOptions;
  42725. private _rootMesh;
  42726. /**
  42727. * Gets the root mesh created by the helper.
  42728. */
  42729. readonly rootMesh: Mesh;
  42730. private _skybox;
  42731. /**
  42732. * Gets the skybox created by the helper.
  42733. */
  42734. readonly skybox: Nullable<Mesh>;
  42735. private _skyboxTexture;
  42736. /**
  42737. * Gets the skybox texture created by the helper.
  42738. */
  42739. readonly skyboxTexture: Nullable<BaseTexture>;
  42740. private _skyboxMaterial;
  42741. /**
  42742. * Gets the skybox material created by the helper.
  42743. */
  42744. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  42745. private _ground;
  42746. /**
  42747. * Gets the ground mesh created by the helper.
  42748. */
  42749. readonly ground: Nullable<Mesh>;
  42750. private _groundTexture;
  42751. /**
  42752. * Gets the ground texture created by the helper.
  42753. */
  42754. readonly groundTexture: Nullable<BaseTexture>;
  42755. private _groundMirror;
  42756. /**
  42757. * Gets the ground mirror created by the helper.
  42758. */
  42759. readonly groundMirror: Nullable<MirrorTexture>;
  42760. /**
  42761. * Gets the ground mirror render list to helps pushing the meshes
  42762. * you wish in the ground reflection.
  42763. */
  42764. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  42765. private _groundMaterial;
  42766. /**
  42767. * Gets the ground material created by the helper.
  42768. */
  42769. readonly groundMaterial: Nullable<BackgroundMaterial>;
  42770. /**
  42771. * Stores the creation options.
  42772. */
  42773. private readonly _scene;
  42774. private _options;
  42775. /**
  42776. * This observable will be notified with any error during the creation of the environment,
  42777. * mainly texture creation errors.
  42778. */
  42779. onErrorObservable: Observable<{
  42780. message?: string;
  42781. exception?: any;
  42782. }>;
  42783. /**
  42784. * constructor
  42785. * @param options Defines the options we want to customize the helper
  42786. * @param scene The scene to add the material to
  42787. */
  42788. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  42789. /**
  42790. * Updates the background according to the new options
  42791. * @param options
  42792. */
  42793. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  42794. /**
  42795. * Sets the primary color of all the available elements.
  42796. * @param color the main color to affect to the ground and the background
  42797. */
  42798. setMainColor(color: Color3): void;
  42799. /**
  42800. * Setup the image processing according to the specified options.
  42801. */
  42802. private _setupImageProcessing;
  42803. /**
  42804. * Setup the environment texture according to the specified options.
  42805. */
  42806. private _setupEnvironmentTexture;
  42807. /**
  42808. * Setup the background according to the specified options.
  42809. */
  42810. private _setupBackground;
  42811. /**
  42812. * Get the scene sizes according to the setup.
  42813. */
  42814. private _getSceneSize;
  42815. /**
  42816. * Setup the ground according to the specified options.
  42817. */
  42818. private _setupGround;
  42819. /**
  42820. * Setup the ground material according to the specified options.
  42821. */
  42822. private _setupGroundMaterial;
  42823. /**
  42824. * Setup the ground diffuse texture according to the specified options.
  42825. */
  42826. private _setupGroundDiffuseTexture;
  42827. /**
  42828. * Setup the ground mirror texture according to the specified options.
  42829. */
  42830. private _setupGroundMirrorTexture;
  42831. /**
  42832. * Setup the ground to receive the mirror texture.
  42833. */
  42834. private _setupMirrorInGroundMaterial;
  42835. /**
  42836. * Setup the skybox according to the specified options.
  42837. */
  42838. private _setupSkybox;
  42839. /**
  42840. * Setup the skybox material according to the specified options.
  42841. */
  42842. private _setupSkyboxMaterial;
  42843. /**
  42844. * Setup the skybox reflection texture according to the specified options.
  42845. */
  42846. private _setupSkyboxReflectionTexture;
  42847. private _errorHandler;
  42848. /**
  42849. * Dispose all the elements created by the Helper.
  42850. */
  42851. dispose(): void;
  42852. }
  42853. }
  42854. declare module BABYLON {
  42855. /**
  42856. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  42857. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  42858. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  42859. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  42860. */
  42861. export class PhotoDome extends TransformNode {
  42862. private _useDirectMapping;
  42863. /**
  42864. * The texture being displayed on the sphere
  42865. */
  42866. protected _photoTexture: Texture;
  42867. /**
  42868. * Gets or sets the texture being displayed on the sphere
  42869. */
  42870. photoTexture: Texture;
  42871. /**
  42872. * Observable raised when an error occured while loading the 360 image
  42873. */
  42874. onLoadErrorObservable: Observable<string>;
  42875. /**
  42876. * The skybox material
  42877. */
  42878. protected _material: BackgroundMaterial;
  42879. /**
  42880. * The surface used for the skybox
  42881. */
  42882. protected _mesh: Mesh;
  42883. /**
  42884. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42885. * Also see the options.resolution property.
  42886. */
  42887. fovMultiplier: number;
  42888. /**
  42889. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  42890. * @param name Element's name, child elements will append suffixes for their own names.
  42891. * @param urlsOfPhoto defines the url of the photo to display
  42892. * @param options defines an object containing optional or exposed sub element properties
  42893. * @param onError defines a callback called when an error occured while loading the texture
  42894. */
  42895. constructor(name: string, urlOfPhoto: string, options: {
  42896. resolution?: number;
  42897. size?: number;
  42898. useDirectMapping?: boolean;
  42899. faceForward?: boolean;
  42900. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  42901. /**
  42902. * Releases resources associated with this node.
  42903. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  42904. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  42905. */
  42906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  42907. }
  42908. }
  42909. declare module BABYLON {
  42910. /**
  42911. * Class used to host texture specific utilities
  42912. */
  42913. export class BRDFTextureTools {
  42914. /**
  42915. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  42916. * @param texture the texture to expand.
  42917. */
  42918. private static _ExpandDefaultBRDFTexture;
  42919. /**
  42920. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  42921. * @param scene defines the hosting scene
  42922. * @returns the environment BRDF texture
  42923. */
  42924. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  42925. private static _environmentBRDFBase64Texture;
  42926. }
  42927. }
  42928. declare module BABYLON {
  42929. /**
  42930. * @hidden
  42931. */
  42932. export interface IMaterialClearCoatDefines {
  42933. CLEARCOAT: boolean;
  42934. CLEARCOAT_DEFAULTIOR: boolean;
  42935. CLEARCOAT_TEXTURE: boolean;
  42936. CLEARCOAT_TEXTUREDIRECTUV: number;
  42937. CLEARCOAT_BUMP: boolean;
  42938. CLEARCOAT_BUMPDIRECTUV: number;
  42939. CLEARCOAT_TINT: boolean;
  42940. CLEARCOAT_TINT_TEXTURE: boolean;
  42941. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  42942. /** @hidden */ areTexturesDirty: boolean;
  42943. }
  42944. /**
  42945. * Define the code related to the clear coat parameters of the pbr material.
  42946. */
  42947. export class PBRClearCoatConfiguration {
  42948. /**
  42949. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42950. * The default fits with a polyurethane material.
  42951. */
  42952. private static readonly _DefaultIndiceOfRefraction;
  42953. private _isEnabled;
  42954. /**
  42955. * Defines if the clear coat is enabled in the material.
  42956. */
  42957. isEnabled: boolean;
  42958. /**
  42959. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  42960. */
  42961. intensity: number;
  42962. /**
  42963. * Defines the clear coat layer roughness.
  42964. */
  42965. roughness: number;
  42966. private _indiceOfRefraction;
  42967. /**
  42968. * Defines the indice of refraction of the clear coat.
  42969. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  42970. * The default fits with a polyurethane material.
  42971. * Changing the default value is more performance intensive.
  42972. */
  42973. indiceOfRefraction: number;
  42974. private _texture;
  42975. /**
  42976. * Stores the clear coat values in a texture.
  42977. */
  42978. texture: Nullable<BaseTexture>;
  42979. private _bumpTexture;
  42980. /**
  42981. * Define the clear coat specific bump texture.
  42982. */
  42983. bumpTexture: Nullable<BaseTexture>;
  42984. private _isTintEnabled;
  42985. /**
  42986. * Defines if the clear coat tint is enabled in the material.
  42987. */
  42988. isTintEnabled: boolean;
  42989. /**
  42990. * Defines if the clear coat tint is enabled in the material.
  42991. * This is only use if tint is enabled
  42992. */
  42993. tintColor: Color3;
  42994. /**
  42995. * Defines if the distance at which the tint color should be found in the
  42996. * clear coat media.
  42997. * This is only use if tint is enabled
  42998. */
  42999. tintColorAtDistance: number;
  43000. /**
  43001. * Defines the clear coat layer thickness.
  43002. * This is only use if tint is enabled
  43003. */
  43004. tintThickness: number;
  43005. private _tintTexture;
  43006. /**
  43007. * Stores the clear tint values in a texture.
  43008. * rgb is tint
  43009. * a is a thickness factor
  43010. */
  43011. tintTexture: Nullable<BaseTexture>;
  43012. /** @hidden */
  43013. private _internalMarkAllSubMeshesAsTexturesDirty;
  43014. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43015. /**
  43016. * Instantiate a new istance of clear coat configuration.
  43017. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43018. */
  43019. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43020. /**
  43021. * Specifies that the submesh is ready to be used.
  43022. * @param defines the list of "defines" to update.
  43023. * @param scene defines the scene the material belongs to.
  43024. * @param engine defines the engine the material belongs to.
  43025. * @param disableBumpMap defines wether the material disables bump or not.
  43026. * @returns - boolean indicating that the submesh is ready or not.
  43027. */
  43028. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43029. /**
  43030. * Checks to see if a texture is used in the material.
  43031. * @param defines the list of "defines" to update.
  43032. * @param scene defines the scene to the material belongs to.
  43033. */
  43034. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43035. /**
  43036. * Binds the material data.
  43037. * @param uniformBuffer defines the Uniform buffer to fill in.
  43038. * @param scene defines the scene the material belongs to.
  43039. * @param engine defines the engine the material belongs to.
  43040. * @param disableBumpMap defines wether the material disables bump or not.
  43041. * @param isFrozen defines wether the material is frozen or not.
  43042. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43043. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43044. */
  43045. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43046. /**
  43047. * Checks to see if a texture is used in the material.
  43048. * @param texture - Base texture to use.
  43049. * @returns - Boolean specifying if a texture is used in the material.
  43050. */
  43051. hasTexture(texture: BaseTexture): boolean;
  43052. /**
  43053. * Returns an array of the actively used textures.
  43054. * @param activeTextures Array of BaseTextures
  43055. */
  43056. getActiveTextures(activeTextures: BaseTexture[]): void;
  43057. /**
  43058. * Returns the animatable textures.
  43059. * @param animatables Array of animatable textures.
  43060. */
  43061. getAnimatables(animatables: IAnimatable[]): void;
  43062. /**
  43063. * Disposes the resources of the material.
  43064. * @param forceDisposeTextures - Forces the disposal of all textures.
  43065. */
  43066. dispose(forceDisposeTextures?: boolean): void;
  43067. /**
  43068. * Get the current class name of the texture useful for serialization or dynamic coding.
  43069. * @returns "PBRClearCoatConfiguration"
  43070. */
  43071. getClassName(): string;
  43072. /**
  43073. * Add fallbacks to the effect fallbacks list.
  43074. * @param defines defines the Base texture to use.
  43075. * @param fallbacks defines the current fallback list.
  43076. * @param currentRank defines the current fallback rank.
  43077. * @returns the new fallback rank.
  43078. */
  43079. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43080. /**
  43081. * Add the required uniforms to the current list.
  43082. * @param uniforms defines the current uniform list.
  43083. */
  43084. static AddUniforms(uniforms: string[]): void;
  43085. /**
  43086. * Add the required samplers to the current list.
  43087. * @param samplers defines the current sampler list.
  43088. */
  43089. static AddSamplers(samplers: string[]): void;
  43090. /**
  43091. * Add the required uniforms to the current buffer.
  43092. * @param uniformBuffer defines the current uniform buffer.
  43093. */
  43094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43095. /**
  43096. * Makes a duplicate of the current configuration into another one.
  43097. * @param clearCoatConfiguration define the config where to copy the info
  43098. */
  43099. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43100. /**
  43101. * Serializes this clear coat configuration.
  43102. * @returns - An object with the serialized config.
  43103. */
  43104. serialize(): any;
  43105. /**
  43106. * Parses a Clear Coat Configuration from a serialized object.
  43107. * @param source - Serialized object.
  43108. */
  43109. parse(source: any): void;
  43110. }
  43111. }
  43112. declare module BABYLON {
  43113. /**
  43114. * @hidden
  43115. */
  43116. export interface IMaterialAnisotropicDefines {
  43117. ANISOTROPIC: boolean;
  43118. ANISOTROPIC_TEXTURE: boolean;
  43119. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43120. MAINUV1: boolean; areTexturesDirty: boolean; needUVs: boolean;
  43121. }
  43122. /**
  43123. * Define the code related to the anisotropic parameters of the pbr material.
  43124. */
  43125. export class PBRAnisotropicConfiguration {
  43126. private _isEnabled;
  43127. /**
  43128. * Defines if the anisotropy is enabled in the material.
  43129. */
  43130. isEnabled: boolean;
  43131. /**
  43132. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43133. */
  43134. intensity: number;
  43135. /**
  43136. * Defines if the effect is along the tangents, bitangents or in between.
  43137. * By default, the effect is "strectching" the highlights along the tangents.
  43138. */
  43139. direction: Vector2;
  43140. private _texture;
  43141. /**
  43142. * Stores the anisotropy values in a texture.
  43143. * rg is direction (like normal from -1 to 1)
  43144. * b is a intensity
  43145. */
  43146. texture: Nullable<BaseTexture>;
  43147. /** @hidden */
  43148. private _internalMarkAllSubMeshesAsTexturesDirty;
  43149. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43150. /**
  43151. * Instantiate a new istance of anisotropy configuration.
  43152. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43153. */
  43154. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43155. /**
  43156. * Specifies that the submesh is ready to be used.
  43157. * @param defines the list of "defines" to update.
  43158. * @param scene defines the scene the material belongs to.
  43159. * @returns - boolean indicating that the submesh is ready or not.
  43160. */
  43161. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43162. /**
  43163. * Checks to see if a texture is used in the material.
  43164. * @param defines the list of "defines" to update.
  43165. * @param mesh the mesh we are preparing the defines for.
  43166. * @param scene defines the scene the material belongs to.
  43167. */
  43168. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43169. /**
  43170. * Binds the material data.
  43171. * @param uniformBuffer defines the Uniform buffer to fill in.
  43172. * @param scene defines the scene the material belongs to.
  43173. * @param isFrozen defines wether the material is frozen or not.
  43174. */
  43175. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43176. /**
  43177. * Checks to see if a texture is used in the material.
  43178. * @param texture - Base texture to use.
  43179. * @returns - Boolean specifying if a texture is used in the material.
  43180. */
  43181. hasTexture(texture: BaseTexture): boolean;
  43182. /**
  43183. * Returns an array of the actively used textures.
  43184. * @param activeTextures Array of BaseTextures
  43185. */
  43186. getActiveTextures(activeTextures: BaseTexture[]): void;
  43187. /**
  43188. * Returns the animatable textures.
  43189. * @param animatables Array of animatable textures.
  43190. */
  43191. getAnimatables(animatables: IAnimatable[]): void;
  43192. /**
  43193. * Disposes the resources of the material.
  43194. * @param forceDisposeTextures - Forces the disposal of all textures.
  43195. */
  43196. dispose(forceDisposeTextures?: boolean): void;
  43197. /**
  43198. * Get the current class name of the texture useful for serialization or dynamic coding.
  43199. * @returns "PBRAnisotropicConfiguration"
  43200. */
  43201. getClassName(): string;
  43202. /**
  43203. * Add fallbacks to the effect fallbacks list.
  43204. * @param defines defines the Base texture to use.
  43205. * @param fallbacks defines the current fallback list.
  43206. * @param currentRank defines the current fallback rank.
  43207. * @returns the new fallback rank.
  43208. */
  43209. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43210. /**
  43211. * Add the required uniforms to the current list.
  43212. * @param uniforms defines the current uniform list.
  43213. */
  43214. static AddUniforms(uniforms: string[]): void;
  43215. /**
  43216. * Add the required uniforms to the current buffer.
  43217. * @param uniformBuffer defines the current uniform buffer.
  43218. */
  43219. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43220. /**
  43221. * Add the required samplers to the current list.
  43222. * @param samplers defines the current sampler list.
  43223. */
  43224. static AddSamplers(samplers: string[]): void;
  43225. /**
  43226. * Makes a duplicate of the current configuration into another one.
  43227. * @param anisotropicConfiguration define the config where to copy the info
  43228. */
  43229. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43230. /**
  43231. * Serializes this anisotropy configuration.
  43232. * @returns - An object with the serialized config.
  43233. */
  43234. serialize(): any;
  43235. /**
  43236. * Parses a anisotropy Configuration from a serialized object.
  43237. * @param source - Serialized object.
  43238. */
  43239. parse(source: any): void;
  43240. }
  43241. }
  43242. declare module BABYLON {
  43243. /**
  43244. * @hidden
  43245. */
  43246. export interface IMaterialBRDFDefines {
  43247. BRDF_V_HEIGHT_CORRELATED: boolean;
  43248. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43249. /** @hidden */ areMiscDirty: boolean;
  43250. }
  43251. /**
  43252. * Define the code related to the BRDF parameters of the pbr material.
  43253. */
  43254. export class PBRBRDFConfiguration {
  43255. /**
  43256. * Default value used for the energy conservation.
  43257. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43258. */
  43259. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43260. /**
  43261. * Default value used for the Smith Visibility Height Correlated mode.
  43262. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43263. */
  43264. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43265. private _useEnergyConservation;
  43266. /**
  43267. * Defines if the material uses energy conservation.
  43268. */
  43269. useEnergyConservation: boolean;
  43270. private _useSmithVisibilityHeightCorrelated;
  43271. /**
  43272. * LEGACY Mode set to false
  43273. * Defines if the material uses height smith correlated visibility term.
  43274. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43275. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43276. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43277. * Not relying on height correlated will also disable energy conservation.
  43278. */
  43279. useSmithVisibilityHeightCorrelated: boolean;
  43280. /** @hidden */
  43281. private _internalMarkAllSubMeshesAsMiscDirty;
  43282. /** @hidden */ markAllSubMeshesAsMiscDirty(): void;
  43283. /**
  43284. * Instantiate a new istance of clear coat configuration.
  43285. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43286. */
  43287. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43288. /**
  43289. * Checks to see if a texture is used in the material.
  43290. * @param defines the list of "defines" to update.
  43291. */
  43292. prepareDefines(defines: IMaterialBRDFDefines): void;
  43293. /**
  43294. * Get the current class name of the texture useful for serialization or dynamic coding.
  43295. * @returns "PBRClearCoatConfiguration"
  43296. */
  43297. getClassName(): string;
  43298. /**
  43299. * Makes a duplicate of the current configuration into another one.
  43300. * @param brdfConfiguration define the config where to copy the info
  43301. */
  43302. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43303. /**
  43304. * Serializes this BRDF configuration.
  43305. * @returns - An object with the serialized config.
  43306. */
  43307. serialize(): any;
  43308. /**
  43309. * Parses a BRDF Configuration from a serialized object.
  43310. * @param source - Serialized object.
  43311. */
  43312. parse(source: any): void;
  43313. }
  43314. }
  43315. declare module BABYLON {
  43316. /**
  43317. * @hidden
  43318. */
  43319. export interface IMaterialSheenDefines {
  43320. SHEEN: boolean;
  43321. SHEEN_TEXTURE: boolean;
  43322. SHEEN_TEXTUREDIRECTUV: number;
  43323. SHEEN_LINKWITHALBEDO: boolean;
  43324. /** @hidden */ areTexturesDirty: boolean;
  43325. }
  43326. /**
  43327. * Define the code related to the Sheen parameters of the pbr material.
  43328. */
  43329. export class PBRSheenConfiguration {
  43330. private _isEnabled;
  43331. /**
  43332. * Defines if the material uses sheen.
  43333. */
  43334. isEnabled: boolean;
  43335. private _linkSheenWithAlbedo;
  43336. /**
  43337. * Defines if the sheen is linked to the sheen color.
  43338. */
  43339. linkSheenWithAlbedo: boolean;
  43340. /**
  43341. * Defines the sheen intensity.
  43342. */
  43343. intensity: number;
  43344. /**
  43345. * Defines the sheen color.
  43346. */
  43347. color: Color3;
  43348. private _texture;
  43349. /**
  43350. * Stores the sheen tint values in a texture.
  43351. * rgb is tint
  43352. * a is a intensity
  43353. */
  43354. texture: Nullable<BaseTexture>;
  43355. /** @hidden */
  43356. private _internalMarkAllSubMeshesAsTexturesDirty;
  43357. /** @hidden */ markAllSubMeshesAsTexturesDirty(): void;
  43358. /**
  43359. * Instantiate a new istance of clear coat configuration.
  43360. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43361. */
  43362. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43363. /**
  43364. * Specifies that the submesh is ready to be used.
  43365. * @param defines the list of "defines" to update.
  43366. * @param scene defines the scene the material belongs to.
  43367. * @returns - boolean indicating that the submesh is ready or not.
  43368. */
  43369. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43370. /**
  43371. * Checks to see if a texture is used in the material.
  43372. * @param defines the list of "defines" to update.
  43373. * @param scene defines the scene the material belongs to.
  43374. */
  43375. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43376. /**
  43377. * Binds the material data.
  43378. * @param uniformBuffer defines the Uniform buffer to fill in.
  43379. * @param scene defines the scene the material belongs to.
  43380. * @param isFrozen defines wether the material is frozen or not.
  43381. */
  43382. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43383. /**
  43384. * Checks to see if a texture is used in the material.
  43385. * @param texture - Base texture to use.
  43386. * @returns - Boolean specifying if a texture is used in the material.
  43387. */
  43388. hasTexture(texture: BaseTexture): boolean;
  43389. /**
  43390. * Returns an array of the actively used textures.
  43391. * @param activeTextures Array of BaseTextures
  43392. */
  43393. getActiveTextures(activeTextures: BaseTexture[]): void;
  43394. /**
  43395. * Returns the animatable textures.
  43396. * @param animatables Array of animatable textures.
  43397. */
  43398. getAnimatables(animatables: IAnimatable[]): void;
  43399. /**
  43400. * Disposes the resources of the material.
  43401. * @param forceDisposeTextures - Forces the disposal of all textures.
  43402. */
  43403. dispose(forceDisposeTextures?: boolean): void;
  43404. /**
  43405. * Get the current class name of the texture useful for serialization or dynamic coding.
  43406. * @returns "PBRSheenConfiguration"
  43407. */
  43408. getClassName(): string;
  43409. /**
  43410. * Add fallbacks to the effect fallbacks list.
  43411. * @param defines defines the Base texture to use.
  43412. * @param fallbacks defines the current fallback list.
  43413. * @param currentRank defines the current fallback rank.
  43414. * @returns the new fallback rank.
  43415. */
  43416. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43417. /**
  43418. * Add the required uniforms to the current list.
  43419. * @param uniforms defines the current uniform list.
  43420. */
  43421. static AddUniforms(uniforms: string[]): void;
  43422. /**
  43423. * Add the required uniforms to the current buffer.
  43424. * @param uniformBuffer defines the current uniform buffer.
  43425. */
  43426. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43427. /**
  43428. * Add the required samplers to the current list.
  43429. * @param samplers defines the current sampler list.
  43430. */
  43431. static AddSamplers(samplers: string[]): void;
  43432. /**
  43433. * Makes a duplicate of the current configuration into another one.
  43434. * @param sheenConfiguration define the config where to copy the info
  43435. */
  43436. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43437. /**
  43438. * Serializes this BRDF configuration.
  43439. * @returns - An object with the serialized config.
  43440. */
  43441. serialize(): any;
  43442. /**
  43443. * Parses a Sheen Configuration from a serialized object.
  43444. * @param source - Serialized object.
  43445. */
  43446. parse(source: any): void;
  43447. }
  43448. }
  43449. declare module BABYLON {
  43450. /** @hidden */
  43451. export var pbrFragmentDeclaration: {
  43452. name: string;
  43453. shader: string;
  43454. };
  43455. }
  43456. declare module BABYLON {
  43457. /** @hidden */
  43458. export var pbrUboDeclaration: {
  43459. name: string;
  43460. shader: string;
  43461. };
  43462. }
  43463. declare module BABYLON {
  43464. /** @hidden */
  43465. export var pbrFragmentExtraDeclaration: {
  43466. name: string;
  43467. shader: string;
  43468. };
  43469. }
  43470. declare module BABYLON {
  43471. /** @hidden */
  43472. export var pbrFragmentSamplersDeclaration: {
  43473. name: string;
  43474. shader: string;
  43475. };
  43476. }
  43477. declare module BABYLON {
  43478. /** @hidden */
  43479. export var pbrHelperFunctions: {
  43480. name: string;
  43481. shader: string;
  43482. };
  43483. }
  43484. declare module BABYLON {
  43485. /** @hidden */
  43486. export var harmonicsFunctions: {
  43487. name: string;
  43488. shader: string;
  43489. };
  43490. }
  43491. declare module BABYLON {
  43492. /** @hidden */
  43493. export var pbrDirectLightingSetupFunctions: {
  43494. name: string;
  43495. shader: string;
  43496. };
  43497. }
  43498. declare module BABYLON {
  43499. /** @hidden */
  43500. export var pbrDirectLightingFalloffFunctions: {
  43501. name: string;
  43502. shader: string;
  43503. };
  43504. }
  43505. declare module BABYLON {
  43506. /** @hidden */
  43507. export var pbrBRDFFunctions: {
  43508. name: string;
  43509. shader: string;
  43510. };
  43511. }
  43512. declare module BABYLON {
  43513. /** @hidden */
  43514. export var pbrDirectLightingFunctions: {
  43515. name: string;
  43516. shader: string;
  43517. };
  43518. }
  43519. declare module BABYLON {
  43520. /** @hidden */
  43521. export var pbrIBLFunctions: {
  43522. name: string;
  43523. shader: string;
  43524. };
  43525. }
  43526. declare module BABYLON {
  43527. /** @hidden */
  43528. export var pbrDebug: {
  43529. name: string;
  43530. shader: string;
  43531. };
  43532. }
  43533. declare module BABYLON {
  43534. /** @hidden */
  43535. export var pbrPixelShader: {
  43536. name: string;
  43537. shader: string;
  43538. };
  43539. }
  43540. declare module BABYLON {
  43541. /** @hidden */
  43542. export var pbrVertexDeclaration: {
  43543. name: string;
  43544. shader: string;
  43545. };
  43546. }
  43547. declare module BABYLON {
  43548. /** @hidden */
  43549. export var pbrVertexShader: {
  43550. name: string;
  43551. shader: string;
  43552. };
  43553. }
  43554. declare module BABYLON {
  43555. /**
  43556. * Manages the defines for the PBR Material.
  43557. * @hidden
  43558. */
  43559. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines {
  43560. PBR: boolean;
  43561. MAINUV1: boolean;
  43562. MAINUV2: boolean;
  43563. UV1: boolean;
  43564. UV2: boolean;
  43565. ALBEDO: boolean;
  43566. ALBEDODIRECTUV: number;
  43567. VERTEXCOLOR: boolean;
  43568. AMBIENT: boolean;
  43569. AMBIENTDIRECTUV: number;
  43570. AMBIENTINGRAYSCALE: boolean;
  43571. OPACITY: boolean;
  43572. VERTEXALPHA: boolean;
  43573. OPACITYDIRECTUV: number;
  43574. OPACITYRGB: boolean;
  43575. ALPHATEST: boolean;
  43576. DEPTHPREPASS: boolean;
  43577. ALPHABLEND: boolean;
  43578. ALPHAFROMALBEDO: boolean;
  43579. ALPHATESTVALUE: string;
  43580. SPECULAROVERALPHA: boolean;
  43581. RADIANCEOVERALPHA: boolean;
  43582. ALPHAFRESNEL: boolean;
  43583. LINEARALPHAFRESNEL: boolean;
  43584. PREMULTIPLYALPHA: boolean;
  43585. EMISSIVE: boolean;
  43586. EMISSIVEDIRECTUV: number;
  43587. REFLECTIVITY: boolean;
  43588. REFLECTIVITYDIRECTUV: number;
  43589. SPECULARTERM: boolean;
  43590. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  43591. MICROSURFACEAUTOMATIC: boolean;
  43592. LODBASEDMICROSFURACE: boolean;
  43593. MICROSURFACEMAP: boolean;
  43594. MICROSURFACEMAPDIRECTUV: number;
  43595. METALLICWORKFLOW: boolean;
  43596. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  43597. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  43598. METALLNESSSTOREINMETALMAPBLUE: boolean;
  43599. AOSTOREINMETALMAPRED: boolean;
  43600. ENVIRONMENTBRDF: boolean;
  43601. ENVIRONMENTBRDF_RGBD: boolean;
  43602. NORMAL: boolean;
  43603. TANGENT: boolean;
  43604. BUMP: boolean;
  43605. BUMPDIRECTUV: number;
  43606. OBJECTSPACE_NORMALMAP: boolean;
  43607. PARALLAX: boolean;
  43608. PARALLAXOCCLUSION: boolean;
  43609. NORMALXYSCALE: boolean;
  43610. LIGHTMAP: boolean;
  43611. LIGHTMAPDIRECTUV: number;
  43612. USELIGHTMAPASSHADOWMAP: boolean;
  43613. GAMMALIGHTMAP: boolean;
  43614. REFLECTION: boolean;
  43615. REFLECTIONMAP_3D: boolean;
  43616. REFLECTIONMAP_SPHERICAL: boolean;
  43617. REFLECTIONMAP_PLANAR: boolean;
  43618. REFLECTIONMAP_CUBIC: boolean;
  43619. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  43620. REFLECTIONMAP_PROJECTION: boolean;
  43621. REFLECTIONMAP_SKYBOX: boolean;
  43622. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  43623. REFLECTIONMAP_EXPLICIT: boolean;
  43624. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  43625. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  43626. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  43627. INVERTCUBICMAP: boolean;
  43628. USESPHERICALFROMREFLECTIONMAP: boolean;
  43629. USESPHERICALINVERTEX: boolean;
  43630. REFLECTIONMAP_OPPOSITEZ: boolean;
  43631. LODINREFLECTIONALPHA: boolean;
  43632. GAMMAREFLECTION: boolean;
  43633. RGBDREFLECTION: boolean;
  43634. RADIANCEOCCLUSION: boolean;
  43635. HORIZONOCCLUSION: boolean;
  43636. REFRACTION: boolean;
  43637. REFRACTIONMAP_3D: boolean;
  43638. REFRACTIONMAP_OPPOSITEZ: boolean;
  43639. LODINREFRACTIONALPHA: boolean;
  43640. GAMMAREFRACTION: boolean;
  43641. RGBDREFRACTION: boolean;
  43642. LINKREFRACTIONTOTRANSPARENCY: boolean;
  43643. INSTANCES: boolean;
  43644. NUM_BONE_INFLUENCERS: number;
  43645. BonesPerMesh: number;
  43646. BONETEXTURE: boolean;
  43647. NONUNIFORMSCALING: boolean;
  43648. MORPHTARGETS: boolean;
  43649. MORPHTARGETS_NORMAL: boolean;
  43650. MORPHTARGETS_TANGENT: boolean;
  43651. NUM_MORPH_INFLUENCERS: number;
  43652. IMAGEPROCESSING: boolean;
  43653. VIGNETTE: boolean;
  43654. VIGNETTEBLENDMODEMULTIPLY: boolean;
  43655. VIGNETTEBLENDMODEOPAQUE: boolean;
  43656. TONEMAPPING: boolean;
  43657. TONEMAPPING_ACES: boolean;
  43658. CONTRAST: boolean;
  43659. COLORCURVES: boolean;
  43660. COLORGRADING: boolean;
  43661. COLORGRADING3D: boolean;
  43662. SAMPLER3DGREENDEPTH: boolean;
  43663. SAMPLER3DBGRMAP: boolean;
  43664. IMAGEPROCESSINGPOSTPROCESS: boolean;
  43665. EXPOSURE: boolean;
  43666. MULTIVIEW: boolean;
  43667. USEPHYSICALLIGHTFALLOFF: boolean;
  43668. USEGLTFLIGHTFALLOFF: boolean;
  43669. TWOSIDEDLIGHTING: boolean;
  43670. SHADOWFLOAT: boolean;
  43671. CLIPPLANE: boolean;
  43672. CLIPPLANE2: boolean;
  43673. CLIPPLANE3: boolean;
  43674. CLIPPLANE4: boolean;
  43675. POINTSIZE: boolean;
  43676. FOG: boolean;
  43677. LOGARITHMICDEPTH: boolean;
  43678. FORCENORMALFORWARD: boolean;
  43679. SPECULARAA: boolean;
  43680. CLEARCOAT: boolean;
  43681. CLEARCOAT_DEFAULTIOR: boolean;
  43682. CLEARCOAT_TEXTURE: boolean;
  43683. CLEARCOAT_TEXTUREDIRECTUV: number;
  43684. CLEARCOAT_BUMP: boolean;
  43685. CLEARCOAT_BUMPDIRECTUV: number;
  43686. CLEARCOAT_TINT: boolean;
  43687. CLEARCOAT_TINT_TEXTURE: boolean;
  43688. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43689. ANISOTROPIC: boolean;
  43690. ANISOTROPIC_TEXTURE: boolean;
  43691. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43692. BRDF_V_HEIGHT_CORRELATED: boolean;
  43693. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43694. SHEEN: boolean;
  43695. SHEEN_TEXTURE: boolean;
  43696. SHEEN_TEXTUREDIRECTUV: number;
  43697. SHEEN_LINKWITHALBEDO: boolean;
  43698. UNLIT: boolean;
  43699. DEBUGMODE: number;
  43700. /**
  43701. * Initializes the PBR Material defines.
  43702. */
  43703. constructor();
  43704. /**
  43705. * Resets the PBR Material defines.
  43706. */
  43707. reset(): void;
  43708. }
  43709. /**
  43710. * The Physically based material base class of BJS.
  43711. *
  43712. * This offers the main features of a standard PBR material.
  43713. * For more information, please refer to the documentation :
  43714. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  43715. */
  43716. export abstract class PBRBaseMaterial extends PushMaterial {
  43717. /**
  43718. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  43719. */
  43720. static readonly PBRMATERIAL_OPAQUE: number;
  43721. /**
  43722. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  43723. */
  43724. static readonly PBRMATERIAL_ALPHATEST: number;
  43725. /**
  43726. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43727. */
  43728. static readonly PBRMATERIAL_ALPHABLEND: number;
  43729. /**
  43730. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  43731. * They are also discarded below the alpha cutoff threshold to improve performances.
  43732. */
  43733. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  43734. /**
  43735. * Defines the default value of how much AO map is occluding the analytical lights
  43736. * (point spot...).
  43737. */
  43738. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  43739. /**
  43740. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  43741. */
  43742. static readonly LIGHTFALLOFF_PHYSICAL: number;
  43743. /**
  43744. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  43745. * to enhance interoperability with other engines.
  43746. */
  43747. static readonly LIGHTFALLOFF_GLTF: number;
  43748. /**
  43749. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  43750. * to enhance interoperability with other materials.
  43751. */
  43752. static readonly LIGHTFALLOFF_STANDARD: number;
  43753. /**
  43754. * Intensity of the direct lights e.g. the four lights available in your scene.
  43755. * This impacts both the direct diffuse and specular highlights.
  43756. */
  43757. protected _directIntensity: number;
  43758. /**
  43759. * Intensity of the emissive part of the material.
  43760. * This helps controlling the emissive effect without modifying the emissive color.
  43761. */
  43762. protected _emissiveIntensity: number;
  43763. /**
  43764. * Intensity of the environment e.g. how much the environment will light the object
  43765. * either through harmonics for rough material or through the refelction for shiny ones.
  43766. */
  43767. protected _environmentIntensity: number;
  43768. /**
  43769. * This is a special control allowing the reduction of the specular highlights coming from the
  43770. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  43771. */
  43772. protected _specularIntensity: number;
  43773. /**
  43774. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  43775. */
  43776. private _lightingInfos;
  43777. /**
  43778. * Debug Control allowing disabling the bump map on this material.
  43779. */
  43780. protected _disableBumpMap: boolean;
  43781. /**
  43782. * AKA Diffuse Texture in standard nomenclature.
  43783. */
  43784. protected _albedoTexture: BaseTexture;
  43785. /**
  43786. * AKA Occlusion Texture in other nomenclature.
  43787. */
  43788. protected _ambientTexture: BaseTexture;
  43789. /**
  43790. * AKA Occlusion Texture Intensity in other nomenclature.
  43791. */
  43792. protected _ambientTextureStrength: number;
  43793. /**
  43794. * Defines how much the AO map is occluding the analytical lights (point spot...).
  43795. * 1 means it completely occludes it
  43796. * 0 mean it has no impact
  43797. */
  43798. protected _ambientTextureImpactOnAnalyticalLights: number;
  43799. /**
  43800. * Stores the alpha values in a texture.
  43801. */
  43802. protected _opacityTexture: BaseTexture;
  43803. /**
  43804. * Stores the reflection values in a texture.
  43805. */
  43806. protected _reflectionTexture: BaseTexture;
  43807. /**
  43808. * Stores the refraction values in a texture.
  43809. */
  43810. protected _refractionTexture: BaseTexture;
  43811. /**
  43812. * Stores the emissive values in a texture.
  43813. */
  43814. protected _emissiveTexture: BaseTexture;
  43815. /**
  43816. * AKA Specular texture in other nomenclature.
  43817. */
  43818. protected _reflectivityTexture: BaseTexture;
  43819. /**
  43820. * Used to switch from specular/glossiness to metallic/roughness workflow.
  43821. */
  43822. protected _metallicTexture: BaseTexture;
  43823. /**
  43824. * Specifies the metallic scalar of the metallic/roughness workflow.
  43825. * Can also be used to scale the metalness values of the metallic texture.
  43826. */
  43827. protected _metallic: Nullable<number>;
  43828. /**
  43829. * Specifies the roughness scalar of the metallic/roughness workflow.
  43830. * Can also be used to scale the roughness values of the metallic texture.
  43831. */
  43832. protected _roughness: Nullable<number>;
  43833. /**
  43834. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  43835. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  43836. */
  43837. protected _microSurfaceTexture: BaseTexture;
  43838. /**
  43839. * Stores surface normal data used to displace a mesh in a texture.
  43840. */
  43841. protected _bumpTexture: BaseTexture;
  43842. /**
  43843. * Stores the pre-calculated light information of a mesh in a texture.
  43844. */
  43845. protected _lightmapTexture: BaseTexture;
  43846. /**
  43847. * The color of a material in ambient lighting.
  43848. */
  43849. protected _ambientColor: Color3;
  43850. /**
  43851. * AKA Diffuse Color in other nomenclature.
  43852. */
  43853. protected _albedoColor: Color3;
  43854. /**
  43855. * AKA Specular Color in other nomenclature.
  43856. */
  43857. protected _reflectivityColor: Color3;
  43858. /**
  43859. * The color applied when light is reflected from a material.
  43860. */
  43861. protected _reflectionColor: Color3;
  43862. /**
  43863. * The color applied when light is emitted from a material.
  43864. */
  43865. protected _emissiveColor: Color3;
  43866. /**
  43867. * AKA Glossiness in other nomenclature.
  43868. */
  43869. protected _microSurface: number;
  43870. /**
  43871. * source material index of refraction (IOR)' / 'destination material IOR.
  43872. */
  43873. protected _indexOfRefraction: number;
  43874. /**
  43875. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43876. */
  43877. protected _invertRefractionY: boolean;
  43878. /**
  43879. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43880. * Materials half opaque for instance using refraction could benefit from this control.
  43881. */
  43882. protected _linkRefractionWithTransparency: boolean;
  43883. /**
  43884. * Specifies that the material will use the light map as a show map.
  43885. */
  43886. protected _useLightmapAsShadowmap: boolean;
  43887. /**
  43888. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  43889. * makes the reflect vector face the model (under horizon).
  43890. */
  43891. protected _useHorizonOcclusion: boolean;
  43892. /**
  43893. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  43894. * too much the area relying on ambient texture to define their ambient occlusion.
  43895. */
  43896. protected _useRadianceOcclusion: boolean;
  43897. /**
  43898. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  43899. */
  43900. protected _useAlphaFromAlbedoTexture: boolean;
  43901. /**
  43902. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  43903. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  43904. */
  43905. protected _useSpecularOverAlpha: boolean;
  43906. /**
  43907. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  43908. */
  43909. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  43910. /**
  43911. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  43912. */
  43913. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  43914. /**
  43915. * Specifies if the metallic texture contains the roughness information in its green channel.
  43916. */
  43917. protected _useRoughnessFromMetallicTextureGreen: boolean;
  43918. /**
  43919. * Specifies if the metallic texture contains the metallness information in its blue channel.
  43920. */
  43921. protected _useMetallnessFromMetallicTextureBlue: boolean;
  43922. /**
  43923. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  43924. */
  43925. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  43926. /**
  43927. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  43928. */
  43929. protected _useAmbientInGrayScale: boolean;
  43930. /**
  43931. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  43932. * The material will try to infer what glossiness each pixel should be.
  43933. */
  43934. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  43935. /**
  43936. * Defines the falloff type used in this material.
  43937. * It by default is Physical.
  43938. */
  43939. protected _lightFalloff: number;
  43940. /**
  43941. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  43942. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  43943. */
  43944. protected _useRadianceOverAlpha: boolean;
  43945. /**
  43946. * Allows using an object space normal map (instead of tangent space).
  43947. */
  43948. protected _useObjectSpaceNormalMap: boolean;
  43949. /**
  43950. * Allows using the bump map in parallax mode.
  43951. */
  43952. protected _useParallax: boolean;
  43953. /**
  43954. * Allows using the bump map in parallax occlusion mode.
  43955. */
  43956. protected _useParallaxOcclusion: boolean;
  43957. /**
  43958. * Controls the scale bias of the parallax mode.
  43959. */
  43960. protected _parallaxScaleBias: number;
  43961. /**
  43962. * If sets to true, disables all the lights affecting the material.
  43963. */
  43964. protected _disableLighting: boolean;
  43965. /**
  43966. * Number of Simultaneous lights allowed on the material.
  43967. */
  43968. protected _maxSimultaneousLights: number;
  43969. /**
  43970. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43971. */
  43972. protected _invertNormalMapX: boolean;
  43973. /**
  43974. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43975. */
  43976. protected _invertNormalMapY: boolean;
  43977. /**
  43978. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  43979. */
  43980. protected _twoSidedLighting: boolean;
  43981. /**
  43982. * Defines the alpha limits in alpha test mode.
  43983. */
  43984. protected _alphaCutOff: number;
  43985. /**
  43986. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  43987. */
  43988. protected _forceAlphaTest: boolean;
  43989. /**
  43990. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43991. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  43992. */
  43993. protected _useAlphaFresnel: boolean;
  43994. /**
  43995. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  43996. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  43997. */
  43998. protected _useLinearAlphaFresnel: boolean;
  43999. /**
  44000. * The transparency mode of the material.
  44001. */
  44002. protected _transparencyMode: Nullable<number>;
  44003. /**
  44004. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44005. * from cos thetav and roughness:
  44006. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44007. */
  44008. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44009. /**
  44010. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44011. */
  44012. protected _forceIrradianceInFragment: boolean;
  44013. /**
  44014. * Force normal to face away from face.
  44015. */
  44016. protected _forceNormalForward: boolean;
  44017. /**
  44018. * Enables specular anti aliasing in the PBR shader.
  44019. * It will both interacts on the Geometry for analytical and IBL lighting.
  44020. * It also prefilter the roughness map based on the bump values.
  44021. */
  44022. protected _enableSpecularAntiAliasing: boolean;
  44023. /**
  44024. * Default configuration related to image processing available in the PBR Material.
  44025. */
  44026. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44027. /**
  44028. * Keep track of the image processing observer to allow dispose and replace.
  44029. */
  44030. private _imageProcessingObserver;
  44031. /**
  44032. * Attaches a new image processing configuration to the PBR Material.
  44033. * @param configuration
  44034. */
  44035. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44036. /**
  44037. * Stores the available render targets.
  44038. */
  44039. private _renderTargets;
  44040. /**
  44041. * Sets the global ambient color for the material used in lighting calculations.
  44042. */
  44043. private _globalAmbientColor;
  44044. /**
  44045. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44046. */
  44047. private _useLogarithmicDepth;
  44048. /**
  44049. * If set to true, no lighting calculations will be applied.
  44050. */
  44051. private _unlit;
  44052. private _debugMode;
  44053. /**
  44054. * @hidden
  44055. * This is reserved for the inspector.
  44056. * Defines the material debug mode.
  44057. * It helps seeing only some components of the material while troubleshooting.
  44058. */
  44059. debugMode: number;
  44060. /**
  44061. * @hidden
  44062. * This is reserved for the inspector.
  44063. * Specify from where on screen the debug mode should start.
  44064. * The value goes from -1 (full screen) to 1 (not visible)
  44065. * It helps with side by side comparison against the final render
  44066. * This defaults to -1
  44067. */
  44068. private debugLimit;
  44069. /**
  44070. * @hidden
  44071. * This is reserved for the inspector.
  44072. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44073. * You can use the factor to better multiply the final value.
  44074. */
  44075. private debugFactor;
  44076. /**
  44077. * Defines the clear coat layer parameters for the material.
  44078. */
  44079. readonly clearCoat: PBRClearCoatConfiguration;
  44080. /**
  44081. * Defines the anisotropic parameters for the material.
  44082. */
  44083. readonly anisotropy: PBRAnisotropicConfiguration;
  44084. /**
  44085. * Defines the BRDF parameters for the material.
  44086. */
  44087. readonly brdf: PBRBRDFConfiguration;
  44088. /**
  44089. * Defines the Sheen parameters for the material.
  44090. */
  44091. readonly sheen: PBRSheenConfiguration;
  44092. /**
  44093. * Custom callback helping to override the default shader used in the material.
  44094. */
  44095. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44096. /**
  44097. * Instantiates a new PBRMaterial instance.
  44098. *
  44099. * @param name The material name
  44100. * @param scene The scene the material will be use in.
  44101. */
  44102. constructor(name: string, scene: Scene);
  44103. /**
  44104. * Gets a boolean indicating that current material needs to register RTT
  44105. */
  44106. readonly hasRenderTargetTextures: boolean;
  44107. /**
  44108. * Gets the name of the material class.
  44109. */
  44110. getClassName(): string;
  44111. /**
  44112. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44113. */
  44114. /**
  44115. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44116. */
  44117. useLogarithmicDepth: boolean;
  44118. /**
  44119. * Gets the current transparency mode.
  44120. */
  44121. /**
  44122. * Sets the transparency mode of the material.
  44123. *
  44124. * | Value | Type | Description |
  44125. * | ----- | ----------------------------------- | ----------- |
  44126. * | 0 | OPAQUE | |
  44127. * | 1 | ALPHATEST | |
  44128. * | 2 | ALPHABLEND | |
  44129. * | 3 | ALPHATESTANDBLEND | |
  44130. *
  44131. */
  44132. transparencyMode: Nullable<number>;
  44133. /**
  44134. * Returns true if alpha blending should be disabled.
  44135. */
  44136. private readonly _disableAlphaBlending;
  44137. /**
  44138. * Specifies whether or not this material should be rendered in alpha blend mode.
  44139. */
  44140. needAlphaBlending(): boolean;
  44141. /**
  44142. * Specifies if the mesh will require alpha blending.
  44143. * @param mesh - BJS mesh.
  44144. */
  44145. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44146. /**
  44147. * Specifies whether or not this material should be rendered in alpha test mode.
  44148. */
  44149. needAlphaTesting(): boolean;
  44150. /**
  44151. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44152. */
  44153. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44154. /**
  44155. * Gets the texture used for the alpha test.
  44156. */
  44157. getAlphaTestTexture(): BaseTexture;
  44158. /**
  44159. * Specifies that the submesh is ready to be used.
  44160. * @param mesh - BJS mesh.
  44161. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44162. * @param useInstances - Specifies that instances should be used.
  44163. * @returns - boolean indicating that the submesh is ready or not.
  44164. */
  44165. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44166. /**
  44167. * Specifies if the material uses metallic roughness workflow.
  44168. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44169. */
  44170. isMetallicWorkflow(): boolean;
  44171. private _prepareEffect;
  44172. private _prepareDefines;
  44173. /**
  44174. * Force shader compilation
  44175. */
  44176. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44177. clipPlane: boolean;
  44178. }>): void;
  44179. /**
  44180. * Initializes the uniform buffer layout for the shader.
  44181. */
  44182. buildUniformLayout(): void;
  44183. /**
  44184. * Unbinds the textures.
  44185. */
  44186. unbind(): void;
  44187. /**
  44188. * Binds the submesh data.
  44189. * @param world - The world matrix.
  44190. * @param mesh - The BJS mesh.
  44191. * @param subMesh - A submesh of the BJS mesh.
  44192. */
  44193. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44194. /**
  44195. * Returns the animatable textures.
  44196. * @returns - Array of animatable textures.
  44197. */
  44198. getAnimatables(): IAnimatable[];
  44199. /**
  44200. * Returns the texture used for reflections.
  44201. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44202. */
  44203. private _getReflectionTexture;
  44204. /**
  44205. * Returns the texture used for refraction or null if none is used.
  44206. * @returns - Refection texture if present. If no refraction texture and refraction
  44207. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44208. */
  44209. private _getRefractionTexture;
  44210. /**
  44211. * Returns an array of the actively used textures.
  44212. * @returns - Array of BaseTextures
  44213. */
  44214. getActiveTextures(): BaseTexture[];
  44215. /**
  44216. * Checks to see if a texture is used in the material.
  44217. * @param texture - Base texture to use.
  44218. * @returns - Boolean specifying if a texture is used in the material.
  44219. */
  44220. hasTexture(texture: BaseTexture): boolean;
  44221. /**
  44222. * Disposes the resources of the material.
  44223. * @param forceDisposeEffect - Forces the disposal of effects.
  44224. * @param forceDisposeTextures - Forces the disposal of all textures.
  44225. */
  44226. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44227. }
  44228. }
  44229. declare module BABYLON {
  44230. /**
  44231. * The Physically based material of BJS.
  44232. *
  44233. * This offers the main features of a standard PBR material.
  44234. * For more information, please refer to the documentation :
  44235. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  44236. */
  44237. export class PBRMaterial extends PBRBaseMaterial {
  44238. /**
  44239. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44240. */
  44241. static readonly PBRMATERIAL_OPAQUE: number;
  44242. /**
  44243. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44244. */
  44245. static readonly PBRMATERIAL_ALPHATEST: number;
  44246. /**
  44247. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44248. */
  44249. static readonly PBRMATERIAL_ALPHABLEND: number;
  44250. /**
  44251. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44252. * They are also discarded below the alpha cutoff threshold to improve performances.
  44253. */
  44254. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44255. /**
  44256. * Defines the default value of how much AO map is occluding the analytical lights
  44257. * (point spot...).
  44258. */
  44259. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44260. /**
  44261. * Intensity of the direct lights e.g. the four lights available in your scene.
  44262. * This impacts both the direct diffuse and specular highlights.
  44263. */
  44264. directIntensity: number;
  44265. /**
  44266. * Intensity of the emissive part of the material.
  44267. * This helps controlling the emissive effect without modifying the emissive color.
  44268. */
  44269. emissiveIntensity: number;
  44270. /**
  44271. * Intensity of the environment e.g. how much the environment will light the object
  44272. * either through harmonics for rough material or through the refelction for shiny ones.
  44273. */
  44274. environmentIntensity: number;
  44275. /**
  44276. * This is a special control allowing the reduction of the specular highlights coming from the
  44277. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44278. */
  44279. specularIntensity: number;
  44280. /**
  44281. * Debug Control allowing disabling the bump map on this material.
  44282. */
  44283. disableBumpMap: boolean;
  44284. /**
  44285. * AKA Diffuse Texture in standard nomenclature.
  44286. */
  44287. albedoTexture: BaseTexture;
  44288. /**
  44289. * AKA Occlusion Texture in other nomenclature.
  44290. */
  44291. ambientTexture: BaseTexture;
  44292. /**
  44293. * AKA Occlusion Texture Intensity in other nomenclature.
  44294. */
  44295. ambientTextureStrength: number;
  44296. /**
  44297. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44298. * 1 means it completely occludes it
  44299. * 0 mean it has no impact
  44300. */
  44301. ambientTextureImpactOnAnalyticalLights: number;
  44302. /**
  44303. * Stores the alpha values in a texture.
  44304. */
  44305. opacityTexture: BaseTexture;
  44306. /**
  44307. * Stores the reflection values in a texture.
  44308. */
  44309. reflectionTexture: Nullable<BaseTexture>;
  44310. /**
  44311. * Stores the emissive values in a texture.
  44312. */
  44313. emissiveTexture: BaseTexture;
  44314. /**
  44315. * AKA Specular texture in other nomenclature.
  44316. */
  44317. reflectivityTexture: BaseTexture;
  44318. /**
  44319. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44320. */
  44321. metallicTexture: BaseTexture;
  44322. /**
  44323. * Specifies the metallic scalar of the metallic/roughness workflow.
  44324. * Can also be used to scale the metalness values of the metallic texture.
  44325. */
  44326. metallic: Nullable<number>;
  44327. /**
  44328. * Specifies the roughness scalar of the metallic/roughness workflow.
  44329. * Can also be used to scale the roughness values of the metallic texture.
  44330. */
  44331. roughness: Nullable<number>;
  44332. /**
  44333. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44334. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44335. */
  44336. microSurfaceTexture: BaseTexture;
  44337. /**
  44338. * Stores surface normal data used to displace a mesh in a texture.
  44339. */
  44340. bumpTexture: BaseTexture;
  44341. /**
  44342. * Stores the pre-calculated light information of a mesh in a texture.
  44343. */
  44344. lightmapTexture: BaseTexture;
  44345. /**
  44346. * Stores the refracted light information in a texture.
  44347. */
  44348. refractionTexture: BaseTexture;
  44349. /**
  44350. * The color of a material in ambient lighting.
  44351. */
  44352. ambientColor: Color3;
  44353. /**
  44354. * AKA Diffuse Color in other nomenclature.
  44355. */
  44356. albedoColor: Color3;
  44357. /**
  44358. * AKA Specular Color in other nomenclature.
  44359. */
  44360. reflectivityColor: Color3;
  44361. /**
  44362. * The color reflected from the material.
  44363. */
  44364. reflectionColor: Color3;
  44365. /**
  44366. * The color emitted from the material.
  44367. */
  44368. emissiveColor: Color3;
  44369. /**
  44370. * AKA Glossiness in other nomenclature.
  44371. */
  44372. microSurface: number;
  44373. /**
  44374. * source material index of refraction (IOR)' / 'destination material IOR.
  44375. */
  44376. indexOfRefraction: number;
  44377. /**
  44378. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  44379. */
  44380. invertRefractionY: boolean;
  44381. /**
  44382. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  44383. * Materials half opaque for instance using refraction could benefit from this control.
  44384. */
  44385. linkRefractionWithTransparency: boolean;
  44386. /**
  44387. * If true, the light map contains occlusion information instead of lighting info.
  44388. */
  44389. useLightmapAsShadowmap: boolean;
  44390. /**
  44391. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44392. */
  44393. useAlphaFromAlbedoTexture: boolean;
  44394. /**
  44395. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44396. */
  44397. forceAlphaTest: boolean;
  44398. /**
  44399. * Defines the alpha limits in alpha test mode.
  44400. */
  44401. alphaCutOff: number;
  44402. /**
  44403. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  44404. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44405. */
  44406. useSpecularOverAlpha: boolean;
  44407. /**
  44408. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44409. */
  44410. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44411. /**
  44412. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44413. */
  44414. useRoughnessFromMetallicTextureAlpha: boolean;
  44415. /**
  44416. * Specifies if the metallic texture contains the roughness information in its green channel.
  44417. */
  44418. useRoughnessFromMetallicTextureGreen: boolean;
  44419. /**
  44420. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44421. */
  44422. useMetallnessFromMetallicTextureBlue: boolean;
  44423. /**
  44424. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44425. */
  44426. useAmbientOcclusionFromMetallicTextureRed: boolean;
  44427. /**
  44428. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44429. */
  44430. useAmbientInGrayScale: boolean;
  44431. /**
  44432. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44433. * The material will try to infer what glossiness each pixel should be.
  44434. */
  44435. useAutoMicroSurfaceFromReflectivityMap: boolean;
  44436. /**
  44437. * BJS is using an harcoded light falloff based on a manually sets up range.
  44438. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44439. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44440. */
  44441. /**
  44442. * BJS is using an harcoded light falloff based on a manually sets up range.
  44443. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  44444. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  44445. */
  44446. usePhysicalLightFalloff: boolean;
  44447. /**
  44448. * In order to support the falloff compatibility with gltf, a special mode has been added
  44449. * to reproduce the gltf light falloff.
  44450. */
  44451. /**
  44452. * In order to support the falloff compatibility with gltf, a special mode has been added
  44453. * to reproduce the gltf light falloff.
  44454. */
  44455. useGLTFLightFalloff: boolean;
  44456. /**
  44457. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44458. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44459. */
  44460. useRadianceOverAlpha: boolean;
  44461. /**
  44462. * Allows using an object space normal map (instead of tangent space).
  44463. */
  44464. useObjectSpaceNormalMap: boolean;
  44465. /**
  44466. * Allows using the bump map in parallax mode.
  44467. */
  44468. useParallax: boolean;
  44469. /**
  44470. * Allows using the bump map in parallax occlusion mode.
  44471. */
  44472. useParallaxOcclusion: boolean;
  44473. /**
  44474. * Controls the scale bias of the parallax mode.
  44475. */
  44476. parallaxScaleBias: number;
  44477. /**
  44478. * If sets to true, disables all the lights affecting the material.
  44479. */
  44480. disableLighting: boolean;
  44481. /**
  44482. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44483. */
  44484. forceIrradianceInFragment: boolean;
  44485. /**
  44486. * Number of Simultaneous lights allowed on the material.
  44487. */
  44488. maxSimultaneousLights: number;
  44489. /**
  44490. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  44491. */
  44492. invertNormalMapX: boolean;
  44493. /**
  44494. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  44495. */
  44496. invertNormalMapY: boolean;
  44497. /**
  44498. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44499. */
  44500. twoSidedLighting: boolean;
  44501. /**
  44502. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44503. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44504. */
  44505. useAlphaFresnel: boolean;
  44506. /**
  44507. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44508. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44509. */
  44510. useLinearAlphaFresnel: boolean;
  44511. /**
  44512. * Let user defines the brdf lookup texture used for IBL.
  44513. * A default 8bit version is embedded but you could point at :
  44514. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  44515. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44516. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  44517. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44518. */
  44519. environmentBRDFTexture: Nullable<BaseTexture>;
  44520. /**
  44521. * Force normal to face away from face.
  44522. */
  44523. forceNormalForward: boolean;
  44524. /**
  44525. * Enables specular anti aliasing in the PBR shader.
  44526. * It will both interacts on the Geometry for analytical and IBL lighting.
  44527. * It also prefilter the roughness map based on the bump values.
  44528. */
  44529. enableSpecularAntiAliasing: boolean;
  44530. /**
  44531. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44532. * makes the reflect vector face the model (under horizon).
  44533. */
  44534. useHorizonOcclusion: boolean;
  44535. /**
  44536. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44537. * too much the area relying on ambient texture to define their ambient occlusion.
  44538. */
  44539. useRadianceOcclusion: boolean;
  44540. /**
  44541. * If set to true, no lighting calculations will be applied.
  44542. */
  44543. unlit: boolean;
  44544. /**
  44545. * Gets the image processing configuration used either in this material.
  44546. */
  44547. /**
  44548. * Sets the Default image processing configuration used either in the this material.
  44549. *
  44550. * If sets to null, the scene one is in use.
  44551. */
  44552. imageProcessingConfiguration: ImageProcessingConfiguration;
  44553. /**
  44554. * Gets wether the color curves effect is enabled.
  44555. */
  44556. /**
  44557. * Sets wether the color curves effect is enabled.
  44558. */
  44559. cameraColorCurvesEnabled: boolean;
  44560. /**
  44561. * Gets wether the color grading effect is enabled.
  44562. */
  44563. /**
  44564. * Gets wether the color grading effect is enabled.
  44565. */
  44566. cameraColorGradingEnabled: boolean;
  44567. /**
  44568. * Gets wether tonemapping is enabled or not.
  44569. */
  44570. /**
  44571. * Sets wether tonemapping is enabled or not
  44572. */
  44573. cameraToneMappingEnabled: boolean;
  44574. /**
  44575. * The camera exposure used on this material.
  44576. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44577. * This corresponds to a photographic exposure.
  44578. */
  44579. /**
  44580. * The camera exposure used on this material.
  44581. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44582. * This corresponds to a photographic exposure.
  44583. */
  44584. cameraExposure: number;
  44585. /**
  44586. * Gets The camera contrast used on this material.
  44587. */
  44588. /**
  44589. * Sets The camera contrast used on this material.
  44590. */
  44591. cameraContrast: number;
  44592. /**
  44593. * Gets the Color Grading 2D Lookup Texture.
  44594. */
  44595. /**
  44596. * Sets the Color Grading 2D Lookup Texture.
  44597. */
  44598. cameraColorGradingTexture: Nullable<BaseTexture>;
  44599. /**
  44600. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44601. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44602. * 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;
  44603. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44604. */
  44605. /**
  44606. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44607. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44608. * 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;
  44609. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44610. */
  44611. cameraColorCurves: Nullable<ColorCurves>;
  44612. /**
  44613. * Instantiates a new PBRMaterial instance.
  44614. *
  44615. * @param name The material name
  44616. * @param scene The scene the material will be use in.
  44617. */
  44618. constructor(name: string, scene: Scene);
  44619. /**
  44620. * Returns the name of this material class.
  44621. */
  44622. getClassName(): string;
  44623. /**
  44624. * Makes a duplicate of the current material.
  44625. * @param name - name to use for the new material.
  44626. */
  44627. clone(name: string): PBRMaterial;
  44628. /**
  44629. * Serializes this PBR Material.
  44630. * @returns - An object with the serialized material.
  44631. */
  44632. serialize(): any;
  44633. /**
  44634. * Parses a PBR Material from a serialized object.
  44635. * @param source - Serialized object.
  44636. * @param scene - BJS scene instance.
  44637. * @param rootUrl - url for the scene object
  44638. * @returns - PBRMaterial
  44639. */
  44640. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  44641. }
  44642. }
  44643. declare module BABYLON {
  44644. /**
  44645. * Direct draw surface info
  44646. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  44647. */
  44648. export interface DDSInfo {
  44649. /**
  44650. * Width of the texture
  44651. */
  44652. width: number;
  44653. /**
  44654. * Width of the texture
  44655. */
  44656. height: number;
  44657. /**
  44658. * Number of Mipmaps for the texture
  44659. * @see https://en.wikipedia.org/wiki/Mipmap
  44660. */
  44661. mipmapCount: number;
  44662. /**
  44663. * If the textures format is a known fourCC format
  44664. * @see https://www.fourcc.org/
  44665. */
  44666. isFourCC: boolean;
  44667. /**
  44668. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  44669. */
  44670. isRGB: boolean;
  44671. /**
  44672. * If the texture is a lumincance format
  44673. */
  44674. isLuminance: boolean;
  44675. /**
  44676. * If this is a cube texture
  44677. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  44678. */
  44679. isCube: boolean;
  44680. /**
  44681. * If the texture is a compressed format eg. FOURCC_DXT1
  44682. */
  44683. isCompressed: boolean;
  44684. /**
  44685. * The dxgiFormat of the texture
  44686. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  44687. */
  44688. dxgiFormat: number;
  44689. /**
  44690. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  44691. */
  44692. textureType: number;
  44693. /**
  44694. * Sphericle polynomial created for the dds texture
  44695. */
  44696. sphericalPolynomial?: SphericalPolynomial;
  44697. }
  44698. /**
  44699. * Class used to provide DDS decompression tools
  44700. */
  44701. export class DDSTools {
  44702. /**
  44703. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  44704. */
  44705. static StoreLODInAlphaChannel: boolean;
  44706. /**
  44707. * Gets DDS information from an array buffer
  44708. * @param arrayBuffer defines the array buffer to read data from
  44709. * @returns the DDS information
  44710. */
  44711. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  44712. private static _FloatView;
  44713. private static _Int32View;
  44714. private static _ToHalfFloat;
  44715. private static _FromHalfFloat;
  44716. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  44717. private static _GetHalfFloatRGBAArrayBuffer;
  44718. private static _GetFloatRGBAArrayBuffer;
  44719. private static _GetFloatAsUIntRGBAArrayBuffer;
  44720. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  44721. private static _GetRGBAArrayBuffer;
  44722. private static _ExtractLongWordOrder;
  44723. private static _GetRGBArrayBuffer;
  44724. private static _GetLuminanceArrayBuffer;
  44725. /**
  44726. * Uploads DDS Levels to a Babylon Texture
  44727. * @hidden
  44728. */
  44729. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  44730. }
  44731. interface Engine {
  44732. /**
  44733. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  44734. * @param rootUrl defines the url where the file to load is located
  44735. * @param scene defines the current scene
  44736. * @param lodScale defines scale to apply to the mip map selection
  44737. * @param lodOffset defines offset to apply to the mip map selection
  44738. * @param onLoad defines an optional callback raised when the texture is loaded
  44739. * @param onError defines an optional callback raised if there is an issue to load the texture
  44740. * @param format defines the format of the data
  44741. * @param forcedExtension defines the extension to use to pick the right loader
  44742. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  44743. * @returns the cube texture as an InternalTexture
  44744. */
  44745. 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;
  44746. }
  44747. }
  44748. declare module BABYLON {
  44749. /**
  44750. * Implementation of the DDS Texture Loader.
  44751. * @hidden
  44752. */
  44753. export class _DDSTextureLoader implements IInternalTextureLoader {
  44754. /**
  44755. * Defines wether the loader supports cascade loading the different faces.
  44756. */
  44757. readonly supportCascades: boolean;
  44758. /**
  44759. * This returns if the loader support the current file information.
  44760. * @param extension defines the file extension of the file being loaded
  44761. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44762. * @param fallback defines the fallback internal texture if any
  44763. * @param isBase64 defines whether the texture is encoded as a base64
  44764. * @param isBuffer defines whether the texture data are stored as a buffer
  44765. * @returns true if the loader can load the specified file
  44766. */
  44767. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  44768. /**
  44769. * Transform the url before loading if required.
  44770. * @param rootUrl the url of the texture
  44771. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44772. * @returns the transformed texture
  44773. */
  44774. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  44775. /**
  44776. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  44777. * @param rootUrl the url of the texture
  44778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44779. * @returns the fallback texture
  44780. */
  44781. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  44782. /**
  44783. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  44784. * @param data contains the texture data
  44785. * @param texture defines the BabylonJS internal texture
  44786. * @param createPolynomials will be true if polynomials have been requested
  44787. * @param onLoad defines the callback to trigger once the texture is ready
  44788. * @param onError defines the callback to trigger in case of error
  44789. */
  44790. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  44791. /**
  44792. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  44793. * @param data contains the texture data
  44794. * @param texture defines the BabylonJS internal texture
  44795. * @param callback defines the method to call once ready to upload
  44796. */
  44797. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  44798. }
  44799. }
  44800. declare module BABYLON {
  44801. /** @hidden */
  44802. export var rgbdEncodePixelShader: {
  44803. name: string;
  44804. shader: string;
  44805. };
  44806. }
  44807. declare module BABYLON {
  44808. /** @hidden */
  44809. export var rgbdDecodePixelShader: {
  44810. name: string;
  44811. shader: string;
  44812. };
  44813. }
  44814. declare module BABYLON {
  44815. /**
  44816. * Raw texture data and descriptor sufficient for WebGL texture upload
  44817. */
  44818. export interface EnvironmentTextureInfo {
  44819. /**
  44820. * Version of the environment map
  44821. */
  44822. version: number;
  44823. /**
  44824. * Width of image
  44825. */
  44826. width: number;
  44827. /**
  44828. * Irradiance information stored in the file.
  44829. */
  44830. irradiance: any;
  44831. /**
  44832. * Specular information stored in the file.
  44833. */
  44834. specular: any;
  44835. }
  44836. /**
  44837. * Sets of helpers addressing the serialization and deserialization of environment texture
  44838. * stored in a BabylonJS env file.
  44839. * Those files are usually stored as .env files.
  44840. */
  44841. export class EnvironmentTextureTools {
  44842. /**
  44843. * Magic number identifying the env file.
  44844. */
  44845. private static _MagicBytes;
  44846. /**
  44847. * Gets the environment info from an env file.
  44848. * @param data The array buffer containing the .env bytes.
  44849. * @returns the environment file info (the json header) if successfully parsed.
  44850. */
  44851. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  44852. /**
  44853. * Creates an environment texture from a loaded cube texture.
  44854. * @param texture defines the cube texture to convert in env file
  44855. * @return a promise containing the environment data if succesfull.
  44856. */
  44857. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  44858. /**
  44859. * Creates a JSON representation of the spherical data.
  44860. * @param texture defines the texture containing the polynomials
  44861. * @return the JSON representation of the spherical info
  44862. */
  44863. private static _CreateEnvTextureIrradiance;
  44864. /**
  44865. * Uploads the texture info contained in the env file to the GPU.
  44866. * @param texture defines the internal texture to upload to
  44867. * @param arrayBuffer defines the buffer cotaining the data to load
  44868. * @param info defines the texture info retrieved through the GetEnvInfo method
  44869. * @returns a promise
  44870. */
  44871. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  44872. /**
  44873. * Uploads the levels of image data to the GPU.
  44874. * @param texture defines the internal texture to upload to
  44875. * @param imageData defines the array buffer views of image data [mipmap][face]
  44876. * @returns a promise
  44877. */
  44878. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  44879. /**
  44880. * Uploads spherical polynomials information to the texture.
  44881. * @param texture defines the texture we are trying to upload the information to
  44882. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  44883. */
  44884. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  44885. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  44886. }
  44887. }
  44888. declare module BABYLON {
  44889. /**
  44890. * Implementation of the ENV Texture Loader.
  44891. * @hidden
  44892. */
  44893. export class _ENVTextureLoader implements IInternalTextureLoader {
  44894. /**
  44895. * Defines wether the loader supports cascade loading the different faces.
  44896. */
  44897. readonly supportCascades: boolean;
  44898. /**
  44899. * This returns if the loader support the current file information.
  44900. * @param extension defines the file extension of the file being loaded
  44901. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44902. * @param fallback defines the fallback internal texture if any
  44903. * @param isBase64 defines whether the texture is encoded as a base64
  44904. * @param isBuffer defines whether the texture data are stored as a buffer
  44905. * @returns true if the loader can load the specified file
  44906. */
  44907. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  44908. /**
  44909. * Transform the url before loading if required.
  44910. * @param rootUrl the url of the texture
  44911. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44912. * @returns the transformed texture
  44913. */
  44914. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  44915. /**
  44916. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  44917. * @param rootUrl the url of the texture
  44918. * @param textureFormatInUse defines the current compressed format in use iun the engine
  44919. * @returns the fallback texture
  44920. */
  44921. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  44922. /**
  44923. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  44924. * @param data contains the texture data
  44925. * @param texture defines the BabylonJS internal texture
  44926. * @param createPolynomials will be true if polynomials have been requested
  44927. * @param onLoad defines the callback to trigger once the texture is ready
  44928. * @param onError defines the callback to trigger in case of error
  44929. */
  44930. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  44931. /**
  44932. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  44933. * @param data contains the texture data
  44934. * @param texture defines the BabylonJS internal texture
  44935. * @param callback defines the method to call once ready to upload
  44936. */
  44937. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  44938. }
  44939. }
  44940. declare module BABYLON {
  44941. /**
  44942. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  44943. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  44944. */
  44945. export class KhronosTextureContainer {
  44946. /** contents of the KTX container file */
  44947. arrayBuffer: any;
  44948. private static HEADER_LEN;
  44949. private static COMPRESSED_2D;
  44950. private static COMPRESSED_3D;
  44951. private static TEX_2D;
  44952. private static TEX_3D;
  44953. /**
  44954. * Gets the openGL type
  44955. */
  44956. glType: number;
  44957. /**
  44958. * Gets the openGL type size
  44959. */
  44960. glTypeSize: number;
  44961. /**
  44962. * Gets the openGL format
  44963. */
  44964. glFormat: number;
  44965. /**
  44966. * Gets the openGL internal format
  44967. */
  44968. glInternalFormat: number;
  44969. /**
  44970. * Gets the base internal format
  44971. */
  44972. glBaseInternalFormat: number;
  44973. /**
  44974. * Gets image width in pixel
  44975. */
  44976. pixelWidth: number;
  44977. /**
  44978. * Gets image height in pixel
  44979. */
  44980. pixelHeight: number;
  44981. /**
  44982. * Gets image depth in pixels
  44983. */
  44984. pixelDepth: number;
  44985. /**
  44986. * Gets the number of array elements
  44987. */
  44988. numberOfArrayElements: number;
  44989. /**
  44990. * Gets the number of faces
  44991. */
  44992. numberOfFaces: number;
  44993. /**
  44994. * Gets the number of mipmap levels
  44995. */
  44996. numberOfMipmapLevels: number;
  44997. /**
  44998. * Gets the bytes of key value data
  44999. */
  45000. bytesOfKeyValueData: number;
  45001. /**
  45002. * Gets the load type
  45003. */
  45004. loadType: number;
  45005. /**
  45006. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45007. */
  45008. isInvalid: boolean;
  45009. /**
  45010. * Creates a new KhronosTextureContainer
  45011. * @param arrayBuffer contents of the KTX container file
  45012. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45013. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45014. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45015. */
  45016. constructor(
  45017. /** contents of the KTX container file */
  45018. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45019. /**
  45020. * Uploads KTX content to a Babylon Texture.
  45021. * It is assumed that the texture has already been created & is currently bound
  45022. * @hidden
  45023. */
  45024. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45025. private _upload2DCompressedLevels;
  45026. }
  45027. }
  45028. declare module BABYLON {
  45029. /**
  45030. * Implementation of the KTX Texture Loader.
  45031. * @hidden
  45032. */
  45033. export class _KTXTextureLoader implements IInternalTextureLoader {
  45034. /**
  45035. * Defines wether the loader supports cascade loading the different faces.
  45036. */
  45037. readonly supportCascades: boolean;
  45038. /**
  45039. * This returns if the loader support the current file information.
  45040. * @param extension defines the file extension of the file being loaded
  45041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45042. * @param fallback defines the fallback internal texture if any
  45043. * @param isBase64 defines whether the texture is encoded as a base64
  45044. * @param isBuffer defines whether the texture data are stored as a buffer
  45045. * @returns true if the loader can load the specified file
  45046. */
  45047. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45048. /**
  45049. * Transform the url before loading if required.
  45050. * @param rootUrl the url of the texture
  45051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45052. * @returns the transformed texture
  45053. */
  45054. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45055. /**
  45056. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45057. * @param rootUrl the url of the texture
  45058. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45059. * @returns the fallback texture
  45060. */
  45061. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45062. /**
  45063. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45064. * @param data contains the texture data
  45065. * @param texture defines the BabylonJS internal texture
  45066. * @param createPolynomials will be true if polynomials have been requested
  45067. * @param onLoad defines the callback to trigger once the texture is ready
  45068. * @param onError defines the callback to trigger in case of error
  45069. */
  45070. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45071. /**
  45072. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45073. * @param data contains the texture data
  45074. * @param texture defines the BabylonJS internal texture
  45075. * @param callback defines the method to call once ready to upload
  45076. */
  45077. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45078. }
  45079. }
  45080. declare module BABYLON {
  45081. /** @hidden */
  45082. export var _forceSceneHelpersToBundle: boolean;
  45083. interface Scene {
  45084. /**
  45085. * Creates a default light for the scene.
  45086. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45087. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45088. */
  45089. createDefaultLight(replace?: boolean): void;
  45090. /**
  45091. * Creates a default camera for the scene.
  45092. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45093. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45094. * @param replace has default false, when true replaces the active camera in the scene
  45095. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45096. */
  45097. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45098. /**
  45099. * Creates a default camera and a default light.
  45100. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45101. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45102. * @param replace has the default false, when true replaces the active camera/light in the scene
  45103. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45104. */
  45105. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45106. /**
  45107. * Creates a new sky box
  45108. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45109. * @param environmentTexture defines the texture to use as environment texture
  45110. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45111. * @param scale defines the overall scale of the skybox
  45112. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45113. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45114. * @returns a new mesh holding the sky box
  45115. */
  45116. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45117. /**
  45118. * Creates a new environment
  45119. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45120. * @param options defines the options you can use to configure the environment
  45121. * @returns the new EnvironmentHelper
  45122. */
  45123. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45124. /**
  45125. * Creates a new VREXperienceHelper
  45126. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45127. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45128. * @returns a new VREXperienceHelper
  45129. */
  45130. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45131. /**
  45132. * Creates a new XREXperienceHelper
  45133. * @see http://doc.babylonjs.com/how_to/webxr
  45134. * @returns a promise for a new XREXperienceHelper
  45135. */
  45136. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45137. }
  45138. }
  45139. declare module BABYLON {
  45140. /**
  45141. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45142. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45143. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45144. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45145. */
  45146. export class VideoDome extends TransformNode {
  45147. /**
  45148. * Define the video source as a Monoscopic panoramic 360 video.
  45149. */
  45150. static readonly MODE_MONOSCOPIC: number;
  45151. /**
  45152. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45153. */
  45154. static readonly MODE_TOPBOTTOM: number;
  45155. /**
  45156. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45157. */
  45158. static readonly MODE_SIDEBYSIDE: number;
  45159. private _useDirectMapping;
  45160. /**
  45161. * The video texture being displayed on the sphere
  45162. */
  45163. protected _videoTexture: VideoTexture;
  45164. /**
  45165. * Gets the video texture being displayed on the sphere
  45166. */
  45167. readonly videoTexture: VideoTexture;
  45168. /**
  45169. * The skybox material
  45170. */
  45171. protected _material: BackgroundMaterial;
  45172. /**
  45173. * The surface used for the skybox
  45174. */
  45175. protected _mesh: Mesh;
  45176. /**
  45177. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45178. * Also see the options.resolution property.
  45179. */
  45180. fovMultiplier: number;
  45181. private _videoMode;
  45182. /**
  45183. * Gets or set the current video mode for the video. It can be:
  45184. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45185. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45186. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45187. */
  45188. videoMode: number;
  45189. /**
  45190. * Oberserver used in Stereoscopic VR Mode.
  45191. */
  45192. private _onBeforeCameraRenderObserver;
  45193. /**
  45194. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45195. * @param name Element's name, child elements will append suffixes for their own names.
  45196. * @param urlsOrVideo defines the url(s) or the video element to use
  45197. * @param options An object containing optional or exposed sub element properties
  45198. */
  45199. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45200. resolution?: number;
  45201. clickToPlay?: boolean;
  45202. autoPlay?: boolean;
  45203. loop?: boolean;
  45204. size?: number;
  45205. poster?: string;
  45206. faceForward?: boolean;
  45207. useDirectMapping?: boolean;
  45208. }, scene: Scene);
  45209. private _changeVideoMode;
  45210. /**
  45211. * Releases resources associated with this node.
  45212. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45213. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45214. */
  45215. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45216. }
  45217. }
  45218. declare module BABYLON {
  45219. /**
  45220. * This class can be used to get instrumentation data from a Babylon engine
  45221. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45222. */
  45223. export class EngineInstrumentation implements IDisposable {
  45224. /**
  45225. * Define the instrumented engine.
  45226. */
  45227. engine: Engine;
  45228. private _captureGPUFrameTime;
  45229. private _gpuFrameTimeToken;
  45230. private _gpuFrameTime;
  45231. private _captureShaderCompilationTime;
  45232. private _shaderCompilationTime;
  45233. private _onBeginFrameObserver;
  45234. private _onEndFrameObserver;
  45235. private _onBeforeShaderCompilationObserver;
  45236. private _onAfterShaderCompilationObserver;
  45237. /**
  45238. * Gets the perf counter used for GPU frame time
  45239. */
  45240. readonly gpuFrameTimeCounter: PerfCounter;
  45241. /**
  45242. * Gets the GPU frame time capture status
  45243. */
  45244. /**
  45245. * Enable or disable the GPU frame time capture
  45246. */
  45247. captureGPUFrameTime: boolean;
  45248. /**
  45249. * Gets the perf counter used for shader compilation time
  45250. */
  45251. readonly shaderCompilationTimeCounter: PerfCounter;
  45252. /**
  45253. * Gets the shader compilation time capture status
  45254. */
  45255. /**
  45256. * Enable or disable the shader compilation time capture
  45257. */
  45258. captureShaderCompilationTime: boolean;
  45259. /**
  45260. * Instantiates a new engine instrumentation.
  45261. * This class can be used to get instrumentation data from a Babylon engine
  45262. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45263. * @param engine Defines the engine to instrument
  45264. */
  45265. constructor(
  45266. /**
  45267. * Define the instrumented engine.
  45268. */
  45269. engine: Engine);
  45270. /**
  45271. * Dispose and release associated resources.
  45272. */
  45273. dispose(): void;
  45274. }
  45275. }
  45276. declare module BABYLON {
  45277. /**
  45278. * This class can be used to get instrumentation data from a Babylon engine
  45279. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45280. */
  45281. export class SceneInstrumentation implements IDisposable {
  45282. /**
  45283. * Defines the scene to instrument
  45284. */
  45285. scene: Scene;
  45286. private _captureActiveMeshesEvaluationTime;
  45287. private _activeMeshesEvaluationTime;
  45288. private _captureRenderTargetsRenderTime;
  45289. private _renderTargetsRenderTime;
  45290. private _captureFrameTime;
  45291. private _frameTime;
  45292. private _captureRenderTime;
  45293. private _renderTime;
  45294. private _captureInterFrameTime;
  45295. private _interFrameTime;
  45296. private _captureParticlesRenderTime;
  45297. private _particlesRenderTime;
  45298. private _captureSpritesRenderTime;
  45299. private _spritesRenderTime;
  45300. private _capturePhysicsTime;
  45301. private _physicsTime;
  45302. private _captureAnimationsTime;
  45303. private _animationsTime;
  45304. private _captureCameraRenderTime;
  45305. private _cameraRenderTime;
  45306. private _onBeforeActiveMeshesEvaluationObserver;
  45307. private _onAfterActiveMeshesEvaluationObserver;
  45308. private _onBeforeRenderTargetsRenderObserver;
  45309. private _onAfterRenderTargetsRenderObserver;
  45310. private _onAfterRenderObserver;
  45311. private _onBeforeDrawPhaseObserver;
  45312. private _onAfterDrawPhaseObserver;
  45313. private _onBeforeAnimationsObserver;
  45314. private _onBeforeParticlesRenderingObserver;
  45315. private _onAfterParticlesRenderingObserver;
  45316. private _onBeforeSpritesRenderingObserver;
  45317. private _onAfterSpritesRenderingObserver;
  45318. private _onBeforePhysicsObserver;
  45319. private _onAfterPhysicsObserver;
  45320. private _onAfterAnimationsObserver;
  45321. private _onBeforeCameraRenderObserver;
  45322. private _onAfterCameraRenderObserver;
  45323. /**
  45324. * Gets the perf counter used for active meshes evaluation time
  45325. */
  45326. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45327. /**
  45328. * Gets the active meshes evaluation time capture status
  45329. */
  45330. /**
  45331. * Enable or disable the active meshes evaluation time capture
  45332. */
  45333. captureActiveMeshesEvaluationTime: boolean;
  45334. /**
  45335. * Gets the perf counter used for render targets render time
  45336. */
  45337. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45338. /**
  45339. * Gets the render targets render time capture status
  45340. */
  45341. /**
  45342. * Enable or disable the render targets render time capture
  45343. */
  45344. captureRenderTargetsRenderTime: boolean;
  45345. /**
  45346. * Gets the perf counter used for particles render time
  45347. */
  45348. readonly particlesRenderTimeCounter: PerfCounter;
  45349. /**
  45350. * Gets the particles render time capture status
  45351. */
  45352. /**
  45353. * Enable or disable the particles render time capture
  45354. */
  45355. captureParticlesRenderTime: boolean;
  45356. /**
  45357. * Gets the perf counter used for sprites render time
  45358. */
  45359. readonly spritesRenderTimeCounter: PerfCounter;
  45360. /**
  45361. * Gets the sprites render time capture status
  45362. */
  45363. /**
  45364. * Enable or disable the sprites render time capture
  45365. */
  45366. captureSpritesRenderTime: boolean;
  45367. /**
  45368. * Gets the perf counter used for physics time
  45369. */
  45370. readonly physicsTimeCounter: PerfCounter;
  45371. /**
  45372. * Gets the physics time capture status
  45373. */
  45374. /**
  45375. * Enable or disable the physics time capture
  45376. */
  45377. capturePhysicsTime: boolean;
  45378. /**
  45379. * Gets the perf counter used for animations time
  45380. */
  45381. readonly animationsTimeCounter: PerfCounter;
  45382. /**
  45383. * Gets the animations time capture status
  45384. */
  45385. /**
  45386. * Enable or disable the animations time capture
  45387. */
  45388. captureAnimationsTime: boolean;
  45389. /**
  45390. * Gets the perf counter used for frame time capture
  45391. */
  45392. readonly frameTimeCounter: PerfCounter;
  45393. /**
  45394. * Gets the frame time capture status
  45395. */
  45396. /**
  45397. * Enable or disable the frame time capture
  45398. */
  45399. captureFrameTime: boolean;
  45400. /**
  45401. * Gets the perf counter used for inter-frames time capture
  45402. */
  45403. readonly interFrameTimeCounter: PerfCounter;
  45404. /**
  45405. * Gets the inter-frames time capture status
  45406. */
  45407. /**
  45408. * Enable or disable the inter-frames time capture
  45409. */
  45410. captureInterFrameTime: boolean;
  45411. /**
  45412. * Gets the perf counter used for render time capture
  45413. */
  45414. readonly renderTimeCounter: PerfCounter;
  45415. /**
  45416. * Gets the render time capture status
  45417. */
  45418. /**
  45419. * Enable or disable the render time capture
  45420. */
  45421. captureRenderTime: boolean;
  45422. /**
  45423. * Gets the perf counter used for camera render time capture
  45424. */
  45425. readonly cameraRenderTimeCounter: PerfCounter;
  45426. /**
  45427. * Gets the camera render time capture status
  45428. */
  45429. /**
  45430. * Enable or disable the camera render time capture
  45431. */
  45432. captureCameraRenderTime: boolean;
  45433. /**
  45434. * Gets the perf counter used for draw calls
  45435. */
  45436. readonly drawCallsCounter: PerfCounter;
  45437. /**
  45438. * Gets the perf counter used for texture collisions
  45439. */
  45440. readonly textureCollisionsCounter: PerfCounter;
  45441. /**
  45442. * Instantiates a new scene instrumentation.
  45443. * This class can be used to get instrumentation data from a Babylon engine
  45444. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45445. * @param scene Defines the scene to instrument
  45446. */
  45447. constructor(
  45448. /**
  45449. * Defines the scene to instrument
  45450. */
  45451. scene: Scene);
  45452. /**
  45453. * Dispose and release associated resources.
  45454. */
  45455. dispose(): void;
  45456. }
  45457. }
  45458. declare module BABYLON {
  45459. /** @hidden */
  45460. export var glowMapGenerationPixelShader: {
  45461. name: string;
  45462. shader: string;
  45463. };
  45464. }
  45465. declare module BABYLON {
  45466. /** @hidden */
  45467. export var glowMapGenerationVertexShader: {
  45468. name: string;
  45469. shader: string;
  45470. };
  45471. }
  45472. declare module BABYLON {
  45473. /**
  45474. * Effect layer options. This helps customizing the behaviour
  45475. * of the effect layer.
  45476. */
  45477. export interface IEffectLayerOptions {
  45478. /**
  45479. * Multiplication factor apply to the canvas size to compute the render target size
  45480. * used to generated the objects (the smaller the faster).
  45481. */
  45482. mainTextureRatio: number;
  45483. /**
  45484. * Enforces a fixed size texture to ensure effect stability across devices.
  45485. */
  45486. mainTextureFixedSize?: number;
  45487. /**
  45488. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  45489. */
  45490. alphaBlendingMode: number;
  45491. /**
  45492. * The camera attached to the layer.
  45493. */
  45494. camera: Nullable<Camera>;
  45495. /**
  45496. * The rendering group to draw the layer in.
  45497. */
  45498. renderingGroupId: number;
  45499. }
  45500. /**
  45501. * The effect layer Helps adding post process effect blended with the main pass.
  45502. *
  45503. * This can be for instance use to generate glow or higlight effects on the scene.
  45504. *
  45505. * The effect layer class can not be used directly and is intented to inherited from to be
  45506. * customized per effects.
  45507. */
  45508. export abstract class EffectLayer {
  45509. private _vertexBuffers;
  45510. private _indexBuffer;
  45511. private _cachedDefines;
  45512. private _effectLayerMapGenerationEffect;
  45513. private _effectLayerOptions;
  45514. private _mergeEffect;
  45515. protected _scene: Scene;
  45516. protected _engine: Engine;
  45517. protected _maxSize: number;
  45518. protected _mainTextureDesiredSize: ISize;
  45519. protected _mainTexture: RenderTargetTexture;
  45520. protected _shouldRender: boolean;
  45521. protected _postProcesses: PostProcess[];
  45522. protected _textures: BaseTexture[];
  45523. protected _emissiveTextureAndColor: {
  45524. texture: Nullable<BaseTexture>;
  45525. color: Color4;
  45526. };
  45527. /**
  45528. * The name of the layer
  45529. */
  45530. name: string;
  45531. /**
  45532. * The clear color of the texture used to generate the glow map.
  45533. */
  45534. neutralColor: Color4;
  45535. /**
  45536. * Specifies wether the highlight layer is enabled or not.
  45537. */
  45538. isEnabled: boolean;
  45539. /**
  45540. * Gets the camera attached to the layer.
  45541. */
  45542. readonly camera: Nullable<Camera>;
  45543. /**
  45544. * Gets the rendering group id the layer should render in.
  45545. */
  45546. readonly renderingGroupId: number;
  45547. /**
  45548. * An event triggered when the effect layer has been disposed.
  45549. */
  45550. onDisposeObservable: Observable<EffectLayer>;
  45551. /**
  45552. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  45553. */
  45554. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  45555. /**
  45556. * An event triggered when the generated texture is being merged in the scene.
  45557. */
  45558. onBeforeComposeObservable: Observable<EffectLayer>;
  45559. /**
  45560. * An event triggered when the generated texture has been merged in the scene.
  45561. */
  45562. onAfterComposeObservable: Observable<EffectLayer>;
  45563. /**
  45564. * An event triggered when the efffect layer changes its size.
  45565. */
  45566. onSizeChangedObservable: Observable<EffectLayer>;
  45567. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  45568. /**
  45569. * Instantiates a new effect Layer and references it in the scene.
  45570. * @param name The name of the layer
  45571. * @param scene The scene to use the layer in
  45572. */
  45573. constructor(
  45574. /** The Friendly of the effect in the scene */
  45575. name: string, scene: Scene);
  45576. /**
  45577. * Get the effect name of the layer.
  45578. * @return The effect name
  45579. */
  45580. abstract getEffectName(): string;
  45581. /**
  45582. * Checks for the readiness of the element composing the layer.
  45583. * @param subMesh the mesh to check for
  45584. * @param useInstances specify wether or not to use instances to render the mesh
  45585. * @return true if ready otherwise, false
  45586. */
  45587. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45588. /**
  45589. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45590. * @returns true if the effect requires stencil during the main canvas render pass.
  45591. */
  45592. abstract needStencil(): boolean;
  45593. /**
  45594. * Create the merge effect. This is the shader use to blit the information back
  45595. * to the main canvas at the end of the scene rendering.
  45596. * @returns The effect containing the shader used to merge the effect on the main canvas
  45597. */
  45598. protected abstract _createMergeEffect(): Effect;
  45599. /**
  45600. * Creates the render target textures and post processes used in the effect layer.
  45601. */
  45602. protected abstract _createTextureAndPostProcesses(): void;
  45603. /**
  45604. * Implementation specific of rendering the generating effect on the main canvas.
  45605. * @param effect The effect used to render through
  45606. */
  45607. protected abstract _internalRender(effect: Effect): void;
  45608. /**
  45609. * Sets the required values for both the emissive texture and and the main color.
  45610. */
  45611. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45612. /**
  45613. * Free any resources and references associated to a mesh.
  45614. * Internal use
  45615. * @param mesh The mesh to free.
  45616. */
  45617. abstract _disposeMesh(mesh: Mesh): void;
  45618. /**
  45619. * Serializes this layer (Glow or Highlight for example)
  45620. * @returns a serialized layer object
  45621. */
  45622. abstract serialize?(): any;
  45623. /**
  45624. * Initializes the effect layer with the required options.
  45625. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  45626. */
  45627. protected _init(options: Partial<IEffectLayerOptions>): void;
  45628. /**
  45629. * Generates the index buffer of the full screen quad blending to the main canvas.
  45630. */
  45631. private _generateIndexBuffer;
  45632. /**
  45633. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  45634. */
  45635. private _genrateVertexBuffer;
  45636. /**
  45637. * Sets the main texture desired size which is the closest power of two
  45638. * of the engine canvas size.
  45639. */
  45640. private _setMainTextureSize;
  45641. /**
  45642. * Creates the main texture for the effect layer.
  45643. */
  45644. protected _createMainTexture(): void;
  45645. /**
  45646. * Adds specific effects defines.
  45647. * @param defines The defines to add specifics to.
  45648. */
  45649. protected _addCustomEffectDefines(defines: string[]): void;
  45650. /**
  45651. * Checks for the readiness of the element composing the layer.
  45652. * @param subMesh the mesh to check for
  45653. * @param useInstances specify wether or not to use instances to render the mesh
  45654. * @param emissiveTexture the associated emissive texture used to generate the glow
  45655. * @return true if ready otherwise, false
  45656. */
  45657. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  45658. /**
  45659. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  45660. */
  45661. render(): void;
  45662. /**
  45663. * Determine if a given mesh will be used in the current effect.
  45664. * @param mesh mesh to test
  45665. * @returns true if the mesh will be used
  45666. */
  45667. hasMesh(mesh: AbstractMesh): boolean;
  45668. /**
  45669. * Returns true if the layer contains information to display, otherwise false.
  45670. * @returns true if the glow layer should be rendered
  45671. */
  45672. shouldRender(): boolean;
  45673. /**
  45674. * Returns true if the mesh should render, otherwise false.
  45675. * @param mesh The mesh to render
  45676. * @returns true if it should render otherwise false
  45677. */
  45678. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  45679. /**
  45680. * Returns true if the mesh can be rendered, otherwise false.
  45681. * @param mesh The mesh to render
  45682. * @param material The material used on the mesh
  45683. * @returns true if it can be rendered otherwise false
  45684. */
  45685. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45686. /**
  45687. * Returns true if the mesh should render, otherwise false.
  45688. * @param mesh The mesh to render
  45689. * @returns true if it should render otherwise false
  45690. */
  45691. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  45692. /**
  45693. * Renders the submesh passed in parameter to the generation map.
  45694. */
  45695. protected _renderSubMesh(subMesh: SubMesh): void;
  45696. /**
  45697. * Rebuild the required buffers.
  45698. * @hidden Internal use only.
  45699. */ rebuild(): void;
  45700. /**
  45701. * Dispose only the render target textures and post process.
  45702. */
  45703. private _disposeTextureAndPostProcesses;
  45704. /**
  45705. * Dispose the highlight layer and free resources.
  45706. */
  45707. dispose(): void;
  45708. /**
  45709. * Gets the class name of the effect layer
  45710. * @returns the string with the class name of the effect layer
  45711. */
  45712. getClassName(): string;
  45713. /**
  45714. * Creates an effect layer from parsed effect layer data
  45715. * @param parsedEffectLayer defines effect layer data
  45716. * @param scene defines the current scene
  45717. * @param rootUrl defines the root URL containing the effect layer information
  45718. * @returns a parsed effect Layer
  45719. */
  45720. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  45721. }
  45722. }
  45723. declare module BABYLON {
  45724. interface AbstractScene {
  45725. /**
  45726. * The list of effect layers (highlights/glow) added to the scene
  45727. * @see http://doc.babylonjs.com/how_to/highlight_layer
  45728. * @see http://doc.babylonjs.com/how_to/glow_layer
  45729. */
  45730. effectLayers: Array<EffectLayer>;
  45731. /**
  45732. * Removes the given effect layer from this scene.
  45733. * @param toRemove defines the effect layer to remove
  45734. * @returns the index of the removed effect layer
  45735. */
  45736. removeEffectLayer(toRemove: EffectLayer): number;
  45737. /**
  45738. * Adds the given effect layer to this scene
  45739. * @param newEffectLayer defines the effect layer to add
  45740. */
  45741. addEffectLayer(newEffectLayer: EffectLayer): void;
  45742. }
  45743. /**
  45744. * Defines the layer scene component responsible to manage any effect layers
  45745. * in a given scene.
  45746. */
  45747. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  45748. /**
  45749. * The component name helpfull to identify the component in the list of scene components.
  45750. */
  45751. readonly name: string;
  45752. /**
  45753. * The scene the component belongs to.
  45754. */
  45755. scene: Scene;
  45756. private _engine;
  45757. private _renderEffects;
  45758. private _needStencil;
  45759. private _previousStencilState;
  45760. /**
  45761. * Creates a new instance of the component for the given scene
  45762. * @param scene Defines the scene to register the component in
  45763. */
  45764. constructor(scene: Scene);
  45765. /**
  45766. * Registers the component in a given scene
  45767. */
  45768. register(): void;
  45769. /**
  45770. * Rebuilds the elements related to this component in case of
  45771. * context lost for instance.
  45772. */
  45773. rebuild(): void;
  45774. /**
  45775. * Serializes the component data to the specified json object
  45776. * @param serializationObject The object to serialize to
  45777. */
  45778. serialize(serializationObject: any): void;
  45779. /**
  45780. * Adds all the element from the container to the scene
  45781. * @param container the container holding the elements
  45782. */
  45783. addFromContainer(container: AbstractScene): void;
  45784. /**
  45785. * Removes all the elements in the container from the scene
  45786. * @param container contains the elements to remove
  45787. * @param dispose if the removed element should be disposed (default: false)
  45788. */
  45789. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45790. /**
  45791. * Disposes the component and the associated ressources.
  45792. */
  45793. dispose(): void;
  45794. private _isReadyForMesh;
  45795. private _renderMainTexture;
  45796. private _setStencil;
  45797. private _setStencilBack;
  45798. private _draw;
  45799. private _drawCamera;
  45800. private _drawRenderingGroup;
  45801. }
  45802. }
  45803. declare module BABYLON {
  45804. /** @hidden */
  45805. export var glowMapMergePixelShader: {
  45806. name: string;
  45807. shader: string;
  45808. };
  45809. }
  45810. declare module BABYLON {
  45811. /** @hidden */
  45812. export var glowMapMergeVertexShader: {
  45813. name: string;
  45814. shader: string;
  45815. };
  45816. }
  45817. declare module BABYLON {
  45818. interface AbstractScene {
  45819. /**
  45820. * Return a the first highlight layer of the scene with a given name.
  45821. * @param name The name of the highlight layer to look for.
  45822. * @return The highlight layer if found otherwise null.
  45823. */
  45824. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  45825. }
  45826. /**
  45827. * Glow layer options. This helps customizing the behaviour
  45828. * of the glow layer.
  45829. */
  45830. export interface IGlowLayerOptions {
  45831. /**
  45832. * Multiplication factor apply to the canvas size to compute the render target size
  45833. * used to generated the glowing objects (the smaller the faster).
  45834. */
  45835. mainTextureRatio: number;
  45836. /**
  45837. * Enforces a fixed size texture to ensure resize independant blur.
  45838. */
  45839. mainTextureFixedSize?: number;
  45840. /**
  45841. * How big is the kernel of the blur texture.
  45842. */
  45843. blurKernelSize: number;
  45844. /**
  45845. * The camera attached to the layer.
  45846. */
  45847. camera: Nullable<Camera>;
  45848. /**
  45849. * Enable MSAA by chosing the number of samples.
  45850. */
  45851. mainTextureSamples?: number;
  45852. /**
  45853. * The rendering group to draw the layer in.
  45854. */
  45855. renderingGroupId: number;
  45856. }
  45857. /**
  45858. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  45859. *
  45860. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  45861. * glowy meshes to your scene.
  45862. *
  45863. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  45864. */
  45865. export class GlowLayer extends EffectLayer {
  45866. /**
  45867. * Effect Name of the layer.
  45868. */
  45869. static readonly EffectName: string;
  45870. /**
  45871. * The default blur kernel size used for the glow.
  45872. */
  45873. static DefaultBlurKernelSize: number;
  45874. /**
  45875. * The default texture size ratio used for the glow.
  45876. */
  45877. static DefaultTextureRatio: number;
  45878. /**
  45879. * Sets the kernel size of the blur.
  45880. */
  45881. /**
  45882. * Gets the kernel size of the blur.
  45883. */
  45884. blurKernelSize: number;
  45885. /**
  45886. * Sets the glow intensity.
  45887. */
  45888. /**
  45889. * Gets the glow intensity.
  45890. */
  45891. intensity: number;
  45892. private _options;
  45893. private _intensity;
  45894. private _horizontalBlurPostprocess1;
  45895. private _verticalBlurPostprocess1;
  45896. private _horizontalBlurPostprocess2;
  45897. private _verticalBlurPostprocess2;
  45898. private _blurTexture1;
  45899. private _blurTexture2;
  45900. private _postProcesses1;
  45901. private _postProcesses2;
  45902. private _includedOnlyMeshes;
  45903. private _excludedMeshes;
  45904. /**
  45905. * Callback used to let the user override the color selection on a per mesh basis
  45906. */
  45907. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  45908. /**
  45909. * Callback used to let the user override the texture selection on a per mesh basis
  45910. */
  45911. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  45912. /**
  45913. * Instantiates a new glow Layer and references it to the scene.
  45914. * @param name The name of the layer
  45915. * @param scene The scene to use the layer in
  45916. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  45917. */
  45918. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  45919. /**
  45920. * Get the effect name of the layer.
  45921. * @return The effect name
  45922. */
  45923. getEffectName(): string;
  45924. /**
  45925. * Create the merge effect. This is the shader use to blit the information back
  45926. * to the main canvas at the end of the scene rendering.
  45927. */
  45928. protected _createMergeEffect(): Effect;
  45929. /**
  45930. * Creates the render target textures and post processes used in the glow layer.
  45931. */
  45932. protected _createTextureAndPostProcesses(): void;
  45933. /**
  45934. * Checks for the readiness of the element composing the layer.
  45935. * @param subMesh the mesh to check for
  45936. * @param useInstances specify wether or not to use instances to render the mesh
  45937. * @param emissiveTexture the associated emissive texture used to generate the glow
  45938. * @return true if ready otherwise, false
  45939. */
  45940. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  45941. /**
  45942. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  45943. */
  45944. needStencil(): boolean;
  45945. /**
  45946. * Returns true if the mesh can be rendered, otherwise false.
  45947. * @param mesh The mesh to render
  45948. * @param material The material used on the mesh
  45949. * @returns true if it can be rendered otherwise false
  45950. */
  45951. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  45952. /**
  45953. * Implementation specific of rendering the generating effect on the main canvas.
  45954. * @param effect The effect used to render through
  45955. */
  45956. protected _internalRender(effect: Effect): void;
  45957. /**
  45958. * Sets the required values for both the emissive texture and and the main color.
  45959. */
  45960. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  45961. /**
  45962. * Returns true if the mesh should render, otherwise false.
  45963. * @param mesh The mesh to render
  45964. * @returns true if it should render otherwise false
  45965. */
  45966. protected _shouldRenderMesh(mesh: Mesh): boolean;
  45967. /**
  45968. * Adds specific effects defines.
  45969. * @param defines The defines to add specifics to.
  45970. */
  45971. protected _addCustomEffectDefines(defines: string[]): void;
  45972. /**
  45973. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  45974. * @param mesh The mesh to exclude from the glow layer
  45975. */
  45976. addExcludedMesh(mesh: Mesh): void;
  45977. /**
  45978. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  45979. * @param mesh The mesh to remove
  45980. */
  45981. removeExcludedMesh(mesh: Mesh): void;
  45982. /**
  45983. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  45984. * @param mesh The mesh to include in the glow layer
  45985. */
  45986. addIncludedOnlyMesh(mesh: Mesh): void;
  45987. /**
  45988. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  45989. * @param mesh The mesh to remove
  45990. */
  45991. removeIncludedOnlyMesh(mesh: Mesh): void;
  45992. /**
  45993. * Determine if a given mesh will be used in the glow layer
  45994. * @param mesh The mesh to test
  45995. * @returns true if the mesh will be highlighted by the current glow layer
  45996. */
  45997. hasMesh(mesh: AbstractMesh): boolean;
  45998. /**
  45999. * Free any resources and references associated to a mesh.
  46000. * Internal use
  46001. * @param mesh The mesh to free.
  46002. * @hidden
  46003. */ disposeMesh(mesh: Mesh): void;
  46004. /**
  46005. * Gets the class name of the effect layer
  46006. * @returns the string with the class name of the effect layer
  46007. */
  46008. getClassName(): string;
  46009. /**
  46010. * Serializes this glow layer
  46011. * @returns a serialized glow layer object
  46012. */
  46013. serialize(): any;
  46014. /**
  46015. * Creates a Glow Layer from parsed glow layer data
  46016. * @param parsedGlowLayer defines glow layer data
  46017. * @param scene defines the current scene
  46018. * @param rootUrl defines the root URL containing the glow layer information
  46019. * @returns a parsed Glow Layer
  46020. */
  46021. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46022. }
  46023. }
  46024. declare module BABYLON {
  46025. /** @hidden */
  46026. export var glowBlurPostProcessPixelShader: {
  46027. name: string;
  46028. shader: string;
  46029. };
  46030. }
  46031. declare module BABYLON {
  46032. interface AbstractScene {
  46033. /**
  46034. * Return a the first highlight layer of the scene with a given name.
  46035. * @param name The name of the highlight layer to look for.
  46036. * @return The highlight layer if found otherwise null.
  46037. */
  46038. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46039. }
  46040. /**
  46041. * Highlight layer options. This helps customizing the behaviour
  46042. * of the highlight layer.
  46043. */
  46044. export interface IHighlightLayerOptions {
  46045. /**
  46046. * Multiplication factor apply to the canvas size to compute the render target size
  46047. * used to generated the glowing objects (the smaller the faster).
  46048. */
  46049. mainTextureRatio: number;
  46050. /**
  46051. * Enforces a fixed size texture to ensure resize independant blur.
  46052. */
  46053. mainTextureFixedSize?: number;
  46054. /**
  46055. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46056. * of the picture to blur (the smaller the faster).
  46057. */
  46058. blurTextureSizeRatio: number;
  46059. /**
  46060. * How big in texel of the blur texture is the vertical blur.
  46061. */
  46062. blurVerticalSize: number;
  46063. /**
  46064. * How big in texel of the blur texture is the horizontal blur.
  46065. */
  46066. blurHorizontalSize: number;
  46067. /**
  46068. * Alpha blending mode used to apply the blur. Default is combine.
  46069. */
  46070. alphaBlendingMode: number;
  46071. /**
  46072. * The camera attached to the layer.
  46073. */
  46074. camera: Nullable<Camera>;
  46075. /**
  46076. * Should we display highlight as a solid stroke?
  46077. */
  46078. isStroke?: boolean;
  46079. /**
  46080. * The rendering group to draw the layer in.
  46081. */
  46082. renderingGroupId: number;
  46083. }
  46084. /**
  46085. * The highlight layer Helps adding a glow effect around a mesh.
  46086. *
  46087. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46088. * glowy meshes to your scene.
  46089. *
  46090. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46091. */
  46092. export class HighlightLayer extends EffectLayer {
  46093. name: string;
  46094. /**
  46095. * Effect Name of the highlight layer.
  46096. */
  46097. static readonly EffectName: string;
  46098. /**
  46099. * The neutral color used during the preparation of the glow effect.
  46100. * This is black by default as the blend operation is a blend operation.
  46101. */
  46102. static NeutralColor: Color4;
  46103. /**
  46104. * Stencil value used for glowing meshes.
  46105. */
  46106. static GlowingMeshStencilReference: number;
  46107. /**
  46108. * Stencil value used for the other meshes in the scene.
  46109. */
  46110. static NormalMeshStencilReference: number;
  46111. /**
  46112. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46113. */
  46114. innerGlow: boolean;
  46115. /**
  46116. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46117. */
  46118. outerGlow: boolean;
  46119. /**
  46120. * Specifies the horizontal size of the blur.
  46121. */
  46122. /**
  46123. * Gets the horizontal size of the blur.
  46124. */
  46125. blurHorizontalSize: number;
  46126. /**
  46127. * Specifies the vertical size of the blur.
  46128. */
  46129. /**
  46130. * Gets the vertical size of the blur.
  46131. */
  46132. blurVerticalSize: number;
  46133. /**
  46134. * An event triggered when the highlight layer is being blurred.
  46135. */
  46136. onBeforeBlurObservable: Observable<HighlightLayer>;
  46137. /**
  46138. * An event triggered when the highlight layer has been blurred.
  46139. */
  46140. onAfterBlurObservable: Observable<HighlightLayer>;
  46141. private _instanceGlowingMeshStencilReference;
  46142. private _options;
  46143. private _downSamplePostprocess;
  46144. private _horizontalBlurPostprocess;
  46145. private _verticalBlurPostprocess;
  46146. private _blurTexture;
  46147. private _meshes;
  46148. private _excludedMeshes;
  46149. /**
  46150. * Instantiates a new highlight Layer and references it to the scene..
  46151. * @param name The name of the layer
  46152. * @param scene The scene to use the layer in
  46153. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46154. */
  46155. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46156. /**
  46157. * Get the effect name of the layer.
  46158. * @return The effect name
  46159. */
  46160. getEffectName(): string;
  46161. /**
  46162. * Create the merge effect. This is the shader use to blit the information back
  46163. * to the main canvas at the end of the scene rendering.
  46164. */
  46165. protected _createMergeEffect(): Effect;
  46166. /**
  46167. * Creates the render target textures and post processes used in the highlight layer.
  46168. */
  46169. protected _createTextureAndPostProcesses(): void;
  46170. /**
  46171. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46172. */
  46173. needStencil(): boolean;
  46174. /**
  46175. * Checks for the readiness of the element composing the layer.
  46176. * @param subMesh the mesh to check for
  46177. * @param useInstances specify wether or not to use instances to render the mesh
  46178. * @param emissiveTexture the associated emissive texture used to generate the glow
  46179. * @return true if ready otherwise, false
  46180. */
  46181. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46182. /**
  46183. * Implementation specific of rendering the generating effect on the main canvas.
  46184. * @param effect The effect used to render through
  46185. */
  46186. protected _internalRender(effect: Effect): void;
  46187. /**
  46188. * Returns true if the layer contains information to display, otherwise false.
  46189. */
  46190. shouldRender(): boolean;
  46191. /**
  46192. * Returns true if the mesh should render, otherwise false.
  46193. * @param mesh The mesh to render
  46194. * @returns true if it should render otherwise false
  46195. */
  46196. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46197. /**
  46198. * Sets the required values for both the emissive texture and and the main color.
  46199. */
  46200. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46201. /**
  46202. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46203. * @param mesh The mesh to exclude from the highlight layer
  46204. */
  46205. addExcludedMesh(mesh: Mesh): void;
  46206. /**
  46207. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46208. * @param mesh The mesh to highlight
  46209. */
  46210. removeExcludedMesh(mesh: Mesh): void;
  46211. /**
  46212. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46213. * @param mesh mesh to test
  46214. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46215. */
  46216. hasMesh(mesh: AbstractMesh): boolean;
  46217. /**
  46218. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46219. * @param mesh The mesh to highlight
  46220. * @param color The color of the highlight
  46221. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46222. */
  46223. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46224. /**
  46225. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46226. * @param mesh The mesh to highlight
  46227. */
  46228. removeMesh(mesh: Mesh): void;
  46229. /**
  46230. * Force the stencil to the normal expected value for none glowing parts
  46231. */
  46232. private _defaultStencilReference;
  46233. /**
  46234. * Free any resources and references associated to a mesh.
  46235. * Internal use
  46236. * @param mesh The mesh to free.
  46237. * @hidden
  46238. */ disposeMesh(mesh: Mesh): void;
  46239. /**
  46240. * Dispose the highlight layer and free resources.
  46241. */
  46242. dispose(): void;
  46243. /**
  46244. * Gets the class name of the effect layer
  46245. * @returns the string with the class name of the effect layer
  46246. */
  46247. getClassName(): string;
  46248. /**
  46249. * Serializes this Highlight layer
  46250. * @returns a serialized Highlight layer object
  46251. */
  46252. serialize(): any;
  46253. /**
  46254. * Creates a Highlight layer from parsed Highlight layer data
  46255. * @param parsedHightlightLayer defines the Highlight layer data
  46256. * @param scene defines the current scene
  46257. * @param rootUrl defines the root URL containing the Highlight layer information
  46258. * @returns a parsed Highlight layer
  46259. */
  46260. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46261. }
  46262. }
  46263. declare module BABYLON {
  46264. /** @hidden */
  46265. export var lensFlarePixelShader: {
  46266. name: string;
  46267. shader: string;
  46268. };
  46269. }
  46270. declare module BABYLON {
  46271. /** @hidden */
  46272. export var lensFlareVertexShader: {
  46273. name: string;
  46274. shader: string;
  46275. };
  46276. }
  46277. declare module BABYLON {
  46278. /**
  46279. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46280. * It is usually composed of several `lensFlare`.
  46281. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46282. */
  46283. export class LensFlareSystem {
  46284. /**
  46285. * Define the name of the lens flare system
  46286. */
  46287. name: string;
  46288. /**
  46289. * List of lens flares used in this system.
  46290. */
  46291. lensFlares: LensFlare[];
  46292. /**
  46293. * Define a limit from the border the lens flare can be visible.
  46294. */
  46295. borderLimit: number;
  46296. /**
  46297. * Define a viewport border we do not want to see the lens flare in.
  46298. */
  46299. viewportBorder: number;
  46300. /**
  46301. * Define a predicate which could limit the list of meshes able to occlude the effect.
  46302. */
  46303. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46304. /**
  46305. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  46306. */
  46307. layerMask: number;
  46308. /**
  46309. * Define the id of the lens flare system in the scene.
  46310. * (equal to name by default)
  46311. */
  46312. id: string;
  46313. private _scene;
  46314. private _emitter;
  46315. private _vertexBuffers;
  46316. private _indexBuffer;
  46317. private _effect;
  46318. private _positionX;
  46319. private _positionY;
  46320. private _isEnabled;
  46321. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46322. /**
  46323. * Instantiates a lens flare system.
  46324. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  46325. * It is usually composed of several `lensFlare`.
  46326. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46327. * @param name Define the name of the lens flare system in the scene
  46328. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  46329. * @param scene Define the scene the lens flare system belongs to
  46330. */
  46331. constructor(
  46332. /**
  46333. * Define the name of the lens flare system
  46334. */
  46335. name: string, emitter: any, scene: Scene);
  46336. /**
  46337. * Define if the lens flare system is enabled.
  46338. */
  46339. isEnabled: boolean;
  46340. /**
  46341. * Get the scene the effects belongs to.
  46342. * @returns the scene holding the lens flare system
  46343. */
  46344. getScene(): Scene;
  46345. /**
  46346. * Get the emitter of the lens flare system.
  46347. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46348. * @returns the emitter of the lens flare system
  46349. */
  46350. getEmitter(): any;
  46351. /**
  46352. * Set the emitter of the lens flare system.
  46353. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  46354. * @param newEmitter Define the new emitter of the system
  46355. */
  46356. setEmitter(newEmitter: any): void;
  46357. /**
  46358. * Get the lens flare system emitter position.
  46359. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  46360. * @returns the position
  46361. */
  46362. getEmitterPosition(): Vector3;
  46363. /**
  46364. * @hidden
  46365. */
  46366. computeEffectivePosition(globalViewport: Viewport): boolean;
  46367. /** @hidden */ isVisible(): boolean;
  46368. /**
  46369. * @hidden
  46370. */
  46371. render(): boolean;
  46372. /**
  46373. * Dispose and release the lens flare with its associated resources.
  46374. */
  46375. dispose(): void;
  46376. /**
  46377. * Parse a lens flare system from a JSON repressentation
  46378. * @param parsedLensFlareSystem Define the JSON to parse
  46379. * @param scene Define the scene the parsed system should be instantiated in
  46380. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  46381. * @returns the parsed system
  46382. */
  46383. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  46384. /**
  46385. * Serialize the current Lens Flare System into a JSON representation.
  46386. * @returns the serialized JSON
  46387. */
  46388. serialize(): any;
  46389. }
  46390. }
  46391. declare module BABYLON {
  46392. /**
  46393. * This represents one of the lens effect in a `lensFlareSystem`.
  46394. * It controls one of the indiviual texture used in the effect.
  46395. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46396. */
  46397. export class LensFlare {
  46398. /**
  46399. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46400. */
  46401. size: number;
  46402. /**
  46403. * 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.
  46404. */
  46405. position: number;
  46406. /**
  46407. * Define the lens color.
  46408. */
  46409. color: Color3;
  46410. /**
  46411. * Define the lens texture.
  46412. */
  46413. texture: Nullable<Texture>;
  46414. /**
  46415. * Define the alpha mode to render this particular lens.
  46416. */
  46417. alphaMode: number;
  46418. private _system;
  46419. /**
  46420. * Creates a new Lens Flare.
  46421. * This represents one of the lens effect in a `lensFlareSystem`.
  46422. * It controls one of the indiviual texture used in the effect.
  46423. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46424. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  46425. * @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.
  46426. * @param color Define the lens color
  46427. * @param imgUrl Define the lens texture url
  46428. * @param system Define the `lensFlareSystem` this flare is part of
  46429. * @returns The newly created Lens Flare
  46430. */
  46431. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  46432. /**
  46433. * Instantiates a new Lens Flare.
  46434. * This represents one of the lens effect in a `lensFlareSystem`.
  46435. * It controls one of the indiviual texture used in the effect.
  46436. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46437. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  46438. * @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.
  46439. * @param color Define the lens color
  46440. * @param imgUrl Define the lens texture url
  46441. * @param system Define the `lensFlareSystem` this flare is part of
  46442. */
  46443. constructor(
  46444. /**
  46445. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  46446. */
  46447. size: number,
  46448. /**
  46449. * 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.
  46450. */
  46451. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  46452. /**
  46453. * Dispose and release the lens flare with its associated resources.
  46454. */
  46455. dispose(): void;
  46456. }
  46457. }
  46458. declare module BABYLON {
  46459. interface AbstractScene {
  46460. /**
  46461. * The list of lens flare system added to the scene
  46462. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  46463. */
  46464. lensFlareSystems: Array<LensFlareSystem>;
  46465. /**
  46466. * Removes the given lens flare system from this scene.
  46467. * @param toRemove The lens flare system to remove
  46468. * @returns The index of the removed lens flare system
  46469. */
  46470. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  46471. /**
  46472. * Adds the given lens flare system to this scene
  46473. * @param newLensFlareSystem The lens flare system to add
  46474. */
  46475. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  46476. /**
  46477. * Gets a lens flare system using its name
  46478. * @param name defines the name to look for
  46479. * @returns the lens flare system or null if not found
  46480. */
  46481. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  46482. /**
  46483. * Gets a lens flare system using its id
  46484. * @param id defines the id to look for
  46485. * @returns the lens flare system or null if not found
  46486. */
  46487. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  46488. }
  46489. /**
  46490. * Defines the lens flare scene component responsible to manage any lens flares
  46491. * in a given scene.
  46492. */
  46493. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  46494. /**
  46495. * The component name helpfull to identify the component in the list of scene components.
  46496. */
  46497. readonly name: string;
  46498. /**
  46499. * The scene the component belongs to.
  46500. */
  46501. scene: Scene;
  46502. /**
  46503. * Creates a new instance of the component for the given scene
  46504. * @param scene Defines the scene to register the component in
  46505. */
  46506. constructor(scene: Scene);
  46507. /**
  46508. * Registers the component in a given scene
  46509. */
  46510. register(): void;
  46511. /**
  46512. * Rebuilds the elements related to this component in case of
  46513. * context lost for instance.
  46514. */
  46515. rebuild(): void;
  46516. /**
  46517. * Adds all the element from the container to the scene
  46518. * @param container the container holding the elements
  46519. */
  46520. addFromContainer(container: AbstractScene): void;
  46521. /**
  46522. * Removes all the elements in the container from the scene
  46523. * @param container contains the elements to remove
  46524. * @param dispose if the removed element should be disposed (default: false)
  46525. */
  46526. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46527. /**
  46528. * Serializes the component data to the specified json object
  46529. * @param serializationObject The object to serialize to
  46530. */
  46531. serialize(serializationObject: any): void;
  46532. /**
  46533. * Disposes the component and the associated ressources.
  46534. */
  46535. dispose(): void;
  46536. private _draw;
  46537. }
  46538. }
  46539. declare module BABYLON {
  46540. /**
  46541. * Defines the shadow generator component responsible to manage any shadow generators
  46542. * in a given scene.
  46543. */
  46544. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  46545. /**
  46546. * The component name helpfull to identify the component in the list of scene components.
  46547. */
  46548. readonly name: string;
  46549. /**
  46550. * The scene the component belongs to.
  46551. */
  46552. scene: Scene;
  46553. /**
  46554. * Creates a new instance of the component for the given scene
  46555. * @param scene Defines the scene to register the component in
  46556. */
  46557. constructor(scene: Scene);
  46558. /**
  46559. * Registers the component in a given scene
  46560. */
  46561. register(): void;
  46562. /**
  46563. * Rebuilds the elements related to this component in case of
  46564. * context lost for instance.
  46565. */
  46566. rebuild(): void;
  46567. /**
  46568. * Serializes the component data to the specified json object
  46569. * @param serializationObject The object to serialize to
  46570. */
  46571. serialize(serializationObject: any): void;
  46572. /**
  46573. * Adds all the element from the container to the scene
  46574. * @param container the container holding the elements
  46575. */
  46576. addFromContainer(container: AbstractScene): void;
  46577. /**
  46578. * Removes all the elements in the container from the scene
  46579. * @param container contains the elements to remove
  46580. * @param dispose if the removed element should be disposed (default: false)
  46581. */
  46582. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46583. /**
  46584. * Rebuilds the elements related to this component in case of
  46585. * context lost for instance.
  46586. */
  46587. dispose(): void;
  46588. private _gatherRenderTargets;
  46589. }
  46590. }
  46591. declare module BABYLON {
  46592. /**
  46593. * A point light is a light defined by an unique point in world space.
  46594. * The light is emitted in every direction from this point.
  46595. * A good example of a point light is a standard light bulb.
  46596. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46597. */
  46598. export class PointLight extends ShadowLight {
  46599. private _shadowAngle;
  46600. /**
  46601. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46602. * This specifies what angle the shadow will use to be created.
  46603. *
  46604. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46605. */
  46606. /**
  46607. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46608. * This specifies what angle the shadow will use to be created.
  46609. *
  46610. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46611. */
  46612. shadowAngle: number;
  46613. /**
  46614. * Gets the direction if it has been set.
  46615. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46616. */
  46617. /**
  46618. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46619. */
  46620. direction: Vector3;
  46621. /**
  46622. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46623. * A PointLight emits the light in every direction.
  46624. * It can cast shadows.
  46625. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46626. * ```javascript
  46627. * var pointLight = new PointLight("pl", camera.position, scene);
  46628. * ```
  46629. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46630. * @param name The light friendly name
  46631. * @param position The position of the point light in the scene
  46632. * @param scene The scene the lights belongs to
  46633. */
  46634. constructor(name: string, position: Vector3, scene: Scene);
  46635. /**
  46636. * Returns the string "PointLight"
  46637. * @returns the class name
  46638. */
  46639. getClassName(): string;
  46640. /**
  46641. * Returns the integer 0.
  46642. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46643. */
  46644. getTypeID(): number;
  46645. /**
  46646. * Specifies wether or not the shadowmap should be a cube texture.
  46647. * @returns true if the shadowmap needs to be a cube texture.
  46648. */
  46649. needCube(): boolean;
  46650. /**
  46651. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  46652. * @param faceIndex The index of the face we are computed the direction to generate shadow
  46653. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  46654. */
  46655. getShadowDirection(faceIndex?: number): Vector3;
  46656. /**
  46657. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  46658. * - fov = PI / 2
  46659. * - aspect ratio : 1.0
  46660. * - z-near and far equal to the active camera minZ and maxZ.
  46661. * Returns the PointLight.
  46662. */
  46663. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  46664. protected _buildUniformLayout(): void;
  46665. /**
  46666. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  46667. * @param effect The effect to update
  46668. * @param lightIndex The index of the light in the effect to update
  46669. * @returns The point light
  46670. */
  46671. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  46672. /**
  46673. * Prepares the list of defines specific to the light type.
  46674. * @param defines the list of defines
  46675. * @param lightIndex defines the index of the light for the effect
  46676. */
  46677. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  46678. }
  46679. }
  46680. declare module BABYLON {
  46681. /**
  46682. * Header information of HDR texture files.
  46683. */
  46684. export interface HDRInfo {
  46685. /**
  46686. * The height of the texture in pixels.
  46687. */
  46688. height: number;
  46689. /**
  46690. * The width of the texture in pixels.
  46691. */
  46692. width: number;
  46693. /**
  46694. * The index of the beginning of the data in the binary file.
  46695. */
  46696. dataPosition: number;
  46697. }
  46698. /**
  46699. * This groups tools to convert HDR texture to native colors array.
  46700. */
  46701. export class HDRTools {
  46702. private static Ldexp;
  46703. private static Rgbe2float;
  46704. private static readStringLine;
  46705. /**
  46706. * Reads header information from an RGBE texture stored in a native array.
  46707. * More information on this format are available here:
  46708. * https://en.wikipedia.org/wiki/RGBE_image_format
  46709. *
  46710. * @param uint8array The binary file stored in native array.
  46711. * @return The header information.
  46712. */
  46713. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  46714. /**
  46715. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  46716. * This RGBE texture needs to store the information as a panorama.
  46717. *
  46718. * More information on this format are available here:
  46719. * https://en.wikipedia.org/wiki/RGBE_image_format
  46720. *
  46721. * @param buffer The binary file stored in an array buffer.
  46722. * @param size The expected size of the extracted cubemap.
  46723. * @return The Cube Map information.
  46724. */
  46725. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  46726. /**
  46727. * Returns the pixels data extracted from an RGBE texture.
  46728. * This pixels will be stored left to right up to down in the R G B order in one array.
  46729. *
  46730. * More information on this format are available here:
  46731. * https://en.wikipedia.org/wiki/RGBE_image_format
  46732. *
  46733. * @param uint8array The binary file stored in an array buffer.
  46734. * @param hdrInfo The header information of the file.
  46735. * @return The pixels data in RGB right to left up to down order.
  46736. */
  46737. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  46738. private static RGBE_ReadPixels_RLE;
  46739. }
  46740. }
  46741. declare module BABYLON {
  46742. /**
  46743. * This represents a texture coming from an HDR input.
  46744. *
  46745. * The only supported format is currently panorama picture stored in RGBE format.
  46746. * Example of such files can be found on HDRLib: http://hdrlib.com/
  46747. */
  46748. export class HDRCubeTexture extends BaseTexture {
  46749. private static _facesMapping;
  46750. private _generateHarmonics;
  46751. private _noMipmap;
  46752. private _textureMatrix;
  46753. private _size;
  46754. private _onLoad;
  46755. private _onError;
  46756. /**
  46757. * The texture URL.
  46758. */
  46759. url: string;
  46760. /**
  46761. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  46762. */
  46763. coordinatesMode: number;
  46764. protected _isBlocking: boolean;
  46765. /**
  46766. * Sets wether or not the texture is blocking during loading.
  46767. */
  46768. /**
  46769. * Gets wether or not the texture is blocking during loading.
  46770. */
  46771. isBlocking: boolean;
  46772. protected _rotationY: number;
  46773. /**
  46774. * Sets texture matrix rotation angle around Y axis in radians.
  46775. */
  46776. /**
  46777. * Gets texture matrix rotation angle around Y axis radians.
  46778. */
  46779. rotationY: number;
  46780. /**
  46781. * Gets or sets the center of the bounding box associated with the cube texture
  46782. * It must define where the camera used to render the texture was set
  46783. */
  46784. boundingBoxPosition: Vector3;
  46785. private _boundingBoxSize;
  46786. /**
  46787. * Gets or sets the size of the bounding box associated with the cube texture
  46788. * When defined, the cubemap will switch to local mode
  46789. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  46790. * @example https://www.babylonjs-playground.com/#RNASML
  46791. */
  46792. boundingBoxSize: Vector3;
  46793. /**
  46794. * Instantiates an HDRTexture from the following parameters.
  46795. *
  46796. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  46797. * @param scene The scene the texture will be used in
  46798. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  46799. * @param noMipmap Forces to not generate the mipmap if true
  46800. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  46801. * @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)
  46802. * @param reserved Reserved flag for internal use.
  46803. */
  46804. 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>);
  46805. /**
  46806. * Get the current class name of the texture useful for serialization or dynamic coding.
  46807. * @returns "HDRCubeTexture"
  46808. */
  46809. getClassName(): string;
  46810. /**
  46811. * Occurs when the file is raw .hdr file.
  46812. */
  46813. private loadTexture;
  46814. clone(): HDRCubeTexture;
  46815. delayLoad(): void;
  46816. /**
  46817. * Get the texture reflection matrix used to rotate/transform the reflection.
  46818. * @returns the reflection matrix
  46819. */
  46820. getReflectionTextureMatrix(): Matrix;
  46821. /**
  46822. * Set the texture reflection matrix used to rotate/transform the reflection.
  46823. * @param value Define the reflection matrix to set
  46824. */
  46825. setReflectionTextureMatrix(value: Matrix): void;
  46826. /**
  46827. * Parses a JSON representation of an HDR Texture in order to create the texture
  46828. * @param parsedTexture Define the JSON representation
  46829. * @param scene Define the scene the texture should be created in
  46830. * @param rootUrl Define the root url in case we need to load relative dependencies
  46831. * @returns the newly created texture after parsing
  46832. */
  46833. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  46834. serialize(): any;
  46835. }
  46836. }
  46837. declare module BABYLON {
  46838. /**
  46839. * Class used to control physics engine
  46840. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  46841. */
  46842. export class PhysicsEngine implements IPhysicsEngine {
  46843. private _physicsPlugin;
  46844. /**
  46845. * Global value used to control the smallest number supported by the simulation
  46846. */
  46847. static Epsilon: number;
  46848. private _impostors;
  46849. private _joints;
  46850. /**
  46851. * Gets the gravity vector used by the simulation
  46852. */
  46853. gravity: Vector3;
  46854. /**
  46855. * Factory used to create the default physics plugin.
  46856. * @returns The default physics plugin
  46857. */
  46858. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  46859. /**
  46860. * Creates a new Physics Engine
  46861. * @param gravity defines the gravity vector used by the simulation
  46862. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  46863. */
  46864. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  46865. /**
  46866. * Sets the gravity vector used by the simulation
  46867. * @param gravity defines the gravity vector to use
  46868. */
  46869. setGravity(gravity: Vector3): void;
  46870. /**
  46871. * Set the time step of the physics engine.
  46872. * Default is 1/60.
  46873. * To slow it down, enter 1/600 for example.
  46874. * To speed it up, 1/30
  46875. * @param newTimeStep defines the new timestep to apply to this world.
  46876. */
  46877. setTimeStep(newTimeStep?: number): void;
  46878. /**
  46879. * Get the time step of the physics engine.
  46880. * @returns the current time step
  46881. */
  46882. getTimeStep(): number;
  46883. /**
  46884. * Release all resources
  46885. */
  46886. dispose(): void;
  46887. /**
  46888. * Gets the name of the current physics plugin
  46889. * @returns the name of the plugin
  46890. */
  46891. getPhysicsPluginName(): string;
  46892. /**
  46893. * Adding a new impostor for the impostor tracking.
  46894. * This will be done by the impostor itself.
  46895. * @param impostor the impostor to add
  46896. */
  46897. addImpostor(impostor: PhysicsImpostor): void;
  46898. /**
  46899. * Remove an impostor from the engine.
  46900. * This impostor and its mesh will not longer be updated by the physics engine.
  46901. * @param impostor the impostor to remove
  46902. */
  46903. removeImpostor(impostor: PhysicsImpostor): void;
  46904. /**
  46905. * Add a joint to the physics engine
  46906. * @param mainImpostor defines the main impostor to which the joint is added.
  46907. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  46908. * @param joint defines the joint that will connect both impostors.
  46909. */
  46910. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  46911. /**
  46912. * Removes a joint from the simulation
  46913. * @param mainImpostor defines the impostor used with the joint
  46914. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  46915. * @param joint defines the joint to remove
  46916. */
  46917. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  46918. /**
  46919. * Called by the scene. No need to call it.
  46920. * @param delta defines the timespam between frames
  46921. */ step(delta: number): void;
  46922. /**
  46923. * Gets the current plugin used to run the simulation
  46924. * @returns current plugin
  46925. */
  46926. getPhysicsPlugin(): IPhysicsEnginePlugin;
  46927. /**
  46928. * Gets the list of physic impostors
  46929. * @returns an array of PhysicsImpostor
  46930. */
  46931. getImpostors(): Array<PhysicsImpostor>;
  46932. /**
  46933. * Gets the impostor for a physics enabled object
  46934. * @param object defines the object impersonated by the impostor
  46935. * @returns the PhysicsImpostor or null if not found
  46936. */
  46937. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  46938. /**
  46939. * Gets the impostor for a physics body object
  46940. * @param body defines physics body used by the impostor
  46941. * @returns the PhysicsImpostor or null if not found
  46942. */
  46943. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  46944. /**
  46945. * Does a raycast in the physics world
  46946. * @param from when should the ray start?
  46947. * @param to when should the ray end?
  46948. * @returns PhysicsRaycastResult
  46949. */
  46950. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  46951. }
  46952. }
  46953. declare module BABYLON {
  46954. /** @hidden */
  46955. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  46956. private _useDeltaForWorldStep;
  46957. world: any;
  46958. name: string;
  46959. private _physicsMaterials;
  46960. private _fixedTimeStep;
  46961. private _cannonRaycastResult;
  46962. private _raycastResult;
  46963. BJSCANNON: any;
  46964. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  46965. setGravity(gravity: Vector3): void;
  46966. setTimeStep(timeStep: number): void;
  46967. getTimeStep(): number;
  46968. executeStep(delta: number): void;
  46969. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46970. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  46971. generatePhysicsBody(impostor: PhysicsImpostor): void;
  46972. private _processChildMeshes;
  46973. removePhysicsBody(impostor: PhysicsImpostor): void;
  46974. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  46975. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  46976. private _addMaterial;
  46977. private _checkWithEpsilon;
  46978. private _createShape;
  46979. private _createHeightmap;
  46980. private _minus90X;
  46981. private _plus90X;
  46982. private _tmpPosition;
  46983. private _tmpDeltaPosition;
  46984. private _tmpUnityRotation;
  46985. private _updatePhysicsBodyTransformation;
  46986. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  46987. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  46988. isSupported(): boolean;
  46989. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46990. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  46991. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46992. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  46993. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  46994. getBodyMass(impostor: PhysicsImpostor): number;
  46995. getBodyFriction(impostor: PhysicsImpostor): number;
  46996. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  46997. getBodyRestitution(impostor: PhysicsImpostor): number;
  46998. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  46999. sleepBody(impostor: PhysicsImpostor): void;
  47000. wakeUpBody(impostor: PhysicsImpostor): void;
  47001. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47002. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47003. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47004. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47005. getRadius(impostor: PhysicsImpostor): number;
  47006. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47007. dispose(): void;
  47008. private _extendNamespace;
  47009. /**
  47010. * Does a raycast in the physics world
  47011. * @param from when should the ray start?
  47012. * @param to when should the ray end?
  47013. * @returns PhysicsRaycastResult
  47014. */
  47015. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47016. }
  47017. }
  47018. declare module BABYLON {
  47019. /** @hidden */
  47020. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47021. world: any;
  47022. name: string;
  47023. BJSOIMO: any;
  47024. private _raycastResult;
  47025. constructor(iterations?: number, oimoInjection?: any);
  47026. setGravity(gravity: Vector3): void;
  47027. setTimeStep(timeStep: number): void;
  47028. getTimeStep(): number;
  47029. private _tmpImpostorsArray;
  47030. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47031. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47032. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47033. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47034. private _tmpPositionVector;
  47035. removePhysicsBody(impostor: PhysicsImpostor): void;
  47036. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47037. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47038. isSupported(): boolean;
  47039. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47040. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47041. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47042. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47043. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47044. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47045. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47046. getBodyMass(impostor: PhysicsImpostor): number;
  47047. getBodyFriction(impostor: PhysicsImpostor): number;
  47048. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47049. getBodyRestitution(impostor: PhysicsImpostor): number;
  47050. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47051. sleepBody(impostor: PhysicsImpostor): void;
  47052. wakeUpBody(impostor: PhysicsImpostor): void;
  47053. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47054. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47055. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47056. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47057. getRadius(impostor: PhysicsImpostor): number;
  47058. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47059. dispose(): void;
  47060. /**
  47061. * Does a raycast in the physics world
  47062. * @param from when should the ray start?
  47063. * @param to when should the ray end?
  47064. * @returns PhysicsRaycastResult
  47065. */
  47066. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47067. }
  47068. }
  47069. declare module BABYLON {
  47070. /**
  47071. * Class containing static functions to help procedurally build meshes
  47072. */
  47073. export class RibbonBuilder {
  47074. /**
  47075. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47076. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47077. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47078. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47079. * * 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
  47080. * * 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
  47081. * * 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
  47082. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47083. * * 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
  47084. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47085. * * 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
  47086. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47087. * * 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
  47088. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47090. * @param name defines the name of the mesh
  47091. * @param options defines the options used to create the mesh
  47092. * @param scene defines the hosting scene
  47093. * @returns the ribbon mesh
  47094. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47095. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47096. */
  47097. static CreateRibbon(name: string, options: {
  47098. pathArray: Vector3[][];
  47099. closeArray?: boolean;
  47100. closePath?: boolean;
  47101. offset?: number;
  47102. updatable?: boolean;
  47103. sideOrientation?: number;
  47104. frontUVs?: Vector4;
  47105. backUVs?: Vector4;
  47106. instance?: Mesh;
  47107. invertUV?: boolean;
  47108. uvs?: Vector2[];
  47109. colors?: Color4[];
  47110. }, scene?: Nullable<Scene>): Mesh;
  47111. }
  47112. }
  47113. declare module BABYLON {
  47114. /**
  47115. * Class containing static functions to help procedurally build meshes
  47116. */
  47117. export class ShapeBuilder {
  47118. /**
  47119. * 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.
  47120. * * 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.
  47121. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47122. * * 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.
  47123. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47124. * * 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
  47125. * * 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
  47126. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47127. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47128. * * 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
  47129. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47131. * @param name defines the name of the mesh
  47132. * @param options defines the options used to create the mesh
  47133. * @param scene defines the hosting scene
  47134. * @returns the extruded shape mesh
  47135. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47136. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47137. */
  47138. static ExtrudeShape(name: string, options: {
  47139. shape: Vector3[];
  47140. path: Vector3[];
  47141. scale?: number;
  47142. rotation?: number;
  47143. cap?: number;
  47144. updatable?: boolean;
  47145. sideOrientation?: number;
  47146. frontUVs?: Vector4;
  47147. backUVs?: Vector4;
  47148. instance?: Mesh;
  47149. invertUV?: boolean;
  47150. }, scene?: Nullable<Scene>): Mesh;
  47151. /**
  47152. * Creates an custom extruded shape mesh.
  47153. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47154. * * 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.
  47155. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47156. * * 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
  47157. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  47158. * * 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
  47159. * * It must returns a float value that will be the scale value applied to the shape on each path point
  47160. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  47161. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  47162. * * 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
  47163. * * 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
  47164. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  47165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47166. * * 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
  47167. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47168. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47169. * @param name defines the name of the mesh
  47170. * @param options defines the options used to create the mesh
  47171. * @param scene defines the hosting scene
  47172. * @returns the custom extruded shape mesh
  47173. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  47174. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47175. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47176. */
  47177. static ExtrudeShapeCustom(name: string, options: {
  47178. shape: Vector3[];
  47179. path: Vector3[];
  47180. scaleFunction?: any;
  47181. rotationFunction?: any;
  47182. ribbonCloseArray?: boolean;
  47183. ribbonClosePath?: boolean;
  47184. cap?: number;
  47185. updatable?: boolean;
  47186. sideOrientation?: number;
  47187. frontUVs?: Vector4;
  47188. backUVs?: Vector4;
  47189. instance?: Mesh;
  47190. invertUV?: boolean;
  47191. }, scene: Scene): Mesh;
  47192. private static _ExtrudeShapeGeneric;
  47193. }
  47194. }
  47195. declare module BABYLON {
  47196. /**
  47197. * AmmoJS Physics plugin
  47198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  47199. * @see https://github.com/kripken/ammo.js/
  47200. */
  47201. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  47202. private _useDeltaForWorldStep;
  47203. /**
  47204. * Reference to the Ammo library
  47205. */
  47206. bjsAMMO: any;
  47207. /**
  47208. * Created ammoJS world which physics bodies are added to
  47209. */
  47210. world: any;
  47211. /**
  47212. * Name of the plugin
  47213. */
  47214. name: string;
  47215. private _timeStep;
  47216. private _fixedTimeStep;
  47217. private _maxSteps;
  47218. private _tmpQuaternion;
  47219. private _tmpAmmoTransform;
  47220. private _tmpAmmoQuaternion;
  47221. private _tmpAmmoConcreteContactResultCallback;
  47222. private _collisionConfiguration;
  47223. private _dispatcher;
  47224. private _overlappingPairCache;
  47225. private _solver;
  47226. private _softBodySolver;
  47227. private _tmpAmmoVectorA;
  47228. private _tmpAmmoVectorB;
  47229. private _tmpAmmoVectorC;
  47230. private _tmpAmmoVectorD;
  47231. private _tmpContactCallbackResult;
  47232. private _tmpAmmoVectorRCA;
  47233. private _tmpAmmoVectorRCB;
  47234. private _raycastResult;
  47235. private static readonly DISABLE_COLLISION_FLAG;
  47236. private static readonly KINEMATIC_FLAG;
  47237. private static readonly DISABLE_DEACTIVATION_FLAG;
  47238. /**
  47239. * Initializes the ammoJS plugin
  47240. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  47241. * @param ammoInjection can be used to inject your own ammo reference
  47242. */
  47243. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  47244. /**
  47245. * Sets the gravity of the physics world (m/(s^2))
  47246. * @param gravity Gravity to set
  47247. */
  47248. setGravity(gravity: Vector3): void;
  47249. /**
  47250. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  47251. * @param timeStep timestep to use in seconds
  47252. */
  47253. setTimeStep(timeStep: number): void;
  47254. /**
  47255. * 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)
  47256. * @param fixedTimeStep fixedTimeStep to use in seconds
  47257. */
  47258. setFixedTimeStep(fixedTimeStep: number): void;
  47259. /**
  47260. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  47261. * @param maxSteps the maximum number of steps by the physics engine per frame
  47262. */
  47263. setMaxSteps(maxSteps: number): void;
  47264. /**
  47265. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  47266. * @returns the current timestep in seconds
  47267. */
  47268. getTimeStep(): number;
  47269. private _isImpostorInContact;
  47270. private _isImpostorPairInContact;
  47271. private _stepSimulation;
  47272. /**
  47273. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  47274. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  47275. * After the step the babylon meshes are set to the position of the physics imposters
  47276. * @param delta amount of time to step forward
  47277. * @param impostors array of imposters to update before/after the step
  47278. */
  47279. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47280. /**
  47281. * Update babylon mesh to match physics world object
  47282. * @param impostor imposter to match
  47283. */
  47284. private _afterSoftStep;
  47285. /**
  47286. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47287. * @param impostor imposter to match
  47288. */
  47289. private _ropeStep;
  47290. /**
  47291. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  47292. * @param impostor imposter to match
  47293. */
  47294. private _softbodyOrClothStep;
  47295. private _tmpVector;
  47296. private _tmpMatrix;
  47297. /**
  47298. * Applies an impulse on the imposter
  47299. * @param impostor imposter to apply impulse to
  47300. * @param force amount of force to be applied to the imposter
  47301. * @param contactPoint the location to apply the impulse on the imposter
  47302. */
  47303. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47304. /**
  47305. * Applies a force on the imposter
  47306. * @param impostor imposter to apply force
  47307. * @param force amount of force to be applied to the imposter
  47308. * @param contactPoint the location to apply the force on the imposter
  47309. */
  47310. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47311. /**
  47312. * Creates a physics body using the plugin
  47313. * @param impostor the imposter to create the physics body on
  47314. */
  47315. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47316. /**
  47317. * Removes the physics body from the imposter and disposes of the body's memory
  47318. * @param impostor imposter to remove the physics body from
  47319. */
  47320. removePhysicsBody(impostor: PhysicsImpostor): void;
  47321. /**
  47322. * Generates a joint
  47323. * @param impostorJoint the imposter joint to create the joint with
  47324. */
  47325. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47326. /**
  47327. * Removes a joint
  47328. * @param impostorJoint the imposter joint to remove the joint from
  47329. */
  47330. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47331. private _addMeshVerts;
  47332. /**
  47333. * Initialise the soft body vertices to match its object's (mesh) vertices
  47334. * Softbody vertices (nodes) are in world space and to match this
  47335. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  47336. * @param impostor to create the softbody for
  47337. */
  47338. private _softVertexData;
  47339. /**
  47340. * Create an impostor's soft body
  47341. * @param impostor to create the softbody for
  47342. */
  47343. private _createSoftbody;
  47344. /**
  47345. * Create cloth for an impostor
  47346. * @param impostor to create the softbody for
  47347. */
  47348. private _createCloth;
  47349. /**
  47350. * Create rope for an impostor
  47351. * @param impostor to create the softbody for
  47352. */
  47353. private _createRope;
  47354. private _addHullVerts;
  47355. private _createShape;
  47356. /**
  47357. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  47358. * @param impostor imposter containing the physics body and babylon object
  47359. */
  47360. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47361. /**
  47362. * Sets the babylon object's position/rotation from the physics body's position/rotation
  47363. * @param impostor imposter containing the physics body and babylon object
  47364. * @param newPosition new position
  47365. * @param newRotation new rotation
  47366. */
  47367. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47368. /**
  47369. * If this plugin is supported
  47370. * @returns true if its supported
  47371. */
  47372. isSupported(): boolean;
  47373. /**
  47374. * Sets the linear velocity of the physics body
  47375. * @param impostor imposter to set the velocity on
  47376. * @param velocity velocity to set
  47377. */
  47378. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47379. /**
  47380. * Sets the angular velocity of the physics body
  47381. * @param impostor imposter to set the velocity on
  47382. * @param velocity velocity to set
  47383. */
  47384. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47385. /**
  47386. * gets the linear velocity
  47387. * @param impostor imposter to get linear velocity from
  47388. * @returns linear velocity
  47389. */
  47390. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47391. /**
  47392. * gets the angular velocity
  47393. * @param impostor imposter to get angular velocity from
  47394. * @returns angular velocity
  47395. */
  47396. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47397. /**
  47398. * Sets the mass of physics body
  47399. * @param impostor imposter to set the mass on
  47400. * @param mass mass to set
  47401. */
  47402. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47403. /**
  47404. * Gets the mass of the physics body
  47405. * @param impostor imposter to get the mass from
  47406. * @returns mass
  47407. */
  47408. getBodyMass(impostor: PhysicsImpostor): number;
  47409. /**
  47410. * Gets friction of the impostor
  47411. * @param impostor impostor to get friction from
  47412. * @returns friction value
  47413. */
  47414. getBodyFriction(impostor: PhysicsImpostor): number;
  47415. /**
  47416. * Sets friction of the impostor
  47417. * @param impostor impostor to set friction on
  47418. * @param friction friction value
  47419. */
  47420. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47421. /**
  47422. * Gets restitution of the impostor
  47423. * @param impostor impostor to get restitution from
  47424. * @returns restitution value
  47425. */
  47426. getBodyRestitution(impostor: PhysicsImpostor): number;
  47427. /**
  47428. * Sets resitution of the impostor
  47429. * @param impostor impostor to set resitution on
  47430. * @param restitution resitution value
  47431. */
  47432. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47433. /**
  47434. * Gets pressure inside the impostor
  47435. * @param impostor impostor to get pressure from
  47436. * @returns pressure value
  47437. */
  47438. getBodyPressure(impostor: PhysicsImpostor): number;
  47439. /**
  47440. * Sets pressure inside a soft body impostor
  47441. * Cloth and rope must remain 0 pressure
  47442. * @param impostor impostor to set pressure on
  47443. * @param pressure pressure value
  47444. */
  47445. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  47446. /**
  47447. * Gets stiffness of the impostor
  47448. * @param impostor impostor to get stiffness from
  47449. * @returns pressure value
  47450. */
  47451. getBodyStiffness(impostor: PhysicsImpostor): number;
  47452. /**
  47453. * Sets stiffness of the impostor
  47454. * @param impostor impostor to set stiffness on
  47455. * @param stiffness stiffness value from 0 to 1
  47456. */
  47457. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  47458. /**
  47459. * Gets velocityIterations of the impostor
  47460. * @param impostor impostor to get velocity iterations from
  47461. * @returns velocityIterations value
  47462. */
  47463. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  47464. /**
  47465. * Sets velocityIterations of the impostor
  47466. * @param impostor impostor to set velocity iterations on
  47467. * @param velocityIterations velocityIterations value
  47468. */
  47469. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  47470. /**
  47471. * Gets positionIterations of the impostor
  47472. * @param impostor impostor to get position iterations from
  47473. * @returns positionIterations value
  47474. */
  47475. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  47476. /**
  47477. * Sets positionIterations of the impostor
  47478. * @param impostor impostor to set position on
  47479. * @param positionIterations positionIterations value
  47480. */
  47481. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  47482. /**
  47483. * Append an anchor to a cloth object
  47484. * @param impostor is the cloth impostor to add anchor to
  47485. * @param otherImpostor is the rigid impostor to anchor to
  47486. * @param width ratio across width from 0 to 1
  47487. * @param height ratio up height from 0 to 1
  47488. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  47489. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47490. */
  47491. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47492. /**
  47493. * Append an hook to a rope object
  47494. * @param impostor is the rope impostor to add hook to
  47495. * @param otherImpostor is the rigid impostor to hook to
  47496. * @param length ratio along the rope from 0 to 1
  47497. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  47498. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  47499. */
  47500. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  47501. /**
  47502. * Sleeps the physics body and stops it from being active
  47503. * @param impostor impostor to sleep
  47504. */
  47505. sleepBody(impostor: PhysicsImpostor): void;
  47506. /**
  47507. * Activates the physics body
  47508. * @param impostor impostor to activate
  47509. */
  47510. wakeUpBody(impostor: PhysicsImpostor): void;
  47511. /**
  47512. * Updates the distance parameters of the joint
  47513. * @param joint joint to update
  47514. * @param maxDistance maximum distance of the joint
  47515. * @param minDistance minimum distance of the joint
  47516. */
  47517. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47518. /**
  47519. * Sets a motor on the joint
  47520. * @param joint joint to set motor on
  47521. * @param speed speed of the motor
  47522. * @param maxForce maximum force of the motor
  47523. * @param motorIndex index of the motor
  47524. */
  47525. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47526. /**
  47527. * Sets the motors limit
  47528. * @param joint joint to set limit on
  47529. * @param upperLimit upper limit
  47530. * @param lowerLimit lower limit
  47531. */
  47532. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47533. /**
  47534. * Syncs the position and rotation of a mesh with the impostor
  47535. * @param mesh mesh to sync
  47536. * @param impostor impostor to update the mesh with
  47537. */
  47538. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47539. /**
  47540. * Gets the radius of the impostor
  47541. * @param impostor impostor to get radius from
  47542. * @returns the radius
  47543. */
  47544. getRadius(impostor: PhysicsImpostor): number;
  47545. /**
  47546. * Gets the box size of the impostor
  47547. * @param impostor impostor to get box size from
  47548. * @param result the resulting box size
  47549. */
  47550. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47551. /**
  47552. * Disposes of the impostor
  47553. */
  47554. dispose(): void;
  47555. /**
  47556. * Does a raycast in the physics world
  47557. * @param from when should the ray start?
  47558. * @param to when should the ray end?
  47559. * @returns PhysicsRaycastResult
  47560. */
  47561. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47562. }
  47563. }
  47564. declare module BABYLON {
  47565. interface AbstractScene {
  47566. /**
  47567. * The list of reflection probes added to the scene
  47568. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47569. */
  47570. reflectionProbes: Array<ReflectionProbe>;
  47571. /**
  47572. * Removes the given reflection probe from this scene.
  47573. * @param toRemove The reflection probe to remove
  47574. * @returns The index of the removed reflection probe
  47575. */
  47576. removeReflectionProbe(toRemove: ReflectionProbe): number;
  47577. /**
  47578. * Adds the given reflection probe to this scene.
  47579. * @param newReflectionProbe The reflection probe to add
  47580. */
  47581. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  47582. }
  47583. /**
  47584. * Class used to generate realtime reflection / refraction cube textures
  47585. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  47586. */
  47587. export class ReflectionProbe {
  47588. /** defines the name of the probe */
  47589. name: string;
  47590. private _scene;
  47591. private _renderTargetTexture;
  47592. private _projectionMatrix;
  47593. private _viewMatrix;
  47594. private _target;
  47595. private _add;
  47596. private _attachedMesh;
  47597. private _invertYAxis;
  47598. /** Gets or sets probe position (center of the cube map) */
  47599. position: Vector3;
  47600. /**
  47601. * Creates a new reflection probe
  47602. * @param name defines the name of the probe
  47603. * @param size defines the texture resolution (for each face)
  47604. * @param scene defines the hosting scene
  47605. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  47606. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  47607. */
  47608. constructor(
  47609. /** defines the name of the probe */
  47610. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  47611. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  47612. samples: number;
  47613. /** Gets or sets the refresh rate to use (on every frame by default) */
  47614. refreshRate: number;
  47615. /**
  47616. * Gets the hosting scene
  47617. * @returns a Scene
  47618. */
  47619. getScene(): Scene;
  47620. /** Gets the internal CubeTexture used to render to */
  47621. readonly cubeTexture: RenderTargetTexture;
  47622. /** Gets the list of meshes to render */
  47623. readonly renderList: Nullable<AbstractMesh[]>;
  47624. /**
  47625. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  47626. * @param mesh defines the mesh to attach to
  47627. */
  47628. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47629. /**
  47630. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  47631. * @param renderingGroupId The rendering group id corresponding to its index
  47632. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47633. */
  47634. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  47635. /**
  47636. * Clean all associated resources
  47637. */
  47638. dispose(): void;
  47639. /**
  47640. * Converts the reflection probe information to a readable string for debug purpose.
  47641. * @param fullDetails Supports for multiple levels of logging within scene loading
  47642. * @returns the human readable reflection probe info
  47643. */
  47644. toString(fullDetails?: boolean): string;
  47645. /**
  47646. * Get the class name of the relfection probe.
  47647. * @returns "ReflectionProbe"
  47648. */
  47649. getClassName(): string;
  47650. /**
  47651. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  47652. * @returns The JSON representation of the texture
  47653. */
  47654. serialize(): any;
  47655. /**
  47656. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  47657. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  47658. * @param scene Define the scene the parsed reflection probe should be instantiated in
  47659. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  47660. * @returns The parsed reflection probe if successful
  47661. */
  47662. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  47663. }
  47664. }
  47665. declare module BABYLON {
  47666. /** @hidden */
  47667. export var _BabylonLoaderRegistered: boolean;
  47668. }
  47669. declare module BABYLON {
  47670. /**
  47671. * The Physically based simple base material of BJS.
  47672. *
  47673. * This enables better naming and convention enforcements on top of the pbrMaterial.
  47674. * It is used as the base class for both the specGloss and metalRough conventions.
  47675. */
  47676. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  47677. /**
  47678. * Number of Simultaneous lights allowed on the material.
  47679. */
  47680. maxSimultaneousLights: number;
  47681. /**
  47682. * If sets to true, disables all the lights affecting the material.
  47683. */
  47684. disableLighting: boolean;
  47685. /**
  47686. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  47687. */
  47688. environmentTexture: BaseTexture;
  47689. /**
  47690. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47691. */
  47692. invertNormalMapX: boolean;
  47693. /**
  47694. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47695. */
  47696. invertNormalMapY: boolean;
  47697. /**
  47698. * Normal map used in the model.
  47699. */
  47700. normalTexture: BaseTexture;
  47701. /**
  47702. * Emissivie color used to self-illuminate the model.
  47703. */
  47704. emissiveColor: Color3;
  47705. /**
  47706. * Emissivie texture used to self-illuminate the model.
  47707. */
  47708. emissiveTexture: BaseTexture;
  47709. /**
  47710. * Occlusion Channel Strenght.
  47711. */
  47712. occlusionStrength: number;
  47713. /**
  47714. * Occlusion Texture of the material (adding extra occlusion effects).
  47715. */
  47716. occlusionTexture: BaseTexture;
  47717. /**
  47718. * Defines the alpha limits in alpha test mode.
  47719. */
  47720. alphaCutOff: number;
  47721. /**
  47722. * Gets the current double sided mode.
  47723. */
  47724. /**
  47725. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47726. */
  47727. doubleSided: boolean;
  47728. /**
  47729. * Stores the pre-calculated light information of a mesh in a texture.
  47730. */
  47731. lightmapTexture: BaseTexture;
  47732. /**
  47733. * If true, the light map contains occlusion information instead of lighting info.
  47734. */
  47735. useLightmapAsShadowmap: boolean;
  47736. /**
  47737. * Instantiates a new PBRMaterial instance.
  47738. *
  47739. * @param name The material name
  47740. * @param scene The scene the material will be use in.
  47741. */
  47742. constructor(name: string, scene: Scene);
  47743. getClassName(): string;
  47744. }
  47745. }
  47746. declare module BABYLON {
  47747. /**
  47748. * The PBR material of BJS following the metal roughness convention.
  47749. *
  47750. * This fits to the PBR convention in the GLTF definition:
  47751. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  47752. */
  47753. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  47754. /**
  47755. * The base color has two different interpretations depending on the value of metalness.
  47756. * When the material is a metal, the base color is the specific measured reflectance value
  47757. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  47758. * of the material.
  47759. */
  47760. baseColor: Color3;
  47761. /**
  47762. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  47763. * well as opacity information in the alpha channel.
  47764. */
  47765. baseTexture: BaseTexture;
  47766. /**
  47767. * Specifies the metallic scalar value of the material.
  47768. * Can also be used to scale the metalness values of the metallic texture.
  47769. */
  47770. metallic: number;
  47771. /**
  47772. * Specifies the roughness scalar value of the material.
  47773. * Can also be used to scale the roughness values of the metallic texture.
  47774. */
  47775. roughness: number;
  47776. /**
  47777. * Texture containing both the metallic value in the B channel and the
  47778. * roughness value in the G channel to keep better precision.
  47779. */
  47780. metallicRoughnessTexture: BaseTexture;
  47781. /**
  47782. * Instantiates a new PBRMetalRoughnessMaterial instance.
  47783. *
  47784. * @param name The material name
  47785. * @param scene The scene the material will be use in.
  47786. */
  47787. constructor(name: string, scene: Scene);
  47788. /**
  47789. * Return the currrent class name of the material.
  47790. */
  47791. getClassName(): string;
  47792. /**
  47793. * Makes a duplicate of the current material.
  47794. * @param name - name to use for the new material.
  47795. */
  47796. clone(name: string): PBRMetallicRoughnessMaterial;
  47797. /**
  47798. * Serialize the material to a parsable JSON object.
  47799. */
  47800. serialize(): any;
  47801. /**
  47802. * Parses a JSON object correponding to the serialize function.
  47803. */
  47804. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  47805. }
  47806. }
  47807. declare module BABYLON {
  47808. /**
  47809. * The PBR material of BJS following the specular glossiness convention.
  47810. *
  47811. * This fits to the PBR convention in the GLTF definition:
  47812. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  47813. */
  47814. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  47815. /**
  47816. * Specifies the diffuse color of the material.
  47817. */
  47818. diffuseColor: Color3;
  47819. /**
  47820. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  47821. * channel.
  47822. */
  47823. diffuseTexture: BaseTexture;
  47824. /**
  47825. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  47826. */
  47827. specularColor: Color3;
  47828. /**
  47829. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  47830. */
  47831. glossiness: number;
  47832. /**
  47833. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  47834. */
  47835. specularGlossinessTexture: BaseTexture;
  47836. /**
  47837. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  47838. *
  47839. * @param name The material name
  47840. * @param scene The scene the material will be use in.
  47841. */
  47842. constructor(name: string, scene: Scene);
  47843. /**
  47844. * Return the currrent class name of the material.
  47845. */
  47846. getClassName(): string;
  47847. /**
  47848. * Makes a duplicate of the current material.
  47849. * @param name - name to use for the new material.
  47850. */
  47851. clone(name: string): PBRSpecularGlossinessMaterial;
  47852. /**
  47853. * Serialize the material to a parsable JSON object.
  47854. */
  47855. serialize(): any;
  47856. /**
  47857. * Parses a JSON object correponding to the serialize function.
  47858. */
  47859. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  47860. }
  47861. }
  47862. declare module BABYLON {
  47863. /**
  47864. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  47865. * It can help converting any input color in a desired output one. This can then be used to create effects
  47866. * from sepia, black and white to sixties or futuristic rendering...
  47867. *
  47868. * The only supported format is currently 3dl.
  47869. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  47870. */
  47871. export class ColorGradingTexture extends BaseTexture {
  47872. /**
  47873. * The current texture matrix. (will always be identity in color grading texture)
  47874. */
  47875. private _textureMatrix;
  47876. /**
  47877. * The texture URL.
  47878. */
  47879. url: string;
  47880. /**
  47881. * Empty line regex stored for GC.
  47882. */
  47883. private static _noneEmptyLineRegex;
  47884. private _engine;
  47885. /**
  47886. * Instantiates a ColorGradingTexture from the following parameters.
  47887. *
  47888. * @param url The location of the color gradind data (currently only supporting 3dl)
  47889. * @param scene The scene the texture will be used in
  47890. */
  47891. constructor(url: string, scene: Scene);
  47892. /**
  47893. * Returns the texture matrix used in most of the material.
  47894. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  47895. */
  47896. getTextureMatrix(): Matrix;
  47897. /**
  47898. * Occurs when the file being loaded is a .3dl LUT file.
  47899. */
  47900. private load3dlTexture;
  47901. /**
  47902. * Starts the loading process of the texture.
  47903. */
  47904. private loadTexture;
  47905. /**
  47906. * Clones the color gradind texture.
  47907. */
  47908. clone(): ColorGradingTexture;
  47909. /**
  47910. * Called during delayed load for textures.
  47911. */
  47912. delayLoad(): void;
  47913. /**
  47914. * Parses a color grading texture serialized by Babylon.
  47915. * @param parsedTexture The texture information being parsedTexture
  47916. * @param scene The scene to load the texture in
  47917. * @param rootUrl The root url of the data assets to load
  47918. * @return A color gradind texture
  47919. */
  47920. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  47921. /**
  47922. * Serializes the LUT texture to json format.
  47923. */
  47924. serialize(): any;
  47925. }
  47926. }
  47927. declare module BABYLON {
  47928. /**
  47929. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  47930. */
  47931. export class EquiRectangularCubeTexture extends BaseTexture {
  47932. /** The six faces of the cube. */
  47933. private static _FacesMapping;
  47934. private _noMipmap;
  47935. private _onLoad;
  47936. private _onError;
  47937. /** The size of the cubemap. */
  47938. private _size;
  47939. /** The buffer of the image. */
  47940. private _buffer;
  47941. /** The width of the input image. */
  47942. private _width;
  47943. /** The height of the input image. */
  47944. private _height;
  47945. /** The URL to the image. */
  47946. url: string;
  47947. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  47948. coordinatesMode: number;
  47949. /**
  47950. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  47951. * @param url The location of the image
  47952. * @param scene The scene the texture will be used in
  47953. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47954. * @param noMipmap Forces to not generate the mipmap if true
  47955. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  47956. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  47957. * @param onLoad — defines a callback called when texture is loaded
  47958. * @param onError — defines a callback called if there is an error
  47959. */
  47960. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  47961. /**
  47962. * Load the image data, by putting the image on a canvas and extracting its buffer.
  47963. */
  47964. private loadImage;
  47965. /**
  47966. * Convert the image buffer into a cubemap and create a CubeTexture.
  47967. */
  47968. private loadTexture;
  47969. /**
  47970. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  47971. * @param buffer The ArrayBuffer that should be converted.
  47972. * @returns The buffer as Float32Array.
  47973. */
  47974. private getFloat32ArrayFromArrayBuffer;
  47975. /**
  47976. * Get the current class name of the texture useful for serialization or dynamic coding.
  47977. * @returns "EquiRectangularCubeTexture"
  47978. */
  47979. getClassName(): string;
  47980. /**
  47981. * Create a clone of the current EquiRectangularCubeTexture and return it.
  47982. * @returns A clone of the current EquiRectangularCubeTexture.
  47983. */
  47984. clone(): EquiRectangularCubeTexture;
  47985. }
  47986. }
  47987. declare module BABYLON {
  47988. /**
  47989. * Based on jsTGALoader - Javascript loader for TGA file
  47990. * By Vincent Thibault
  47991. * @see http://blog.robrowser.com/javascript-tga-loader.html
  47992. */
  47993. export class TGATools {
  47994. private static _TYPE_INDEXED;
  47995. private static _TYPE_RGB;
  47996. private static _TYPE_GREY;
  47997. private static _TYPE_RLE_INDEXED;
  47998. private static _TYPE_RLE_RGB;
  47999. private static _TYPE_RLE_GREY;
  48000. private static _ORIGIN_MASK;
  48001. private static _ORIGIN_SHIFT;
  48002. private static _ORIGIN_BL;
  48003. private static _ORIGIN_BR;
  48004. private static _ORIGIN_UL;
  48005. private static _ORIGIN_UR;
  48006. /**
  48007. * Gets the header of a TGA file
  48008. * @param data defines the TGA data
  48009. * @returns the header
  48010. */
  48011. static GetTGAHeader(data: Uint8Array): any;
  48012. /**
  48013. * Uploads TGA content to a Babylon Texture
  48014. * @hidden
  48015. */
  48016. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48017. /** @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;
  48018. /** @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;
  48019. /** @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;
  48020. /** @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;
  48021. /** @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;
  48022. /** @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;
  48023. }
  48024. }
  48025. declare module BABYLON {
  48026. /**
  48027. * Implementation of the TGA Texture Loader.
  48028. * @hidden
  48029. */
  48030. export class _TGATextureLoader implements IInternalTextureLoader {
  48031. /**
  48032. * Defines wether the loader supports cascade loading the different faces.
  48033. */
  48034. readonly supportCascades: boolean;
  48035. /**
  48036. * This returns if the loader support the current file information.
  48037. * @param extension defines the file extension of the file being loaded
  48038. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48039. * @param fallback defines the fallback internal texture if any
  48040. * @param isBase64 defines whether the texture is encoded as a base64
  48041. * @param isBuffer defines whether the texture data are stored as a buffer
  48042. * @returns true if the loader can load the specified file
  48043. */
  48044. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48045. /**
  48046. * Transform the url before loading if required.
  48047. * @param rootUrl the url of the texture
  48048. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48049. * @returns the transformed texture
  48050. */
  48051. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48052. /**
  48053. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48054. * @param rootUrl the url of the texture
  48055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48056. * @returns the fallback texture
  48057. */
  48058. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48059. /**
  48060. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48061. * @param data contains the texture data
  48062. * @param texture defines the BabylonJS internal texture
  48063. * @param createPolynomials will be true if polynomials have been requested
  48064. * @param onLoad defines the callback to trigger once the texture is ready
  48065. * @param onError defines the callback to trigger in case of error
  48066. */
  48067. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48068. /**
  48069. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48070. * @param data contains the texture data
  48071. * @param texture defines the BabylonJS internal texture
  48072. * @param callback defines the method to call once ready to upload
  48073. */
  48074. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48075. }
  48076. }
  48077. declare module BABYLON {
  48078. /**
  48079. * 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.
  48080. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48081. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48082. */
  48083. export class CustomProceduralTexture extends ProceduralTexture {
  48084. private _animate;
  48085. private _time;
  48086. private _config;
  48087. private _texturePath;
  48088. /**
  48089. * Instantiates a new Custom Procedural Texture.
  48090. * 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.
  48091. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48092. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48093. * @param name Define the name of the texture
  48094. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48095. * @param size Define the size of the texture to create
  48096. * @param scene Define the scene the texture belongs to
  48097. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48098. * @param generateMipMaps Define if the texture should creates mip maps or not
  48099. */
  48100. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48101. private _loadJson;
  48102. /**
  48103. * Is the texture ready to be used ? (rendered at least once)
  48104. * @returns true if ready, otherwise, false.
  48105. */
  48106. isReady(): boolean;
  48107. /**
  48108. * Render the texture to its associated render target.
  48109. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48110. */
  48111. render(useCameraPostProcess?: boolean): void;
  48112. /**
  48113. * Update the list of dependant textures samplers in the shader.
  48114. */
  48115. updateTextures(): void;
  48116. /**
  48117. * Update the uniform values of the procedural texture in the shader.
  48118. */
  48119. updateShaderUniforms(): void;
  48120. /**
  48121. * Define if the texture animates or not.
  48122. */
  48123. animate: boolean;
  48124. }
  48125. }
  48126. declare module BABYLON {
  48127. /** @hidden */
  48128. export var noisePixelShader: {
  48129. name: string;
  48130. shader: string;
  48131. };
  48132. }
  48133. declare module BABYLON {
  48134. /**
  48135. * Class used to generate noise procedural textures
  48136. */
  48137. export class NoiseProceduralTexture extends ProceduralTexture {
  48138. private _time;
  48139. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48140. brightness: number;
  48141. /** Defines the number of octaves to process */
  48142. octaves: number;
  48143. /** Defines the level of persistence (0.8 by default) */
  48144. persistence: number;
  48145. /** Gets or sets animation speed factor (default is 1) */
  48146. animationSpeedFactor: number;
  48147. /**
  48148. * Creates a new NoiseProceduralTexture
  48149. * @param name defines the name fo the texture
  48150. * @param size defines the size of the texture (default is 256)
  48151. * @param scene defines the hosting scene
  48152. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48153. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48154. */
  48155. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48156. private _updateShaderUniforms;
  48157. protected _getDefines(): string;
  48158. /** Generate the current state of the procedural texture */
  48159. render(useCameraPostProcess?: boolean): void;
  48160. /**
  48161. * Serializes this noise procedural texture
  48162. * @returns a serialized noise procedural texture object
  48163. */
  48164. serialize(): any;
  48165. /**
  48166. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  48167. * @param parsedTexture defines parsed texture data
  48168. * @param scene defines the current scene
  48169. * @param rootUrl defines the root URL containing noise procedural texture information
  48170. * @returns a parsed NoiseProceduralTexture
  48171. */
  48172. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  48173. }
  48174. }
  48175. declare module BABYLON {
  48176. /**
  48177. * Raw cube texture where the raw buffers are passed in
  48178. */
  48179. export class RawCubeTexture extends CubeTexture {
  48180. /**
  48181. * Creates a cube texture where the raw buffers are passed in.
  48182. * @param scene defines the scene the texture is attached to
  48183. * @param data defines the array of data to use to create each face
  48184. * @param size defines the size of the textures
  48185. * @param format defines the format of the data
  48186. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  48187. * @param generateMipMaps defines if the engine should generate the mip levels
  48188. * @param invertY defines if data must be stored with Y axis inverted
  48189. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  48190. * @param compression defines the compression used (null by default)
  48191. */
  48192. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  48193. /**
  48194. * Updates the raw cube texture.
  48195. * @param data defines the data to store
  48196. * @param format defines the data format
  48197. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  48198. * @param invertY defines if data must be stored with Y axis inverted
  48199. * @param compression defines the compression used (null by default)
  48200. * @param level defines which level of the texture to update
  48201. */
  48202. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  48203. /**
  48204. * Updates a raw cube texture with RGBD encoded data.
  48205. * @param data defines the array of data [mipmap][face] to use to create each face
  48206. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  48207. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  48208. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  48209. * @returns a promsie that resolves when the operation is complete
  48210. */
  48211. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  48212. /**
  48213. * Clones the raw cube texture.
  48214. * @return a new cube texture
  48215. */
  48216. clone(): CubeTexture;
  48217. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48218. }
  48219. }
  48220. declare module BABYLON {
  48221. /**
  48222. * Class used to store 3D textures containing user data
  48223. */
  48224. export class RawTexture3D extends Texture {
  48225. /** Gets or sets the texture format to use */
  48226. format: number;
  48227. private _engine;
  48228. /**
  48229. * Create a new RawTexture3D
  48230. * @param data defines the data of the texture
  48231. * @param width defines the width of the texture
  48232. * @param height defines the height of the texture
  48233. * @param depth defines the depth of the texture
  48234. * @param format defines the texture format to use
  48235. * @param scene defines the hosting scene
  48236. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  48237. * @param invertY defines if texture must be stored with Y axis inverted
  48238. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  48239. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  48240. */
  48241. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  48242. /** Gets or sets the texture format to use */
  48243. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  48244. /**
  48245. * Update the texture with new data
  48246. * @param data defines the data to store in the texture
  48247. */
  48248. update(data: ArrayBufferView): void;
  48249. }
  48250. }
  48251. declare module BABYLON {
  48252. /**
  48253. * Creates a refraction texture used by refraction channel of the standard material.
  48254. * It is like a mirror but to see through a material.
  48255. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48256. */
  48257. export class RefractionTexture extends RenderTargetTexture {
  48258. /**
  48259. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  48260. * 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.
  48261. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48262. */
  48263. refractionPlane: Plane;
  48264. /**
  48265. * Define how deep under the surface we should see.
  48266. */
  48267. depth: number;
  48268. /**
  48269. * Creates a refraction texture used by refraction channel of the standard material.
  48270. * It is like a mirror but to see through a material.
  48271. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  48272. * @param name Define the texture name
  48273. * @param size Define the size of the underlying texture
  48274. * @param scene Define the scene the refraction belongs to
  48275. * @param generateMipMaps Define if we need to generate mips level for the refraction
  48276. */
  48277. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  48278. /**
  48279. * Clone the refraction texture.
  48280. * @returns the cloned texture
  48281. */
  48282. clone(): RefractionTexture;
  48283. /**
  48284. * Serialize the texture to a JSON representation you could use in Parse later on
  48285. * @returns the serialized JSON representation
  48286. */
  48287. serialize(): any;
  48288. }
  48289. }
  48290. declare module BABYLON {
  48291. /**
  48292. * Configuration for Draco compression
  48293. */
  48294. export interface IDracoCompressionConfiguration {
  48295. /**
  48296. * Configuration for the decoder.
  48297. */
  48298. decoder?: {
  48299. /**
  48300. * The url to the WebAssembly module.
  48301. */
  48302. wasmUrl?: string;
  48303. /**
  48304. * The url to the WebAssembly binary.
  48305. */
  48306. wasmBinaryUrl?: string;
  48307. /**
  48308. * The url to the fallback JavaScript module.
  48309. */
  48310. fallbackUrl?: string;
  48311. };
  48312. }
  48313. /**
  48314. * Draco compression (https://google.github.io/draco/)
  48315. *
  48316. * This class wraps the Draco module.
  48317. *
  48318. * **Encoder**
  48319. *
  48320. * The encoder is not currently implemented.
  48321. *
  48322. * **Decoder**
  48323. *
  48324. * 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.
  48325. *
  48326. * To update the configuration, use the following code:
  48327. * ```javascript
  48328. * DracoCompression.Configuration = {
  48329. * decoder: {
  48330. * wasmUrl: "<url to the WebAssembly library>",
  48331. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  48332. * fallbackUrl: "<url to the fallback JavaScript library>",
  48333. * }
  48334. * };
  48335. * ```
  48336. *
  48337. * 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.
  48338. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  48339. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  48340. *
  48341. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  48342. * ```javascript
  48343. * var dracoCompression = new DracoCompression();
  48344. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  48345. * [VertexBuffer.PositionKind]: 0
  48346. * });
  48347. * ```
  48348. *
  48349. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  48350. */
  48351. export class DracoCompression implements IDisposable {
  48352. private static _DecoderModulePromise;
  48353. /**
  48354. * The configuration. Defaults to the following urls:
  48355. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  48356. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  48357. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  48358. */
  48359. static Configuration: IDracoCompressionConfiguration;
  48360. /**
  48361. * Returns true if the decoder is available.
  48362. */
  48363. static readonly DecoderAvailable: boolean;
  48364. /**
  48365. * Constructor
  48366. */
  48367. constructor();
  48368. /**
  48369. * Stop all async operations and release resources.
  48370. */
  48371. dispose(): void;
  48372. /**
  48373. * Decode Draco compressed mesh data to vertex data.
  48374. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  48375. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  48376. * @returns A promise that resolves with the decoded vertex data
  48377. */
  48378. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes: {
  48379. [kind: string]: number;
  48380. }): Promise<VertexData>;
  48381. private static _GetDecoderModule;
  48382. private static _LoadScriptAsync;
  48383. private static _LoadFileAsync;
  48384. }
  48385. }
  48386. declare module BABYLON {
  48387. /**
  48388. * Class for building Constructive Solid Geometry
  48389. */
  48390. export class CSG {
  48391. private polygons;
  48392. /**
  48393. * The world matrix
  48394. */
  48395. matrix: Matrix;
  48396. /**
  48397. * Stores the position
  48398. */
  48399. position: Vector3;
  48400. /**
  48401. * Stores the rotation
  48402. */
  48403. rotation: Vector3;
  48404. /**
  48405. * Stores the rotation quaternion
  48406. */
  48407. rotationQuaternion: Nullable<Quaternion>;
  48408. /**
  48409. * Stores the scaling vector
  48410. */
  48411. scaling: Vector3;
  48412. /**
  48413. * Convert the Mesh to CSG
  48414. * @param mesh The Mesh to convert to CSG
  48415. * @returns A new CSG from the Mesh
  48416. */
  48417. static FromMesh(mesh: Mesh): CSG;
  48418. /**
  48419. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  48420. * @param polygons Polygons used to construct a CSG solid
  48421. */
  48422. private static FromPolygons;
  48423. /**
  48424. * Clones, or makes a deep copy, of the CSG
  48425. * @returns A new CSG
  48426. */
  48427. clone(): CSG;
  48428. /**
  48429. * Unions this CSG with another CSG
  48430. * @param csg The CSG to union against this CSG
  48431. * @returns The unioned CSG
  48432. */
  48433. union(csg: CSG): CSG;
  48434. /**
  48435. * Unions this CSG with another CSG in place
  48436. * @param csg The CSG to union against this CSG
  48437. */
  48438. unionInPlace(csg: CSG): void;
  48439. /**
  48440. * Subtracts this CSG with another CSG
  48441. * @param csg The CSG to subtract against this CSG
  48442. * @returns A new CSG
  48443. */
  48444. subtract(csg: CSG): CSG;
  48445. /**
  48446. * Subtracts this CSG with another CSG in place
  48447. * @param csg The CSG to subtact against this CSG
  48448. */
  48449. subtractInPlace(csg: CSG): void;
  48450. /**
  48451. * Intersect this CSG with another CSG
  48452. * @param csg The CSG to intersect against this CSG
  48453. * @returns A new CSG
  48454. */
  48455. intersect(csg: CSG): CSG;
  48456. /**
  48457. * Intersects this CSG with another CSG in place
  48458. * @param csg The CSG to intersect against this CSG
  48459. */
  48460. intersectInPlace(csg: CSG): void;
  48461. /**
  48462. * Return a new CSG solid with solid and empty space switched. This solid is
  48463. * not modified.
  48464. * @returns A new CSG solid with solid and empty space switched
  48465. */
  48466. inverse(): CSG;
  48467. /**
  48468. * Inverses the CSG in place
  48469. */
  48470. inverseInPlace(): void;
  48471. /**
  48472. * This is used to keep meshes transformations so they can be restored
  48473. * when we build back a Babylon Mesh
  48474. * NB : All CSG operations are performed in world coordinates
  48475. * @param csg The CSG to copy the transform attributes from
  48476. * @returns This CSG
  48477. */
  48478. copyTransformAttributes(csg: CSG): CSG;
  48479. /**
  48480. * Build Raw mesh from CSG
  48481. * Coordinates here are in world space
  48482. * @param name The name of the mesh geometry
  48483. * @param scene The Scene
  48484. * @param keepSubMeshes Specifies if the submeshes should be kept
  48485. * @returns A new Mesh
  48486. */
  48487. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  48488. /**
  48489. * Build Mesh from CSG taking material and transforms into account
  48490. * @param name The name of the Mesh
  48491. * @param material The material of the Mesh
  48492. * @param scene The Scene
  48493. * @param keepSubMeshes Specifies if submeshes should be kept
  48494. * @returns The new Mesh
  48495. */
  48496. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  48497. }
  48498. }
  48499. declare module BABYLON {
  48500. /**
  48501. * Class used to create a trail following a mesh
  48502. */
  48503. export class TrailMesh extends Mesh {
  48504. private _generator;
  48505. private _autoStart;
  48506. private _running;
  48507. private _diameter;
  48508. private _length;
  48509. private _sectionPolygonPointsCount;
  48510. private _sectionVectors;
  48511. private _sectionNormalVectors;
  48512. private _beforeRenderObserver;
  48513. /**
  48514. * @constructor
  48515. * @param name The value used by scene.getMeshByName() to do a lookup.
  48516. * @param generator The mesh to generate a trail.
  48517. * @param scene The scene to add this mesh to.
  48518. * @param diameter Diameter of trailing mesh. Default is 1.
  48519. * @param length Length of trailing mesh. Default is 60.
  48520. * @param autoStart Automatically start trailing mesh. Default true.
  48521. */
  48522. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  48523. /**
  48524. * "TrailMesh"
  48525. * @returns "TrailMesh"
  48526. */
  48527. getClassName(): string;
  48528. private _createMesh;
  48529. /**
  48530. * Start trailing mesh.
  48531. */
  48532. start(): void;
  48533. /**
  48534. * Stop trailing mesh.
  48535. */
  48536. stop(): void;
  48537. /**
  48538. * Update trailing mesh geometry.
  48539. */
  48540. update(): void;
  48541. /**
  48542. * Returns a new TrailMesh object.
  48543. * @param name is a string, the name given to the new mesh
  48544. * @param newGenerator use new generator object for cloned trail mesh
  48545. * @returns a new mesh
  48546. */
  48547. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  48548. /**
  48549. * Serializes this trail mesh
  48550. * @param serializationObject object to write serialization to
  48551. */
  48552. serialize(serializationObject: any): void;
  48553. /**
  48554. * Parses a serialized trail mesh
  48555. * @param parsedMesh the serialized mesh
  48556. * @param scene the scene to create the trail mesh in
  48557. * @returns the created trail mesh
  48558. */
  48559. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  48560. }
  48561. }
  48562. declare module BABYLON {
  48563. /**
  48564. * Class containing static functions to help procedurally build meshes
  48565. */
  48566. export class TorusKnotBuilder {
  48567. /**
  48568. * Creates a torus knot mesh
  48569. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  48570. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  48571. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  48572. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  48573. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48574. * * 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
  48575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48576. * @param name defines the name of the mesh
  48577. * @param options defines the options used to create the mesh
  48578. * @param scene defines the hosting scene
  48579. * @returns the torus knot mesh
  48580. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  48581. */
  48582. static CreateTorusKnot(name: string, options: {
  48583. radius?: number;
  48584. tube?: number;
  48585. radialSegments?: number;
  48586. tubularSegments?: number;
  48587. p?: number;
  48588. q?: number;
  48589. updatable?: boolean;
  48590. sideOrientation?: number;
  48591. frontUVs?: Vector4;
  48592. backUVs?: Vector4;
  48593. }, scene: any): Mesh;
  48594. }
  48595. }
  48596. declare module BABYLON {
  48597. /**
  48598. * Polygon
  48599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  48600. */
  48601. export class Polygon {
  48602. /**
  48603. * Creates a rectangle
  48604. * @param xmin bottom X coord
  48605. * @param ymin bottom Y coord
  48606. * @param xmax top X coord
  48607. * @param ymax top Y coord
  48608. * @returns points that make the resulting rectation
  48609. */
  48610. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  48611. /**
  48612. * Creates a circle
  48613. * @param radius radius of circle
  48614. * @param cx scale in x
  48615. * @param cy scale in y
  48616. * @param numberOfSides number of sides that make up the circle
  48617. * @returns points that make the resulting circle
  48618. */
  48619. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  48620. /**
  48621. * Creates a polygon from input string
  48622. * @param input Input polygon data
  48623. * @returns the parsed points
  48624. */
  48625. static Parse(input: string): Vector2[];
  48626. /**
  48627. * Starts building a polygon from x and y coordinates
  48628. * @param x x coordinate
  48629. * @param y y coordinate
  48630. * @returns the started path2
  48631. */
  48632. static StartingAt(x: number, y: number): Path2;
  48633. }
  48634. /**
  48635. * Builds a polygon
  48636. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  48637. */
  48638. export class PolygonMeshBuilder {
  48639. private _points;
  48640. private _outlinepoints;
  48641. private _holes;
  48642. private _name;
  48643. private _scene;
  48644. private _epoints;
  48645. private _eholes;
  48646. private _addToepoint;
  48647. /**
  48648. * Babylon reference to the earcut plugin.
  48649. */
  48650. bjsEarcut: any;
  48651. /**
  48652. * Creates a PolygonMeshBuilder
  48653. * @param name name of the builder
  48654. * @param contours Path of the polygon
  48655. * @param scene scene to add to when creating the mesh
  48656. * @param earcutInjection can be used to inject your own earcut reference
  48657. */
  48658. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  48659. /**
  48660. * Adds a whole within the polygon
  48661. * @param hole Array of points defining the hole
  48662. * @returns this
  48663. */
  48664. addHole(hole: Vector2[]): PolygonMeshBuilder;
  48665. /**
  48666. * Creates the polygon
  48667. * @param updatable If the mesh should be updatable
  48668. * @param depth The depth of the mesh created
  48669. * @returns the created mesh
  48670. */
  48671. build(updatable?: boolean, depth?: number): Mesh;
  48672. /**
  48673. * Creates the polygon
  48674. * @param depth The depth of the mesh created
  48675. * @returns the created VertexData
  48676. */
  48677. buildVertexData(depth?: number): VertexData;
  48678. /**
  48679. * Adds a side to the polygon
  48680. * @param positions points that make the polygon
  48681. * @param normals normals of the polygon
  48682. * @param uvs uvs of the polygon
  48683. * @param indices indices of the polygon
  48684. * @param bounds bounds of the polygon
  48685. * @param points points of the polygon
  48686. * @param depth depth of the polygon
  48687. * @param flip flip of the polygon
  48688. */
  48689. private addSide;
  48690. }
  48691. }
  48692. declare module BABYLON {
  48693. /**
  48694. * Class containing static functions to help procedurally build meshes
  48695. */
  48696. export class PolygonBuilder {
  48697. /**
  48698. * Creates a polygon mesh
  48699. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  48700. * * 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
  48701. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  48702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48703. * * 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)
  48704. * * Remember you can only change the shape positions, not their number when updating a polygon
  48705. * @param name defines the name of the mesh
  48706. * @param options defines the options used to create the mesh
  48707. * @param scene defines the hosting scene
  48708. * @param earcutInjection can be used to inject your own earcut reference
  48709. * @returns the polygon mesh
  48710. */
  48711. static CreatePolygon(name: string, options: {
  48712. shape: Vector3[];
  48713. holes?: Vector3[][];
  48714. depth?: number;
  48715. faceUV?: Vector4[];
  48716. faceColors?: Color4[];
  48717. updatable?: boolean;
  48718. sideOrientation?: number;
  48719. frontUVs?: Vector4;
  48720. backUVs?: Vector4;
  48721. }, scene: Scene, earcutInjection?: any): Mesh;
  48722. /**
  48723. * Creates an extruded polygon mesh, with depth in the Y direction.
  48724. * * 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)
  48725. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48726. * @param name defines the name of the mesh
  48727. * @param options defines the options used to create the mesh
  48728. * @param scene defines the hosting scene
  48729. * @param earcutInjection can be used to inject your own earcut reference
  48730. * @returns the polygon mesh
  48731. */
  48732. static ExtrudePolygon(name: string, options: {
  48733. shape: Vector3[];
  48734. holes?: Vector3[][];
  48735. depth?: number;
  48736. faceUV?: Vector4[];
  48737. faceColors?: Color4[];
  48738. updatable?: boolean;
  48739. sideOrientation?: number;
  48740. frontUVs?: Vector4;
  48741. backUVs?: Vector4;
  48742. }, scene: Scene, earcutInjection?: any): Mesh;
  48743. }
  48744. }
  48745. declare module BABYLON {
  48746. /**
  48747. * Class containing static functions to help procedurally build meshes
  48748. */
  48749. export class LatheBuilder {
  48750. /**
  48751. * Creates lathe mesh.
  48752. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  48753. * * 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
  48754. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  48755. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  48756. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  48757. * * 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
  48758. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  48759. * * 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
  48760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48761. * * 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
  48762. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48763. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48764. * @param name defines the name of the mesh
  48765. * @param options defines the options used to create the mesh
  48766. * @param scene defines the hosting scene
  48767. * @returns the lathe mesh
  48768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  48769. */
  48770. static CreateLathe(name: string, options: {
  48771. shape: Vector3[];
  48772. radius?: number;
  48773. tessellation?: number;
  48774. clip?: number;
  48775. arc?: number;
  48776. closed?: boolean;
  48777. updatable?: boolean;
  48778. sideOrientation?: number;
  48779. frontUVs?: Vector4;
  48780. backUVs?: Vector4;
  48781. cap?: number;
  48782. invertUV?: boolean;
  48783. }, scene: Scene): Mesh;
  48784. }
  48785. }
  48786. declare module BABYLON {
  48787. /**
  48788. * Class containing static functions to help procedurally build meshes
  48789. */
  48790. export class TubeBuilder {
  48791. /**
  48792. * Creates a tube mesh.
  48793. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  48794. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  48795. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  48796. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  48797. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  48798. * * 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)
  48799. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  48800. * * 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
  48801. * * 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
  48802. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48803. * * 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
  48804. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48806. * @param name defines the name of the mesh
  48807. * @param options defines the options used to create the mesh
  48808. * @param scene defines the hosting scene
  48809. * @returns the tube mesh
  48810. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48811. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  48812. */
  48813. static CreateTube(name: string, options: {
  48814. path: Vector3[];
  48815. radius?: number;
  48816. tessellation?: number;
  48817. radiusFunction?: {
  48818. (i: number, distance: number): number;
  48819. };
  48820. cap?: number;
  48821. arc?: number;
  48822. updatable?: boolean;
  48823. sideOrientation?: number;
  48824. frontUVs?: Vector4;
  48825. backUVs?: Vector4;
  48826. instance?: Mesh;
  48827. invertUV?: boolean;
  48828. }, scene: Scene): Mesh;
  48829. }
  48830. }
  48831. declare module BABYLON {
  48832. /**
  48833. * Class containing static functions to help procedurally build meshes
  48834. */
  48835. export class IcoSphereBuilder {
  48836. /**
  48837. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  48838. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  48839. * * 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`)
  48840. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  48841. * * 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
  48842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48843. * * 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
  48844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48845. * @param name defines the name of the mesh
  48846. * @param options defines the options used to create the mesh
  48847. * @param scene defines the hosting scene
  48848. * @returns the icosahedron mesh
  48849. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  48850. */
  48851. static CreateIcoSphere(name: string, options: {
  48852. radius?: number;
  48853. radiusX?: number;
  48854. radiusY?: number;
  48855. radiusZ?: number;
  48856. flat?: boolean;
  48857. subdivisions?: number;
  48858. sideOrientation?: number;
  48859. frontUVs?: Vector4;
  48860. backUVs?: Vector4;
  48861. updatable?: boolean;
  48862. }, scene: Scene): Mesh;
  48863. }
  48864. }
  48865. declare module BABYLON {
  48866. /**
  48867. * Class containing static functions to help procedurally build meshes
  48868. */
  48869. export class DecalBuilder {
  48870. /**
  48871. * Creates a decal mesh.
  48872. * 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
  48873. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  48874. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  48875. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  48876. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  48877. * @param name defines the name of the mesh
  48878. * @param sourceMesh defines the mesh where the decal must be applied
  48879. * @param options defines the options used to create the mesh
  48880. * @param scene defines the hosting scene
  48881. * @returns the decal mesh
  48882. * @see https://doc.babylonjs.com/how_to/decals
  48883. */
  48884. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  48885. position?: Vector3;
  48886. normal?: Vector3;
  48887. size?: Vector3;
  48888. angle?: number;
  48889. }): Mesh;
  48890. }
  48891. }
  48892. declare module BABYLON {
  48893. /**
  48894. * Class containing static functions to help procedurally build meshes
  48895. */
  48896. export class MeshBuilder {
  48897. /**
  48898. * Creates a box mesh
  48899. * * The parameter `size` sets the size (float) of each box side (default 1)
  48900. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48901. * * 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)
  48902. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48904. * * 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
  48905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48906. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48907. * @param name defines the name of the mesh
  48908. * @param options defines the options used to create the mesh
  48909. * @param scene defines the hosting scene
  48910. * @returns the box mesh
  48911. */
  48912. static CreateBox(name: string, options: {
  48913. size?: number;
  48914. width?: number;
  48915. height?: number;
  48916. depth?: number;
  48917. faceUV?: Vector4[];
  48918. faceColors?: Color4[];
  48919. sideOrientation?: number;
  48920. frontUVs?: Vector4;
  48921. backUVs?: Vector4;
  48922. updatable?: boolean;
  48923. }, scene?: Nullable<Scene>): Mesh;
  48924. /**
  48925. * Creates a sphere mesh
  48926. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48927. * * 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`)
  48928. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48929. * * 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
  48930. * * 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)
  48931. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48932. * * 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
  48933. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48934. * @param name defines the name of the mesh
  48935. * @param options defines the options used to create the mesh
  48936. * @param scene defines the hosting scene
  48937. * @returns the sphere mesh
  48938. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48939. */
  48940. static CreateSphere(name: string, options: {
  48941. segments?: number;
  48942. diameter?: number;
  48943. diameterX?: number;
  48944. diameterY?: number;
  48945. diameterZ?: number;
  48946. arc?: number;
  48947. slice?: number;
  48948. sideOrientation?: number;
  48949. frontUVs?: Vector4;
  48950. backUVs?: Vector4;
  48951. updatable?: boolean;
  48952. }, scene: any): Mesh;
  48953. /**
  48954. * Creates a plane polygonal mesh. By default, this is a disc
  48955. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  48956. * * 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
  48957. * * 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
  48958. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48959. * * 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
  48960. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48961. * @param name defines the name of the mesh
  48962. * @param options defines the options used to create the mesh
  48963. * @param scene defines the hosting scene
  48964. * @returns the plane polygonal mesh
  48965. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  48966. */
  48967. static CreateDisc(name: string, options: {
  48968. radius?: number;
  48969. tessellation?: number;
  48970. arc?: number;
  48971. updatable?: boolean;
  48972. sideOrientation?: number;
  48973. frontUVs?: Vector4;
  48974. backUVs?: Vector4;
  48975. }, scene?: Nullable<Scene>): Mesh;
  48976. /**
  48977. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  48978. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  48979. * * 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`)
  48980. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  48981. * * 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
  48982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48983. * * 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
  48984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48985. * @param name defines the name of the mesh
  48986. * @param options defines the options used to create the mesh
  48987. * @param scene defines the hosting scene
  48988. * @returns the icosahedron mesh
  48989. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  48990. */
  48991. static CreateIcoSphere(name: string, options: {
  48992. radius?: number;
  48993. radiusX?: number;
  48994. radiusY?: number;
  48995. radiusZ?: number;
  48996. flat?: boolean;
  48997. subdivisions?: number;
  48998. sideOrientation?: number;
  48999. frontUVs?: Vector4;
  49000. backUVs?: Vector4;
  49001. updatable?: boolean;
  49002. }, scene: Scene): Mesh;
  49003. /**
  49004. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49005. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49006. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49007. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49008. * * 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
  49009. * * 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
  49010. * * 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
  49011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49012. * * 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
  49013. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49014. * * 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
  49015. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49016. * * 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
  49017. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49018. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49019. * @param name defines the name of the mesh
  49020. * @param options defines the options used to create the mesh
  49021. * @param scene defines the hosting scene
  49022. * @returns the ribbon mesh
  49023. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49024. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49025. */
  49026. static CreateRibbon(name: string, options: {
  49027. pathArray: Vector3[][];
  49028. closeArray?: boolean;
  49029. closePath?: boolean;
  49030. offset?: number;
  49031. updatable?: boolean;
  49032. sideOrientation?: number;
  49033. frontUVs?: Vector4;
  49034. backUVs?: Vector4;
  49035. instance?: Mesh;
  49036. invertUV?: boolean;
  49037. uvs?: Vector2[];
  49038. colors?: Color4[];
  49039. }, scene?: Nullable<Scene>): Mesh;
  49040. /**
  49041. * Creates a cylinder or a cone mesh
  49042. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49043. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49044. * * 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.
  49045. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49046. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49047. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49048. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49049. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49050. * * 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).
  49051. * * 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
  49052. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49053. * * 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
  49054. * * 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.
  49055. * * If `enclose` is false, a ring surface is one element.
  49056. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49057. * * 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
  49058. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49059. * * 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
  49060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49061. * @param name defines the name of the mesh
  49062. * @param options defines the options used to create the mesh
  49063. * @param scene defines the hosting scene
  49064. * @returns the cylinder mesh
  49065. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49066. */
  49067. static CreateCylinder(name: string, options: {
  49068. height?: number;
  49069. diameterTop?: number;
  49070. diameterBottom?: number;
  49071. diameter?: number;
  49072. tessellation?: number;
  49073. subdivisions?: number;
  49074. arc?: number;
  49075. faceColors?: Color4[];
  49076. faceUV?: Vector4[];
  49077. updatable?: boolean;
  49078. hasRings?: boolean;
  49079. enclose?: boolean;
  49080. sideOrientation?: number;
  49081. frontUVs?: Vector4;
  49082. backUVs?: Vector4;
  49083. }, scene: any): Mesh;
  49084. /**
  49085. * Creates a torus mesh
  49086. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49087. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49088. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49090. * * 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
  49091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49092. * @param name defines the name of the mesh
  49093. * @param options defines the options used to create the mesh
  49094. * @param scene defines the hosting scene
  49095. * @returns the torus mesh
  49096. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49097. */
  49098. static CreateTorus(name: string, options: {
  49099. diameter?: number;
  49100. thickness?: number;
  49101. tessellation?: number;
  49102. updatable?: boolean;
  49103. sideOrientation?: number;
  49104. frontUVs?: Vector4;
  49105. backUVs?: Vector4;
  49106. }, scene: any): Mesh;
  49107. /**
  49108. * Creates a torus knot mesh
  49109. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  49110. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  49111. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  49112. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  49113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49114. * * 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
  49115. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49116. * @param name defines the name of the mesh
  49117. * @param options defines the options used to create the mesh
  49118. * @param scene defines the hosting scene
  49119. * @returns the torus knot mesh
  49120. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  49121. */
  49122. static CreateTorusKnot(name: string, options: {
  49123. radius?: number;
  49124. tube?: number;
  49125. radialSegments?: number;
  49126. tubularSegments?: number;
  49127. p?: number;
  49128. q?: number;
  49129. updatable?: boolean;
  49130. sideOrientation?: number;
  49131. frontUVs?: Vector4;
  49132. backUVs?: Vector4;
  49133. }, scene: any): Mesh;
  49134. /**
  49135. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49136. * * 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
  49137. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49138. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49139. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49140. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49141. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49142. * * 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
  49143. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49144. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49146. * @param name defines the name of the new line system
  49147. * @param options defines the options used to create the line system
  49148. * @param scene defines the hosting scene
  49149. * @returns a new line system mesh
  49150. */
  49151. static CreateLineSystem(name: string, options: {
  49152. lines: Vector3[][];
  49153. updatable?: boolean;
  49154. instance?: Nullable<LinesMesh>;
  49155. colors?: Nullable<Color4[][]>;
  49156. useVertexAlpha?: boolean;
  49157. }, scene: Nullable<Scene>): LinesMesh;
  49158. /**
  49159. * Creates a line mesh
  49160. * 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
  49161. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49162. * * The parameter `points` is an array successive Vector3
  49163. * * 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
  49164. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49165. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49166. * * When updating an instance, remember that only point positions can change, not the number of points
  49167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49168. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49169. * @param name defines the name of the new line system
  49170. * @param options defines the options used to create the line system
  49171. * @param scene defines the hosting scene
  49172. * @returns a new line mesh
  49173. */
  49174. static CreateLines(name: string, options: {
  49175. points: Vector3[];
  49176. updatable?: boolean;
  49177. instance?: Nullable<LinesMesh>;
  49178. colors?: Color4[];
  49179. useVertexAlpha?: boolean;
  49180. }, scene?: Nullable<Scene>): LinesMesh;
  49181. /**
  49182. * Creates a dashed line mesh
  49183. * * 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
  49184. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49185. * * The parameter `points` is an array successive Vector3
  49186. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49187. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49188. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49189. * * 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
  49190. * * When updating an instance, remember that only point positions can change, not the number of points
  49191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49192. * @param name defines the name of the mesh
  49193. * @param options defines the options used to create the mesh
  49194. * @param scene defines the hosting scene
  49195. * @returns the dashed line mesh
  49196. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49197. */
  49198. static CreateDashedLines(name: string, options: {
  49199. points: Vector3[];
  49200. dashSize?: number;
  49201. gapSize?: number;
  49202. dashNb?: number;
  49203. updatable?: boolean;
  49204. instance?: LinesMesh;
  49205. }, scene?: Nullable<Scene>): LinesMesh;
  49206. /**
  49207. * 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.
  49208. * * 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.
  49209. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49210. * * 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.
  49211. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49212. * * 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
  49213. * * 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
  49214. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49216. * * 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
  49217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49219. * @param name defines the name of the mesh
  49220. * @param options defines the options used to create the mesh
  49221. * @param scene defines the hosting scene
  49222. * @returns the extruded shape mesh
  49223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49224. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49225. */
  49226. static ExtrudeShape(name: string, options: {
  49227. shape: Vector3[];
  49228. path: Vector3[];
  49229. scale?: number;
  49230. rotation?: number;
  49231. cap?: number;
  49232. updatable?: boolean;
  49233. sideOrientation?: number;
  49234. frontUVs?: Vector4;
  49235. backUVs?: Vector4;
  49236. instance?: Mesh;
  49237. invertUV?: boolean;
  49238. }, scene?: Nullable<Scene>): Mesh;
  49239. /**
  49240. * Creates an custom extruded shape mesh.
  49241. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49242. * * 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.
  49243. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49244. * * 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
  49245. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49246. * * 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
  49247. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49248. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49249. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49250. * * 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
  49251. * * 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
  49252. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49254. * * 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
  49255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49257. * @param name defines the name of the mesh
  49258. * @param options defines the options used to create the mesh
  49259. * @param scene defines the hosting scene
  49260. * @returns the custom extruded shape mesh
  49261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49262. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49263. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49264. */
  49265. static ExtrudeShapeCustom(name: string, options: {
  49266. shape: Vector3[];
  49267. path: Vector3[];
  49268. scaleFunction?: any;
  49269. rotationFunction?: any;
  49270. ribbonCloseArray?: boolean;
  49271. ribbonClosePath?: boolean;
  49272. cap?: number;
  49273. updatable?: boolean;
  49274. sideOrientation?: number;
  49275. frontUVs?: Vector4;
  49276. backUVs?: Vector4;
  49277. instance?: Mesh;
  49278. invertUV?: boolean;
  49279. }, scene: Scene): Mesh;
  49280. /**
  49281. * Creates lathe mesh.
  49282. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  49283. * * 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
  49284. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  49285. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  49286. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  49287. * * 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
  49288. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  49289. * * 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
  49290. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49291. * * 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
  49292. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49294. * @param name defines the name of the mesh
  49295. * @param options defines the options used to create the mesh
  49296. * @param scene defines the hosting scene
  49297. * @returns the lathe mesh
  49298. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  49299. */
  49300. static CreateLathe(name: string, options: {
  49301. shape: Vector3[];
  49302. radius?: number;
  49303. tessellation?: number;
  49304. clip?: number;
  49305. arc?: number;
  49306. closed?: boolean;
  49307. updatable?: boolean;
  49308. sideOrientation?: number;
  49309. frontUVs?: Vector4;
  49310. backUVs?: Vector4;
  49311. cap?: number;
  49312. invertUV?: boolean;
  49313. }, scene: Scene): Mesh;
  49314. /**
  49315. * Creates a plane mesh
  49316. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49317. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49318. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49319. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49320. * * 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
  49321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49322. * @param name defines the name of the mesh
  49323. * @param options defines the options used to create the mesh
  49324. * @param scene defines the hosting scene
  49325. * @returns the plane mesh
  49326. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49327. */
  49328. static CreatePlane(name: string, options: {
  49329. size?: number;
  49330. width?: number;
  49331. height?: number;
  49332. sideOrientation?: number;
  49333. frontUVs?: Vector4;
  49334. backUVs?: Vector4;
  49335. updatable?: boolean;
  49336. sourcePlane?: Plane;
  49337. }, scene: Scene): Mesh;
  49338. /**
  49339. * Creates a ground mesh
  49340. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49341. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49343. * @param name defines the name of the mesh
  49344. * @param options defines the options used to create the mesh
  49345. * @param scene defines the hosting scene
  49346. * @returns the ground mesh
  49347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49348. */
  49349. static CreateGround(name: string, options: {
  49350. width?: number;
  49351. height?: number;
  49352. subdivisions?: number;
  49353. subdivisionsX?: number;
  49354. subdivisionsY?: number;
  49355. updatable?: boolean;
  49356. }, scene: any): Mesh;
  49357. /**
  49358. * Creates a tiled ground mesh
  49359. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49360. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49361. * * 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
  49362. * * 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
  49363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49364. * @param name defines the name of the mesh
  49365. * @param options defines the options used to create the mesh
  49366. * @param scene defines the hosting scene
  49367. * @returns the tiled ground mesh
  49368. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49369. */
  49370. static CreateTiledGround(name: string, options: {
  49371. xmin: number;
  49372. zmin: number;
  49373. xmax: number;
  49374. zmax: number;
  49375. subdivisions?: {
  49376. w: number;
  49377. h: number;
  49378. };
  49379. precision?: {
  49380. w: number;
  49381. h: number;
  49382. };
  49383. updatable?: boolean;
  49384. }, scene: Scene): Mesh;
  49385. /**
  49386. * Creates a ground mesh from a height map
  49387. * * The parameter `url` sets the URL of the height map image resource.
  49388. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49389. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49390. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49391. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49392. * * 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.
  49393. * * 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).
  49394. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49396. * @param name defines the name of the mesh
  49397. * @param url defines the url to the height map
  49398. * @param options defines the options used to create the mesh
  49399. * @param scene defines the hosting scene
  49400. * @returns the ground mesh
  49401. * @see https://doc.babylonjs.com/babylon101/height_map
  49402. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49403. */
  49404. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49405. width?: number;
  49406. height?: number;
  49407. subdivisions?: number;
  49408. minHeight?: number;
  49409. maxHeight?: number;
  49410. colorFilter?: Color3;
  49411. alphaFilter?: number;
  49412. updatable?: boolean;
  49413. onReady?: (mesh: GroundMesh) => void;
  49414. }, scene: Scene): GroundMesh;
  49415. /**
  49416. * Creates a polygon mesh
  49417. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  49418. * * 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
  49419. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  49420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49421. * * 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)
  49422. * * Remember you can only change the shape positions, not their number when updating a polygon
  49423. * @param name defines the name of the mesh
  49424. * @param options defines the options used to create the mesh
  49425. * @param scene defines the hosting scene
  49426. * @param earcutInjection can be used to inject your own earcut reference
  49427. * @returns the polygon mesh
  49428. */
  49429. static CreatePolygon(name: string, options: {
  49430. shape: Vector3[];
  49431. holes?: Vector3[][];
  49432. depth?: number;
  49433. faceUV?: Vector4[];
  49434. faceColors?: Color4[];
  49435. updatable?: boolean;
  49436. sideOrientation?: number;
  49437. frontUVs?: Vector4;
  49438. backUVs?: Vector4;
  49439. }, scene: Scene, earcutInjection?: any): Mesh;
  49440. /**
  49441. * Creates an extruded polygon mesh, with depth in the Y direction.
  49442. * * 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)
  49443. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  49444. * @param name defines the name of the mesh
  49445. * @param options defines the options used to create the mesh
  49446. * @param scene defines the hosting scene
  49447. * @param earcutInjection can be used to inject your own earcut reference
  49448. * @returns the polygon mesh
  49449. */
  49450. static ExtrudePolygon(name: string, options: {
  49451. shape: Vector3[];
  49452. holes?: Vector3[][];
  49453. depth?: number;
  49454. faceUV?: Vector4[];
  49455. faceColors?: Color4[];
  49456. updatable?: boolean;
  49457. sideOrientation?: number;
  49458. frontUVs?: Vector4;
  49459. backUVs?: Vector4;
  49460. }, scene: Scene, earcutInjection?: any): Mesh;
  49461. /**
  49462. * Creates a tube mesh.
  49463. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49464. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  49465. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  49466. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  49467. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  49468. * * 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)
  49469. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  49470. * * 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
  49471. * * 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
  49472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49473. * * 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
  49474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49476. * @param name defines the name of the mesh
  49477. * @param options defines the options used to create the mesh
  49478. * @param scene defines the hosting scene
  49479. * @returns the tube mesh
  49480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49481. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  49482. */
  49483. static CreateTube(name: string, options: {
  49484. path: Vector3[];
  49485. radius?: number;
  49486. tessellation?: number;
  49487. radiusFunction?: {
  49488. (i: number, distance: number): number;
  49489. };
  49490. cap?: number;
  49491. arc?: number;
  49492. updatable?: boolean;
  49493. sideOrientation?: number;
  49494. frontUVs?: Vector4;
  49495. backUVs?: Vector4;
  49496. instance?: Mesh;
  49497. invertUV?: boolean;
  49498. }, scene: Scene): Mesh;
  49499. /**
  49500. * Creates a polyhedron mesh
  49501. * * 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
  49502. * * The parameter `size` (positive float, default 1) sets the polygon size
  49503. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  49504. * * 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`
  49505. * * 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
  49506. * * 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)`)
  49507. * * 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
  49508. * * 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
  49509. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49510. * * 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
  49511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49512. * @param name defines the name of the mesh
  49513. * @param options defines the options used to create the mesh
  49514. * @param scene defines the hosting scene
  49515. * @returns the polyhedron mesh
  49516. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  49517. */
  49518. static CreatePolyhedron(name: string, options: {
  49519. type?: number;
  49520. size?: number;
  49521. sizeX?: number;
  49522. sizeY?: number;
  49523. sizeZ?: number;
  49524. custom?: any;
  49525. faceUV?: Vector4[];
  49526. faceColors?: Color4[];
  49527. flat?: boolean;
  49528. updatable?: boolean;
  49529. sideOrientation?: number;
  49530. frontUVs?: Vector4;
  49531. backUVs?: Vector4;
  49532. }, scene: Scene): Mesh;
  49533. /**
  49534. * Creates a decal mesh.
  49535. * 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
  49536. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  49537. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  49538. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  49539. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  49540. * @param name defines the name of the mesh
  49541. * @param sourceMesh defines the mesh where the decal must be applied
  49542. * @param options defines the options used to create the mesh
  49543. * @param scene defines the hosting scene
  49544. * @returns the decal mesh
  49545. * @see https://doc.babylonjs.com/how_to/decals
  49546. */
  49547. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  49548. position?: Vector3;
  49549. normal?: Vector3;
  49550. size?: Vector3;
  49551. angle?: number;
  49552. }): Mesh;
  49553. }
  49554. }
  49555. declare module BABYLON {
  49556. /**
  49557. * A simplifier interface for future simplification implementations
  49558. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49559. */
  49560. export interface ISimplifier {
  49561. /**
  49562. * Simplification of a given mesh according to the given settings.
  49563. * Since this requires computation, it is assumed that the function runs async.
  49564. * @param settings The settings of the simplification, including quality and distance
  49565. * @param successCallback A callback that will be called after the mesh was simplified.
  49566. * @param errorCallback in case of an error, this callback will be called. optional.
  49567. */
  49568. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  49569. }
  49570. /**
  49571. * Expected simplification settings.
  49572. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  49573. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49574. */
  49575. export interface ISimplificationSettings {
  49576. /**
  49577. * Gets or sets the expected quality
  49578. */
  49579. quality: number;
  49580. /**
  49581. * Gets or sets the distance when this optimized version should be used
  49582. */
  49583. distance: number;
  49584. /**
  49585. * Gets an already optimized mesh
  49586. */
  49587. optimizeMesh?: boolean;
  49588. }
  49589. /**
  49590. * Class used to specify simplification options
  49591. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49592. */
  49593. export class SimplificationSettings implements ISimplificationSettings {
  49594. /** expected quality */
  49595. quality: number;
  49596. /** distance when this optimized version should be used */
  49597. distance: number;
  49598. /** already optimized mesh */
  49599. optimizeMesh?: boolean | undefined;
  49600. /**
  49601. * Creates a SimplificationSettings
  49602. * @param quality expected quality
  49603. * @param distance distance when this optimized version should be used
  49604. * @param optimizeMesh already optimized mesh
  49605. */
  49606. constructor(
  49607. /** expected quality */
  49608. quality: number,
  49609. /** distance when this optimized version should be used */
  49610. distance: number,
  49611. /** already optimized mesh */
  49612. optimizeMesh?: boolean | undefined);
  49613. }
  49614. /**
  49615. * Interface used to define a simplification task
  49616. */
  49617. export interface ISimplificationTask {
  49618. /**
  49619. * Array of settings
  49620. */
  49621. settings: Array<ISimplificationSettings>;
  49622. /**
  49623. * Simplification type
  49624. */
  49625. simplificationType: SimplificationType;
  49626. /**
  49627. * Mesh to simplify
  49628. */
  49629. mesh: Mesh;
  49630. /**
  49631. * Callback called on success
  49632. */
  49633. successCallback?: () => void;
  49634. /**
  49635. * Defines if parallel processing can be used
  49636. */
  49637. parallelProcessing: boolean;
  49638. }
  49639. /**
  49640. * Queue used to order the simplification tasks
  49641. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49642. */
  49643. export class SimplificationQueue {
  49644. private _simplificationArray;
  49645. /**
  49646. * Gets a boolean indicating that the process is still running
  49647. */
  49648. running: boolean;
  49649. /**
  49650. * Creates a new queue
  49651. */
  49652. constructor();
  49653. /**
  49654. * Adds a new simplification task
  49655. * @param task defines a task to add
  49656. */
  49657. addTask(task: ISimplificationTask): void;
  49658. /**
  49659. * Execute next task
  49660. */
  49661. executeNext(): void;
  49662. /**
  49663. * Execute a simplification task
  49664. * @param task defines the task to run
  49665. */
  49666. runSimplification(task: ISimplificationTask): void;
  49667. private getSimplifier;
  49668. }
  49669. /**
  49670. * The implemented types of simplification
  49671. * At the moment only Quadratic Error Decimation is implemented
  49672. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49673. */
  49674. export enum SimplificationType {
  49675. /** Quadratic error decimation */
  49676. QUADRATIC = 0
  49677. }
  49678. }
  49679. declare module BABYLON {
  49680. interface Scene {
  49681. /** @hidden (Backing field) */ simplificationQueue: SimplificationQueue;
  49682. /**
  49683. * Gets or sets the simplification queue attached to the scene
  49684. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  49685. */
  49686. simplificationQueue: SimplificationQueue;
  49687. }
  49688. interface Mesh {
  49689. /**
  49690. * Simplify the mesh according to the given array of settings.
  49691. * Function will return immediately and will simplify async
  49692. * @param settings a collection of simplification settings
  49693. * @param parallelProcessing should all levels calculate parallel or one after the other
  49694. * @param simplificationType the type of simplification to run
  49695. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  49696. * @returns the current mesh
  49697. */
  49698. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  49699. }
  49700. /**
  49701. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  49702. * created in a scene
  49703. */
  49704. export class SimplicationQueueSceneComponent implements ISceneComponent {
  49705. /**
  49706. * The component name helpfull to identify the component in the list of scene components.
  49707. */
  49708. readonly name: string;
  49709. /**
  49710. * The scene the component belongs to.
  49711. */
  49712. scene: Scene;
  49713. /**
  49714. * Creates a new instance of the component for the given scene
  49715. * @param scene Defines the scene to register the component in
  49716. */
  49717. constructor(scene: Scene);
  49718. /**
  49719. * Registers the component in a given scene
  49720. */
  49721. register(): void;
  49722. /**
  49723. * Rebuilds the elements related to this component in case of
  49724. * context lost for instance.
  49725. */
  49726. rebuild(): void;
  49727. /**
  49728. * Disposes the component and the associated ressources
  49729. */
  49730. dispose(): void;
  49731. private _beforeCameraUpdate;
  49732. }
  49733. }
  49734. declare module BABYLON {
  49735. /**
  49736. * Class used to enable access to IndexedDB
  49737. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  49738. */
  49739. export class Database implements IOfflineProvider {
  49740. private _callbackManifestChecked;
  49741. private _currentSceneUrl;
  49742. private _db;
  49743. private _enableSceneOffline;
  49744. private _enableTexturesOffline;
  49745. private _manifestVersionFound;
  49746. private _mustUpdateRessources;
  49747. private _hasReachedQuota;
  49748. private _isSupported;
  49749. private _idbFactory;
  49750. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  49751. private static IsUASupportingBlobStorage;
  49752. /**
  49753. * Gets a boolean indicating if Database storate is enabled (off by default)
  49754. */
  49755. static IDBStorageEnabled: boolean;
  49756. /**
  49757. * Gets a boolean indicating if scene must be saved in the database
  49758. */
  49759. readonly enableSceneOffline: boolean;
  49760. /**
  49761. * Gets a boolean indicating if textures must be saved in the database
  49762. */
  49763. readonly enableTexturesOffline: boolean;
  49764. /**
  49765. * Creates a new Database
  49766. * @param urlToScene defines the url to load the scene
  49767. * @param callbackManifestChecked defines the callback to use when manifest is checked
  49768. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  49769. */
  49770. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  49771. private static _ParseURL;
  49772. private static _ReturnFullUrlLocation;
  49773. private _checkManifestFile;
  49774. /**
  49775. * Open the database and make it available
  49776. * @param successCallback defines the callback to call on success
  49777. * @param errorCallback defines the callback to call on error
  49778. */
  49779. open(successCallback: () => void, errorCallback: () => void): void;
  49780. /**
  49781. * Loads an image from the database
  49782. * @param url defines the url to load from
  49783. * @param image defines the target DOM image
  49784. */
  49785. loadImage(url: string, image: HTMLImageElement): void;
  49786. private _loadImageFromDBAsync;
  49787. private _saveImageIntoDBAsync;
  49788. private _checkVersionFromDB;
  49789. private _loadVersionFromDBAsync;
  49790. private _saveVersionIntoDBAsync;
  49791. /**
  49792. * Loads a file from database
  49793. * @param url defines the URL to load from
  49794. * @param sceneLoaded defines a callback to call on success
  49795. * @param progressCallBack defines a callback to call when progress changed
  49796. * @param errorCallback defines a callback to call on error
  49797. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  49798. */
  49799. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  49800. private _loadFileAsync;
  49801. private _saveFileAsync;
  49802. /**
  49803. * Validates if xhr data is correct
  49804. * @param xhr defines the request to validate
  49805. * @param dataType defines the expected data type
  49806. * @returns true if data is correct
  49807. */
  49808. private static _ValidateXHRData;
  49809. }
  49810. }
  49811. declare module BABYLON {
  49812. /** @hidden */
  49813. export var gpuUpdateParticlesPixelShader: {
  49814. name: string;
  49815. shader: string;
  49816. };
  49817. }
  49818. declare module BABYLON {
  49819. /** @hidden */
  49820. export var gpuUpdateParticlesVertexShader: {
  49821. name: string;
  49822. shader: string;
  49823. };
  49824. }
  49825. declare module BABYLON {
  49826. /** @hidden */
  49827. export var clipPlaneFragmentDeclaration2: {
  49828. name: string;
  49829. shader: string;
  49830. };
  49831. }
  49832. declare module BABYLON {
  49833. /** @hidden */
  49834. export var gpuRenderParticlesPixelShader: {
  49835. name: string;
  49836. shader: string;
  49837. };
  49838. }
  49839. declare module BABYLON {
  49840. /** @hidden */
  49841. export var clipPlaneVertexDeclaration2: {
  49842. name: string;
  49843. shader: string;
  49844. };
  49845. }
  49846. declare module BABYLON {
  49847. /** @hidden */
  49848. export var gpuRenderParticlesVertexShader: {
  49849. name: string;
  49850. shader: string;
  49851. };
  49852. }
  49853. declare module BABYLON {
  49854. /**
  49855. * This represents a GPU particle system in Babylon
  49856. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  49857. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  49858. */
  49859. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  49860. /**
  49861. * The layer mask we are rendering the particles through.
  49862. */
  49863. layerMask: number;
  49864. private _capacity;
  49865. private _activeCount;
  49866. private _currentActiveCount;
  49867. private _accumulatedCount;
  49868. private _renderEffect;
  49869. private _updateEffect;
  49870. private _buffer0;
  49871. private _buffer1;
  49872. private _spriteBuffer;
  49873. private _updateVAO;
  49874. private _renderVAO;
  49875. private _targetIndex;
  49876. private _sourceBuffer;
  49877. private _targetBuffer;
  49878. private _engine;
  49879. private _currentRenderId;
  49880. private _started;
  49881. private _stopped;
  49882. private _timeDelta;
  49883. private _randomTexture;
  49884. private _randomTexture2;
  49885. private _attributesStrideSize;
  49886. private _updateEffectOptions;
  49887. private _randomTextureSize;
  49888. private _actualFrame;
  49889. private readonly _rawTextureWidth;
  49890. /**
  49891. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  49892. */
  49893. static readonly IsSupported: boolean;
  49894. /**
  49895. * An event triggered when the system is disposed.
  49896. */
  49897. onDisposeObservable: Observable<GPUParticleSystem>;
  49898. /**
  49899. * Gets the maximum number of particles active at the same time.
  49900. * @returns The max number of active particles.
  49901. */
  49902. getCapacity(): number;
  49903. /**
  49904. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  49905. * to override the particles.
  49906. */
  49907. forceDepthWrite: boolean;
  49908. /**
  49909. * Gets or set the number of active particles
  49910. */
  49911. activeParticleCount: number;
  49912. private _preWarmDone;
  49913. /**
  49914. * Is this system ready to be used/rendered
  49915. * @return true if the system is ready
  49916. */
  49917. isReady(): boolean;
  49918. /**
  49919. * Gets if the system has been started. (Note: this will still be true after stop is called)
  49920. * @returns True if it has been started, otherwise false.
  49921. */
  49922. isStarted(): boolean;
  49923. /**
  49924. * Starts the particle system and begins to emit
  49925. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  49926. */
  49927. start(delay?: number): void;
  49928. /**
  49929. * Stops the particle system.
  49930. */
  49931. stop(): void;
  49932. /**
  49933. * Remove all active particles
  49934. */
  49935. reset(): void;
  49936. /**
  49937. * Returns the string "GPUParticleSystem"
  49938. * @returns a string containing the class name
  49939. */
  49940. getClassName(): string;
  49941. private _colorGradientsTexture;
  49942. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  49943. /**
  49944. * Adds a new color gradient
  49945. * @param gradient defines the gradient to use (between 0 and 1)
  49946. * @param color1 defines the color to affect to the specified gradient
  49947. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  49948. * @returns the current particle system
  49949. */
  49950. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  49951. /**
  49952. * Remove a specific color gradient
  49953. * @param gradient defines the gradient to remove
  49954. * @returns the current particle system
  49955. */
  49956. removeColorGradient(gradient: number): GPUParticleSystem;
  49957. private _angularSpeedGradientsTexture;
  49958. private _sizeGradientsTexture;
  49959. private _velocityGradientsTexture;
  49960. private _limitVelocityGradientsTexture;
  49961. private _dragGradientsTexture;
  49962. private _addFactorGradient;
  49963. /**
  49964. * Adds a new size gradient
  49965. * @param gradient defines the gradient to use (between 0 and 1)
  49966. * @param factor defines the size factor to affect to the specified gradient
  49967. * @returns the current particle system
  49968. */
  49969. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  49970. /**
  49971. * Remove a specific size gradient
  49972. * @param gradient defines the gradient to remove
  49973. * @returns the current particle system
  49974. */
  49975. removeSizeGradient(gradient: number): GPUParticleSystem;
  49976. /**
  49977. * Adds a new angular speed gradient
  49978. * @param gradient defines the gradient to use (between 0 and 1)
  49979. * @param factor defines the angular speed to affect to the specified gradient
  49980. * @returns the current particle system
  49981. */
  49982. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  49983. /**
  49984. * Remove a specific angular speed gradient
  49985. * @param gradient defines the gradient to remove
  49986. * @returns the current particle system
  49987. */
  49988. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  49989. /**
  49990. * Adds a new velocity gradient
  49991. * @param gradient defines the gradient to use (between 0 and 1)
  49992. * @param factor defines the velocity to affect to the specified gradient
  49993. * @returns the current particle system
  49994. */
  49995. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  49996. /**
  49997. * Remove a specific velocity gradient
  49998. * @param gradient defines the gradient to remove
  49999. * @returns the current particle system
  50000. */
  50001. removeVelocityGradient(gradient: number): GPUParticleSystem;
  50002. /**
  50003. * Adds a new limit velocity gradient
  50004. * @param gradient defines the gradient to use (between 0 and 1)
  50005. * @param factor defines the limit velocity value to affect to the specified gradient
  50006. * @returns the current particle system
  50007. */
  50008. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  50009. /**
  50010. * Remove a specific limit velocity gradient
  50011. * @param gradient defines the gradient to remove
  50012. * @returns the current particle system
  50013. */
  50014. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  50015. /**
  50016. * Adds a new drag gradient
  50017. * @param gradient defines the gradient to use (between 0 and 1)
  50018. * @param factor defines the drag value to affect to the specified gradient
  50019. * @returns the current particle system
  50020. */
  50021. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  50022. /**
  50023. * Remove a specific drag gradient
  50024. * @param gradient defines the gradient to remove
  50025. * @returns the current particle system
  50026. */
  50027. removeDragGradient(gradient: number): GPUParticleSystem;
  50028. /**
  50029. * Not supported by GPUParticleSystem
  50030. * @param gradient defines the gradient to use (between 0 and 1)
  50031. * @param factor defines the emit rate value to affect to the specified gradient
  50032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50033. * @returns the current particle system
  50034. */
  50035. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50036. /**
  50037. * Not supported by GPUParticleSystem
  50038. * @param gradient defines the gradient to remove
  50039. * @returns the current particle system
  50040. */
  50041. removeEmitRateGradient(gradient: number): IParticleSystem;
  50042. /**
  50043. * Not supported by GPUParticleSystem
  50044. * @param gradient defines the gradient to use (between 0 and 1)
  50045. * @param factor defines the start size value to affect to the specified gradient
  50046. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50047. * @returns the current particle system
  50048. */
  50049. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50050. /**
  50051. * Not supported by GPUParticleSystem
  50052. * @param gradient defines the gradient to remove
  50053. * @returns the current particle system
  50054. */
  50055. removeStartSizeGradient(gradient: number): IParticleSystem;
  50056. /**
  50057. * Not supported by GPUParticleSystem
  50058. * @param gradient defines the gradient to use (between 0 and 1)
  50059. * @param min defines the color remap minimal range
  50060. * @param max defines the color remap maximal range
  50061. * @returns the current particle system
  50062. */
  50063. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50064. /**
  50065. * Not supported by GPUParticleSystem
  50066. * @param gradient defines the gradient to remove
  50067. * @returns the current particle system
  50068. */
  50069. removeColorRemapGradient(): IParticleSystem;
  50070. /**
  50071. * Not supported by GPUParticleSystem
  50072. * @param gradient defines the gradient to use (between 0 and 1)
  50073. * @param min defines the alpha remap minimal range
  50074. * @param max defines the alpha remap maximal range
  50075. * @returns the current particle system
  50076. */
  50077. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  50078. /**
  50079. * Not supported by GPUParticleSystem
  50080. * @param gradient defines the gradient to remove
  50081. * @returns the current particle system
  50082. */
  50083. removeAlphaRemapGradient(): IParticleSystem;
  50084. /**
  50085. * Not supported by GPUParticleSystem
  50086. * @param gradient defines the gradient to use (between 0 and 1)
  50087. * @param color defines the color to affect to the specified gradient
  50088. * @returns the current particle system
  50089. */
  50090. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  50091. /**
  50092. * Not supported by GPUParticleSystem
  50093. * @param gradient defines the gradient to remove
  50094. * @returns the current particle system
  50095. */
  50096. removeRampGradient(): IParticleSystem;
  50097. /**
  50098. * Not supported by GPUParticleSystem
  50099. * @returns the list of ramp gradients
  50100. */
  50101. getRampGradients(): Nullable<Array<Color3Gradient>>;
  50102. /**
  50103. * Not supported by GPUParticleSystem
  50104. * Gets or sets a boolean indicating that ramp gradients must be used
  50105. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  50106. */
  50107. useRampGradients: boolean;
  50108. /**
  50109. * Not supported by GPUParticleSystem
  50110. * @param gradient defines the gradient to use (between 0 and 1)
  50111. * @param factor defines the life time factor to affect to the specified gradient
  50112. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  50113. * @returns the current particle system
  50114. */
  50115. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  50116. /**
  50117. * Not supported by GPUParticleSystem
  50118. * @param gradient defines the gradient to remove
  50119. * @returns the current particle system
  50120. */
  50121. removeLifeTimeGradient(gradient: number): IParticleSystem;
  50122. /**
  50123. * Instantiates a GPU particle system.
  50124. * 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.
  50125. * @param name The name of the particle system
  50126. * @param options The options used to create the system
  50127. * @param scene The scene the particle system belongs to
  50128. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  50129. */
  50130. constructor(name: string, options: Partial<{
  50131. capacity: number;
  50132. randomTextureSize: number;
  50133. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  50134. protected _reset(): void;
  50135. private _createUpdateVAO;
  50136. private _createRenderVAO;
  50137. private _initialize;
  50138. /** @hidden */ recreateUpdateEffect(): void;
  50139. /** @hidden */ recreateRenderEffect(): void;
  50140. /**
  50141. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  50142. * @param preWarm defines if we are in the pre-warmimg phase
  50143. */
  50144. animate(preWarm?: boolean): void;
  50145. private _createFactorGradientTexture;
  50146. private _createSizeGradientTexture;
  50147. private _createAngularSpeedGradientTexture;
  50148. private _createVelocityGradientTexture;
  50149. private _createLimitVelocityGradientTexture;
  50150. private _createDragGradientTexture;
  50151. private _createColorGradientTexture;
  50152. /**
  50153. * Renders the particle system in its current state
  50154. * @param preWarm defines if the system should only update the particles but not render them
  50155. * @returns the current number of particles
  50156. */
  50157. render(preWarm?: boolean): number;
  50158. /**
  50159. * Rebuilds the particle system
  50160. */
  50161. rebuild(): void;
  50162. private _releaseBuffers;
  50163. private _releaseVAOs;
  50164. /**
  50165. * Disposes the particle system and free the associated resources
  50166. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  50167. */
  50168. dispose(disposeTexture?: boolean): void;
  50169. /**
  50170. * Clones the particle system.
  50171. * @param name The name of the cloned object
  50172. * @param newEmitter The new emitter to use
  50173. * @returns the cloned particle system
  50174. */
  50175. clone(name: string, newEmitter: any): GPUParticleSystem;
  50176. /**
  50177. * Serializes the particle system to a JSON object.
  50178. * @returns the JSON object
  50179. */
  50180. serialize(): any;
  50181. /**
  50182. * Parses a JSON object to create a GPU particle system.
  50183. * @param parsedParticleSystem The JSON object to parse
  50184. * @param scene The scene to create the particle system in
  50185. * @param rootUrl The root url to use to load external dependencies like texture
  50186. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  50187. * @returns the parsed GPU particle system
  50188. */
  50189. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  50190. }
  50191. }
  50192. declare module BABYLON {
  50193. /**
  50194. * Represents a set of particle systems working together to create a specific effect
  50195. */
  50196. export class ParticleSystemSet implements IDisposable {
  50197. private _emitterCreationOptions;
  50198. private _emitterNode;
  50199. /**
  50200. * Gets the particle system list
  50201. */
  50202. systems: IParticleSystem[];
  50203. /**
  50204. * Gets the emitter node used with this set
  50205. */
  50206. readonly emitterNode: Nullable<TransformNode>;
  50207. /**
  50208. * Creates a new emitter mesh as a sphere
  50209. * @param options defines the options used to create the sphere
  50210. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  50211. * @param scene defines the hosting scene
  50212. */
  50213. setEmitterAsSphere(options: {
  50214. diameter: number;
  50215. segments: number;
  50216. color: Color3;
  50217. }, renderingGroupId: number, scene: Scene): void;
  50218. /**
  50219. * Starts all particle systems of the set
  50220. * @param emitter defines an optional mesh to use as emitter for the particle systems
  50221. */
  50222. start(emitter?: AbstractMesh): void;
  50223. /**
  50224. * Release all associated resources
  50225. */
  50226. dispose(): void;
  50227. /**
  50228. * Serialize the set into a JSON compatible object
  50229. * @returns a JSON compatible representation of the set
  50230. */
  50231. serialize(): any;
  50232. /**
  50233. * Parse a new ParticleSystemSet from a serialized source
  50234. * @param data defines a JSON compatible representation of the set
  50235. * @param scene defines the hosting scene
  50236. * @param gpu defines if we want GPU particles or CPU particles
  50237. * @returns a new ParticleSystemSet
  50238. */
  50239. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  50240. }
  50241. }
  50242. declare module BABYLON {
  50243. /**
  50244. * This class is made for on one-liner static method to help creating particle system set.
  50245. */
  50246. export class ParticleHelper {
  50247. /**
  50248. * Gets or sets base Assets URL
  50249. */
  50250. static BaseAssetsUrl: string;
  50251. /**
  50252. * Create a default particle system that you can tweak
  50253. * @param emitter defines the emitter to use
  50254. * @param capacity defines the system capacity (default is 500 particles)
  50255. * @param scene defines the hosting scene
  50256. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  50257. * @returns the new Particle system
  50258. */
  50259. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  50260. /**
  50261. * This is the main static method (one-liner) of this helper to create different particle systems
  50262. * @param type This string represents the type to the particle system to create
  50263. * @param scene The scene where the particle system should live
  50264. * @param gpu If the system will use gpu
  50265. * @returns the ParticleSystemSet created
  50266. */
  50267. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  50268. /**
  50269. * Static function used to export a particle system to a ParticleSystemSet variable.
  50270. * Please note that the emitter shape is not exported
  50271. * @param systems defines the particle systems to export
  50272. * @returns the created particle system set
  50273. */
  50274. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  50275. }
  50276. }
  50277. declare module BABYLON {
  50278. interface Engine {
  50279. /**
  50280. * Create an effect to use with particle systems.
  50281. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  50282. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  50283. * @param uniformsNames defines a list of attribute names
  50284. * @param samplers defines an array of string used to represent textures
  50285. * @param defines defines the string containing the defines to use to compile the shaders
  50286. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  50287. * @param onCompiled defines a function to call when the effect creation is successful
  50288. * @param onError defines a function to call when the effect creation has failed
  50289. * @returns the new Effect
  50290. */
  50291. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  50292. }
  50293. interface Mesh {
  50294. /**
  50295. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  50296. * @returns an array of IParticleSystem
  50297. */
  50298. getEmittedParticleSystems(): IParticleSystem[];
  50299. /**
  50300. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  50301. * @returns an array of IParticleSystem
  50302. */
  50303. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  50304. }
  50305. /**
  50306. * @hidden
  50307. */
  50308. export var _IDoNeedToBeInTheBuild: number;
  50309. }
  50310. declare module BABYLON {
  50311. interface Scene {
  50312. /** @hidden (Backing field) */ physicsEngine: Nullable<IPhysicsEngine>;
  50313. /**
  50314. * Gets the current physics engine
  50315. * @returns a IPhysicsEngine or null if none attached
  50316. */
  50317. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  50318. /**
  50319. * Enables physics to the current scene
  50320. * @param gravity defines the scene's gravity for the physics engine
  50321. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  50322. * @return a boolean indicating if the physics engine was initialized
  50323. */
  50324. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  50325. /**
  50326. * Disables and disposes the physics engine associated with the scene
  50327. */
  50328. disablePhysicsEngine(): void;
  50329. /**
  50330. * Gets a boolean indicating if there is an active physics engine
  50331. * @returns a boolean indicating if there is an active physics engine
  50332. */
  50333. isPhysicsEnabled(): boolean;
  50334. /**
  50335. * Deletes a physics compound impostor
  50336. * @param compound defines the compound to delete
  50337. */
  50338. deleteCompoundImpostor(compound: any): void;
  50339. /**
  50340. * An event triggered when physic simulation is about to be run
  50341. */
  50342. onBeforePhysicsObservable: Observable<Scene>;
  50343. /**
  50344. * An event triggered when physic simulation has been done
  50345. */
  50346. onAfterPhysicsObservable: Observable<Scene>;
  50347. }
  50348. interface AbstractMesh {
  50349. /** @hidden */ physicsImpostor: Nullable<PhysicsImpostor>;
  50350. /**
  50351. * Gets or sets impostor used for physic simulation
  50352. * @see http://doc.babylonjs.com/features/physics_engine
  50353. */
  50354. physicsImpostor: Nullable<PhysicsImpostor>;
  50355. /**
  50356. * Gets the current physics impostor
  50357. * @see http://doc.babylonjs.com/features/physics_engine
  50358. * @returns a physics impostor or null
  50359. */
  50360. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  50361. /** Apply a physic impulse to the mesh
  50362. * @param force defines the force to apply
  50363. * @param contactPoint defines where to apply the force
  50364. * @returns the current mesh
  50365. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50366. */
  50367. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  50368. /**
  50369. * Creates a physic joint between two meshes
  50370. * @param otherMesh defines the other mesh to use
  50371. * @param pivot1 defines the pivot to use on this mesh
  50372. * @param pivot2 defines the pivot to use on the other mesh
  50373. * @param options defines additional options (can be plugin dependent)
  50374. * @returns the current mesh
  50375. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  50376. */
  50377. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  50378. /** @hidden */ disposePhysicsObserver: Nullable<Observer<Node>>;
  50379. }
  50380. /**
  50381. * Defines the physics engine scene component responsible to manage a physics engine
  50382. */
  50383. export class PhysicsEngineSceneComponent implements ISceneComponent {
  50384. /**
  50385. * The component name helpful to identify the component in the list of scene components.
  50386. */
  50387. readonly name: string;
  50388. /**
  50389. * The scene the component belongs to.
  50390. */
  50391. scene: Scene;
  50392. /**
  50393. * Creates a new instance of the component for the given scene
  50394. * @param scene Defines the scene to register the component in
  50395. */
  50396. constructor(scene: Scene);
  50397. /**
  50398. * Registers the component in a given scene
  50399. */
  50400. register(): void;
  50401. /**
  50402. * Rebuilds the elements related to this component in case of
  50403. * context lost for instance.
  50404. */
  50405. rebuild(): void;
  50406. /**
  50407. * Disposes the component and the associated ressources
  50408. */
  50409. dispose(): void;
  50410. }
  50411. }
  50412. declare module BABYLON {
  50413. /**
  50414. * A helper for physics simulations
  50415. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50416. */
  50417. export class PhysicsHelper {
  50418. private _scene;
  50419. private _physicsEngine;
  50420. /**
  50421. * Initializes the Physics helper
  50422. * @param scene Babylon.js scene
  50423. */
  50424. constructor(scene: Scene);
  50425. /**
  50426. * Applies a radial explosion impulse
  50427. * @param origin the origin of the explosion
  50428. * @param radiusOrEventOptions the radius or the options of radial explosion
  50429. * @param strength the explosion strength
  50430. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50431. * @returns A physics radial explosion event, or null
  50432. */
  50433. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50434. /**
  50435. * Applies a radial explosion force
  50436. * @param origin the origin of the explosion
  50437. * @param radiusOrEventOptions the radius or the options of radial explosion
  50438. * @param strength the explosion strength
  50439. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50440. * @returns A physics radial explosion event, or null
  50441. */
  50442. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  50443. /**
  50444. * Creates a gravitational field
  50445. * @param origin the origin of the explosion
  50446. * @param radiusOrEventOptions the radius or the options of radial explosion
  50447. * @param strength the explosion strength
  50448. * @param falloff possible options: Constant & Linear. Defaults to Constant
  50449. * @returns A physics gravitational field event, or null
  50450. */
  50451. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  50452. /**
  50453. * Creates a physics updraft event
  50454. * @param origin the origin of the updraft
  50455. * @param radiusOrEventOptions the radius or the options of the updraft
  50456. * @param strength the strength of the updraft
  50457. * @param height the height of the updraft
  50458. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  50459. * @returns A physics updraft event, or null
  50460. */
  50461. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  50462. /**
  50463. * Creates a physics vortex event
  50464. * @param origin the of the vortex
  50465. * @param radiusOrEventOptions the radius or the options of the vortex
  50466. * @param strength the strength of the vortex
  50467. * @param height the height of the vortex
  50468. * @returns a Physics vortex event, or null
  50469. * A physics vortex event or null
  50470. */
  50471. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  50472. }
  50473. /**
  50474. * Represents a physics radial explosion event
  50475. */
  50476. class PhysicsRadialExplosionEvent {
  50477. private _scene;
  50478. private _options;
  50479. private _sphere;
  50480. private _dataFetched;
  50481. /**
  50482. * Initializes a radial explosioin event
  50483. * @param _scene BabylonJS scene
  50484. * @param _options The options for the vortex event
  50485. */
  50486. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  50487. /**
  50488. * Returns the data related to the radial explosion event (sphere).
  50489. * @returns The radial explosion event data
  50490. */
  50491. getData(): PhysicsRadialExplosionEventData;
  50492. /**
  50493. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  50494. * @param impostor A physics imposter
  50495. * @param origin the origin of the explosion
  50496. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  50497. */
  50498. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  50499. /**
  50500. * Triggers affecterd impostors callbacks
  50501. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  50502. */
  50503. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  50504. /**
  50505. * Disposes the sphere.
  50506. * @param force Specifies if the sphere should be disposed by force
  50507. */
  50508. dispose(force?: boolean): void;
  50509. /*** Helpers ***/
  50510. private _prepareSphere;
  50511. private _intersectsWithSphere;
  50512. }
  50513. /**
  50514. * Represents a gravitational field event
  50515. */
  50516. class PhysicsGravitationalFieldEvent {
  50517. private _physicsHelper;
  50518. private _scene;
  50519. private _origin;
  50520. private _options;
  50521. private _tickCallback;
  50522. private _sphere;
  50523. private _dataFetched;
  50524. /**
  50525. * Initializes the physics gravitational field event
  50526. * @param _physicsHelper A physics helper
  50527. * @param _scene BabylonJS scene
  50528. * @param _origin The origin position of the gravitational field event
  50529. * @param _options The options for the vortex event
  50530. */
  50531. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  50532. /**
  50533. * Returns the data related to the gravitational field event (sphere).
  50534. * @returns A gravitational field event
  50535. */
  50536. getData(): PhysicsGravitationalFieldEventData;
  50537. /**
  50538. * Enables the gravitational field.
  50539. */
  50540. enable(): void;
  50541. /**
  50542. * Disables the gravitational field.
  50543. */
  50544. disable(): void;
  50545. /**
  50546. * Disposes the sphere.
  50547. * @param force The force to dispose from the gravitational field event
  50548. */
  50549. dispose(force?: boolean): void;
  50550. private _tick;
  50551. }
  50552. /**
  50553. * Represents a physics updraft event
  50554. */
  50555. class PhysicsUpdraftEvent {
  50556. private _scene;
  50557. private _origin;
  50558. private _options;
  50559. private _physicsEngine;
  50560. private _originTop;
  50561. private _originDirection;
  50562. private _tickCallback;
  50563. private _cylinder;
  50564. private _cylinderPosition;
  50565. private _dataFetched;
  50566. /**
  50567. * Initializes the physics updraft event
  50568. * @param _scene BabylonJS scene
  50569. * @param _origin The origin position of the updraft
  50570. * @param _options The options for the updraft event
  50571. */
  50572. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  50573. /**
  50574. * Returns the data related to the updraft event (cylinder).
  50575. * @returns A physics updraft event
  50576. */
  50577. getData(): PhysicsUpdraftEventData;
  50578. /**
  50579. * Enables the updraft.
  50580. */
  50581. enable(): void;
  50582. /**
  50583. * Disables the updraft.
  50584. */
  50585. disable(): void;
  50586. /**
  50587. * Disposes the cylinder.
  50588. * @param force Specifies if the updraft should be disposed by force
  50589. */
  50590. dispose(force?: boolean): void;
  50591. private getImpostorHitData;
  50592. private _tick;
  50593. /*** Helpers ***/
  50594. private _prepareCylinder;
  50595. private _intersectsWithCylinder;
  50596. }
  50597. /**
  50598. * Represents a physics vortex event
  50599. */
  50600. class PhysicsVortexEvent {
  50601. private _scene;
  50602. private _origin;
  50603. private _options;
  50604. private _physicsEngine;
  50605. private _originTop;
  50606. private _tickCallback;
  50607. private _cylinder;
  50608. private _cylinderPosition;
  50609. private _dataFetched;
  50610. /**
  50611. * Initializes the physics vortex event
  50612. * @param _scene The BabylonJS scene
  50613. * @param _origin The origin position of the vortex
  50614. * @param _options The options for the vortex event
  50615. */
  50616. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  50617. /**
  50618. * Returns the data related to the vortex event (cylinder).
  50619. * @returns The physics vortex event data
  50620. */
  50621. getData(): PhysicsVortexEventData;
  50622. /**
  50623. * Enables the vortex.
  50624. */
  50625. enable(): void;
  50626. /**
  50627. * Disables the cortex.
  50628. */
  50629. disable(): void;
  50630. /**
  50631. * Disposes the sphere.
  50632. * @param force
  50633. */
  50634. dispose(force?: boolean): void;
  50635. private getImpostorHitData;
  50636. private _tick;
  50637. /*** Helpers ***/
  50638. private _prepareCylinder;
  50639. private _intersectsWithCylinder;
  50640. }
  50641. /**
  50642. * Options fot the radial explosion event
  50643. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50644. */
  50645. export class PhysicsRadialExplosionEventOptions {
  50646. /**
  50647. * The radius of the sphere for the radial explosion.
  50648. */
  50649. radius: number;
  50650. /**
  50651. * The strenth of the explosion.
  50652. */
  50653. strength: number;
  50654. /**
  50655. * The strenght of the force in correspondence to the distance of the affected object
  50656. */
  50657. falloff: PhysicsRadialImpulseFalloff;
  50658. /**
  50659. * Sphere options for the radial explosion.
  50660. */
  50661. sphere: {
  50662. segments: number;
  50663. diameter: number;
  50664. };
  50665. /**
  50666. * Sphere options for the radial explosion.
  50667. */
  50668. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  50669. }
  50670. /**
  50671. * Options fot the updraft event
  50672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50673. */
  50674. export class PhysicsUpdraftEventOptions {
  50675. /**
  50676. * The radius of the cylinder for the vortex
  50677. */
  50678. radius: number;
  50679. /**
  50680. * The strenth of the updraft.
  50681. */
  50682. strength: number;
  50683. /**
  50684. * The height of the cylinder for the updraft.
  50685. */
  50686. height: number;
  50687. /**
  50688. * The mode for the the updraft.
  50689. */
  50690. updraftMode: PhysicsUpdraftMode;
  50691. }
  50692. /**
  50693. * Options fot the vortex event
  50694. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50695. */
  50696. export class PhysicsVortexEventOptions {
  50697. /**
  50698. * The radius of the cylinder for the vortex
  50699. */
  50700. radius: number;
  50701. /**
  50702. * The strenth of the vortex.
  50703. */
  50704. strength: number;
  50705. /**
  50706. * The height of the cylinder for the vortex.
  50707. */
  50708. height: number;
  50709. /**
  50710. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  50711. */
  50712. centripetalForceThreshold: number;
  50713. /**
  50714. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  50715. */
  50716. centripetalForceMultiplier: number;
  50717. /**
  50718. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  50719. */
  50720. centrifugalForceMultiplier: number;
  50721. /**
  50722. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  50723. */
  50724. updraftForceMultiplier: number;
  50725. }
  50726. /**
  50727. * The strenght of the force in correspondence to the distance of the affected object
  50728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50729. */
  50730. export enum PhysicsRadialImpulseFalloff {
  50731. /** Defines that impulse is constant in strength across it's whole radius */
  50732. Constant = 0,
  50733. /** Defines that impulse gets weaker if it's further from the origin */
  50734. Linear = 1
  50735. }
  50736. /**
  50737. * The strength of the force in correspondence to the distance of the affected object
  50738. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50739. */
  50740. export enum PhysicsUpdraftMode {
  50741. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  50742. Center = 0,
  50743. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  50744. Perpendicular = 1
  50745. }
  50746. /**
  50747. * Interface for a physics hit data
  50748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50749. */
  50750. export interface PhysicsHitData {
  50751. /**
  50752. * The force applied at the contact point
  50753. */
  50754. force: Vector3;
  50755. /**
  50756. * The contact point
  50757. */
  50758. contactPoint: Vector3;
  50759. /**
  50760. * The distance from the origin to the contact point
  50761. */
  50762. distanceFromOrigin: number;
  50763. }
  50764. /**
  50765. * Interface for radial explosion event data
  50766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50767. */
  50768. export interface PhysicsRadialExplosionEventData {
  50769. /**
  50770. * A sphere used for the radial explosion event
  50771. */
  50772. sphere: Mesh;
  50773. }
  50774. /**
  50775. * Interface for gravitational field event data
  50776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50777. */
  50778. export interface PhysicsGravitationalFieldEventData {
  50779. /**
  50780. * A sphere mesh used for the gravitational field event
  50781. */
  50782. sphere: Mesh;
  50783. }
  50784. /**
  50785. * Interface for updraft event data
  50786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50787. */
  50788. export interface PhysicsUpdraftEventData {
  50789. /**
  50790. * A cylinder used for the updraft event
  50791. */
  50792. cylinder: Mesh;
  50793. }
  50794. /**
  50795. * Interface for vortex event data
  50796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50797. */
  50798. export interface PhysicsVortexEventData {
  50799. /**
  50800. * A cylinder used for the vortex event
  50801. */
  50802. cylinder: Mesh;
  50803. }
  50804. /**
  50805. * Interface for an affected physics impostor
  50806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  50807. */
  50808. export interface PhysicsAffectedImpostorWithData {
  50809. /**
  50810. * The impostor affected by the effect
  50811. */
  50812. impostor: PhysicsImpostor;
  50813. /**
  50814. * The data about the hit/horce from the explosion
  50815. */
  50816. hitData: PhysicsHitData;
  50817. }
  50818. }
  50819. declare module BABYLON {
  50820. /** @hidden */
  50821. export var blackAndWhitePixelShader: {
  50822. name: string;
  50823. shader: string;
  50824. };
  50825. }
  50826. declare module BABYLON {
  50827. /**
  50828. * Post process used to render in black and white
  50829. */
  50830. export class BlackAndWhitePostProcess extends PostProcess {
  50831. /**
  50832. * Linear about to convert he result to black and white (default: 1)
  50833. */
  50834. degree: number;
  50835. /**
  50836. * Creates a black and white post process
  50837. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  50838. * @param name The name of the effect.
  50839. * @param options The required width/height ratio to downsize to before computing the render pass.
  50840. * @param camera The camera to apply the render pass to.
  50841. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50842. * @param engine The engine which the post process will be applied. (default: current engine)
  50843. * @param reusable If the post process can be reused on the same frame. (default: false)
  50844. */
  50845. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  50846. }
  50847. }
  50848. declare module BABYLON {
  50849. /**
  50850. * This represents a set of one or more post processes in Babylon.
  50851. * A post process can be used to apply a shader to a texture after it is rendered.
  50852. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  50853. */
  50854. export class PostProcessRenderEffect {
  50855. private _postProcesses;
  50856. private _getPostProcesses;
  50857. private _singleInstance;
  50858. private _cameras;
  50859. private _indicesForCamera;
  50860. /**
  50861. * Name of the effect
  50862. * @hidden
  50863. */ name: string;
  50864. /**
  50865. * Instantiates a post process render effect.
  50866. * A post process can be used to apply a shader to a texture after it is rendered.
  50867. * @param engine The engine the effect is tied to
  50868. * @param name The name of the effect
  50869. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  50870. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  50871. */
  50872. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  50873. /**
  50874. * Checks if all the post processes in the effect are supported.
  50875. */
  50876. readonly isSupported: boolean;
  50877. /**
  50878. * Updates the current state of the effect
  50879. * @hidden
  50880. */ update(): void;
  50881. /**
  50882. * Attaches the effect on cameras
  50883. * @param cameras The camera to attach to.
  50884. * @hidden
  50885. */ attachCameras(cameras: Camera): void;
  50886. /**
  50887. * Attaches the effect on cameras
  50888. * @param cameras The camera to attach to.
  50889. * @hidden
  50890. */ attachCameras(cameras: Camera[]): void;
  50891. /**
  50892. * Detatches the effect on cameras
  50893. * @param cameras The camera to detatch from.
  50894. * @hidden
  50895. */ detachCameras(cameras: Camera): void;
  50896. /**
  50897. * Detatches the effect on cameras
  50898. * @param cameras The camera to detatch from.
  50899. * @hidden
  50900. */ detachCameras(cameras: Camera[]): void;
  50901. /**
  50902. * Enables the effect on given cameras
  50903. * @param cameras The camera to enable.
  50904. * @hidden
  50905. */ enable(cameras: Camera): void;
  50906. /**
  50907. * Enables the effect on given cameras
  50908. * @param cameras The camera to enable.
  50909. * @hidden
  50910. */ enable(cameras: Nullable<Camera[]>): void;
  50911. /**
  50912. * Disables the effect on the given cameras
  50913. * @param cameras The camera to disable.
  50914. * @hidden
  50915. */ disable(cameras: Camera): void;
  50916. /**
  50917. * Disables the effect on the given cameras
  50918. * @param cameras The camera to disable.
  50919. * @hidden
  50920. */ disable(cameras: Nullable<Camera[]>): void;
  50921. /**
  50922. * Gets a list of the post processes contained in the effect.
  50923. * @param camera The camera to get the post processes on.
  50924. * @returns The list of the post processes in the effect.
  50925. */
  50926. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  50927. }
  50928. }
  50929. declare module BABYLON {
  50930. /** @hidden */
  50931. export var extractHighlightsPixelShader: {
  50932. name: string;
  50933. shader: string;
  50934. };
  50935. }
  50936. declare module BABYLON {
  50937. /**
  50938. * 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.
  50939. */
  50940. export class ExtractHighlightsPostProcess extends PostProcess {
  50941. /**
  50942. * The luminance threshold, pixels below this value will be set to black.
  50943. */
  50944. threshold: number;
  50945. /** @hidden */ exposure: number;
  50946. /**
  50947. * Post process which has the input texture to be used when performing highlight extraction
  50948. * @hidden
  50949. */ inputPostProcess: Nullable<PostProcess>;
  50950. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50951. }
  50952. }
  50953. declare module BABYLON {
  50954. /** @hidden */
  50955. export var bloomMergePixelShader: {
  50956. name: string;
  50957. shader: string;
  50958. };
  50959. }
  50960. declare module BABYLON {
  50961. /**
  50962. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  50963. */
  50964. export class BloomMergePostProcess extends PostProcess {
  50965. /** Weight of the bloom to be added to the original input. */
  50966. weight: number;
  50967. /**
  50968. * Creates a new instance of @see BloomMergePostProcess
  50969. * @param name The name of the effect.
  50970. * @param originalFromInput Post process which's input will be used for the merge.
  50971. * @param blurred Blurred highlights post process which's output will be used.
  50972. * @param weight Weight of the bloom to be added to the original input.
  50973. * @param options The required width/height ratio to downsize to before computing the render pass.
  50974. * @param camera The camera to apply the render pass to.
  50975. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  50976. * @param engine The engine which the post process will be applied. (default: current engine)
  50977. * @param reusable If the post process can be reused on the same frame. (default: false)
  50978. * @param textureType Type of textures used when performing the post process. (default: 0)
  50979. * @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)
  50980. */
  50981. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  50982. /** Weight of the bloom to be added to the original input. */
  50983. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  50984. }
  50985. }
  50986. declare module BABYLON {
  50987. /**
  50988. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  50989. */
  50990. export class BloomEffect extends PostProcessRenderEffect {
  50991. private bloomScale;
  50992. /**
  50993. * @hidden Internal
  50994. */ effects: Array<PostProcess>;
  50995. /**
  50996. * @hidden Internal
  50997. */ downscale: ExtractHighlightsPostProcess;
  50998. private _blurX;
  50999. private _blurY;
  51000. private _merge;
  51001. /**
  51002. * The luminance threshold to find bright areas of the image to bloom.
  51003. */
  51004. threshold: number;
  51005. /**
  51006. * The strength of the bloom.
  51007. */
  51008. weight: number;
  51009. /**
  51010. * Specifies the size of the bloom blur kernel, relative to the final output size
  51011. */
  51012. kernel: number;
  51013. /**
  51014. * Creates a new instance of @see BloomEffect
  51015. * @param scene The scene the effect belongs to.
  51016. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  51017. * @param bloomKernel The size of the kernel to be used when applying the blur.
  51018. * @param bloomWeight The the strength of bloom.
  51019. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51020. * @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)
  51021. */
  51022. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  51023. /**
  51024. * Disposes each of the internal effects for a given camera.
  51025. * @param camera The camera to dispose the effect on.
  51026. */
  51027. disposeEffects(camera: Camera): void;
  51028. /**
  51029. * @hidden Internal
  51030. */ updateEffects(): void;
  51031. /**
  51032. * Internal
  51033. * @returns if all the contained post processes are ready.
  51034. * @hidden
  51035. */ isReady(): boolean;
  51036. }
  51037. }
  51038. declare module BABYLON {
  51039. /** @hidden */
  51040. export var chromaticAberrationPixelShader: {
  51041. name: string;
  51042. shader: string;
  51043. };
  51044. }
  51045. declare module BABYLON {
  51046. /**
  51047. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  51048. */
  51049. export class ChromaticAberrationPostProcess extends PostProcess {
  51050. /**
  51051. * The amount of seperation of rgb channels (default: 30)
  51052. */
  51053. aberrationAmount: number;
  51054. /**
  51055. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  51056. */
  51057. radialIntensity: number;
  51058. /**
  51059. * 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))
  51060. */
  51061. direction: Vector2;
  51062. /**
  51063. * 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))
  51064. */
  51065. centerPosition: Vector2;
  51066. /**
  51067. * Creates a new instance ChromaticAberrationPostProcess
  51068. * @param name The name of the effect.
  51069. * @param screenWidth The width of the screen to apply the effect on.
  51070. * @param screenHeight The height of the screen to apply the effect on.
  51071. * @param options The required width/height ratio to downsize to before computing the render pass.
  51072. * @param camera The camera to apply the render pass to.
  51073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51074. * @param engine The engine which the post process will be applied. (default: current engine)
  51075. * @param reusable If the post process can be reused on the same frame. (default: false)
  51076. * @param textureType Type of textures used when performing the post process. (default: 0)
  51077. * @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)
  51078. */
  51079. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51080. }
  51081. }
  51082. declare module BABYLON {
  51083. /** @hidden */
  51084. export var circleOfConfusionPixelShader: {
  51085. name: string;
  51086. shader: string;
  51087. };
  51088. }
  51089. declare module BABYLON {
  51090. /**
  51091. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  51092. */
  51093. export class CircleOfConfusionPostProcess extends PostProcess {
  51094. /**
  51095. * 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.
  51096. */
  51097. lensSize: number;
  51098. /**
  51099. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51100. */
  51101. fStop: number;
  51102. /**
  51103. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51104. */
  51105. focusDistance: number;
  51106. /**
  51107. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  51108. */
  51109. focalLength: number;
  51110. private _depthTexture;
  51111. /**
  51112. * Creates a new instance CircleOfConfusionPostProcess
  51113. * @param name The name of the effect.
  51114. * @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.
  51115. * @param options The required width/height ratio to downsize to before computing the render pass.
  51116. * @param camera The camera to apply the render pass to.
  51117. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51118. * @param engine The engine which the post process will be applied. (default: current engine)
  51119. * @param reusable If the post process can be reused on the same frame. (default: false)
  51120. * @param textureType Type of textures used when performing the post process. (default: 0)
  51121. * @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)
  51122. */
  51123. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51124. /**
  51125. * 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.
  51126. */
  51127. depthTexture: RenderTargetTexture;
  51128. }
  51129. }
  51130. declare module BABYLON {
  51131. /** @hidden */
  51132. export var colorCorrectionPixelShader: {
  51133. name: string;
  51134. shader: string;
  51135. };
  51136. }
  51137. declare module BABYLON {
  51138. /**
  51139. *
  51140. * This post-process allows the modification of rendered colors by using
  51141. * a 'look-up table' (LUT). This effect is also called Color Grading.
  51142. *
  51143. * The object needs to be provided an url to a texture containing the color
  51144. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  51145. * Use an image editing software to tweak the LUT to match your needs.
  51146. *
  51147. * For an example of a color LUT, see here:
  51148. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  51149. * For explanations on color grading, see here:
  51150. * @see http://udn.epicgames.com/Three/ColorGrading.html
  51151. *
  51152. */
  51153. export class ColorCorrectionPostProcess extends PostProcess {
  51154. private _colorTableTexture;
  51155. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51156. }
  51157. }
  51158. declare module BABYLON {
  51159. /** @hidden */
  51160. export var convolutionPixelShader: {
  51161. name: string;
  51162. shader: string;
  51163. };
  51164. }
  51165. declare module BABYLON {
  51166. /**
  51167. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  51168. * input texture to perform effects such as edge detection or sharpening
  51169. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51170. */
  51171. export class ConvolutionPostProcess extends PostProcess {
  51172. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51173. kernel: number[];
  51174. /**
  51175. * Creates a new instance ConvolutionPostProcess
  51176. * @param name The name of the effect.
  51177. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  51178. * @param options The required width/height ratio to downsize to before computing the render pass.
  51179. * @param camera The camera to apply the render pass to.
  51180. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51181. * @param engine The engine which the post process will be applied. (default: current engine)
  51182. * @param reusable If the post process can be reused on the same frame. (default: false)
  51183. * @param textureType Type of textures used when performing the post process. (default: 0)
  51184. */
  51185. constructor(name: string,
  51186. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  51187. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51188. /**
  51189. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51190. */
  51191. static EdgeDetect0Kernel: number[];
  51192. /**
  51193. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51194. */
  51195. static EdgeDetect1Kernel: number[];
  51196. /**
  51197. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51198. */
  51199. static EdgeDetect2Kernel: number[];
  51200. /**
  51201. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51202. */
  51203. static SharpenKernel: number[];
  51204. /**
  51205. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51206. */
  51207. static EmbossKernel: number[];
  51208. /**
  51209. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  51210. */
  51211. static GaussianKernel: number[];
  51212. }
  51213. }
  51214. declare module BABYLON {
  51215. /**
  51216. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  51217. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  51218. * based on samples that have a large difference in distance than the center pixel.
  51219. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  51220. */
  51221. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  51222. direction: Vector2;
  51223. /**
  51224. * Creates a new instance CircleOfConfusionPostProcess
  51225. * @param name The name of the effect.
  51226. * @param scene The scene the effect belongs to.
  51227. * @param direction The direction the blur should be applied.
  51228. * @param kernel The size of the kernel used to blur.
  51229. * @param options The required width/height ratio to downsize to before computing the render pass.
  51230. * @param camera The camera to apply the render pass to.
  51231. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  51232. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  51233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51234. * @param engine The engine which the post process will be applied. (default: current engine)
  51235. * @param reusable If the post process can be reused on the same frame. (default: false)
  51236. * @param textureType Type of textures used when performing the post process. (default: 0)
  51237. * @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)
  51238. */
  51239. 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);
  51240. }
  51241. }
  51242. declare module BABYLON {
  51243. /** @hidden */
  51244. export var depthOfFieldMergePixelShader: {
  51245. name: string;
  51246. shader: string;
  51247. };
  51248. }
  51249. declare module BABYLON {
  51250. /**
  51251. * Options to be set when merging outputs from the default pipeline.
  51252. */
  51253. export class DepthOfFieldMergePostProcessOptions {
  51254. /**
  51255. * The original image to merge on top of
  51256. */
  51257. originalFromInput: PostProcess;
  51258. /**
  51259. * Parameters to perform the merge of the depth of field effect
  51260. */
  51261. depthOfField?: {
  51262. circleOfConfusion: PostProcess;
  51263. blurSteps: Array<PostProcess>;
  51264. };
  51265. /**
  51266. * Parameters to perform the merge of bloom effect
  51267. */
  51268. bloom?: {
  51269. blurred: PostProcess;
  51270. weight: number;
  51271. };
  51272. }
  51273. /**
  51274. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  51275. */
  51276. export class DepthOfFieldMergePostProcess extends PostProcess {
  51277. private blurSteps;
  51278. /**
  51279. * Creates a new instance of DepthOfFieldMergePostProcess
  51280. * @param name The name of the effect.
  51281. * @param originalFromInput Post process which's input will be used for the merge.
  51282. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  51283. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  51284. * @param options The required width/height ratio to downsize to before computing the render pass.
  51285. * @param camera The camera to apply the render pass to.
  51286. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51287. * @param engine The engine which the post process will be applied. (default: current engine)
  51288. * @param reusable If the post process can be reused on the same frame. (default: false)
  51289. * @param textureType Type of textures used when performing the post process. (default: 0)
  51290. * @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)
  51291. */
  51292. 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);
  51293. /**
  51294. * Updates the effect with the current post process compile time values and recompiles the shader.
  51295. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  51296. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  51297. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  51298. * @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
  51299. * @param onCompiled Called when the shader has been compiled.
  51300. * @param onError Called if there is an error when compiling a shader.
  51301. */
  51302. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  51303. }
  51304. }
  51305. declare module BABYLON {
  51306. /**
  51307. * Specifies the level of max blur that should be applied when using the depth of field effect
  51308. */
  51309. export enum DepthOfFieldEffectBlurLevel {
  51310. /**
  51311. * Subtle blur
  51312. */
  51313. Low = 0,
  51314. /**
  51315. * Medium blur
  51316. */
  51317. Medium = 1,
  51318. /**
  51319. * Large blur
  51320. */
  51321. High = 2
  51322. }
  51323. /**
  51324. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  51325. */
  51326. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  51327. private _circleOfConfusion;
  51328. /**
  51329. * @hidden Internal, blurs from high to low
  51330. */ depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  51331. private _depthOfFieldBlurY;
  51332. private _dofMerge;
  51333. /**
  51334. * @hidden Internal post processes in depth of field effect
  51335. */ effects: Array<PostProcess>;
  51336. /**
  51337. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  51338. */
  51339. focalLength: number;
  51340. /**
  51341. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  51342. */
  51343. fStop: number;
  51344. /**
  51345. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  51346. */
  51347. focusDistance: number;
  51348. /**
  51349. * 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.
  51350. */
  51351. lensSize: number;
  51352. /**
  51353. * Creates a new instance DepthOfFieldEffect
  51354. * @param scene The scene the effect belongs to.
  51355. * @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.
  51356. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  51357. * @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)
  51358. */
  51359. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  51360. /**
  51361. * 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.
  51362. */
  51363. depthTexture: RenderTargetTexture;
  51364. /**
  51365. * Disposes each of the internal effects for a given camera.
  51366. * @param camera The camera to dispose the effect on.
  51367. */
  51368. disposeEffects(camera: Camera): void;
  51369. /**
  51370. * @hidden Internal
  51371. */ updateEffects(): void;
  51372. /**
  51373. * Internal
  51374. * @returns if all the contained post processes are ready.
  51375. * @hidden
  51376. */ isReady(): boolean;
  51377. }
  51378. }
  51379. declare module BABYLON {
  51380. /** @hidden */
  51381. export var displayPassPixelShader: {
  51382. name: string;
  51383. shader: string;
  51384. };
  51385. }
  51386. declare module BABYLON {
  51387. /**
  51388. * DisplayPassPostProcess which produces an output the same as it's input
  51389. */
  51390. export class DisplayPassPostProcess extends PostProcess {
  51391. /**
  51392. * Creates the DisplayPassPostProcess
  51393. * @param name The name of the effect.
  51394. * @param options The required width/height ratio to downsize to before computing the render pass.
  51395. * @param camera The camera to apply the render pass to.
  51396. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51397. * @param engine The engine which the post process will be applied. (default: current engine)
  51398. * @param reusable If the post process can be reused on the same frame. (default: false)
  51399. */
  51400. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51401. }
  51402. }
  51403. declare module BABYLON {
  51404. /** @hidden */
  51405. export var filterPixelShader: {
  51406. name: string;
  51407. shader: string;
  51408. };
  51409. }
  51410. declare module BABYLON {
  51411. /**
  51412. * Applies a kernel filter to the image
  51413. */
  51414. export class FilterPostProcess extends PostProcess {
  51415. /** The matrix to be applied to the image */
  51416. kernelMatrix: Matrix;
  51417. /**
  51418. *
  51419. * @param name The name of the effect.
  51420. * @param kernelMatrix The matrix to be applied to the image
  51421. * @param options The required width/height ratio to downsize to before computing the render pass.
  51422. * @param camera The camera to apply the render pass to.
  51423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51424. * @param engine The engine which the post process will be applied. (default: current engine)
  51425. * @param reusable If the post process can be reused on the same frame. (default: false)
  51426. */
  51427. constructor(name: string,
  51428. /** The matrix to be applied to the image */
  51429. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51430. }
  51431. }
  51432. declare module BABYLON {
  51433. /** @hidden */
  51434. export var fxaaPixelShader: {
  51435. name: string;
  51436. shader: string;
  51437. };
  51438. }
  51439. declare module BABYLON {
  51440. /** @hidden */
  51441. export var fxaaVertexShader: {
  51442. name: string;
  51443. shader: string;
  51444. };
  51445. }
  51446. declare module BABYLON {
  51447. /**
  51448. * Fxaa post process
  51449. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  51450. */
  51451. export class FxaaPostProcess extends PostProcess {
  51452. /** @hidden */
  51453. texelWidth: number;
  51454. /** @hidden */
  51455. texelHeight: number;
  51456. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51457. private _getDefines;
  51458. }
  51459. }
  51460. declare module BABYLON {
  51461. /** @hidden */
  51462. export var grainPixelShader: {
  51463. name: string;
  51464. shader: string;
  51465. };
  51466. }
  51467. declare module BABYLON {
  51468. /**
  51469. * The GrainPostProcess adds noise to the image at mid luminance levels
  51470. */
  51471. export class GrainPostProcess extends PostProcess {
  51472. /**
  51473. * The intensity of the grain added (default: 30)
  51474. */
  51475. intensity: number;
  51476. /**
  51477. * If the grain should be randomized on every frame
  51478. */
  51479. animated: boolean;
  51480. /**
  51481. * Creates a new instance of @see GrainPostProcess
  51482. * @param name The name of the effect.
  51483. * @param options The required width/height ratio to downsize to before computing the render pass.
  51484. * @param camera The camera to apply the render pass to.
  51485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51486. * @param engine The engine which the post process will be applied. (default: current engine)
  51487. * @param reusable If the post process can be reused on the same frame. (default: false)
  51488. * @param textureType Type of textures used when performing the post process. (default: 0)
  51489. * @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)
  51490. */
  51491. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51492. }
  51493. }
  51494. declare module BABYLON {
  51495. /** @hidden */
  51496. export var highlightsPixelShader: {
  51497. name: string;
  51498. shader: string;
  51499. };
  51500. }
  51501. declare module BABYLON {
  51502. /**
  51503. * Extracts highlights from the image
  51504. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51505. */
  51506. export class HighlightsPostProcess extends PostProcess {
  51507. /**
  51508. * Extracts highlights from the image
  51509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  51510. * @param name The name of the effect.
  51511. * @param options The required width/height ratio to downsize to before computing the render pass.
  51512. * @param camera The camera to apply the render pass to.
  51513. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51514. * @param engine The engine which the post process will be applied. (default: current engine)
  51515. * @param reusable If the post process can be reused on the same frame. (default: false)
  51516. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  51517. */
  51518. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  51519. }
  51520. }
  51521. declare module BABYLON {
  51522. /** @hidden */
  51523. export var mrtFragmentDeclaration: {
  51524. name: string;
  51525. shader: string;
  51526. };
  51527. }
  51528. declare module BABYLON {
  51529. /** @hidden */
  51530. export var geometryPixelShader: {
  51531. name: string;
  51532. shader: string;
  51533. };
  51534. }
  51535. declare module BABYLON {
  51536. /** @hidden */
  51537. export var geometryVertexShader: {
  51538. name: string;
  51539. shader: string;
  51540. };
  51541. }
  51542. declare module BABYLON {
  51543. /**
  51544. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  51545. */
  51546. export class GeometryBufferRenderer {
  51547. /**
  51548. * Constant used to retrieve the position texture index in the G-Buffer textures array
  51549. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  51550. */
  51551. static readonly POSITION_TEXTURE_TYPE: number;
  51552. /**
  51553. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  51554. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  51555. */
  51556. static readonly VELOCITY_TEXTURE_TYPE: number;
  51557. /**
  51558. * Dictionary used to store the previous transformation matrices of each rendered mesh
  51559. * in order to compute objects velocities when enableVelocity is set to "true"
  51560. * @hidden
  51561. */ previousTransformationMatrices: {
  51562. [index: number]: Matrix;
  51563. };
  51564. private _scene;
  51565. private _multiRenderTarget;
  51566. private _ratio;
  51567. private _enablePosition;
  51568. private _enableVelocity;
  51569. private _positionIndex;
  51570. private _velocityIndex;
  51571. protected _effect: Effect;
  51572. protected _cachedDefines: string;
  51573. /**
  51574. * Set the render list (meshes to be rendered) used in the G buffer.
  51575. */
  51576. renderList: Mesh[];
  51577. /**
  51578. * Gets wether or not G buffer are supported by the running hardware.
  51579. * This requires draw buffer supports
  51580. */
  51581. readonly isSupported: boolean;
  51582. /**
  51583. * Returns the index of the given texture type in the G-Buffer textures array
  51584. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  51585. * @returns the index of the given texture type in the G-Buffer textures array
  51586. */
  51587. getTextureIndex(textureType: number): number;
  51588. /**
  51589. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  51590. */
  51591. /**
  51592. * Sets whether or not objects positions are enabled for the G buffer.
  51593. */
  51594. enablePosition: boolean;
  51595. /**
  51596. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  51597. */
  51598. /**
  51599. * Sets wether or not objects velocities are enabled for the G buffer.
  51600. */
  51601. enableVelocity: boolean;
  51602. /**
  51603. * Gets the scene associated with the buffer.
  51604. */
  51605. readonly scene: Scene;
  51606. /**
  51607. * Gets the ratio used by the buffer during its creation.
  51608. * How big is the buffer related to the main canvas.
  51609. */
  51610. readonly ratio: number;
  51611. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  51612. /**
  51613. * Creates a new G Buffer for the scene
  51614. * @param scene The scene the buffer belongs to
  51615. * @param ratio How big is the buffer related to the main canvas.
  51616. */
  51617. constructor(scene: Scene, ratio?: number);
  51618. /**
  51619. * Checks wether everything is ready to render a submesh to the G buffer.
  51620. * @param subMesh the submesh to check readiness for
  51621. * @param useInstances is the mesh drawn using instance or not
  51622. * @returns true if ready otherwise false
  51623. */
  51624. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51625. /**
  51626. * Gets the current underlying G Buffer.
  51627. * @returns the buffer
  51628. */
  51629. getGBuffer(): MultiRenderTarget;
  51630. /**
  51631. * Gets the number of samples used to render the buffer (anti aliasing).
  51632. */
  51633. /**
  51634. * Sets the number of samples used to render the buffer (anti aliasing).
  51635. */
  51636. samples: number;
  51637. /**
  51638. * Disposes the renderer and frees up associated resources.
  51639. */
  51640. dispose(): void;
  51641. protected _createRenderTargets(): void;
  51642. }
  51643. }
  51644. declare module BABYLON {
  51645. interface Scene {
  51646. /** @hidden (Backing field) */ geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51647. /**
  51648. * Gets or Sets the current geometry buffer associated to the scene.
  51649. */
  51650. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  51651. /**
  51652. * Enables a GeometryBufferRender and associates it with the scene
  51653. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  51654. * @returns the GeometryBufferRenderer
  51655. */
  51656. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  51657. /**
  51658. * Disables the GeometryBufferRender associated with the scene
  51659. */
  51660. disableGeometryBufferRenderer(): void;
  51661. }
  51662. /**
  51663. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  51664. * in several rendering techniques.
  51665. */
  51666. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  51667. /**
  51668. * The component name helpful to identify the component in the list of scene components.
  51669. */
  51670. readonly name: string;
  51671. /**
  51672. * The scene the component belongs to.
  51673. */
  51674. scene: Scene;
  51675. /**
  51676. * Creates a new instance of the component for the given scene
  51677. * @param scene Defines the scene to register the component in
  51678. */
  51679. constructor(scene: Scene);
  51680. /**
  51681. * Registers the component in a given scene
  51682. */
  51683. register(): void;
  51684. /**
  51685. * Rebuilds the elements related to this component in case of
  51686. * context lost for instance.
  51687. */
  51688. rebuild(): void;
  51689. /**
  51690. * Disposes the component and the associated ressources
  51691. */
  51692. dispose(): void;
  51693. private _gatherRenderTargets;
  51694. }
  51695. }
  51696. declare module BABYLON {
  51697. /** @hidden */
  51698. export var motionBlurPixelShader: {
  51699. name: string;
  51700. shader: string;
  51701. };
  51702. }
  51703. declare module BABYLON {
  51704. /**
  51705. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  51706. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  51707. * As an example, all you have to do is to create the post-process:
  51708. * var mb = new BABYLON.MotionBlurPostProcess(
  51709. * 'mb', // The name of the effect.
  51710. * scene, // The scene containing the objects to blur according to their velocity.
  51711. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  51712. * camera // The camera to apply the render pass to.
  51713. * );
  51714. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  51715. */
  51716. export class MotionBlurPostProcess extends PostProcess {
  51717. /**
  51718. * Defines how much the image is blurred by the movement. Default value is equal to 1
  51719. */
  51720. motionStrength: number;
  51721. /**
  51722. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  51723. */
  51724. /**
  51725. * Sets the number of iterations to be used for motion blur quality
  51726. */
  51727. motionBlurSamples: number;
  51728. private _motionBlurSamples;
  51729. private _geometryBufferRenderer;
  51730. /**
  51731. * Creates a new instance MotionBlurPostProcess
  51732. * @param name The name of the effect.
  51733. * @param scene The scene containing the objects to blur according to their velocity.
  51734. * @param options The required width/height ratio to downsize to before computing the render pass.
  51735. * @param camera The camera to apply the render pass to.
  51736. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51737. * @param engine The engine which the post process will be applied. (default: current engine)
  51738. * @param reusable If the post process can be reused on the same frame. (default: false)
  51739. * @param textureType Type of textures used when performing the post process. (default: 0)
  51740. * @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)
  51741. */
  51742. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51743. /**
  51744. * Disposes the post process.
  51745. * @param camera The camera to dispose the post process on.
  51746. */
  51747. dispose(camera?: Camera): void;
  51748. }
  51749. }
  51750. declare module BABYLON {
  51751. /** @hidden */
  51752. export var refractionPixelShader: {
  51753. name: string;
  51754. shader: string;
  51755. };
  51756. }
  51757. declare module BABYLON {
  51758. /**
  51759. * Post process which applies a refractin texture
  51760. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51761. */
  51762. export class RefractionPostProcess extends PostProcess {
  51763. /** the base color of the refraction (used to taint the rendering) */
  51764. color: Color3;
  51765. /** simulated refraction depth */
  51766. depth: number;
  51767. /** the coefficient of the base color (0 to remove base color tainting) */
  51768. colorLevel: number;
  51769. private _refTexture;
  51770. private _ownRefractionTexture;
  51771. /**
  51772. * Gets or sets the refraction texture
  51773. * Please note that you are responsible for disposing the texture if you set it manually
  51774. */
  51775. refractionTexture: Texture;
  51776. /**
  51777. * Initializes the RefractionPostProcess
  51778. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  51779. * @param name The name of the effect.
  51780. * @param refractionTextureUrl Url of the refraction texture to use
  51781. * @param color the base color of the refraction (used to taint the rendering)
  51782. * @param depth simulated refraction depth
  51783. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  51784. * @param camera The camera to apply the render pass to.
  51785. * @param options The required width/height ratio to downsize to before computing the render pass.
  51786. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51787. * @param engine The engine which the post process will be applied. (default: current engine)
  51788. * @param reusable If the post process can be reused on the same frame. (default: false)
  51789. */
  51790. constructor(name: string, refractionTextureUrl: string,
  51791. /** the base color of the refraction (used to taint the rendering) */
  51792. color: Color3,
  51793. /** simulated refraction depth */
  51794. depth: number,
  51795. /** the coefficient of the base color (0 to remove base color tainting) */
  51796. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  51797. /**
  51798. * Disposes of the post process
  51799. * @param camera Camera to dispose post process on
  51800. */
  51801. dispose(camera: Camera): void;
  51802. }
  51803. }
  51804. declare module BABYLON {
  51805. /** @hidden */
  51806. export var sharpenPixelShader: {
  51807. name: string;
  51808. shader: string;
  51809. };
  51810. }
  51811. declare module BABYLON {
  51812. /**
  51813. * The SharpenPostProcess applies a sharpen kernel to every pixel
  51814. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  51815. */
  51816. export class SharpenPostProcess extends PostProcess {
  51817. /**
  51818. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  51819. */
  51820. colorAmount: number;
  51821. /**
  51822. * How much sharpness should be applied (default: 0.3)
  51823. */
  51824. edgeAmount: number;
  51825. /**
  51826. * Creates a new instance ConvolutionPostProcess
  51827. * @param name The name of the effect.
  51828. * @param options The required width/height ratio to downsize to before computing the render pass.
  51829. * @param camera The camera to apply the render pass to.
  51830. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51831. * @param engine The engine which the post process will be applied. (default: current engine)
  51832. * @param reusable If the post process can be reused on the same frame. (default: false)
  51833. * @param textureType Type of textures used when performing the post process. (default: 0)
  51834. * @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)
  51835. */
  51836. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51837. }
  51838. }
  51839. declare module BABYLON {
  51840. /**
  51841. * PostProcessRenderPipeline
  51842. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51843. */
  51844. export class PostProcessRenderPipeline {
  51845. private engine;
  51846. private _renderEffects;
  51847. private _renderEffectsForIsolatedPass;
  51848. /**
  51849. * List of inspectable custom properties (used by the Inspector)
  51850. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  51851. */
  51852. inspectableCustomProperties: IInspectable[];
  51853. /**
  51854. * @hidden
  51855. */
  51856. protected _cameras: Camera[];
  51857. /** @hidden */ name: string;
  51858. /**
  51859. * Gets pipeline name
  51860. */
  51861. readonly name: string;
  51862. /**
  51863. * Initializes a PostProcessRenderPipeline
  51864. * @param engine engine to add the pipeline to
  51865. * @param name name of the pipeline
  51866. */
  51867. constructor(engine: Engine, name: string);
  51868. /**
  51869. * Gets the class name
  51870. * @returns "PostProcessRenderPipeline"
  51871. */
  51872. getClassName(): string;
  51873. /**
  51874. * If all the render effects in the pipeline are supported
  51875. */
  51876. readonly isSupported: boolean;
  51877. /**
  51878. * Adds an effect to the pipeline
  51879. * @param renderEffect the effect to add
  51880. */
  51881. addEffect(renderEffect: PostProcessRenderEffect): void;
  51882. /** @hidden */ rebuild(): void;
  51883. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera): void;
  51884. /** @hidden */ enableEffect(renderEffectName: string, cameras: Camera[]): void;
  51885. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51886. /** @hidden */ disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  51887. /** @hidden */ attachCameras(cameras: Camera, unique: boolean): void;
  51888. /** @hidden */ attachCameras(cameras: Camera[], unique: boolean): void;
  51889. /** @hidden */ detachCameras(cameras: Camera): void;
  51890. /** @hidden */ detachCameras(cameras: Nullable<Camera[]>): void;
  51891. /** @hidden */ update(): void;
  51892. /** @hidden */ reset(): void;
  51893. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  51894. /**
  51895. * Disposes of the pipeline
  51896. */
  51897. dispose(): void;
  51898. }
  51899. }
  51900. declare module BABYLON {
  51901. /**
  51902. * PostProcessRenderPipelineManager class
  51903. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51904. */
  51905. export class PostProcessRenderPipelineManager {
  51906. private _renderPipelines;
  51907. /**
  51908. * Initializes a PostProcessRenderPipelineManager
  51909. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51910. */
  51911. constructor();
  51912. /**
  51913. * Gets the list of supported render pipelines
  51914. */
  51915. readonly supportedPipelines: PostProcessRenderPipeline[];
  51916. /**
  51917. * Adds a pipeline to the manager
  51918. * @param renderPipeline The pipeline to add
  51919. */
  51920. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  51921. /**
  51922. * Attaches a camera to the pipeline
  51923. * @param renderPipelineName The name of the pipeline to attach to
  51924. * @param cameras the camera to attach
  51925. * @param unique if the camera can be attached multiple times to the pipeline
  51926. */
  51927. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  51928. /**
  51929. * Detaches a camera from the pipeline
  51930. * @param renderPipelineName The name of the pipeline to detach from
  51931. * @param cameras the camera to detach
  51932. */
  51933. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  51934. /**
  51935. * Enables an effect by name on a pipeline
  51936. * @param renderPipelineName the name of the pipeline to enable the effect in
  51937. * @param renderEffectName the name of the effect to enable
  51938. * @param cameras the cameras that the effect should be enabled on
  51939. */
  51940. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51941. /**
  51942. * Disables an effect by name on a pipeline
  51943. * @param renderPipelineName the name of the pipeline to disable the effect in
  51944. * @param renderEffectName the name of the effect to disable
  51945. * @param cameras the cameras that the effect should be disabled on
  51946. */
  51947. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  51948. /**
  51949. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  51950. */
  51951. update(): void;
  51952. /** @hidden */ rebuild(): void;
  51953. /**
  51954. * Disposes of the manager and pipelines
  51955. */
  51956. dispose(): void;
  51957. }
  51958. }
  51959. declare module BABYLON {
  51960. interface Scene {
  51961. /** @hidden (Backing field) */ postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51962. /**
  51963. * Gets the postprocess render pipeline manager
  51964. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  51965. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  51966. */
  51967. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  51968. }
  51969. /**
  51970. * Defines the Render Pipeline scene component responsible to rendering pipelines
  51971. */
  51972. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  51973. /**
  51974. * The component name helpfull to identify the component in the list of scene components.
  51975. */
  51976. readonly name: string;
  51977. /**
  51978. * The scene the component belongs to.
  51979. */
  51980. scene: Scene;
  51981. /**
  51982. * Creates a new instance of the component for the given scene
  51983. * @param scene Defines the scene to register the component in
  51984. */
  51985. constructor(scene: Scene);
  51986. /**
  51987. * Registers the component in a given scene
  51988. */
  51989. register(): void;
  51990. /**
  51991. * Rebuilds the elements related to this component in case of
  51992. * context lost for instance.
  51993. */
  51994. rebuild(): void;
  51995. /**
  51996. * Disposes the component and the associated ressources
  51997. */
  51998. dispose(): void;
  51999. private _gatherRenderTargets;
  52000. }
  52001. }
  52002. declare module BABYLON {
  52003. /**
  52004. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  52005. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  52006. */
  52007. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52008. private _scene;
  52009. private _camerasToBeAttached;
  52010. /**
  52011. * ID of the sharpen post process,
  52012. */
  52013. private readonly SharpenPostProcessId;
  52014. /**
  52015. * @ignore
  52016. * ID of the image processing post process;
  52017. */
  52018. readonly ImageProcessingPostProcessId: string;
  52019. /**
  52020. * @ignore
  52021. * ID of the Fast Approximate Anti-Aliasing post process;
  52022. */
  52023. readonly FxaaPostProcessId: string;
  52024. /**
  52025. * ID of the chromatic aberration post process,
  52026. */
  52027. private readonly ChromaticAberrationPostProcessId;
  52028. /**
  52029. * ID of the grain post process
  52030. */
  52031. private readonly GrainPostProcessId;
  52032. /**
  52033. * Sharpen post process which will apply a sharpen convolution to enhance edges
  52034. */
  52035. sharpen: SharpenPostProcess;
  52036. private _sharpenEffect;
  52037. private bloom;
  52038. /**
  52039. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  52040. */
  52041. depthOfField: DepthOfFieldEffect;
  52042. /**
  52043. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52044. */
  52045. fxaa: FxaaPostProcess;
  52046. /**
  52047. * Image post processing pass used to perform operations such as tone mapping or color grading.
  52048. */
  52049. imageProcessing: ImageProcessingPostProcess;
  52050. /**
  52051. * Chromatic aberration post process which will shift rgb colors in the image
  52052. */
  52053. chromaticAberration: ChromaticAberrationPostProcess;
  52054. private _chromaticAberrationEffect;
  52055. /**
  52056. * Grain post process which add noise to the image
  52057. */
  52058. grain: GrainPostProcess;
  52059. private _grainEffect;
  52060. /**
  52061. * Glow post process which adds a glow to emissive areas of the image
  52062. */
  52063. private _glowLayer;
  52064. /**
  52065. * Animations which can be used to tweak settings over a period of time
  52066. */
  52067. animations: Animation[];
  52068. private _imageProcessingConfigurationObserver;
  52069. private _sharpenEnabled;
  52070. private _bloomEnabled;
  52071. private _depthOfFieldEnabled;
  52072. private _depthOfFieldBlurLevel;
  52073. private _fxaaEnabled;
  52074. private _imageProcessingEnabled;
  52075. private _defaultPipelineTextureType;
  52076. private _bloomScale;
  52077. private _chromaticAberrationEnabled;
  52078. private _grainEnabled;
  52079. private _buildAllowed;
  52080. /**
  52081. * Gets active scene
  52082. */
  52083. readonly scene: Scene;
  52084. /**
  52085. * Enable or disable the sharpen process from the pipeline
  52086. */
  52087. sharpenEnabled: boolean;
  52088. private _resizeObserver;
  52089. private _hardwareScaleLevel;
  52090. private _bloomKernel;
  52091. /**
  52092. * Specifies the size of the bloom blur kernel, relative to the final output size
  52093. */
  52094. bloomKernel: number;
  52095. /**
  52096. * Specifies the weight of the bloom in the final rendering
  52097. */
  52098. private _bloomWeight;
  52099. /**
  52100. * Specifies the luma threshold for the area that will be blurred by the bloom
  52101. */
  52102. private _bloomThreshold;
  52103. private _hdr;
  52104. /**
  52105. * The strength of the bloom.
  52106. */
  52107. bloomWeight: number;
  52108. /**
  52109. * The strength of the bloom.
  52110. */
  52111. bloomThreshold: number;
  52112. /**
  52113. * The scale of the bloom, lower value will provide better performance.
  52114. */
  52115. bloomScale: number;
  52116. /**
  52117. * Enable or disable the bloom from the pipeline
  52118. */
  52119. bloomEnabled: boolean;
  52120. private _rebuildBloom;
  52121. /**
  52122. * If the depth of field is enabled.
  52123. */
  52124. depthOfFieldEnabled: boolean;
  52125. /**
  52126. * Blur level of the depth of field effect. (Higher blur will effect performance)
  52127. */
  52128. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  52129. /**
  52130. * If the anti aliasing is enabled.
  52131. */
  52132. fxaaEnabled: boolean;
  52133. private _samples;
  52134. /**
  52135. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52136. */
  52137. samples: number;
  52138. /**
  52139. * If image processing is enabled.
  52140. */
  52141. imageProcessingEnabled: boolean;
  52142. /**
  52143. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  52144. */
  52145. glowLayerEnabled: boolean;
  52146. /**
  52147. * Enable or disable the chromaticAberration process from the pipeline
  52148. */
  52149. chromaticAberrationEnabled: boolean;
  52150. /**
  52151. * Enable or disable the grain process from the pipeline
  52152. */
  52153. grainEnabled: boolean;
  52154. /**
  52155. * @constructor
  52156. * @param name - The rendering pipeline name (default: "")
  52157. * @param hdr - If high dynamic range textures should be used (default: true)
  52158. * @param scene - The scene linked to this pipeline (default: the last created scene)
  52159. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  52160. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  52161. */
  52162. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  52163. /**
  52164. * Get the class name
  52165. * @returns "DefaultRenderingPipeline"
  52166. */
  52167. getClassName(): string;
  52168. /**
  52169. * Force the compilation of the entire pipeline.
  52170. */
  52171. prepare(): void;
  52172. private _hasCleared;
  52173. private _prevPostProcess;
  52174. private _prevPrevPostProcess;
  52175. private _setAutoClearAndTextureSharing;
  52176. private _depthOfFieldSceneObserver;
  52177. private _buildPipeline;
  52178. private _disposePostProcesses;
  52179. /**
  52180. * Adds a camera to the pipeline
  52181. * @param camera the camera to be added
  52182. */
  52183. addCamera(camera: Camera): void;
  52184. /**
  52185. * Removes a camera from the pipeline
  52186. * @param camera the camera to remove
  52187. */
  52188. removeCamera(camera: Camera): void;
  52189. /**
  52190. * Dispose of the pipeline and stop all post processes
  52191. */
  52192. dispose(): void;
  52193. /**
  52194. * Serialize the rendering pipeline (Used when exporting)
  52195. * @returns the serialized object
  52196. */
  52197. serialize(): any;
  52198. /**
  52199. * Parse the serialized pipeline
  52200. * @param source Source pipeline.
  52201. * @param scene The scene to load the pipeline to.
  52202. * @param rootUrl The URL of the serialized pipeline.
  52203. * @returns An instantiated pipeline from the serialized object.
  52204. */
  52205. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  52206. }
  52207. }
  52208. declare module BABYLON {
  52209. /** @hidden */
  52210. export var lensHighlightsPixelShader: {
  52211. name: string;
  52212. shader: string;
  52213. };
  52214. }
  52215. declare module BABYLON {
  52216. /** @hidden */
  52217. export var depthOfFieldPixelShader: {
  52218. name: string;
  52219. shader: string;
  52220. };
  52221. }
  52222. declare module BABYLON {
  52223. /**
  52224. * BABYLON.JS Chromatic Aberration GLSL Shader
  52225. * Author: Olivier Guyot
  52226. * Separates very slightly R, G and B colors on the edges of the screen
  52227. * Inspired by Francois Tarlier & Martins Upitis
  52228. */
  52229. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  52230. /**
  52231. * @ignore
  52232. * The chromatic aberration PostProcess id in the pipeline
  52233. */
  52234. LensChromaticAberrationEffect: string;
  52235. /**
  52236. * @ignore
  52237. * The highlights enhancing PostProcess id in the pipeline
  52238. */
  52239. HighlightsEnhancingEffect: string;
  52240. /**
  52241. * @ignore
  52242. * The depth-of-field PostProcess id in the pipeline
  52243. */
  52244. LensDepthOfFieldEffect: string;
  52245. private _scene;
  52246. private _depthTexture;
  52247. private _grainTexture;
  52248. private _chromaticAberrationPostProcess;
  52249. private _highlightsPostProcess;
  52250. private _depthOfFieldPostProcess;
  52251. private _edgeBlur;
  52252. private _grainAmount;
  52253. private _chromaticAberration;
  52254. private _distortion;
  52255. private _highlightsGain;
  52256. private _highlightsThreshold;
  52257. private _dofDistance;
  52258. private _dofAperture;
  52259. private _dofDarken;
  52260. private _dofPentagon;
  52261. private _blurNoise;
  52262. /**
  52263. * @constructor
  52264. *
  52265. * Effect parameters are as follow:
  52266. * {
  52267. * chromatic_aberration: number; // from 0 to x (1 for realism)
  52268. * edge_blur: number; // from 0 to x (1 for realism)
  52269. * distortion: number; // from 0 to x (1 for realism)
  52270. * grain_amount: number; // from 0 to 1
  52271. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  52272. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  52273. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  52274. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  52275. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  52276. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  52277. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  52278. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  52279. * }
  52280. * Note: if an effect parameter is unset, effect is disabled
  52281. *
  52282. * @param name The rendering pipeline name
  52283. * @param parameters - An object containing all parameters (see above)
  52284. * @param scene The scene linked to this pipeline
  52285. * @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)
  52286. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52287. */
  52288. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  52289. /**
  52290. * Get the class name
  52291. * @returns "LensRenderingPipeline"
  52292. */
  52293. getClassName(): string;
  52294. /**
  52295. * Gets associated scene
  52296. */
  52297. readonly scene: Scene;
  52298. /**
  52299. * Gets or sets the edge blur
  52300. */
  52301. edgeBlur: number;
  52302. /**
  52303. * Gets or sets the grain amount
  52304. */
  52305. grainAmount: number;
  52306. /**
  52307. * Gets or sets the chromatic aberration amount
  52308. */
  52309. chromaticAberration: number;
  52310. /**
  52311. * Gets or sets the depth of field aperture
  52312. */
  52313. dofAperture: number;
  52314. /**
  52315. * Gets or sets the edge distortion
  52316. */
  52317. edgeDistortion: number;
  52318. /**
  52319. * Gets or sets the depth of field distortion
  52320. */
  52321. dofDistortion: number;
  52322. /**
  52323. * Gets or sets the darken out of focus amount
  52324. */
  52325. darkenOutOfFocus: number;
  52326. /**
  52327. * Gets or sets a boolean indicating if blur noise is enabled
  52328. */
  52329. blurNoise: boolean;
  52330. /**
  52331. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  52332. */
  52333. pentagonBokeh: boolean;
  52334. /**
  52335. * Gets or sets the highlight grain amount
  52336. */
  52337. highlightsGain: number;
  52338. /**
  52339. * Gets or sets the highlight threshold
  52340. */
  52341. highlightsThreshold: number;
  52342. /**
  52343. * Sets the amount of blur at the edges
  52344. * @param amount blur amount
  52345. */
  52346. setEdgeBlur(amount: number): void;
  52347. /**
  52348. * Sets edge blur to 0
  52349. */
  52350. disableEdgeBlur(): void;
  52351. /**
  52352. * Sets the amout of grain
  52353. * @param amount Amount of grain
  52354. */
  52355. setGrainAmount(amount: number): void;
  52356. /**
  52357. * Set grain amount to 0
  52358. */
  52359. disableGrain(): void;
  52360. /**
  52361. * Sets the chromatic aberration amount
  52362. * @param amount amount of chromatic aberration
  52363. */
  52364. setChromaticAberration(amount: number): void;
  52365. /**
  52366. * Sets chromatic aberration amount to 0
  52367. */
  52368. disableChromaticAberration(): void;
  52369. /**
  52370. * Sets the EdgeDistortion amount
  52371. * @param amount amount of EdgeDistortion
  52372. */
  52373. setEdgeDistortion(amount: number): void;
  52374. /**
  52375. * Sets edge distortion to 0
  52376. */
  52377. disableEdgeDistortion(): void;
  52378. /**
  52379. * Sets the FocusDistance amount
  52380. * @param amount amount of FocusDistance
  52381. */
  52382. setFocusDistance(amount: number): void;
  52383. /**
  52384. * Disables depth of field
  52385. */
  52386. disableDepthOfField(): void;
  52387. /**
  52388. * Sets the Aperture amount
  52389. * @param amount amount of Aperture
  52390. */
  52391. setAperture(amount: number): void;
  52392. /**
  52393. * Sets the DarkenOutOfFocus amount
  52394. * @param amount amount of DarkenOutOfFocus
  52395. */
  52396. setDarkenOutOfFocus(amount: number): void;
  52397. private _pentagonBokehIsEnabled;
  52398. /**
  52399. * Creates a pentagon bokeh effect
  52400. */
  52401. enablePentagonBokeh(): void;
  52402. /**
  52403. * Disables the pentagon bokeh effect
  52404. */
  52405. disablePentagonBokeh(): void;
  52406. /**
  52407. * Enables noise blur
  52408. */
  52409. enableNoiseBlur(): void;
  52410. /**
  52411. * Disables noise blur
  52412. */
  52413. disableNoiseBlur(): void;
  52414. /**
  52415. * Sets the HighlightsGain amount
  52416. * @param amount amount of HighlightsGain
  52417. */
  52418. setHighlightsGain(amount: number): void;
  52419. /**
  52420. * Sets the HighlightsThreshold amount
  52421. * @param amount amount of HighlightsThreshold
  52422. */
  52423. setHighlightsThreshold(amount: number): void;
  52424. /**
  52425. * Disables highlights
  52426. */
  52427. disableHighlights(): void;
  52428. /**
  52429. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  52430. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  52431. */
  52432. dispose(disableDepthRender?: boolean): void;
  52433. private _createChromaticAberrationPostProcess;
  52434. private _createHighlightsPostProcess;
  52435. private _createDepthOfFieldPostProcess;
  52436. private _createGrainTexture;
  52437. }
  52438. }
  52439. declare module BABYLON {
  52440. /** @hidden */
  52441. export var ssao2PixelShader: {
  52442. name: string;
  52443. shader: string;
  52444. };
  52445. }
  52446. declare module BABYLON {
  52447. /** @hidden */
  52448. export var ssaoCombinePixelShader: {
  52449. name: string;
  52450. shader: string;
  52451. };
  52452. }
  52453. declare module BABYLON {
  52454. /**
  52455. * Render pipeline to produce ssao effect
  52456. */
  52457. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  52458. /**
  52459. * @ignore
  52460. * The PassPostProcess id in the pipeline that contains the original scene color
  52461. */
  52462. SSAOOriginalSceneColorEffect: string;
  52463. /**
  52464. * @ignore
  52465. * The SSAO PostProcess id in the pipeline
  52466. */
  52467. SSAORenderEffect: string;
  52468. /**
  52469. * @ignore
  52470. * The horizontal blur PostProcess id in the pipeline
  52471. */
  52472. SSAOBlurHRenderEffect: string;
  52473. /**
  52474. * @ignore
  52475. * The vertical blur PostProcess id in the pipeline
  52476. */
  52477. SSAOBlurVRenderEffect: string;
  52478. /**
  52479. * @ignore
  52480. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52481. */
  52482. SSAOCombineRenderEffect: string;
  52483. /**
  52484. * The output strength of the SSAO post-process. Default value is 1.0.
  52485. */
  52486. totalStrength: number;
  52487. /**
  52488. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  52489. */
  52490. maxZ: number;
  52491. /**
  52492. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  52493. */
  52494. minZAspect: number;
  52495. private _samples;
  52496. /**
  52497. * Number of samples used for the SSAO calculations. Default value is 8
  52498. */
  52499. samples: number;
  52500. private _textureSamples;
  52501. /**
  52502. * Number of samples to use for antialiasing
  52503. */
  52504. textureSamples: number;
  52505. /**
  52506. * Ratio object used for SSAO ratio and blur ratio
  52507. */
  52508. private _ratio;
  52509. /**
  52510. * Dynamically generated sphere sampler.
  52511. */
  52512. private _sampleSphere;
  52513. /**
  52514. * Blur filter offsets
  52515. */
  52516. private _samplerOffsets;
  52517. private _expensiveBlur;
  52518. /**
  52519. * If bilateral blur should be used
  52520. */
  52521. expensiveBlur: boolean;
  52522. /**
  52523. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  52524. */
  52525. radius: number;
  52526. /**
  52527. * The base color of the SSAO post-process
  52528. * The final result is "base + ssao" between [0, 1]
  52529. */
  52530. base: number;
  52531. /**
  52532. * Support test.
  52533. */
  52534. static readonly IsSupported: boolean;
  52535. private _scene;
  52536. private _depthTexture;
  52537. private _normalTexture;
  52538. private _randomTexture;
  52539. private _originalColorPostProcess;
  52540. private _ssaoPostProcess;
  52541. private _blurHPostProcess;
  52542. private _blurVPostProcess;
  52543. private _ssaoCombinePostProcess;
  52544. private _firstUpdate;
  52545. /**
  52546. * Gets active scene
  52547. */
  52548. readonly scene: Scene;
  52549. /**
  52550. * @constructor
  52551. * @param name The rendering pipeline name
  52552. * @param scene The scene linked to this pipeline
  52553. * @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 }
  52554. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52555. */
  52556. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52557. /**
  52558. * Get the class name
  52559. * @returns "SSAO2RenderingPipeline"
  52560. */
  52561. getClassName(): string;
  52562. /**
  52563. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52564. */
  52565. dispose(disableGeometryBufferRenderer?: boolean): void;
  52566. private _createBlurPostProcess;
  52567. /** @hidden */ rebuild(): void;
  52568. private _bits;
  52569. private _radicalInverse_VdC;
  52570. private _hammersley;
  52571. private _hemisphereSample_uniform;
  52572. private _generateHemisphere;
  52573. private _createSSAOPostProcess;
  52574. private _createSSAOCombinePostProcess;
  52575. private _createRandomTexture;
  52576. /**
  52577. * Serialize the rendering pipeline (Used when exporting)
  52578. * @returns the serialized object
  52579. */
  52580. serialize(): any;
  52581. /**
  52582. * Parse the serialized pipeline
  52583. * @param source Source pipeline.
  52584. * @param scene The scene to load the pipeline to.
  52585. * @param rootUrl The URL of the serialized pipeline.
  52586. * @returns An instantiated pipeline from the serialized object.
  52587. */
  52588. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  52589. }
  52590. }
  52591. declare module BABYLON {
  52592. /** @hidden */
  52593. export var ssaoPixelShader: {
  52594. name: string;
  52595. shader: string;
  52596. };
  52597. }
  52598. declare module BABYLON {
  52599. /**
  52600. * Render pipeline to produce ssao effect
  52601. */
  52602. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  52603. /**
  52604. * @ignore
  52605. * The PassPostProcess id in the pipeline that contains the original scene color
  52606. */
  52607. SSAOOriginalSceneColorEffect: string;
  52608. /**
  52609. * @ignore
  52610. * The SSAO PostProcess id in the pipeline
  52611. */
  52612. SSAORenderEffect: string;
  52613. /**
  52614. * @ignore
  52615. * The horizontal blur PostProcess id in the pipeline
  52616. */
  52617. SSAOBlurHRenderEffect: string;
  52618. /**
  52619. * @ignore
  52620. * The vertical blur PostProcess id in the pipeline
  52621. */
  52622. SSAOBlurVRenderEffect: string;
  52623. /**
  52624. * @ignore
  52625. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  52626. */
  52627. SSAOCombineRenderEffect: string;
  52628. /**
  52629. * The output strength of the SSAO post-process. Default value is 1.0.
  52630. */
  52631. totalStrength: number;
  52632. /**
  52633. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  52634. */
  52635. radius: number;
  52636. /**
  52637. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  52638. * Must not be equal to fallOff and superior to fallOff.
  52639. * Default value is 0.0075
  52640. */
  52641. area: number;
  52642. /**
  52643. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  52644. * Must not be equal to area and inferior to area.
  52645. * Default value is 0.000001
  52646. */
  52647. fallOff: number;
  52648. /**
  52649. * The base color of the SSAO post-process
  52650. * The final result is "base + ssao" between [0, 1]
  52651. */
  52652. base: number;
  52653. private _scene;
  52654. private _depthTexture;
  52655. private _randomTexture;
  52656. private _originalColorPostProcess;
  52657. private _ssaoPostProcess;
  52658. private _blurHPostProcess;
  52659. private _blurVPostProcess;
  52660. private _ssaoCombinePostProcess;
  52661. private _firstUpdate;
  52662. /**
  52663. * Gets active scene
  52664. */
  52665. readonly scene: Scene;
  52666. /**
  52667. * @constructor
  52668. * @param name - The rendering pipeline name
  52669. * @param scene - The scene linked to this pipeline
  52670. * @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 }
  52671. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  52672. */
  52673. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  52674. /**
  52675. * Get the class name
  52676. * @returns "SSAORenderingPipeline"
  52677. */
  52678. getClassName(): string;
  52679. /**
  52680. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  52681. */
  52682. dispose(disableDepthRender?: boolean): void;
  52683. private _createBlurPostProcess;
  52684. /** @hidden */ rebuild(): void;
  52685. private _createSSAOPostProcess;
  52686. private _createSSAOCombinePostProcess;
  52687. private _createRandomTexture;
  52688. }
  52689. }
  52690. declare module BABYLON {
  52691. /** @hidden */
  52692. export var standardPixelShader: {
  52693. name: string;
  52694. shader: string;
  52695. };
  52696. }
  52697. declare module BABYLON {
  52698. /**
  52699. * Standard rendering pipeline
  52700. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52701. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  52702. */
  52703. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  52704. /**
  52705. * Public members
  52706. */
  52707. /**
  52708. * Post-process which contains the original scene color before the pipeline applies all the effects
  52709. */
  52710. originalPostProcess: Nullable<PostProcess>;
  52711. /**
  52712. * Post-process used to down scale an image x4
  52713. */
  52714. downSampleX4PostProcess: Nullable<PostProcess>;
  52715. /**
  52716. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  52717. */
  52718. brightPassPostProcess: Nullable<PostProcess>;
  52719. /**
  52720. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  52721. */
  52722. blurHPostProcesses: PostProcess[];
  52723. /**
  52724. * Post-process array storing all the vertical blur post-processes used by the pipeline
  52725. */
  52726. blurVPostProcesses: PostProcess[];
  52727. /**
  52728. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  52729. */
  52730. textureAdderPostProcess: Nullable<PostProcess>;
  52731. /**
  52732. * Post-process used to create volumetric lighting effect
  52733. */
  52734. volumetricLightPostProcess: Nullable<PostProcess>;
  52735. /**
  52736. * Post-process used to smooth the previous volumetric light post-process on the X axis
  52737. */
  52738. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  52739. /**
  52740. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  52741. */
  52742. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  52743. /**
  52744. * Post-process used to merge the volumetric light effect and the real scene color
  52745. */
  52746. volumetricLightMergePostProces: Nullable<PostProcess>;
  52747. /**
  52748. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  52749. */
  52750. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  52751. /**
  52752. * Base post-process used to calculate the average luminance of the final image for HDR
  52753. */
  52754. luminancePostProcess: Nullable<PostProcess>;
  52755. /**
  52756. * Post-processes used to create down sample post-processes in order to get
  52757. * the average luminance of the final image for HDR
  52758. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  52759. */
  52760. luminanceDownSamplePostProcesses: PostProcess[];
  52761. /**
  52762. * Post-process used to create a HDR effect (light adaptation)
  52763. */
  52764. hdrPostProcess: Nullable<PostProcess>;
  52765. /**
  52766. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  52767. */
  52768. textureAdderFinalPostProcess: Nullable<PostProcess>;
  52769. /**
  52770. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  52771. */
  52772. lensFlareFinalPostProcess: Nullable<PostProcess>;
  52773. /**
  52774. * Post-process used to merge the final HDR post-process and the real scene color
  52775. */
  52776. hdrFinalPostProcess: Nullable<PostProcess>;
  52777. /**
  52778. * Post-process used to create a lens flare effect
  52779. */
  52780. lensFlarePostProcess: Nullable<PostProcess>;
  52781. /**
  52782. * Post-process that merges the result of the lens flare post-process and the real scene color
  52783. */
  52784. lensFlareComposePostProcess: Nullable<PostProcess>;
  52785. /**
  52786. * Post-process used to create a motion blur effect
  52787. */
  52788. motionBlurPostProcess: Nullable<PostProcess>;
  52789. /**
  52790. * Post-process used to create a depth of field effect
  52791. */
  52792. depthOfFieldPostProcess: Nullable<PostProcess>;
  52793. /**
  52794. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  52795. */
  52796. fxaaPostProcess: Nullable<FxaaPostProcess>;
  52797. /**
  52798. * Represents the brightness threshold in order to configure the illuminated surfaces
  52799. */
  52800. brightThreshold: number;
  52801. /**
  52802. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  52803. */
  52804. blurWidth: number;
  52805. /**
  52806. * Sets if the blur for highlighted surfaces must be only horizontal
  52807. */
  52808. horizontalBlur: boolean;
  52809. /**
  52810. * Sets the overall exposure used by the pipeline
  52811. */
  52812. exposure: number;
  52813. /**
  52814. * Texture used typically to simulate "dirty" on camera lens
  52815. */
  52816. lensTexture: Nullable<Texture>;
  52817. /**
  52818. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  52819. */
  52820. volumetricLightCoefficient: number;
  52821. /**
  52822. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  52823. */
  52824. volumetricLightPower: number;
  52825. /**
  52826. * Used the set the blur intensity to smooth the volumetric lights
  52827. */
  52828. volumetricLightBlurScale: number;
  52829. /**
  52830. * Light (spot or directional) used to generate the volumetric lights rays
  52831. * The source light must have a shadow generate so the pipeline can get its
  52832. * depth map
  52833. */
  52834. sourceLight: Nullable<SpotLight | DirectionalLight>;
  52835. /**
  52836. * For eye adaptation, represents the minimum luminance the eye can see
  52837. */
  52838. hdrMinimumLuminance: number;
  52839. /**
  52840. * For eye adaptation, represents the decrease luminance speed
  52841. */
  52842. hdrDecreaseRate: number;
  52843. /**
  52844. * For eye adaptation, represents the increase luminance speed
  52845. */
  52846. hdrIncreaseRate: number;
  52847. /**
  52848. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  52849. */
  52850. lensColorTexture: Nullable<Texture>;
  52851. /**
  52852. * The overall strengh for the lens flare effect
  52853. */
  52854. lensFlareStrength: number;
  52855. /**
  52856. * Dispersion coefficient for lens flare ghosts
  52857. */
  52858. lensFlareGhostDispersal: number;
  52859. /**
  52860. * Main lens flare halo width
  52861. */
  52862. lensFlareHaloWidth: number;
  52863. /**
  52864. * Based on the lens distortion effect, defines how much the lens flare result
  52865. * is distorted
  52866. */
  52867. lensFlareDistortionStrength: number;
  52868. /**
  52869. * Lens star texture must be used to simulate rays on the flares and is available
  52870. * in the documentation
  52871. */
  52872. lensStarTexture: Nullable<Texture>;
  52873. /**
  52874. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  52875. * flare effect by taking account of the dirt texture
  52876. */
  52877. lensFlareDirtTexture: Nullable<Texture>;
  52878. /**
  52879. * Represents the focal length for the depth of field effect
  52880. */
  52881. depthOfFieldDistance: number;
  52882. /**
  52883. * Represents the blur intensity for the blurred part of the depth of field effect
  52884. */
  52885. depthOfFieldBlurWidth: number;
  52886. /**
  52887. * For motion blur, defines how much the image is blurred by the movement
  52888. */
  52889. motionStrength: number;
  52890. /**
  52891. * List of animations for the pipeline (IAnimatable implementation)
  52892. */
  52893. animations: Animation[];
  52894. /**
  52895. * Private members
  52896. */
  52897. private _scene;
  52898. private _currentDepthOfFieldSource;
  52899. private _basePostProcess;
  52900. private _hdrCurrentLuminance;
  52901. private _floatTextureType;
  52902. private _ratio;
  52903. private _bloomEnabled;
  52904. private _depthOfFieldEnabled;
  52905. private _vlsEnabled;
  52906. private _lensFlareEnabled;
  52907. private _hdrEnabled;
  52908. private _motionBlurEnabled;
  52909. private _fxaaEnabled;
  52910. private _motionBlurSamples;
  52911. private _volumetricLightStepsCount;
  52912. private _samples;
  52913. /**
  52914. * @ignore
  52915. * Specifies if the bloom pipeline is enabled
  52916. */
  52917. BloomEnabled: boolean;
  52918. /**
  52919. * @ignore
  52920. * Specifies if the depth of field pipeline is enabed
  52921. */
  52922. DepthOfFieldEnabled: boolean;
  52923. /**
  52924. * @ignore
  52925. * Specifies if the lens flare pipeline is enabed
  52926. */
  52927. LensFlareEnabled: boolean;
  52928. /**
  52929. * @ignore
  52930. * Specifies if the HDR pipeline is enabled
  52931. */
  52932. HDREnabled: boolean;
  52933. /**
  52934. * @ignore
  52935. * Specifies if the volumetric lights scattering effect is enabled
  52936. */
  52937. VLSEnabled: boolean;
  52938. /**
  52939. * @ignore
  52940. * Specifies if the motion blur effect is enabled
  52941. */
  52942. MotionBlurEnabled: boolean;
  52943. /**
  52944. * Specifies if anti-aliasing is enabled
  52945. */
  52946. fxaaEnabled: boolean;
  52947. /**
  52948. * Specifies the number of steps used to calculate the volumetric lights
  52949. * Typically in interval [50, 200]
  52950. */
  52951. volumetricLightStepsCount: number;
  52952. /**
  52953. * Specifies the number of samples used for the motion blur effect
  52954. * Typically in interval [16, 64]
  52955. */
  52956. motionBlurSamples: number;
  52957. /**
  52958. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  52959. */
  52960. samples: number;
  52961. /**
  52962. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  52963. * @constructor
  52964. * @param name The rendering pipeline name
  52965. * @param scene The scene linked to this pipeline
  52966. * @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)
  52967. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  52968. * @param cameras The array of cameras that the rendering pipeline will be attached to
  52969. */
  52970. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  52971. private _buildPipeline;
  52972. private _createDownSampleX4PostProcess;
  52973. private _createBrightPassPostProcess;
  52974. private _createBlurPostProcesses;
  52975. private _createTextureAdderPostProcess;
  52976. private _createVolumetricLightPostProcess;
  52977. private _createLuminancePostProcesses;
  52978. private _createHdrPostProcess;
  52979. private _createLensFlarePostProcess;
  52980. private _createDepthOfFieldPostProcess;
  52981. private _createMotionBlurPostProcess;
  52982. private _getDepthTexture;
  52983. private _disposePostProcesses;
  52984. /**
  52985. * Dispose of the pipeline and stop all post processes
  52986. */
  52987. dispose(): void;
  52988. /**
  52989. * Serialize the rendering pipeline (Used when exporting)
  52990. * @returns the serialized object
  52991. */
  52992. serialize(): any;
  52993. /**
  52994. * Parse the serialized pipeline
  52995. * @param source Source pipeline.
  52996. * @param scene The scene to load the pipeline to.
  52997. * @param rootUrl The URL of the serialized pipeline.
  52998. * @returns An instantiated pipeline from the serialized object.
  52999. */
  53000. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  53001. /**
  53002. * Luminance steps
  53003. */
  53004. static LuminanceSteps: number;
  53005. }
  53006. }
  53007. declare module BABYLON {
  53008. /** @hidden */
  53009. export var tonemapPixelShader: {
  53010. name: string;
  53011. shader: string;
  53012. };
  53013. }
  53014. declare module BABYLON {
  53015. /** Defines operator used for tonemapping */
  53016. export enum TonemappingOperator {
  53017. /** Hable */
  53018. Hable = 0,
  53019. /** Reinhard */
  53020. Reinhard = 1,
  53021. /** HejiDawson */
  53022. HejiDawson = 2,
  53023. /** Photographic */
  53024. Photographic = 3
  53025. }
  53026. /**
  53027. * Defines a post process to apply tone mapping
  53028. */
  53029. export class TonemapPostProcess extends PostProcess {
  53030. private _operator;
  53031. /** Defines the required exposure adjustement */
  53032. exposureAdjustment: number;
  53033. /**
  53034. * Creates a new TonemapPostProcess
  53035. * @param name defines the name of the postprocess
  53036. * @param _operator defines the operator to use
  53037. * @param exposureAdjustment defines the required exposure adjustement
  53038. * @param camera defines the camera to use (can be null)
  53039. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  53040. * @param engine defines the hosting engine (can be ignore if camera is set)
  53041. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  53042. */
  53043. constructor(name: string, _operator: TonemappingOperator,
  53044. /** Defines the required exposure adjustement */
  53045. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  53046. }
  53047. }
  53048. declare module BABYLON {
  53049. /** @hidden */
  53050. export var depthVertexShader: {
  53051. name: string;
  53052. shader: string;
  53053. };
  53054. }
  53055. declare module BABYLON {
  53056. /** @hidden */
  53057. export var volumetricLightScatteringPixelShader: {
  53058. name: string;
  53059. shader: string;
  53060. };
  53061. }
  53062. declare module BABYLON {
  53063. /** @hidden */
  53064. export var volumetricLightScatteringPassPixelShader: {
  53065. name: string;
  53066. shader: string;
  53067. };
  53068. }
  53069. declare module BABYLON {
  53070. /**
  53071. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  53072. */
  53073. export class VolumetricLightScatteringPostProcess extends PostProcess {
  53074. private _volumetricLightScatteringPass;
  53075. private _volumetricLightScatteringRTT;
  53076. private _viewPort;
  53077. private _screenCoordinates;
  53078. private _cachedDefines;
  53079. /**
  53080. * If not undefined, the mesh position is computed from the attached node position
  53081. */
  53082. attachedNode: {
  53083. position: Vector3;
  53084. };
  53085. /**
  53086. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  53087. */
  53088. customMeshPosition: Vector3;
  53089. /**
  53090. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  53091. */
  53092. useCustomMeshPosition: boolean;
  53093. /**
  53094. * If the post-process should inverse the light scattering direction
  53095. */
  53096. invert: boolean;
  53097. /**
  53098. * The internal mesh used by the post-process
  53099. */
  53100. mesh: Mesh;
  53101. /**
  53102. * @hidden
  53103. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  53104. */
  53105. useDiffuseColor: boolean;
  53106. /**
  53107. * Array containing the excluded meshes not rendered in the internal pass
  53108. */
  53109. excludedMeshes: AbstractMesh[];
  53110. /**
  53111. * Controls the overall intensity of the post-process
  53112. */
  53113. exposure: number;
  53114. /**
  53115. * Dissipates each sample's contribution in range [0, 1]
  53116. */
  53117. decay: number;
  53118. /**
  53119. * Controls the overall intensity of each sample
  53120. */
  53121. weight: number;
  53122. /**
  53123. * Controls the density of each sample
  53124. */
  53125. density: number;
  53126. /**
  53127. * @constructor
  53128. * @param name The post-process name
  53129. * @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)
  53130. * @param camera The camera that the post-process will be attached to
  53131. * @param mesh The mesh used to create the light scattering
  53132. * @param samples The post-process quality, default 100
  53133. * @param samplingModeThe post-process filtering mode
  53134. * @param engine The babylon engine
  53135. * @param reusable If the post-process is reusable
  53136. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  53137. */
  53138. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  53139. /**
  53140. * Returns the string "VolumetricLightScatteringPostProcess"
  53141. * @returns "VolumetricLightScatteringPostProcess"
  53142. */
  53143. getClassName(): string;
  53144. private _isReady;
  53145. /**
  53146. * Sets the new light position for light scattering effect
  53147. * @param position The new custom light position
  53148. */
  53149. setCustomMeshPosition(position: Vector3): void;
  53150. /**
  53151. * Returns the light position for light scattering effect
  53152. * @return Vector3 The custom light position
  53153. */
  53154. getCustomMeshPosition(): Vector3;
  53155. /**
  53156. * Disposes the internal assets and detaches the post-process from the camera
  53157. */
  53158. dispose(camera: Camera): void;
  53159. /**
  53160. * Returns the render target texture used by the post-process
  53161. * @return the render target texture used by the post-process
  53162. */
  53163. getPass(): RenderTargetTexture;
  53164. private _meshExcluded;
  53165. private _createPass;
  53166. private _updateMeshScreenCoordinates;
  53167. /**
  53168. * Creates a default mesh for the Volumeric Light Scattering post-process
  53169. * @param name The mesh name
  53170. * @param scene The scene where to create the mesh
  53171. * @return the default mesh
  53172. */
  53173. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  53174. }
  53175. }
  53176. declare module BABYLON {
  53177. interface Scene {
  53178. /** @hidden (Backing field) */ boundingBoxRenderer: BoundingBoxRenderer;
  53179. /** @hidden (Backing field) */ forceShowBoundingBoxes: boolean;
  53180. /**
  53181. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  53182. */
  53183. forceShowBoundingBoxes: boolean;
  53184. /**
  53185. * Gets the bounding box renderer associated with the scene
  53186. * @returns a BoundingBoxRenderer
  53187. */
  53188. getBoundingBoxRenderer(): BoundingBoxRenderer;
  53189. }
  53190. interface AbstractMesh {
  53191. /** @hidden (Backing field) */ showBoundingBox: boolean;
  53192. /**
  53193. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  53194. */
  53195. showBoundingBox: boolean;
  53196. }
  53197. /**
  53198. * Component responsible of rendering the bounding box of the meshes in a scene.
  53199. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  53200. */
  53201. export class BoundingBoxRenderer implements ISceneComponent {
  53202. /**
  53203. * The component name helpfull to identify the component in the list of scene components.
  53204. */
  53205. readonly name: string;
  53206. /**
  53207. * The scene the component belongs to.
  53208. */
  53209. scene: Scene;
  53210. /**
  53211. * Color of the bounding box lines placed in front of an object
  53212. */
  53213. frontColor: Color3;
  53214. /**
  53215. * Color of the bounding box lines placed behind an object
  53216. */
  53217. backColor: Color3;
  53218. /**
  53219. * Defines if the renderer should show the back lines or not
  53220. */
  53221. showBackLines: boolean;
  53222. /**
  53223. * @hidden
  53224. */
  53225. renderList: SmartArray<BoundingBox>;
  53226. private _colorShader;
  53227. private _vertexBuffers;
  53228. private _indexBuffer;
  53229. /**
  53230. * Instantiates a new bounding box renderer in a scene.
  53231. * @param scene the scene the renderer renders in
  53232. */
  53233. constructor(scene: Scene);
  53234. /**
  53235. * Registers the component in a given scene
  53236. */
  53237. register(): void;
  53238. private _evaluateSubMesh;
  53239. private _activeMesh;
  53240. private _prepareRessources;
  53241. private _createIndexBuffer;
  53242. /**
  53243. * Rebuilds the elements related to this component in case of
  53244. * context lost for instance.
  53245. */
  53246. rebuild(): void;
  53247. /**
  53248. * @hidden
  53249. */
  53250. reset(): void;
  53251. /**
  53252. * Render the bounding boxes of a specific rendering group
  53253. * @param renderingGroupId defines the rendering group to render
  53254. */
  53255. render(renderingGroupId: number): void;
  53256. /**
  53257. * In case of occlusion queries, we can render the occlusion bounding box through this method
  53258. * @param mesh Define the mesh to render the occlusion bounding box for
  53259. */
  53260. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  53261. /**
  53262. * Dispose and release the resources attached to this renderer.
  53263. */
  53264. dispose(): void;
  53265. }
  53266. }
  53267. declare module BABYLON {
  53268. /** @hidden */
  53269. export var depthPixelShader: {
  53270. name: string;
  53271. shader: string;
  53272. };
  53273. }
  53274. declare module BABYLON {
  53275. /**
  53276. * This represents a depth renderer in Babylon.
  53277. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53278. */
  53279. export class DepthRenderer {
  53280. private _scene;
  53281. private _depthMap;
  53282. private _effect;
  53283. private _cachedDefines;
  53284. private _camera;
  53285. /**
  53286. * Specifiess that the depth renderer will only be used within
  53287. * the camera it is created for.
  53288. * This can help forcing its rendering during the camera processing.
  53289. */
  53290. useOnlyInActiveCamera: boolean;
  53291. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  53292. /**
  53293. * Instantiates a depth renderer
  53294. * @param scene The scene the renderer belongs to
  53295. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53296. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53297. */
  53298. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  53299. /**
  53300. * Creates the depth rendering effect and checks if the effect is ready.
  53301. * @param subMesh The submesh to be used to render the depth map of
  53302. * @param useInstances If multiple world instances should be used
  53303. * @returns if the depth renderer is ready to render the depth map
  53304. */
  53305. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53306. /**
  53307. * Gets the texture which the depth map will be written to.
  53308. * @returns The depth map texture
  53309. */
  53310. getDepthMap(): RenderTargetTexture;
  53311. /**
  53312. * Disposes of the depth renderer.
  53313. */
  53314. dispose(): void;
  53315. }
  53316. }
  53317. declare module BABYLON {
  53318. interface Scene {
  53319. /** @hidden (Backing field) */ depthRenderer: {
  53320. [id: string]: DepthRenderer;
  53321. };
  53322. /**
  53323. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  53324. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  53325. * @returns the created depth renderer
  53326. */
  53327. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  53328. /**
  53329. * Disables a depth renderer for a given camera
  53330. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  53331. */
  53332. disableDepthRenderer(camera?: Nullable<Camera>): void;
  53333. }
  53334. /**
  53335. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  53336. * in several rendering techniques.
  53337. */
  53338. export class DepthRendererSceneComponent implements ISceneComponent {
  53339. /**
  53340. * The component name helpfull to identify the component in the list of scene components.
  53341. */
  53342. readonly name: string;
  53343. /**
  53344. * The scene the component belongs to.
  53345. */
  53346. scene: Scene;
  53347. /**
  53348. * Creates a new instance of the component for the given scene
  53349. * @param scene Defines the scene to register the component in
  53350. */
  53351. constructor(scene: Scene);
  53352. /**
  53353. * Registers the component in a given scene
  53354. */
  53355. register(): void;
  53356. /**
  53357. * Rebuilds the elements related to this component in case of
  53358. * context lost for instance.
  53359. */
  53360. rebuild(): void;
  53361. /**
  53362. * Disposes the component and the associated ressources
  53363. */
  53364. dispose(): void;
  53365. private _gatherRenderTargets;
  53366. private _gatherActiveCameraRenderTargets;
  53367. }
  53368. }
  53369. declare module BABYLON {
  53370. /** @hidden */
  53371. export var outlinePixelShader: {
  53372. name: string;
  53373. shader: string;
  53374. };
  53375. }
  53376. declare module BABYLON {
  53377. /** @hidden */
  53378. export var outlineVertexShader: {
  53379. name: string;
  53380. shader: string;
  53381. };
  53382. }
  53383. declare module BABYLON {
  53384. interface Scene {
  53385. /** @hidden */ outlineRenderer: OutlineRenderer;
  53386. /**
  53387. * Gets the outline renderer associated with the scene
  53388. * @returns a OutlineRenderer
  53389. */
  53390. getOutlineRenderer(): OutlineRenderer;
  53391. }
  53392. interface AbstractMesh {
  53393. /** @hidden (Backing field) */ renderOutline: boolean;
  53394. /**
  53395. * Gets or sets a boolean indicating if the outline must be rendered as well
  53396. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  53397. */
  53398. renderOutline: boolean;
  53399. /** @hidden (Backing field) */ renderOverlay: boolean;
  53400. /**
  53401. * Gets or sets a boolean indicating if the overlay must be rendered as well
  53402. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  53403. */
  53404. renderOverlay: boolean;
  53405. }
  53406. /**
  53407. * This class is responsible to draw bothe outline/overlay of meshes.
  53408. * It should not be used directly but through the available method on mesh.
  53409. */
  53410. export class OutlineRenderer implements ISceneComponent {
  53411. /**
  53412. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  53413. */
  53414. private static _StencilReference;
  53415. /**
  53416. * The name of the component. Each component must have a unique name.
  53417. */
  53418. name: string;
  53419. /**
  53420. * The scene the component belongs to.
  53421. */
  53422. scene: Scene;
  53423. /**
  53424. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  53425. */
  53426. zOffset: number;
  53427. private _engine;
  53428. private _effect;
  53429. private _cachedDefines;
  53430. private _savedDepthWrite;
  53431. /**
  53432. * Instantiates a new outline renderer. (There could be only one per scene).
  53433. * @param scene Defines the scene it belongs to
  53434. */
  53435. constructor(scene: Scene);
  53436. /**
  53437. * Register the component to one instance of a scene.
  53438. */
  53439. register(): void;
  53440. /**
  53441. * Rebuilds the elements related to this component in case of
  53442. * context lost for instance.
  53443. */
  53444. rebuild(): void;
  53445. /**
  53446. * Disposes the component and the associated ressources.
  53447. */
  53448. dispose(): void;
  53449. /**
  53450. * Renders the outline in the canvas.
  53451. * @param subMesh Defines the sumesh to render
  53452. * @param batch Defines the batch of meshes in case of instances
  53453. * @param useOverlay Defines if the rendering is for the overlay or the outline
  53454. */
  53455. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  53456. /**
  53457. * Returns whether or not the outline renderer is ready for a given submesh.
  53458. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  53459. * @param subMesh Defines the submesh to check readyness for
  53460. * @param useInstances Defines wheter wee are trying to render instances or not
  53461. * @returns true if ready otherwise false
  53462. */
  53463. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53464. private _beforeRenderingMesh;
  53465. private _afterRenderingMesh;
  53466. }
  53467. }
  53468. declare module BABYLON {
  53469. /**
  53470. * Defines the list of states available for a task inside a AssetsManager
  53471. */
  53472. export enum AssetTaskState {
  53473. /**
  53474. * Initialization
  53475. */
  53476. INIT = 0,
  53477. /**
  53478. * Running
  53479. */
  53480. RUNNING = 1,
  53481. /**
  53482. * Done
  53483. */
  53484. DONE = 2,
  53485. /**
  53486. * Error
  53487. */
  53488. ERROR = 3
  53489. }
  53490. /**
  53491. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  53492. */
  53493. export abstract class AbstractAssetTask {
  53494. /**
  53495. * Task name
  53496. */ name: string;
  53497. /**
  53498. * Callback called when the task is successful
  53499. */
  53500. onSuccess: (task: any) => void;
  53501. /**
  53502. * Callback called when the task is not successful
  53503. */
  53504. onError: (task: any, message?: string, exception?: any) => void;
  53505. /**
  53506. * Creates a new AssetsManager
  53507. * @param name defines the name of the task
  53508. */
  53509. constructor(
  53510. /**
  53511. * Task name
  53512. */ name: string);
  53513. private _isCompleted;
  53514. private _taskState;
  53515. private _errorObject;
  53516. /**
  53517. * Get if the task is completed
  53518. */
  53519. readonly isCompleted: boolean;
  53520. /**
  53521. * Gets the current state of the task
  53522. */
  53523. readonly taskState: AssetTaskState;
  53524. /**
  53525. * Gets the current error object (if task is in error)
  53526. */
  53527. readonly errorObject: {
  53528. message?: string;
  53529. exception?: any;
  53530. };
  53531. /**
  53532. * Internal only
  53533. * @hidden
  53534. */ setErrorObject(message?: string, exception?: any): void;
  53535. /**
  53536. * Execute the current task
  53537. * @param scene defines the scene where you want your assets to be loaded
  53538. * @param onSuccess is a callback called when the task is successfully executed
  53539. * @param onError is a callback called if an error occurs
  53540. */
  53541. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53542. /**
  53543. * Execute the current task
  53544. * @param scene defines the scene where you want your assets to be loaded
  53545. * @param onSuccess is a callback called when the task is successfully executed
  53546. * @param onError is a callback called if an error occurs
  53547. */
  53548. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53549. /**
  53550. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  53551. * This can be used with failed tasks that have the reason for failure fixed.
  53552. */
  53553. reset(): void;
  53554. private onErrorCallback;
  53555. private onDoneCallback;
  53556. }
  53557. /**
  53558. * Define the interface used by progress events raised during assets loading
  53559. */
  53560. export interface IAssetsProgressEvent {
  53561. /**
  53562. * Defines the number of remaining tasks to process
  53563. */
  53564. remainingCount: number;
  53565. /**
  53566. * Defines the total number of tasks
  53567. */
  53568. totalCount: number;
  53569. /**
  53570. * Defines the task that was just processed
  53571. */
  53572. task: AbstractAssetTask;
  53573. }
  53574. /**
  53575. * Class used to share progress information about assets loading
  53576. */
  53577. export class AssetsProgressEvent implements IAssetsProgressEvent {
  53578. /**
  53579. * Defines the number of remaining tasks to process
  53580. */
  53581. remainingCount: number;
  53582. /**
  53583. * Defines the total number of tasks
  53584. */
  53585. totalCount: number;
  53586. /**
  53587. * Defines the task that was just processed
  53588. */
  53589. task: AbstractAssetTask;
  53590. /**
  53591. * Creates a AssetsProgressEvent
  53592. * @param remainingCount defines the number of remaining tasks to process
  53593. * @param totalCount defines the total number of tasks
  53594. * @param task defines the task that was just processed
  53595. */
  53596. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  53597. }
  53598. /**
  53599. * Define a task used by AssetsManager to load meshes
  53600. */
  53601. export class MeshAssetTask extends AbstractAssetTask {
  53602. /**
  53603. * Defines the name of the task
  53604. */
  53605. name: string;
  53606. /**
  53607. * Defines the list of mesh's names you want to load
  53608. */
  53609. meshesNames: any;
  53610. /**
  53611. * Defines the root url to use as a base to load your meshes and associated resources
  53612. */
  53613. rootUrl: string;
  53614. /**
  53615. * Defines the filename of the scene to load from
  53616. */
  53617. sceneFilename: string;
  53618. /**
  53619. * Gets the list of loaded meshes
  53620. */
  53621. loadedMeshes: Array<AbstractMesh>;
  53622. /**
  53623. * Gets the list of loaded particle systems
  53624. */
  53625. loadedParticleSystems: Array<IParticleSystem>;
  53626. /**
  53627. * Gets the list of loaded skeletons
  53628. */
  53629. loadedSkeletons: Array<Skeleton>;
  53630. /**
  53631. * Gets the list of loaded animation groups
  53632. */
  53633. loadedAnimationGroups: Array<AnimationGroup>;
  53634. /**
  53635. * Callback called when the task is successful
  53636. */
  53637. onSuccess: (task: MeshAssetTask) => void;
  53638. /**
  53639. * Callback called when the task is successful
  53640. */
  53641. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  53642. /**
  53643. * Creates a new MeshAssetTask
  53644. * @param name defines the name of the task
  53645. * @param meshesNames defines the list of mesh's names you want to load
  53646. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  53647. * @param sceneFilename defines the filename of the scene to load from
  53648. */
  53649. constructor(
  53650. /**
  53651. * Defines the name of the task
  53652. */
  53653. name: string,
  53654. /**
  53655. * Defines the list of mesh's names you want to load
  53656. */
  53657. meshesNames: any,
  53658. /**
  53659. * Defines the root url to use as a base to load your meshes and associated resources
  53660. */
  53661. rootUrl: string,
  53662. /**
  53663. * Defines the filename of the scene to load from
  53664. */
  53665. sceneFilename: string);
  53666. /**
  53667. * Execute the current task
  53668. * @param scene defines the scene where you want your assets to be loaded
  53669. * @param onSuccess is a callback called when the task is successfully executed
  53670. * @param onError is a callback called if an error occurs
  53671. */
  53672. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53673. }
  53674. /**
  53675. * Define a task used by AssetsManager to load text content
  53676. */
  53677. export class TextFileAssetTask extends AbstractAssetTask {
  53678. /**
  53679. * Defines the name of the task
  53680. */
  53681. name: string;
  53682. /**
  53683. * Defines the location of the file to load
  53684. */
  53685. url: string;
  53686. /**
  53687. * Gets the loaded text string
  53688. */
  53689. text: string;
  53690. /**
  53691. * Callback called when the task is successful
  53692. */
  53693. onSuccess: (task: TextFileAssetTask) => void;
  53694. /**
  53695. * Callback called when the task is successful
  53696. */
  53697. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  53698. /**
  53699. * Creates a new TextFileAssetTask object
  53700. * @param name defines the name of the task
  53701. * @param url defines the location of the file to load
  53702. */
  53703. constructor(
  53704. /**
  53705. * Defines the name of the task
  53706. */
  53707. name: string,
  53708. /**
  53709. * Defines the location of the file to load
  53710. */
  53711. url: string);
  53712. /**
  53713. * Execute the current task
  53714. * @param scene defines the scene where you want your assets to be loaded
  53715. * @param onSuccess is a callback called when the task is successfully executed
  53716. * @param onError is a callback called if an error occurs
  53717. */
  53718. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53719. }
  53720. /**
  53721. * Define a task used by AssetsManager to load binary data
  53722. */
  53723. export class BinaryFileAssetTask extends AbstractAssetTask {
  53724. /**
  53725. * Defines the name of the task
  53726. */
  53727. name: string;
  53728. /**
  53729. * Defines the location of the file to load
  53730. */
  53731. url: string;
  53732. /**
  53733. * Gets the lodaded data (as an array buffer)
  53734. */
  53735. data: ArrayBuffer;
  53736. /**
  53737. * Callback called when the task is successful
  53738. */
  53739. onSuccess: (task: BinaryFileAssetTask) => void;
  53740. /**
  53741. * Callback called when the task is successful
  53742. */
  53743. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  53744. /**
  53745. * Creates a new BinaryFileAssetTask object
  53746. * @param name defines the name of the new task
  53747. * @param url defines the location of the file to load
  53748. */
  53749. constructor(
  53750. /**
  53751. * Defines the name of the task
  53752. */
  53753. name: string,
  53754. /**
  53755. * Defines the location of the file to load
  53756. */
  53757. url: string);
  53758. /**
  53759. * Execute the current task
  53760. * @param scene defines the scene where you want your assets to be loaded
  53761. * @param onSuccess is a callback called when the task is successfully executed
  53762. * @param onError is a callback called if an error occurs
  53763. */
  53764. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53765. }
  53766. /**
  53767. * Define a task used by AssetsManager to load images
  53768. */
  53769. export class ImageAssetTask extends AbstractAssetTask {
  53770. /**
  53771. * Defines the name of the task
  53772. */
  53773. name: string;
  53774. /**
  53775. * Defines the location of the image to load
  53776. */
  53777. url: string;
  53778. /**
  53779. * Gets the loaded images
  53780. */
  53781. image: HTMLImageElement;
  53782. /**
  53783. * Callback called when the task is successful
  53784. */
  53785. onSuccess: (task: ImageAssetTask) => void;
  53786. /**
  53787. * Callback called when the task is successful
  53788. */
  53789. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  53790. /**
  53791. * Creates a new ImageAssetTask
  53792. * @param name defines the name of the task
  53793. * @param url defines the location of the image to load
  53794. */
  53795. constructor(
  53796. /**
  53797. * Defines the name of the task
  53798. */
  53799. name: string,
  53800. /**
  53801. * Defines the location of the image to load
  53802. */
  53803. url: string);
  53804. /**
  53805. * Execute the current task
  53806. * @param scene defines the scene where you want your assets to be loaded
  53807. * @param onSuccess is a callback called when the task is successfully executed
  53808. * @param onError is a callback called if an error occurs
  53809. */
  53810. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53811. }
  53812. /**
  53813. * Defines the interface used by texture loading tasks
  53814. */
  53815. export interface ITextureAssetTask<TEX extends BaseTexture> {
  53816. /**
  53817. * Gets the loaded texture
  53818. */
  53819. texture: TEX;
  53820. }
  53821. /**
  53822. * Define a task used by AssetsManager to load 2D textures
  53823. */
  53824. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  53825. /**
  53826. * Defines the name of the task
  53827. */
  53828. name: string;
  53829. /**
  53830. * Defines the location of the file to load
  53831. */
  53832. url: string;
  53833. /**
  53834. * Defines if mipmap should not be generated (default is false)
  53835. */
  53836. noMipmap?: boolean | undefined;
  53837. /**
  53838. * Defines if texture must be inverted on Y axis (default is false)
  53839. */
  53840. invertY?: boolean | undefined;
  53841. /**
  53842. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53843. */
  53844. samplingMode: number;
  53845. /**
  53846. * Gets the loaded texture
  53847. */
  53848. texture: Texture;
  53849. /**
  53850. * Callback called when the task is successful
  53851. */
  53852. onSuccess: (task: TextureAssetTask) => void;
  53853. /**
  53854. * Callback called when the task is successful
  53855. */
  53856. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  53857. /**
  53858. * Creates a new TextureAssetTask object
  53859. * @param name defines the name of the task
  53860. * @param url defines the location of the file to load
  53861. * @param noMipmap defines if mipmap should not be generated (default is false)
  53862. * @param invertY defines if texture must be inverted on Y axis (default is false)
  53863. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53864. */
  53865. constructor(
  53866. /**
  53867. * Defines the name of the task
  53868. */
  53869. name: string,
  53870. /**
  53871. * Defines the location of the file to load
  53872. */
  53873. url: string,
  53874. /**
  53875. * Defines if mipmap should not be generated (default is false)
  53876. */
  53877. noMipmap?: boolean | undefined,
  53878. /**
  53879. * Defines if texture must be inverted on Y axis (default is false)
  53880. */
  53881. invertY?: boolean | undefined,
  53882. /**
  53883. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  53884. */
  53885. samplingMode?: number);
  53886. /**
  53887. * Execute the current task
  53888. * @param scene defines the scene where you want your assets to be loaded
  53889. * @param onSuccess is a callback called when the task is successfully executed
  53890. * @param onError is a callback called if an error occurs
  53891. */
  53892. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53893. }
  53894. /**
  53895. * Define a task used by AssetsManager to load cube textures
  53896. */
  53897. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  53898. /**
  53899. * Defines the name of the task
  53900. */
  53901. name: string;
  53902. /**
  53903. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  53904. */
  53905. url: string;
  53906. /**
  53907. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  53908. */
  53909. extensions?: string[] | undefined;
  53910. /**
  53911. * Defines if mipmaps should not be generated (default is false)
  53912. */
  53913. noMipmap?: boolean | undefined;
  53914. /**
  53915. * Defines the explicit list of files (undefined by default)
  53916. */
  53917. files?: string[] | undefined;
  53918. /**
  53919. * Gets the loaded texture
  53920. */
  53921. texture: CubeTexture;
  53922. /**
  53923. * Callback called when the task is successful
  53924. */
  53925. onSuccess: (task: CubeTextureAssetTask) => void;
  53926. /**
  53927. * Callback called when the task is successful
  53928. */
  53929. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  53930. /**
  53931. * Creates a new CubeTextureAssetTask
  53932. * @param name defines the name of the task
  53933. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  53934. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  53935. * @param noMipmap defines if mipmaps should not be generated (default is false)
  53936. * @param files defines the explicit list of files (undefined by default)
  53937. */
  53938. constructor(
  53939. /**
  53940. * Defines the name of the task
  53941. */
  53942. name: string,
  53943. /**
  53944. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  53945. */
  53946. url: string,
  53947. /**
  53948. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  53949. */
  53950. extensions?: string[] | undefined,
  53951. /**
  53952. * Defines if mipmaps should not be generated (default is false)
  53953. */
  53954. noMipmap?: boolean | undefined,
  53955. /**
  53956. * Defines the explicit list of files (undefined by default)
  53957. */
  53958. files?: string[] | undefined);
  53959. /**
  53960. * Execute the current task
  53961. * @param scene defines the scene where you want your assets to be loaded
  53962. * @param onSuccess is a callback called when the task is successfully executed
  53963. * @param onError is a callback called if an error occurs
  53964. */
  53965. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  53966. }
  53967. /**
  53968. * Define a task used by AssetsManager to load HDR cube textures
  53969. */
  53970. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  53971. /**
  53972. * Defines the name of the task
  53973. */
  53974. name: string;
  53975. /**
  53976. * Defines the location of the file to load
  53977. */
  53978. url: string;
  53979. /**
  53980. * Defines the desired size (the more it increases the longer the generation will be)
  53981. */
  53982. size: number;
  53983. /**
  53984. * Defines if mipmaps should not be generated (default is false)
  53985. */
  53986. noMipmap: boolean;
  53987. /**
  53988. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  53989. */
  53990. generateHarmonics: boolean;
  53991. /**
  53992. * 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)
  53993. */
  53994. gammaSpace: boolean;
  53995. /**
  53996. * Internal Use Only
  53997. */
  53998. reserved: boolean;
  53999. /**
  54000. * Gets the loaded texture
  54001. */
  54002. texture: HDRCubeTexture;
  54003. /**
  54004. * Callback called when the task is successful
  54005. */
  54006. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  54007. /**
  54008. * Callback called when the task is successful
  54009. */
  54010. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  54011. /**
  54012. * Creates a new HDRCubeTextureAssetTask object
  54013. * @param name defines the name of the task
  54014. * @param url defines the location of the file to load
  54015. * @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.
  54016. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54017. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54018. * @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)
  54019. * @param reserved Internal use only
  54020. */
  54021. constructor(
  54022. /**
  54023. * Defines the name of the task
  54024. */
  54025. name: string,
  54026. /**
  54027. * Defines the location of the file to load
  54028. */
  54029. url: string,
  54030. /**
  54031. * Defines the desired size (the more it increases the longer the generation will be)
  54032. */
  54033. size: number,
  54034. /**
  54035. * Defines if mipmaps should not be generated (default is false)
  54036. */
  54037. noMipmap?: boolean,
  54038. /**
  54039. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  54040. */
  54041. generateHarmonics?: boolean,
  54042. /**
  54043. * 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)
  54044. */
  54045. gammaSpace?: boolean,
  54046. /**
  54047. * Internal Use Only
  54048. */
  54049. reserved?: boolean);
  54050. /**
  54051. * Execute the current task
  54052. * @param scene defines the scene where you want your assets to be loaded
  54053. * @param onSuccess is a callback called when the task is successfully executed
  54054. * @param onError is a callback called if an error occurs
  54055. */
  54056. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54057. }
  54058. /**
  54059. * Define a task used by AssetsManager to load Equirectangular cube textures
  54060. */
  54061. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  54062. /**
  54063. * Defines the name of the task
  54064. */
  54065. name: string;
  54066. /**
  54067. * Defines the location of the file to load
  54068. */
  54069. url: string;
  54070. /**
  54071. * Defines the desired size (the more it increases the longer the generation will be)
  54072. */
  54073. size: number;
  54074. /**
  54075. * Defines if mipmaps should not be generated (default is false)
  54076. */
  54077. noMipmap: boolean;
  54078. /**
  54079. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54080. * but the standard material would require them in Gamma space) (default is true)
  54081. */
  54082. gammaSpace: boolean;
  54083. /**
  54084. * Gets the loaded texture
  54085. */
  54086. texture: EquiRectangularCubeTexture;
  54087. /**
  54088. * Callback called when the task is successful
  54089. */
  54090. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  54091. /**
  54092. * Callback called when the task is successful
  54093. */
  54094. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  54095. /**
  54096. * Creates a new EquiRectangularCubeTextureAssetTask object
  54097. * @param name defines the name of the task
  54098. * @param url defines the location of the file to load
  54099. * @param size defines the desired size (the more it increases the longer the generation will be)
  54100. * If the size is omitted this implies you are using a preprocessed cubemap.
  54101. * @param noMipmap defines if mipmaps should not be generated (default is false)
  54102. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  54103. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  54104. * (default is true)
  54105. */
  54106. constructor(
  54107. /**
  54108. * Defines the name of the task
  54109. */
  54110. name: string,
  54111. /**
  54112. * Defines the location of the file to load
  54113. */
  54114. url: string,
  54115. /**
  54116. * Defines the desired size (the more it increases the longer the generation will be)
  54117. */
  54118. size: number,
  54119. /**
  54120. * Defines if mipmaps should not be generated (default is false)
  54121. */
  54122. noMipmap?: boolean,
  54123. /**
  54124. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  54125. * but the standard material would require them in Gamma space) (default is true)
  54126. */
  54127. gammaSpace?: boolean);
  54128. /**
  54129. * Execute the current task
  54130. * @param scene defines the scene where you want your assets to be loaded
  54131. * @param onSuccess is a callback called when the task is successfully executed
  54132. * @param onError is a callback called if an error occurs
  54133. */
  54134. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  54135. }
  54136. /**
  54137. * This class can be used to easily import assets into a scene
  54138. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  54139. */
  54140. export class AssetsManager {
  54141. private _scene;
  54142. private _isLoading;
  54143. protected _tasks: AbstractAssetTask[];
  54144. protected _waitingTasksCount: number;
  54145. protected _totalTasksCount: number;
  54146. /**
  54147. * Callback called when all tasks are processed
  54148. */
  54149. onFinish: (tasks: AbstractAssetTask[]) => void;
  54150. /**
  54151. * Callback called when a task is successful
  54152. */
  54153. onTaskSuccess: (task: AbstractAssetTask) => void;
  54154. /**
  54155. * Callback called when a task had an error
  54156. */
  54157. onTaskError: (task: AbstractAssetTask) => void;
  54158. /**
  54159. * Callback called when a task is done (whatever the result is)
  54160. */
  54161. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  54162. /**
  54163. * Observable called when all tasks are processed
  54164. */
  54165. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  54166. /**
  54167. * Observable called when a task had an error
  54168. */
  54169. onTaskErrorObservable: Observable<AbstractAssetTask>;
  54170. /**
  54171. * Observable called when all tasks were executed
  54172. */
  54173. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  54174. /**
  54175. * Observable called when a task is done (whatever the result is)
  54176. */
  54177. onProgressObservable: Observable<IAssetsProgressEvent>;
  54178. /**
  54179. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  54180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  54181. */
  54182. useDefaultLoadingScreen: boolean;
  54183. /**
  54184. * Creates a new AssetsManager
  54185. * @param scene defines the scene to work on
  54186. */
  54187. constructor(scene: Scene);
  54188. /**
  54189. * Add a MeshAssetTask to the list of active tasks
  54190. * @param taskName defines the name of the new task
  54191. * @param meshesNames defines the name of meshes to load
  54192. * @param rootUrl defines the root url to use to locate files
  54193. * @param sceneFilename defines the filename of the scene file
  54194. * @returns a new MeshAssetTask object
  54195. */
  54196. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  54197. /**
  54198. * Add a TextFileAssetTask to the list of active tasks
  54199. * @param taskName defines the name of the new task
  54200. * @param url defines the url of the file to load
  54201. * @returns a new TextFileAssetTask object
  54202. */
  54203. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  54204. /**
  54205. * Add a BinaryFileAssetTask to the list of active tasks
  54206. * @param taskName defines the name of the new task
  54207. * @param url defines the url of the file to load
  54208. * @returns a new BinaryFileAssetTask object
  54209. */
  54210. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  54211. /**
  54212. * Add a ImageAssetTask to the list of active tasks
  54213. * @param taskName defines the name of the new task
  54214. * @param url defines the url of the file to load
  54215. * @returns a new ImageAssetTask object
  54216. */
  54217. addImageTask(taskName: string, url: string): ImageAssetTask;
  54218. /**
  54219. * Add a TextureAssetTask to the list of active tasks
  54220. * @param taskName defines the name of the new task
  54221. * @param url defines the url of the file to load
  54222. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54223. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  54224. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54225. * @returns a new TextureAssetTask object
  54226. */
  54227. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  54228. /**
  54229. * Add a CubeTextureAssetTask to the list of active tasks
  54230. * @param taskName defines the name of the new task
  54231. * @param url defines the url of the file to load
  54232. * @param extensions defines the extension to use to load the cube map (can be null)
  54233. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54234. * @param files defines the list of files to load (can be null)
  54235. * @returns a new CubeTextureAssetTask object
  54236. */
  54237. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  54238. /**
  54239. *
  54240. * Add a HDRCubeTextureAssetTask to the list of active tasks
  54241. * @param taskName defines the name of the new task
  54242. * @param url defines the url of the file to load
  54243. * @param size defines the size you want for the cubemap (can be null)
  54244. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54245. * @param generateHarmonics defines if you want to automatically generate (true by default)
  54246. * @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)
  54247. * @param reserved Internal use only
  54248. * @returns a new HDRCubeTextureAssetTask object
  54249. */
  54250. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  54251. /**
  54252. *
  54253. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  54254. * @param taskName defines the name of the new task
  54255. * @param url defines the url of the file to load
  54256. * @param size defines the size you want for the cubemap (can be null)
  54257. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  54258. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54259. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54260. * @returns a new EquiRectangularCubeTextureAssetTask object
  54261. */
  54262. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  54263. /**
  54264. * Remove a task from the assets manager.
  54265. * @param task the task to remove
  54266. */
  54267. removeTask(task: AbstractAssetTask): void;
  54268. private _decreaseWaitingTasksCount;
  54269. private _runTask;
  54270. /**
  54271. * Reset the AssetsManager and remove all tasks
  54272. * @return the current instance of the AssetsManager
  54273. */
  54274. reset(): AssetsManager;
  54275. /**
  54276. * Start the loading process
  54277. * @return the current instance of the AssetsManager
  54278. */
  54279. load(): AssetsManager;
  54280. /**
  54281. * Start the loading process as an async operation
  54282. * @return a promise returning the list of failed tasks
  54283. */
  54284. loadAsync(): Promise<void>;
  54285. }
  54286. }
  54287. declare module BABYLON {
  54288. /**
  54289. * Wrapper class for promise with external resolve and reject.
  54290. */
  54291. export class Deferred<T> {
  54292. /**
  54293. * The promise associated with this deferred object.
  54294. */
  54295. readonly promise: Promise<T>;
  54296. private _resolve;
  54297. private _reject;
  54298. /**
  54299. * The resolve method of the promise associated with this deferred object.
  54300. */
  54301. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  54302. /**
  54303. * The reject method of the promise associated with this deferred object.
  54304. */
  54305. readonly reject: (reason?: any) => void;
  54306. /**
  54307. * Constructor for this deferred object.
  54308. */
  54309. constructor();
  54310. }
  54311. }
  54312. declare module BABYLON {
  54313. /**
  54314. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  54315. */
  54316. export class MeshExploder {
  54317. private _centerMesh;
  54318. private _meshes;
  54319. private _meshesOrigins;
  54320. private _toCenterVectors;
  54321. private _scaledDirection;
  54322. private _newPosition;
  54323. private _centerPosition;
  54324. /**
  54325. * Explodes meshes from a center mesh.
  54326. * @param meshes The meshes to explode.
  54327. * @param centerMesh The mesh to be center of explosion.
  54328. */
  54329. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  54330. private _setCenterMesh;
  54331. /**
  54332. * Get class name
  54333. * @returns "MeshExploder"
  54334. */
  54335. getClassName(): string;
  54336. /**
  54337. * "Exploded meshes"
  54338. * @returns Array of meshes with the centerMesh at index 0.
  54339. */
  54340. getMeshes(): Array<Mesh>;
  54341. /**
  54342. * Explodes meshes giving a specific direction
  54343. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  54344. */
  54345. explode(direction?: number): void;
  54346. }
  54347. }
  54348. declare module BABYLON {
  54349. /**
  54350. * Class used to help managing file picking and drag'n'drop
  54351. */
  54352. export class FilesInput {
  54353. /**
  54354. * List of files ready to be loaded
  54355. */
  54356. static readonly FilesToLoad: {
  54357. [key: string]: File;
  54358. };
  54359. /**
  54360. * Callback called when a file is processed
  54361. */
  54362. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  54363. private _engine;
  54364. private _currentScene;
  54365. private _sceneLoadedCallback;
  54366. private _progressCallback;
  54367. private _additionalRenderLoopLogicCallback;
  54368. private _textureLoadingCallback;
  54369. private _startingProcessingFilesCallback;
  54370. private _onReloadCallback;
  54371. private _errorCallback;
  54372. private _elementToMonitor;
  54373. private _sceneFileToLoad;
  54374. private _filesToLoad;
  54375. /**
  54376. * Creates a new FilesInput
  54377. * @param engine defines the rendering engine
  54378. * @param scene defines the hosting scene
  54379. * @param sceneLoadedCallback callback called when scene is loaded
  54380. * @param progressCallback callback called to track progress
  54381. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  54382. * @param textureLoadingCallback callback called when a texture is loading
  54383. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  54384. * @param onReloadCallback callback called when a reload is requested
  54385. * @param errorCallback callback call if an error occurs
  54386. */
  54387. 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);
  54388. private _dragEnterHandler;
  54389. private _dragOverHandler;
  54390. private _dropHandler;
  54391. /**
  54392. * Calls this function to listen to drag'n'drop events on a specific DOM element
  54393. * @param elementToMonitor defines the DOM element to track
  54394. */
  54395. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  54396. /**
  54397. * Release all associated resources
  54398. */
  54399. dispose(): void;
  54400. private renderFunction;
  54401. private drag;
  54402. private drop;
  54403. private _traverseFolder;
  54404. private _processFiles;
  54405. /**
  54406. * Load files from a drop event
  54407. * @param event defines the drop event to use as source
  54408. */
  54409. loadFiles(event: any): void;
  54410. private _processReload;
  54411. /**
  54412. * Reload the current scene from the loaded files
  54413. */
  54414. reload(): void;
  54415. }
  54416. }
  54417. declare module BABYLON {
  54418. /**
  54419. * Defines the root class used to create scene optimization to use with SceneOptimizer
  54420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54421. */
  54422. export class SceneOptimization {
  54423. /**
  54424. * Defines the priority of this optimization (0 by default which means first in the list)
  54425. */
  54426. priority: number;
  54427. /**
  54428. * Gets a string describing the action executed by the current optimization
  54429. * @returns description string
  54430. */
  54431. getDescription(): string;
  54432. /**
  54433. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54434. * @param scene defines the current scene where to apply this optimization
  54435. * @param optimizer defines the current optimizer
  54436. * @returns true if everything that can be done was applied
  54437. */
  54438. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54439. /**
  54440. * Creates the SceneOptimization object
  54441. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54442. * @param desc defines the description associated with the optimization
  54443. */
  54444. constructor(
  54445. /**
  54446. * Defines the priority of this optimization (0 by default which means first in the list)
  54447. */
  54448. priority?: number);
  54449. }
  54450. /**
  54451. * Defines an optimization used to reduce the size of render target textures
  54452. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54453. */
  54454. export class TextureOptimization extends SceneOptimization {
  54455. /**
  54456. * Defines the priority of this optimization (0 by default which means first in the list)
  54457. */
  54458. priority: number;
  54459. /**
  54460. * 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
  54461. */
  54462. maximumSize: number;
  54463. /**
  54464. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54465. */
  54466. step: number;
  54467. /**
  54468. * Gets a string describing the action executed by the current optimization
  54469. * @returns description string
  54470. */
  54471. getDescription(): string;
  54472. /**
  54473. * Creates the TextureOptimization object
  54474. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54475. * @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
  54476. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54477. */
  54478. constructor(
  54479. /**
  54480. * Defines the priority of this optimization (0 by default which means first in the list)
  54481. */
  54482. priority?: number,
  54483. /**
  54484. * 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
  54485. */
  54486. maximumSize?: number,
  54487. /**
  54488. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  54489. */
  54490. step?: number);
  54491. /**
  54492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54493. * @param scene defines the current scene where to apply this optimization
  54494. * @param optimizer defines the current optimizer
  54495. * @returns true if everything that can be done was applied
  54496. */
  54497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54498. }
  54499. /**
  54500. * Defines an optimization used to increase or decrease the rendering resolution
  54501. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54502. */
  54503. export class HardwareScalingOptimization extends SceneOptimization {
  54504. /**
  54505. * Defines the priority of this optimization (0 by default which means first in the list)
  54506. */
  54507. priority: number;
  54508. /**
  54509. * Defines the maximum scale to use (2 by default)
  54510. */
  54511. maximumScale: number;
  54512. /**
  54513. * Defines the step to use between two passes (0.5 by default)
  54514. */
  54515. step: number;
  54516. private _currentScale;
  54517. private _directionOffset;
  54518. /**
  54519. * Gets a string describing the action executed by the current optimization
  54520. * @return description string
  54521. */
  54522. getDescription(): string;
  54523. /**
  54524. * Creates the HardwareScalingOptimization object
  54525. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54526. * @param maximumScale defines the maximum scale to use (2 by default)
  54527. * @param step defines the step to use between two passes (0.5 by default)
  54528. */
  54529. constructor(
  54530. /**
  54531. * Defines the priority of this optimization (0 by default which means first in the list)
  54532. */
  54533. priority?: number,
  54534. /**
  54535. * Defines the maximum scale to use (2 by default)
  54536. */
  54537. maximumScale?: number,
  54538. /**
  54539. * Defines the step to use between two passes (0.5 by default)
  54540. */
  54541. step?: number);
  54542. /**
  54543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54544. * @param scene defines the current scene where to apply this optimization
  54545. * @param optimizer defines the current optimizer
  54546. * @returns true if everything that can be done was applied
  54547. */
  54548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54549. }
  54550. /**
  54551. * Defines an optimization used to remove shadows
  54552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54553. */
  54554. export class ShadowsOptimization extends SceneOptimization {
  54555. /**
  54556. * Gets a string describing the action executed by the current optimization
  54557. * @return description string
  54558. */
  54559. getDescription(): string;
  54560. /**
  54561. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54562. * @param scene defines the current scene where to apply this optimization
  54563. * @param optimizer defines the current optimizer
  54564. * @returns true if everything that can be done was applied
  54565. */
  54566. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54567. }
  54568. /**
  54569. * Defines an optimization used to turn post-processes off
  54570. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54571. */
  54572. export class PostProcessesOptimization extends SceneOptimization {
  54573. /**
  54574. * Gets a string describing the action executed by the current optimization
  54575. * @return description string
  54576. */
  54577. getDescription(): string;
  54578. /**
  54579. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54580. * @param scene defines the current scene where to apply this optimization
  54581. * @param optimizer defines the current optimizer
  54582. * @returns true if everything that can be done was applied
  54583. */
  54584. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54585. }
  54586. /**
  54587. * Defines an optimization used to turn lens flares off
  54588. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54589. */
  54590. export class LensFlaresOptimization extends SceneOptimization {
  54591. /**
  54592. * Gets a string describing the action executed by the current optimization
  54593. * @return description string
  54594. */
  54595. getDescription(): string;
  54596. /**
  54597. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54598. * @param scene defines the current scene where to apply this optimization
  54599. * @param optimizer defines the current optimizer
  54600. * @returns true if everything that can be done was applied
  54601. */
  54602. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54603. }
  54604. /**
  54605. * Defines an optimization based on user defined callback.
  54606. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54607. */
  54608. export class CustomOptimization extends SceneOptimization {
  54609. /**
  54610. * Callback called to apply the custom optimization.
  54611. */
  54612. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  54613. /**
  54614. * Callback called to get custom description
  54615. */
  54616. onGetDescription: () => string;
  54617. /**
  54618. * Gets a string describing the action executed by the current optimization
  54619. * @returns description string
  54620. */
  54621. getDescription(): string;
  54622. /**
  54623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54624. * @param scene defines the current scene where to apply this optimization
  54625. * @param optimizer defines the current optimizer
  54626. * @returns true if everything that can be done was applied
  54627. */
  54628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54629. }
  54630. /**
  54631. * Defines an optimization used to turn particles off
  54632. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54633. */
  54634. export class ParticlesOptimization extends SceneOptimization {
  54635. /**
  54636. * Gets a string describing the action executed by the current optimization
  54637. * @return description string
  54638. */
  54639. getDescription(): string;
  54640. /**
  54641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54642. * @param scene defines the current scene where to apply this optimization
  54643. * @param optimizer defines the current optimizer
  54644. * @returns true if everything that can be done was applied
  54645. */
  54646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54647. }
  54648. /**
  54649. * Defines an optimization used to turn render targets off
  54650. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54651. */
  54652. export class RenderTargetsOptimization extends SceneOptimization {
  54653. /**
  54654. * Gets a string describing the action executed by the current optimization
  54655. * @return description string
  54656. */
  54657. getDescription(): string;
  54658. /**
  54659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54660. * @param scene defines the current scene where to apply this optimization
  54661. * @param optimizer defines the current optimizer
  54662. * @returns true if everything that can be done was applied
  54663. */
  54664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  54665. }
  54666. /**
  54667. * Defines an optimization used to merge meshes with compatible materials
  54668. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54669. */
  54670. export class MergeMeshesOptimization extends SceneOptimization {
  54671. private static _UpdateSelectionTree;
  54672. /**
  54673. * Gets or sets a boolean which defines if optimization octree has to be updated
  54674. */
  54675. /**
  54676. * Gets or sets a boolean which defines if optimization octree has to be updated
  54677. */
  54678. static UpdateSelectionTree: boolean;
  54679. /**
  54680. * Gets a string describing the action executed by the current optimization
  54681. * @return description string
  54682. */
  54683. getDescription(): string;
  54684. private _canBeMerged;
  54685. /**
  54686. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  54687. * @param scene defines the current scene where to apply this optimization
  54688. * @param optimizer defines the current optimizer
  54689. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  54690. * @returns true if everything that can be done was applied
  54691. */
  54692. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  54693. }
  54694. /**
  54695. * Defines a list of options used by SceneOptimizer
  54696. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54697. */
  54698. export class SceneOptimizerOptions {
  54699. /**
  54700. * Defines the target frame rate to reach (60 by default)
  54701. */
  54702. targetFrameRate: number;
  54703. /**
  54704. * Defines the interval between two checkes (2000ms by default)
  54705. */
  54706. trackerDuration: number;
  54707. /**
  54708. * Gets the list of optimizations to apply
  54709. */
  54710. optimizations: SceneOptimization[];
  54711. /**
  54712. * Creates a new list of options used by SceneOptimizer
  54713. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  54714. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  54715. */
  54716. constructor(
  54717. /**
  54718. * Defines the target frame rate to reach (60 by default)
  54719. */
  54720. targetFrameRate?: number,
  54721. /**
  54722. * Defines the interval between two checkes (2000ms by default)
  54723. */
  54724. trackerDuration?: number);
  54725. /**
  54726. * Add a new optimization
  54727. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  54728. * @returns the current SceneOptimizerOptions
  54729. */
  54730. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  54731. /**
  54732. * Add a new custom optimization
  54733. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  54734. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  54735. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  54736. * @returns the current SceneOptimizerOptions
  54737. */
  54738. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  54739. /**
  54740. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  54741. * @param targetFrameRate defines the target frame rate (60 by default)
  54742. * @returns a SceneOptimizerOptions object
  54743. */
  54744. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54745. /**
  54746. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  54747. * @param targetFrameRate defines the target frame rate (60 by default)
  54748. * @returns a SceneOptimizerOptions object
  54749. */
  54750. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54751. /**
  54752. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  54753. * @param targetFrameRate defines the target frame rate (60 by default)
  54754. * @returns a SceneOptimizerOptions object
  54755. */
  54756. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  54757. }
  54758. /**
  54759. * Class used to run optimizations in order to reach a target frame rate
  54760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  54761. */
  54762. export class SceneOptimizer implements IDisposable {
  54763. private _isRunning;
  54764. private _options;
  54765. private _scene;
  54766. private _currentPriorityLevel;
  54767. private _targetFrameRate;
  54768. private _trackerDuration;
  54769. private _currentFrameRate;
  54770. private _sceneDisposeObserver;
  54771. private _improvementMode;
  54772. /**
  54773. * Defines an observable called when the optimizer reaches the target frame rate
  54774. */
  54775. onSuccessObservable: Observable<SceneOptimizer>;
  54776. /**
  54777. * Defines an observable called when the optimizer enables an optimization
  54778. */
  54779. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  54780. /**
  54781. * Defines an observable called when the optimizer is not able to reach the target frame rate
  54782. */
  54783. onFailureObservable: Observable<SceneOptimizer>;
  54784. /**
  54785. * Gets a boolean indicating if the optimizer is in improvement mode
  54786. */
  54787. readonly isInImprovementMode: boolean;
  54788. /**
  54789. * Gets the current priority level (0 at start)
  54790. */
  54791. readonly currentPriorityLevel: number;
  54792. /**
  54793. * Gets the current frame rate checked by the SceneOptimizer
  54794. */
  54795. readonly currentFrameRate: number;
  54796. /**
  54797. * Gets or sets the current target frame rate (60 by default)
  54798. */
  54799. /**
  54800. * Gets or sets the current target frame rate (60 by default)
  54801. */
  54802. targetFrameRate: number;
  54803. /**
  54804. * Gets or sets the current interval between two checks (every 2000ms by default)
  54805. */
  54806. /**
  54807. * Gets or sets the current interval between two checks (every 2000ms by default)
  54808. */
  54809. trackerDuration: number;
  54810. /**
  54811. * Gets the list of active optimizations
  54812. */
  54813. readonly optimizations: SceneOptimization[];
  54814. /**
  54815. * Creates a new SceneOptimizer
  54816. * @param scene defines the scene to work on
  54817. * @param options defines the options to use with the SceneOptimizer
  54818. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  54819. * @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)
  54820. */
  54821. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  54822. /**
  54823. * Stops the current optimizer
  54824. */
  54825. stop(): void;
  54826. /**
  54827. * Reset the optimizer to initial step (current priority level = 0)
  54828. */
  54829. reset(): void;
  54830. /**
  54831. * Start the optimizer. By default it will try to reach a specific framerate
  54832. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  54833. */
  54834. start(): void;
  54835. private _checkCurrentState;
  54836. /**
  54837. * Release all resources
  54838. */
  54839. dispose(): void;
  54840. /**
  54841. * Helper function to create a SceneOptimizer with one single line of code
  54842. * @param scene defines the scene to work on
  54843. * @param options defines the options to use with the SceneOptimizer
  54844. * @param onSuccess defines a callback to call on success
  54845. * @param onFailure defines a callback to call on failure
  54846. * @returns the new SceneOptimizer object
  54847. */
  54848. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  54849. }
  54850. }
  54851. declare module BABYLON {
  54852. /**
  54853. * Class used to serialize a scene into a string
  54854. */
  54855. export class SceneSerializer {
  54856. /**
  54857. * Clear cache used by a previous serialization
  54858. */
  54859. static ClearCache(): void;
  54860. /**
  54861. * Serialize a scene into a JSON compatible object
  54862. * @param scene defines the scene to serialize
  54863. * @returns a JSON compatible object
  54864. */
  54865. static Serialize(scene: Scene): any;
  54866. /**
  54867. * Serialize a mesh into a JSON compatible object
  54868. * @param toSerialize defines the mesh to serialize
  54869. * @param withParents defines if parents must be serialized as well
  54870. * @param withChildren defines if children must be serialized as well
  54871. * @returns a JSON compatible object
  54872. */
  54873. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  54874. }
  54875. }
  54876. declare module BABYLON {
  54877. /**
  54878. * Class used to host texture specific utilities
  54879. */
  54880. export class TextureTools {
  54881. /**
  54882. * Uses the GPU to create a copy texture rescaled at a given size
  54883. * @param texture Texture to copy from
  54884. * @param width defines the desired width
  54885. * @param height defines the desired height
  54886. * @param useBilinearMode defines if bilinear mode has to be used
  54887. * @return the generated texture
  54888. */
  54889. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  54890. }
  54891. }
  54892. declare module BABYLON {
  54893. /**
  54894. * This represents the different options avilable for the video capture.
  54895. */
  54896. export interface VideoRecorderOptions {
  54897. /** Defines the mime type of the video */
  54898. mimeType: string;
  54899. /** Defines the video the video should be recorded at */
  54900. fps: number;
  54901. /** Defines the chunk size for the recording data */
  54902. recordChunckSize: number;
  54903. /** The audio tracks to attach to the record */
  54904. audioTracks?: MediaStreamTrack[];
  54905. }
  54906. /**
  54907. * This can helps recording videos from BabylonJS.
  54908. * This is based on the available WebRTC functionalities of the browser.
  54909. *
  54910. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  54911. */
  54912. export class VideoRecorder {
  54913. private static readonly _defaultOptions;
  54914. /**
  54915. * Returns wehther or not the VideoRecorder is available in your browser.
  54916. * @param engine Defines the Babylon Engine to check the support for
  54917. * @returns true if supported otherwise false
  54918. */
  54919. static IsSupported(engine: Engine): boolean;
  54920. private readonly _options;
  54921. private _canvas;
  54922. private _mediaRecorder;
  54923. private _recordedChunks;
  54924. private _fileName;
  54925. private _resolve;
  54926. private _reject;
  54927. /**
  54928. * True wether a recording is already in progress.
  54929. */
  54930. readonly isRecording: boolean;
  54931. /**
  54932. * Create a new VideoCapture object which can help converting what you see in Babylon to
  54933. * a video file.
  54934. * @param engine Defines the BabylonJS Engine you wish to record
  54935. * @param options Defines options that can be used to customized the capture
  54936. */
  54937. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  54938. /**
  54939. * Stops the current recording before the default capture timeout passed in the startRecording
  54940. * functions.
  54941. */
  54942. stopRecording(): void;
  54943. /**
  54944. * Starts recording the canvas for a max duration specified in parameters.
  54945. * @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.
  54946. * @param maxDuration Defines the maximum recording time in seconds.
  54947. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  54948. * @return a promise callback at the end of the recording with the video data in Blob.
  54949. */
  54950. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  54951. /**
  54952. * Releases internal resources used during the recording.
  54953. */
  54954. dispose(): void;
  54955. private _handleDataAvailable;
  54956. private _handleError;
  54957. private _handleStop;
  54958. }
  54959. }
  54960. declare module BABYLON {
  54961. /**
  54962. * Helper class to push actions to a pool of workers.
  54963. */
  54964. export class WorkerPool implements IDisposable {
  54965. private _workerInfos;
  54966. private _pendingActions;
  54967. /**
  54968. * Constructor
  54969. * @param workers Array of workers to use for actions
  54970. */
  54971. constructor(workers: Array<Worker>);
  54972. /**
  54973. * Terminates all workers and clears any pending actions.
  54974. */
  54975. dispose(): void;
  54976. /**
  54977. * Pushes an action to the worker pool. If all the workers are active, the action will be
  54978. * pended until a worker has completed its action.
  54979. * @param action The action to perform. Call onComplete when the action is complete.
  54980. */
  54981. push(action: (worker: Worker, onComplete: () => void) => void): void;
  54982. private _execute;
  54983. }
  54984. }
  54985. declare module BABYLON {
  54986. /**
  54987. * Class containing a set of static utilities functions for screenshots
  54988. */
  54989. export class ScreenshotTools {
  54990. /**
  54991. * Captures a screenshot of the current rendering
  54992. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  54993. * @param engine defines the rendering engine
  54994. * @param camera defines the source camera
  54995. * @param size This parameter can be set to a single number or to an object with the
  54996. * following (optional) properties: precision, width, height. If a single number is passed,
  54997. * it will be used for both width and height. If an object is passed, the screenshot size
  54998. * will be derived from the parameters. The precision property is a multiplier allowing
  54999. * rendering at a higher or lower resolution
  55000. * @param successCallback defines the callback receives a single parameter which contains the
  55001. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55002. * src parameter of an <img> to display it
  55003. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  55004. * Check your browser for supported MIME types
  55005. */
  55006. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  55007. /**
  55008. * Generates an image screenshot from the specified camera.
  55009. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  55010. * @param engine The engine to use for rendering
  55011. * @param camera The camera to use for rendering
  55012. * @param size This parameter can be set to a single number or to an object with the
  55013. * following (optional) properties: precision, width, height. If a single number is passed,
  55014. * it will be used for both width and height. If an object is passed, the screenshot size
  55015. * will be derived from the parameters. The precision property is a multiplier allowing
  55016. * rendering at a higher or lower resolution
  55017. * @param successCallback The callback receives a single parameter which contains the
  55018. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  55019. * src parameter of an <img> to display it
  55020. * @param mimeType The MIME type of the screenshot image (default: image/png).
  55021. * Check your browser for supported MIME types
  55022. * @param samples Texture samples (default: 1)
  55023. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  55024. * @param fileName A name for for the downloaded file.
  55025. */
  55026. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  55027. }
  55028. }
  55029. declare module BABYLON {
  55030. /**
  55031. * A cursor which tracks a point on a path
  55032. */
  55033. export class PathCursor {
  55034. private path;
  55035. /**
  55036. * Stores path cursor callbacks for when an onchange event is triggered
  55037. */
  55038. private _onchange;
  55039. /**
  55040. * The value of the path cursor
  55041. */
  55042. value: number;
  55043. /**
  55044. * The animation array of the path cursor
  55045. */
  55046. animations: Animation[];
  55047. /**
  55048. * Initializes the path cursor
  55049. * @param path The path to track
  55050. */
  55051. constructor(path: Path2);
  55052. /**
  55053. * Gets the cursor point on the path
  55054. * @returns A point on the path cursor at the cursor location
  55055. */
  55056. getPoint(): Vector3;
  55057. /**
  55058. * Moves the cursor ahead by the step amount
  55059. * @param step The amount to move the cursor forward
  55060. * @returns This path cursor
  55061. */
  55062. moveAhead(step?: number): PathCursor;
  55063. /**
  55064. * Moves the cursor behind by the step amount
  55065. * @param step The amount to move the cursor back
  55066. * @returns This path cursor
  55067. */
  55068. moveBack(step?: number): PathCursor;
  55069. /**
  55070. * Moves the cursor by the step amount
  55071. * If the step amount is greater than one, an exception is thrown
  55072. * @param step The amount to move the cursor
  55073. * @returns This path cursor
  55074. */
  55075. move(step: number): PathCursor;
  55076. /**
  55077. * Ensures that the value is limited between zero and one
  55078. * @returns This path cursor
  55079. */
  55080. private ensureLimits;
  55081. /**
  55082. * Runs onchange callbacks on change (used by the animation engine)
  55083. * @returns This path cursor
  55084. */
  55085. private raiseOnChange;
  55086. /**
  55087. * Executes a function on change
  55088. * @param f A path cursor onchange callback
  55089. * @returns This path cursor
  55090. */
  55091. onchange(f: (cursor: PathCursor) => void): PathCursor;
  55092. }
  55093. }
  55094. declare module BABYLON {
  55095. /** @hidden */
  55096. export var blurPixelShader: {
  55097. name: string;
  55098. shader: string;
  55099. };
  55100. }
  55101. declare module BABYLON {
  55102. /** @hidden */
  55103. export var bones300Declaration: {
  55104. name: string;
  55105. shader: string;
  55106. };
  55107. }
  55108. declare module BABYLON {
  55109. /** @hidden */
  55110. export var instances300Declaration: {
  55111. name: string;
  55112. shader: string;
  55113. };
  55114. }
  55115. declare module BABYLON {
  55116. /** @hidden */
  55117. export var pointCloudVertexDeclaration: {
  55118. name: string;
  55119. shader: string;
  55120. };
  55121. }
  55122. // Mixins
  55123. interface Window {
  55124. mozIndexedDB: IDBFactory;
  55125. webkitIndexedDB: IDBFactory;
  55126. msIndexedDB: IDBFactory;
  55127. webkitURL: typeof URL;
  55128. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  55129. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  55130. WebGLRenderingContext: WebGLRenderingContext;
  55131. MSGesture: MSGesture;
  55132. CANNON: any;
  55133. AudioContext: AudioContext;
  55134. webkitAudioContext: AudioContext;
  55135. PointerEvent: any;
  55136. Math: Math;
  55137. Uint8Array: Uint8ArrayConstructor;
  55138. Float32Array: Float32ArrayConstructor;
  55139. mozURL: typeof URL;
  55140. msURL: typeof URL;
  55141. VRFrameData: any; // WebVR, from specs 1.1
  55142. DracoDecoderModule: any;
  55143. setImmediate(handler: (...args: any[]) => void): number;
  55144. }
  55145. interface HTMLCanvasElement {
  55146. requestPointerLock(): void;
  55147. msRequestPointerLock?(): void;
  55148. mozRequestPointerLock?(): void;
  55149. webkitRequestPointerLock?(): void;
  55150. /** Track wether a record is in progress */
  55151. isRecording: boolean;
  55152. /** Capture Stream method defined by some browsers */
  55153. captureStream(fps?: number): MediaStream;
  55154. }
  55155. interface CanvasRenderingContext2D {
  55156. msImageSmoothingEnabled: boolean;
  55157. }
  55158. interface MouseEvent {
  55159. mozMovementX: number;
  55160. mozMovementY: number;
  55161. webkitMovementX: number;
  55162. webkitMovementY: number;
  55163. msMovementX: number;
  55164. msMovementY: number;
  55165. }
  55166. interface Navigator {
  55167. mozGetVRDevices: (any: any) => any;
  55168. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55169. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55170. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  55171. webkitGetGamepads(): Gamepad[];
  55172. msGetGamepads(): Gamepad[];
  55173. webkitGamepads(): Gamepad[];
  55174. }
  55175. interface HTMLVideoElement {
  55176. mozSrcObject: any;
  55177. }
  55178. interface Math {
  55179. fround(x: number): number;
  55180. imul(a: number, b: number): number;
  55181. }
  55182. interface WebGLProgram {
  55183. context?: WebGLRenderingContext;
  55184. vertexShader?: WebGLShader;
  55185. fragmentShader?: WebGLShader;
  55186. isParallelCompiled: boolean;
  55187. onCompiled?: () => void;
  55188. }
  55189. interface WebGLRenderingContext {
  55190. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  55191. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  55192. vertexAttribDivisor(index: number, divisor: number): void;
  55193. createVertexArray(): any;
  55194. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  55195. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  55196. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55197. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  55198. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  55199. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  55200. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  55201. // Queries
  55202. createQuery(): WebGLQuery;
  55203. deleteQuery(query: WebGLQuery): void;
  55204. beginQuery(target: number, query: WebGLQuery): void;
  55205. endQuery(target: number): void;
  55206. getQueryParameter(query: WebGLQuery, pname: number): any;
  55207. getQuery(target: number, pname: number): any;
  55208. MAX_SAMPLES: number;
  55209. RGBA8: number;
  55210. READ_FRAMEBUFFER: number;
  55211. DRAW_FRAMEBUFFER: number;
  55212. UNIFORM_BUFFER: number;
  55213. HALF_FLOAT_OES: number;
  55214. RGBA16F: number;
  55215. RGBA32F: number;
  55216. R32F: number;
  55217. RG32F: number;
  55218. RGB32F: number;
  55219. R16F: number;
  55220. RG16F: number;
  55221. RGB16F: number;
  55222. RED: number;
  55223. RG: number;
  55224. R8: number;
  55225. RG8: number;
  55226. UNSIGNED_INT_24_8: number;
  55227. DEPTH24_STENCIL8: number;
  55228. /* Multiple Render Targets */
  55229. drawBuffers(buffers: number[]): void;
  55230. readBuffer(src: number): void;
  55231. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  55232. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  55233. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  55234. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  55235. // Occlusion Query
  55236. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  55237. ANY_SAMPLES_PASSED: number;
  55238. QUERY_RESULT_AVAILABLE: number;
  55239. QUERY_RESULT: number;
  55240. }
  55241. interface WebGLBuffer {
  55242. references: number;
  55243. capacity: number;
  55244. is32Bits: boolean;
  55245. }
  55246. interface WebGLProgram {
  55247. transformFeedback?: WebGLTransformFeedback | null; private _SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  55248. }
  55249. interface EXT_disjoint_timer_query {
  55250. QUERY_COUNTER_BITS_EXT: number;
  55251. TIME_ELAPSED_EXT: number;
  55252. TIMESTAMP_EXT: number;
  55253. GPU_DISJOINT_EXT: number;
  55254. QUERY_RESULT_EXT: number;
  55255. QUERY_RESULT_AVAILABLE_EXT: number;
  55256. queryCounterEXT(query: WebGLQuery, target: number): void;
  55257. createQueryEXT(): WebGLQuery;
  55258. beginQueryEXT(target: number, query: WebGLQuery): void;
  55259. endQueryEXT(target: number): void;
  55260. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  55261. deleteQueryEXT(query: WebGLQuery): void;
  55262. }
  55263. interface WebGLUniformLocation { currentState: any;
  55264. }
  55265. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  55266. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  55267. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  55268. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55269. interface WebGLRenderingContext {
  55270. readonly RASTERIZER_DISCARD: number;
  55271. readonly DEPTH_COMPONENT24: number;
  55272. readonly TEXTURE_3D: number;
  55273. readonly TEXTURE_2D_ARRAY: number;
  55274. readonly TEXTURE_COMPARE_FUNC: number;
  55275. readonly TEXTURE_COMPARE_MODE: number;
  55276. readonly COMPARE_REF_TO_TEXTURE: number;
  55277. readonly TEXTURE_WRAP_R: number;
  55278. readonly HALF_FLOAT: number;
  55279. readonly RGB8: number;
  55280. readonly RED_INTEGER: number;
  55281. readonly RG_INTEGER: number;
  55282. readonly RGB_INTEGER: number;
  55283. readonly RGBA_INTEGER: number;
  55284. readonly R8_SNORM: number;
  55285. readonly RG8_SNORM: number;
  55286. readonly RGB8_SNORM: number;
  55287. readonly RGBA8_SNORM: number;
  55288. readonly R8I: number;
  55289. readonly RG8I: number;
  55290. readonly RGB8I: number;
  55291. readonly RGBA8I: number;
  55292. readonly R8UI: number;
  55293. readonly RG8UI: number;
  55294. readonly RGB8UI: number;
  55295. readonly RGBA8UI: number;
  55296. readonly R16I: number;
  55297. readonly RG16I: number;
  55298. readonly RGB16I: number;
  55299. readonly RGBA16I: number;
  55300. readonly R16UI: number;
  55301. readonly RG16UI: number;
  55302. readonly RGB16UI: number;
  55303. readonly RGBA16UI: number;
  55304. readonly R32I: number;
  55305. readonly RG32I: number;
  55306. readonly RGB32I: number;
  55307. readonly RGBA32I: number;
  55308. readonly R32UI: number;
  55309. readonly RG32UI: number;
  55310. readonly RGB32UI: number;
  55311. readonly RGBA32UI: number;
  55312. readonly RGB10_A2UI: number;
  55313. readonly R11F_G11F_B10F: number;
  55314. readonly RGB9_E5: number;
  55315. readonly RGB10_A2: number;
  55316. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  55317. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  55318. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  55319. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  55320. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  55321. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  55322. 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;
  55323. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  55324. readonly TRANSFORM_FEEDBACK: number;
  55325. readonly INTERLEAVED_ATTRIBS: number;
  55326. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  55327. createTransformFeedback(): WebGLTransformFeedback;
  55328. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  55329. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  55330. beginTransformFeedback(primitiveMode: number): void;
  55331. endTransformFeedback(): void;
  55332. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  55333. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55334. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55335. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  55336. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  55337. }
  55338. interface ImageBitmap {
  55339. readonly width: number;
  55340. readonly height: number;
  55341. close(): void;
  55342. }
  55343. interface WebGLQuery extends WebGLObject {
  55344. }
  55345. declare var WebGLQuery: {
  55346. prototype: WebGLQuery;
  55347. new(): WebGLQuery;
  55348. };
  55349. interface WebGLSampler extends WebGLObject {
  55350. }
  55351. declare var WebGLSampler: {
  55352. prototype: WebGLSampler;
  55353. new(): WebGLSampler;
  55354. };
  55355. interface WebGLSync extends WebGLObject {
  55356. }
  55357. declare var WebGLSync: {
  55358. prototype: WebGLSync;
  55359. new(): WebGLSync;
  55360. };
  55361. interface WebGLTransformFeedback extends WebGLObject {
  55362. }
  55363. declare var WebGLTransformFeedback: {
  55364. prototype: WebGLTransformFeedback;
  55365. new(): WebGLTransformFeedback;
  55366. };
  55367. interface WebGLVertexArrayObject extends WebGLObject {
  55368. }
  55369. declare var WebGLVertexArrayObject: {
  55370. prototype: WebGLVertexArrayObject;
  55371. new(): WebGLVertexArrayObject;
  55372. };
  55373. // Type definitions for WebVR API
  55374. // Project: https://w3c.github.io/webvr/
  55375. // Definitions by: six a <https://github.com/lostfictions>
  55376. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  55377. interface VRDisplay extends EventTarget {
  55378. /**
  55379. * Dictionary of capabilities describing the VRDisplay.
  55380. */
  55381. readonly capabilities: VRDisplayCapabilities;
  55382. /**
  55383. * z-depth defining the far plane of the eye view frustum
  55384. * enables mapping of values in the render target depth
  55385. * attachment to scene coordinates. Initially set to 10000.0.
  55386. */
  55387. depthFar: number;
  55388. /**
  55389. * z-depth defining the near plane of the eye view frustum
  55390. * enables mapping of values in the render target depth
  55391. * attachment to scene coordinates. Initially set to 0.01.
  55392. */
  55393. depthNear: number;
  55394. /**
  55395. * An identifier for this distinct VRDisplay. Used as an
  55396. * association point in the Gamepad API.
  55397. */
  55398. readonly displayId: number;
  55399. /**
  55400. * A display name, a user-readable name identifying it.
  55401. */
  55402. readonly displayName: string;
  55403. readonly isConnected: boolean;
  55404. readonly isPresenting: boolean;
  55405. /**
  55406. * If this VRDisplay supports room-scale experiences, the optional
  55407. * stage attribute contains details on the room-scale parameters.
  55408. */
  55409. readonly stageParameters: VRStageParameters | null;
  55410. /**
  55411. * Passing the value returned by `requestAnimationFrame` to
  55412. * `cancelAnimationFrame` will unregister the callback.
  55413. * @param handle Define the hanle of the request to cancel
  55414. */
  55415. cancelAnimationFrame(handle: number): void;
  55416. /**
  55417. * Stops presenting to the VRDisplay.
  55418. * @returns a promise to know when it stopped
  55419. */
  55420. exitPresent(): Promise<void>;
  55421. /**
  55422. * Return the current VREyeParameters for the given eye.
  55423. * @param whichEye Define the eye we want the parameter for
  55424. * @returns the eye parameters
  55425. */
  55426. getEyeParameters(whichEye: string): VREyeParameters;
  55427. /**
  55428. * Populates the passed VRFrameData with the information required to render
  55429. * the current frame.
  55430. * @param frameData Define the data structure to populate
  55431. * @returns true if ok otherwise false
  55432. */
  55433. getFrameData(frameData: VRFrameData): boolean;
  55434. /**
  55435. * Get the layers currently being presented.
  55436. * @returns the list of VR layers
  55437. */
  55438. getLayers(): VRLayer[];
  55439. /**
  55440. * Return a VRPose containing the future predicted pose of the VRDisplay
  55441. * when the current frame will be presented. The value returned will not
  55442. * change until JavaScript has returned control to the browser.
  55443. *
  55444. * The VRPose will contain the position, orientation, velocity,
  55445. * and acceleration of each of these properties.
  55446. * @returns the pose object
  55447. */
  55448. getPose(): VRPose;
  55449. /**
  55450. * Return the current instantaneous pose of the VRDisplay, with no
  55451. * prediction applied.
  55452. * @returns the current instantaneous pose
  55453. */
  55454. getImmediatePose(): VRPose;
  55455. /**
  55456. * The callback passed to `requestAnimationFrame` will be called
  55457. * any time a new frame should be rendered. When the VRDisplay is
  55458. * presenting the callback will be called at the native refresh
  55459. * rate of the HMD. When not presenting this function acts
  55460. * identically to how window.requestAnimationFrame acts. Content should
  55461. * make no assumptions of frame rate or vsync behavior as the HMD runs
  55462. * asynchronously from other displays and at differing refresh rates.
  55463. * @param callback Define the eaction to run next frame
  55464. * @returns the request handle it
  55465. */
  55466. requestAnimationFrame(callback: FrameRequestCallback): number;
  55467. /**
  55468. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  55469. * Repeat calls while already presenting will update the VRLayers being displayed.
  55470. * @param layers Define the list of layer to present
  55471. * @returns a promise to know when the request has been fulfilled
  55472. */
  55473. requestPresent(layers: VRLayer[]): Promise<void>;
  55474. /**
  55475. * Reset the pose for this display, treating its current position and
  55476. * orientation as the "origin/zero" values. VRPose.position,
  55477. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  55478. * updated when calling resetPose(). This should be called in only
  55479. * sitting-space experiences.
  55480. */
  55481. resetPose(): void;
  55482. /**
  55483. * The VRLayer provided to the VRDisplay will be captured and presented
  55484. * in the HMD. Calling this function has the same effect on the source
  55485. * canvas as any other operation that uses its source image, and canvases
  55486. * created without preserveDrawingBuffer set to true will be cleared.
  55487. * @param pose Define the pose to submit
  55488. */
  55489. submitFrame(pose?: VRPose): void;
  55490. }
  55491. declare var VRDisplay: {
  55492. prototype: VRDisplay;
  55493. new(): VRDisplay;
  55494. };
  55495. interface VRLayer {
  55496. leftBounds?: number[] | Float32Array | null;
  55497. rightBounds?: number[] | Float32Array | null;
  55498. source?: HTMLCanvasElement | null;
  55499. }
  55500. interface VRDisplayCapabilities {
  55501. readonly canPresent: boolean;
  55502. readonly hasExternalDisplay: boolean;
  55503. readonly hasOrientation: boolean;
  55504. readonly hasPosition: boolean;
  55505. readonly maxLayers: number;
  55506. }
  55507. interface VREyeParameters {
  55508. /** @deprecated */
  55509. readonly fieldOfView: VRFieldOfView;
  55510. readonly offset: Float32Array;
  55511. readonly renderHeight: number;
  55512. readonly renderWidth: number;
  55513. }
  55514. interface VRFieldOfView {
  55515. readonly downDegrees: number;
  55516. readonly leftDegrees: number;
  55517. readonly rightDegrees: number;
  55518. readonly upDegrees: number;
  55519. }
  55520. interface VRFrameData {
  55521. readonly leftProjectionMatrix: Float32Array;
  55522. readonly leftViewMatrix: Float32Array;
  55523. readonly pose: VRPose;
  55524. readonly rightProjectionMatrix: Float32Array;
  55525. readonly rightViewMatrix: Float32Array;
  55526. readonly timestamp: number;
  55527. }
  55528. interface VRPose {
  55529. readonly angularAcceleration: Float32Array | null;
  55530. readonly angularVelocity: Float32Array | null;
  55531. readonly linearAcceleration: Float32Array | null;
  55532. readonly linearVelocity: Float32Array | null;
  55533. readonly orientation: Float32Array | null;
  55534. readonly position: Float32Array | null;
  55535. readonly timestamp: number;
  55536. }
  55537. interface VRStageParameters {
  55538. sittingToStandingTransform?: Float32Array;
  55539. sizeX?: number;
  55540. sizeY?: number;
  55541. }
  55542. interface Navigator {
  55543. getVRDisplays(): Promise<VRDisplay[]>;
  55544. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  55545. }
  55546. interface Window {
  55547. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  55548. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  55549. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  55550. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55551. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  55552. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  55553. }
  55554. interface Gamepad {
  55555. readonly displayId: number;
  55556. }
  55557. interface XRDevice {
  55558. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  55559. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  55560. }
  55561. interface XRSession {
  55562. getInputSources(): Array<any>;
  55563. baseLayer: XRWebGLLayer;
  55564. requestFrameOfReference(type: string): Promise<void>;
  55565. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  55566. end(): Promise<void>;
  55567. requestAnimationFrame: Function;
  55568. addEventListener: Function;
  55569. }
  55570. interface XRSessionCreationOptions {
  55571. outputContext?: WebGLRenderingContext | null;
  55572. immersive?: boolean;
  55573. environmentIntegration?: boolean;
  55574. }
  55575. interface XRLayer {
  55576. getViewport: Function;
  55577. framebufferWidth: number;
  55578. framebufferHeight: number;
  55579. }
  55580. interface XRView {
  55581. projectionMatrix: Float32Array;
  55582. }
  55583. interface XRFrame {
  55584. getDevicePose: Function;
  55585. getInputPose: Function;
  55586. views: Array<XRView>;
  55587. baseLayer: XRLayer;
  55588. }
  55589. interface XRFrameOfReference {
  55590. }
  55591. interface XRWebGLLayer extends XRLayer {
  55592. framebuffer: WebGLFramebuffer;
  55593. }
  55594. declare var XRWebGLLayer: {
  55595. prototype: XRWebGLLayer;
  55596. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  55597. };
  55598. declare module BABYLON.GUI {
  55599. /**
  55600. * Class used to specific a value and its associated unit
  55601. */
  55602. export class ValueAndUnit {
  55603. /** defines the unit to store */
  55604. unit: number;
  55605. /** defines a boolean indicating if the value can be negative */
  55606. negativeValueAllowed: boolean;
  55607. private _value;
  55608. private _originalUnit;
  55609. /**
  55610. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  55611. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  55612. */
  55613. ignoreAdaptiveScaling: boolean;
  55614. /**
  55615. * Creates a new ValueAndUnit
  55616. * @param value defines the value to store
  55617. * @param unit defines the unit to store
  55618. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  55619. */
  55620. constructor(value: number,
  55621. /** defines the unit to store */
  55622. unit?: number,
  55623. /** defines a boolean indicating if the value can be negative */
  55624. negativeValueAllowed?: boolean);
  55625. /** Gets a boolean indicating if the value is a percentage */
  55626. readonly isPercentage: boolean;
  55627. /** Gets a boolean indicating if the value is store as pixel */
  55628. readonly isPixel: boolean;
  55629. /** Gets direct internal value */
  55630. readonly internalValue: number;
  55631. /**
  55632. * Gets value as pixel
  55633. * @param host defines the root host
  55634. * @param refValue defines the reference value for percentages
  55635. * @returns the value as pixel
  55636. */
  55637. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  55638. /**
  55639. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  55640. * @param value defines the value to store
  55641. * @param unit defines the unit to store
  55642. * @returns the current ValueAndUnit
  55643. */
  55644. updateInPlace(value: number, unit?: number): ValueAndUnit;
  55645. /**
  55646. * Gets the value accordingly to its unit
  55647. * @param host defines the root host
  55648. * @returns the value
  55649. */
  55650. getValue(host: AdvancedDynamicTexture): number;
  55651. /**
  55652. * Gets a string representation of the value
  55653. * @param host defines the root host
  55654. * @param decimals defines an optional number of decimals to display
  55655. * @returns a string
  55656. */
  55657. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  55658. /**
  55659. * Store a value parsed from a string
  55660. * @param source defines the source string
  55661. * @returns true if the value was successfully parsed
  55662. */
  55663. fromString(source: string | number): boolean;
  55664. private static _Regex;
  55665. private static _UNITMODE_PERCENTAGE;
  55666. private static _UNITMODE_PIXEL;
  55667. /** UNITMODE_PERCENTAGE */
  55668. static readonly UNITMODE_PERCENTAGE: number;
  55669. /** UNITMODE_PIXEL */
  55670. static readonly UNITMODE_PIXEL: number;
  55671. }
  55672. }
  55673. declare module BABYLON.GUI {
  55674. /**
  55675. * Define a style used by control to automatically setup properties based on a template.
  55676. * Only support font related properties so far
  55677. */
  55678. export class Style implements BABYLON.IDisposable {
  55679. private _fontFamily;
  55680. private _fontStyle;
  55681. private _fontWeight;
  55682. /** @hidden */ host: AdvancedDynamicTexture;
  55683. /** @hidden */ fontSize: ValueAndUnit;
  55684. /**
  55685. * BABYLON.Observable raised when the style values are changed
  55686. */
  55687. onChangedObservable: BABYLON.Observable<Style>;
  55688. /**
  55689. * Creates a new style object
  55690. * @param host defines the AdvancedDynamicTexture which hosts this style
  55691. */
  55692. constructor(host: AdvancedDynamicTexture);
  55693. /**
  55694. * Gets or sets the font size
  55695. */
  55696. fontSize: string | number;
  55697. /**
  55698. * Gets or sets the font family
  55699. */
  55700. fontFamily: string;
  55701. /**
  55702. * Gets or sets the font style
  55703. */
  55704. fontStyle: string;
  55705. /** Gets or sets font weight */
  55706. fontWeight: string;
  55707. /** Dispose all associated resources */
  55708. dispose(): void;
  55709. }
  55710. }
  55711. declare module BABYLON.GUI {
  55712. /**
  55713. * Class used to transport BABYLON.Vector2 information for pointer events
  55714. */
  55715. export class Vector2WithInfo extends BABYLON.Vector2 {
  55716. /** defines the current mouse button index */
  55717. buttonIndex: number;
  55718. /**
  55719. * Creates a new Vector2WithInfo
  55720. * @param source defines the vector2 data to transport
  55721. * @param buttonIndex defines the current mouse button index
  55722. */
  55723. constructor(source: BABYLON.Vector2,
  55724. /** defines the current mouse button index */
  55725. buttonIndex?: number);
  55726. }
  55727. /** Class used to provide 2D matrix features */
  55728. export class Matrix2D {
  55729. /** Gets the internal array of 6 floats used to store matrix data */
  55730. m: Float32Array;
  55731. /**
  55732. * Creates a new matrix
  55733. * @param m00 defines value for (0, 0)
  55734. * @param m01 defines value for (0, 1)
  55735. * @param m10 defines value for (1, 0)
  55736. * @param m11 defines value for (1, 1)
  55737. * @param m20 defines value for (2, 0)
  55738. * @param m21 defines value for (2, 1)
  55739. */
  55740. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  55741. /**
  55742. * Fills the matrix from direct values
  55743. * @param m00 defines value for (0, 0)
  55744. * @param m01 defines value for (0, 1)
  55745. * @param m10 defines value for (1, 0)
  55746. * @param m11 defines value for (1, 1)
  55747. * @param m20 defines value for (2, 0)
  55748. * @param m21 defines value for (2, 1)
  55749. * @returns the current modified matrix
  55750. */
  55751. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  55752. /**
  55753. * Gets matrix determinant
  55754. * @returns the determinant
  55755. */
  55756. determinant(): number;
  55757. /**
  55758. * Inverses the matrix and stores it in a target matrix
  55759. * @param result defines the target matrix
  55760. * @returns the current matrix
  55761. */
  55762. invertToRef(result: Matrix2D): Matrix2D;
  55763. /**
  55764. * Multiplies the current matrix with another one
  55765. * @param other defines the second operand
  55766. * @param result defines the target matrix
  55767. * @returns the current matrix
  55768. */
  55769. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  55770. /**
  55771. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  55772. * @param x defines the x coordinate to transform
  55773. * @param y defines the x coordinate to transform
  55774. * @param result defines the target vector2
  55775. * @returns the current matrix
  55776. */
  55777. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  55778. /**
  55779. * Creates an identity matrix
  55780. * @returns a new matrix
  55781. */
  55782. static Identity(): Matrix2D;
  55783. /**
  55784. * Creates a translation matrix and stores it in a target matrix
  55785. * @param x defines the x coordinate of the translation
  55786. * @param y defines the y coordinate of the translation
  55787. * @param result defines the target matrix
  55788. */
  55789. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  55790. /**
  55791. * Creates a scaling matrix and stores it in a target matrix
  55792. * @param x defines the x coordinate of the scaling
  55793. * @param y defines the y coordinate of the scaling
  55794. * @param result defines the target matrix
  55795. */
  55796. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  55797. /**
  55798. * Creates a rotation matrix and stores it in a target matrix
  55799. * @param angle defines the rotation angle
  55800. * @param result defines the target matrix
  55801. */
  55802. static RotationToRef(angle: number, result: Matrix2D): void;
  55803. private static _TempPreTranslationMatrix;
  55804. private static _TempPostTranslationMatrix;
  55805. private static _TempRotationMatrix;
  55806. private static _TempScalingMatrix;
  55807. private static _TempCompose0;
  55808. private static _TempCompose1;
  55809. private static _TempCompose2;
  55810. /**
  55811. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  55812. * @param tx defines the x coordinate of the translation
  55813. * @param ty defines the y coordinate of the translation
  55814. * @param angle defines the rotation angle
  55815. * @param scaleX defines the x coordinate of the scaling
  55816. * @param scaleY defines the y coordinate of the scaling
  55817. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  55818. * @param result defines the target matrix
  55819. */
  55820. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  55821. }
  55822. }
  55823. declare module BABYLON.GUI {
  55824. /**
  55825. * Class used to store 2D control sizes
  55826. */
  55827. export class Measure {
  55828. /** defines left coordinate */
  55829. left: number;
  55830. /** defines top coordinate */
  55831. top: number;
  55832. /** defines width dimension */
  55833. width: number;
  55834. /** defines height dimension */
  55835. height: number;
  55836. /**
  55837. * Creates a new measure
  55838. * @param left defines left coordinate
  55839. * @param top defines top coordinate
  55840. * @param width defines width dimension
  55841. * @param height defines height dimension
  55842. */
  55843. constructor(
  55844. /** defines left coordinate */
  55845. left: number,
  55846. /** defines top coordinate */
  55847. top: number,
  55848. /** defines width dimension */
  55849. width: number,
  55850. /** defines height dimension */
  55851. height: number);
  55852. /**
  55853. * Copy from another measure
  55854. * @param other defines the other measure to copy from
  55855. */
  55856. copyFrom(other: Measure): void;
  55857. /**
  55858. * Copy from a group of 4 floats
  55859. * @param left defines left coordinate
  55860. * @param top defines top coordinate
  55861. * @param width defines width dimension
  55862. * @param height defines height dimension
  55863. */
  55864. copyFromFloats(left: number, top: number, width: number, height: number): void;
  55865. /**
  55866. * Computes the axis aligned bounding box measure for two given measures
  55867. * @param a Input measure
  55868. * @param b Input measure
  55869. * @param result the resulting bounding measure
  55870. */
  55871. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  55872. /**
  55873. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  55874. * @param transform the matrix to transform the measure before computing the AABB
  55875. * @param result the resulting AABB
  55876. */
  55877. transformToRef(transform: Matrix2D, result: Measure): void;
  55878. /**
  55879. * Check equality between this measure and another one
  55880. * @param other defines the other measures
  55881. * @returns true if both measures are equals
  55882. */
  55883. isEqualsTo(other: Measure): boolean;
  55884. /**
  55885. * Creates an empty measure
  55886. * @returns a new measure
  55887. */
  55888. static Empty(): Measure;
  55889. }
  55890. }
  55891. declare module BABYLON.GUI {
  55892. /**
  55893. * Interface used to define a control that can receive focus
  55894. */
  55895. export interface IFocusableControl {
  55896. /**
  55897. * Function called when the control receives the focus
  55898. */
  55899. onFocus(): void;
  55900. /**
  55901. * Function called when the control loses the focus
  55902. */
  55903. onBlur(): void;
  55904. /**
  55905. * Function called to let the control handle keyboard events
  55906. * @param evt defines the current keyboard event
  55907. */
  55908. processKeyboard(evt: KeyboardEvent): void;
  55909. /**
  55910. * Function called to get the list of controls that should not steal the focus from this control
  55911. * @returns an array of controls
  55912. */
  55913. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  55914. }
  55915. /**
  55916. * Class used to create texture to support 2D GUI elements
  55917. * @see http://doc.babylonjs.com/how_to/gui
  55918. */
  55919. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  55920. private _isDirty;
  55921. private _renderObserver;
  55922. private _resizeObserver;
  55923. private _preKeyboardObserver;
  55924. private _pointerMoveObserver;
  55925. private _pointerObserver;
  55926. private _canvasPointerOutObserver;
  55927. private _background;
  55928. /** @hidden */ rootContainer: Container;
  55929. /** @hidden */ lastPickedControl: Control;
  55930. /** @hidden */ lastControlOver: {
  55931. [pointerId: number]: Control;
  55932. };
  55933. /** @hidden */ lastControlDown: {
  55934. [pointerId: number]: Control;
  55935. };
  55936. /** @hidden */ capturingControl: {
  55937. [pointerId: number]: Control;
  55938. };
  55939. /** @hidden */ shouldBlockPointer: boolean;
  55940. /** @hidden */ layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  55941. /** @hidden */ linkedControls: Control[];
  55942. private _isFullscreen;
  55943. private _fullscreenViewport;
  55944. private _idealWidth;
  55945. private _idealHeight;
  55946. private _useSmallestIdeal;
  55947. private _renderAtIdealSize;
  55948. private _focusedControl;
  55949. private _blockNextFocusCheck;
  55950. private _renderScale;
  55951. private _rootCanvas;
  55952. private _cursorChanged;
  55953. /**
  55954. * Define type to string to ensure compatibility across browsers
  55955. * Safari doesn't support DataTransfer constructor
  55956. */
  55957. private _clipboardData;
  55958. /**
  55959. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  55960. */
  55961. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  55962. /**
  55963. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  55964. */
  55965. onControlPickedObservable: BABYLON.Observable<Control>;
  55966. /**
  55967. * BABYLON.Observable event triggered before layout is evaluated
  55968. */
  55969. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  55970. /**
  55971. * BABYLON.Observable event triggered after the layout was evaluated
  55972. */
  55973. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  55974. /**
  55975. * BABYLON.Observable event triggered before the texture is rendered
  55976. */
  55977. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  55978. /**
  55979. * BABYLON.Observable event triggered after the texture was rendered
  55980. */
  55981. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  55982. /**
  55983. * Gets or sets a boolean defining if alpha is stored as premultiplied
  55984. */
  55985. premulAlpha: boolean;
  55986. /**
  55987. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  55988. * Useful when you want more antialiasing
  55989. */
  55990. renderScale: number;
  55991. /** Gets or sets the background color */
  55992. background: string;
  55993. /**
  55994. * Gets or sets the ideal width used to design controls.
  55995. * The GUI will then rescale everything accordingly
  55996. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  55997. */
  55998. idealWidth: number;
  55999. /**
  56000. * Gets or sets the ideal height used to design controls.
  56001. * The GUI will then rescale everything accordingly
  56002. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56003. */
  56004. idealHeight: number;
  56005. /**
  56006. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  56007. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56008. */
  56009. useSmallestIdeal: boolean;
  56010. /**
  56011. * Gets or sets a boolean indicating if adaptive scaling must be used
  56012. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  56013. */
  56014. renderAtIdealSize: boolean;
  56015. /**
  56016. * Gets the underlying layer used to render the texture when in fullscreen mode
  56017. */
  56018. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  56019. /**
  56020. * Gets the root container control
  56021. */
  56022. readonly rootContainer: Container;
  56023. /**
  56024. * Returns an array containing the root container.
  56025. * This is mostly used to let the Inspector introspects the ADT
  56026. * @returns an array containing the rootContainer
  56027. */
  56028. getChildren(): Array<Container>;
  56029. /**
  56030. * Will return all controls that are inside this texture
  56031. * @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
  56032. * @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
  56033. * @return all child controls
  56034. */
  56035. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56036. /**
  56037. * Gets or sets the current focused control
  56038. */
  56039. focusedControl: BABYLON.Nullable<IFocusableControl>;
  56040. /**
  56041. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  56042. */
  56043. isForeground: boolean;
  56044. /**
  56045. * Gets or set information about clipboardData
  56046. */
  56047. clipboardData: string;
  56048. /**
  56049. * Creates a new AdvancedDynamicTexture
  56050. * @param name defines the name of the texture
  56051. * @param width defines the width of the texture
  56052. * @param height defines the height of the texture
  56053. * @param scene defines the hosting scene
  56054. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  56055. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  56056. */
  56057. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  56058. /**
  56059. * Get the current class name of the texture useful for serialization or dynamic coding.
  56060. * @returns "AdvancedDynamicTexture"
  56061. */
  56062. getClassName(): string;
  56063. /**
  56064. * Function used to execute a function on all controls
  56065. * @param func defines the function to execute
  56066. * @param container defines the container where controls belong. If null the root container will be used
  56067. */
  56068. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  56069. private _useInvalidateRectOptimization;
  56070. /**
  56071. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  56072. */
  56073. useInvalidateRectOptimization: boolean;
  56074. private _invalidatedRectangle;
  56075. /**
  56076. * Invalidates a rectangle area on the gui texture
  56077. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  56078. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  56079. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  56080. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  56081. */
  56082. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  56083. /**
  56084. * Marks the texture as dirty forcing a complete update
  56085. */
  56086. markAsDirty(): void;
  56087. /**
  56088. * Helper function used to create a new style
  56089. * @returns a new style
  56090. * @see http://doc.babylonjs.com/how_to/gui#styles
  56091. */
  56092. createStyle(): Style;
  56093. /**
  56094. * Adds a new control to the root container
  56095. * @param control defines the control to add
  56096. * @returns the current texture
  56097. */
  56098. addControl(control: Control): AdvancedDynamicTexture;
  56099. /**
  56100. * Removes a control from the root container
  56101. * @param control defines the control to remove
  56102. * @returns the current texture
  56103. */
  56104. removeControl(control: Control): AdvancedDynamicTexture;
  56105. /**
  56106. * Release all resources
  56107. */
  56108. dispose(): void;
  56109. private _onResize;
  56110. /** @hidden */ getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  56111. /**
  56112. * Get screen coordinates for a vector3
  56113. * @param position defines the position to project
  56114. * @param worldMatrix defines the world matrix to use
  56115. * @returns the projected position
  56116. */
  56117. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  56118. private _checkUpdate;
  56119. private _clearMeasure;
  56120. private _render;
  56121. /** @hidden */ changeCursor(cursor: string): void;
  56122. /** @hidden */ registerLastControlDown(control: Control, pointerId: number): void;
  56123. private _doPicking;
  56124. /** @hidden */ cleanControlAfterRemovalFromList(list: {
  56125. [pointerId: number]: Control;
  56126. }, control: Control): void;
  56127. /** @hidden */ cleanControlAfterRemoval(control: Control): void;
  56128. /** Attach to all scene events required to support pointer events */
  56129. attach(): void;
  56130. /** @hidden */
  56131. private onClipboardCopy;
  56132. /** @hidden */
  56133. private onClipboardCut;
  56134. /** @hidden */
  56135. private onClipboardPaste;
  56136. /**
  56137. * Register the clipboard Events onto the canvas
  56138. */
  56139. registerClipboardEvents(): void;
  56140. /**
  56141. * Unregister the clipboard Events from the canvas
  56142. */
  56143. unRegisterClipboardEvents(): void;
  56144. /**
  56145. * Connect the texture to a hosting mesh to enable interactions
  56146. * @param mesh defines the mesh to attach to
  56147. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  56148. */
  56149. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  56150. /**
  56151. * Move the focus to a specific control
  56152. * @param control defines the control which will receive the focus
  56153. */
  56154. moveFocusToControl(control: IFocusableControl): void;
  56155. private _manageFocus;
  56156. private _attachToOnPointerOut;
  56157. /**
  56158. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  56159. * @param mesh defines the mesh which will receive the texture
  56160. * @param width defines the texture width (1024 by default)
  56161. * @param height defines the texture height (1024 by default)
  56162. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  56163. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  56164. * @returns a new AdvancedDynamicTexture
  56165. */
  56166. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  56167. /**
  56168. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  56169. * In this mode the texture will rely on a layer for its rendering.
  56170. * This allows it to be treated like any other layer.
  56171. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  56172. * LayerMask is set through advancedTexture.layer.layerMask
  56173. * @param name defines name for the texture
  56174. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  56175. * @param scene defines the hsoting scene
  56176. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  56177. * @returns a new AdvancedDynamicTexture
  56178. */
  56179. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  56180. }
  56181. }
  56182. declare module BABYLON.GUI {
  56183. /**
  56184. * Root class used for all 2D controls
  56185. * @see http://doc.babylonjs.com/how_to/gui#controls
  56186. */
  56187. export class Control {
  56188. /** defines the name of the control */
  56189. name?: string | undefined;
  56190. /**
  56191. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  56192. */
  56193. static AllowAlphaInheritance: boolean;
  56194. private _alpha;
  56195. private _alphaSet;
  56196. private _zIndex;
  56197. /** @hidden */ host: AdvancedDynamicTexture;
  56198. /** Gets or sets the control parent */
  56199. parent: BABYLON.Nullable<Container>;
  56200. /** @hidden */ currentMeasure: Measure;
  56201. private _fontFamily;
  56202. private _fontStyle;
  56203. private _fontWeight;
  56204. private _fontSize;
  56205. private _font;
  56206. /** @hidden */ width: ValueAndUnit;
  56207. /** @hidden */ height: ValueAndUnit;
  56208. /** @hidden */
  56209. protected _fontOffset: {
  56210. ascent: number;
  56211. height: number;
  56212. descent: number;
  56213. };
  56214. private _color;
  56215. private _style;
  56216. private _styleObserver;
  56217. /** @hidden */
  56218. protected _horizontalAlignment: number;
  56219. /** @hidden */
  56220. protected _verticalAlignment: number;
  56221. /** @hidden */
  56222. protected _isDirty: boolean;
  56223. /** @hidden */
  56224. protected _wasDirty: boolean;
  56225. /** @hidden */ tempParentMeasure: Measure;
  56226. /** @hidden */ prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  56227. /** @hidden */
  56228. protected _cachedParentMeasure: Measure;
  56229. private _paddingLeft;
  56230. private _paddingRight;
  56231. private _paddingTop;
  56232. private _paddingBottom;
  56233. /** @hidden */ left: ValueAndUnit;
  56234. /** @hidden */ top: ValueAndUnit;
  56235. private _scaleX;
  56236. private _scaleY;
  56237. private _rotation;
  56238. private _transformCenterX;
  56239. private _transformCenterY;
  56240. /** @hidden */ transformMatrix: Matrix2D;
  56241. /** @hidden */
  56242. protected _invertTransformMatrix: Matrix2D;
  56243. /** @hidden */
  56244. protected _transformedPosition: BABYLON.Vector2;
  56245. private _isMatrixDirty;
  56246. private _cachedOffsetX;
  56247. private _cachedOffsetY;
  56248. private _isVisible;
  56249. private _isHighlighted;
  56250. /** @hidden */ linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56251. private _fontSet;
  56252. private _dummyVector2;
  56253. private _downCount;
  56254. private _enterCount;
  56255. private _doNotRender;
  56256. private _downPointerIds;
  56257. protected _isEnabled: boolean;
  56258. protected _disabledColor: string;
  56259. /** @hidden */
  56260. protected _rebuildLayout: boolean;
  56261. /** @hidden */ isClipped: boolean;
  56262. /** @hidden */ tag: any;
  56263. /**
  56264. * 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
  56265. */
  56266. uniqueId: number;
  56267. /**
  56268. * Gets or sets an object used to store user defined information for the node
  56269. */
  56270. metadata: any;
  56271. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  56272. isHitTestVisible: boolean;
  56273. /** Gets or sets a boolean indicating if the control can block pointer events */
  56274. isPointerBlocker: boolean;
  56275. /** Gets or sets a boolean indicating if the control can be focusable */
  56276. isFocusInvisible: boolean;
  56277. /**
  56278. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  56279. * 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
  56280. */
  56281. clipChildren: boolean;
  56282. /**
  56283. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  56284. */
  56285. useBitmapCache: boolean;
  56286. private _cacheData;
  56287. private _shadowOffsetX;
  56288. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  56289. shadowOffsetX: number;
  56290. private _shadowOffsetY;
  56291. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  56292. shadowOffsetY: number;
  56293. private _shadowBlur;
  56294. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  56295. shadowBlur: number;
  56296. private _shadowColor;
  56297. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  56298. shadowColor: string;
  56299. /** Gets or sets the cursor to use when the control is hovered */
  56300. hoverCursor: string;
  56301. /** @hidden */
  56302. protected _linkOffsetX: ValueAndUnit;
  56303. /** @hidden */
  56304. protected _linkOffsetY: ValueAndUnit;
  56305. /** Gets the control type name */
  56306. readonly typeName: string;
  56307. /**
  56308. * Get the current class name of the control.
  56309. * @returns current class name
  56310. */
  56311. getClassName(): string;
  56312. /**
  56313. * An event triggered when the pointer move over the control.
  56314. */
  56315. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  56316. /**
  56317. * An event triggered when the pointer move out of the control.
  56318. */
  56319. onPointerOutObservable: BABYLON.Observable<Control>;
  56320. /**
  56321. * An event triggered when the pointer taps the control
  56322. */
  56323. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  56324. /**
  56325. * An event triggered when pointer up
  56326. */
  56327. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  56328. /**
  56329. * An event triggered when a control is clicked on
  56330. */
  56331. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  56332. /**
  56333. * An event triggered when pointer enters the control
  56334. */
  56335. onPointerEnterObservable: BABYLON.Observable<Control>;
  56336. /**
  56337. * An event triggered when the control is marked as dirty
  56338. */
  56339. onDirtyObservable: BABYLON.Observable<Control>;
  56340. /**
  56341. * An event triggered before drawing the control
  56342. */
  56343. onBeforeDrawObservable: BABYLON.Observable<Control>;
  56344. /**
  56345. * An event triggered after the control was drawn
  56346. */
  56347. onAfterDrawObservable: BABYLON.Observable<Control>;
  56348. /**
  56349. * Get the hosting AdvancedDynamicTexture
  56350. */
  56351. readonly host: AdvancedDynamicTexture;
  56352. /** Gets or set information about font offsets (used to render and align text) */
  56353. fontOffset: {
  56354. ascent: number;
  56355. height: number;
  56356. descent: number;
  56357. };
  56358. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  56359. alpha: number;
  56360. /**
  56361. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  56362. */
  56363. isHighlighted: boolean;
  56364. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  56365. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56366. */
  56367. scaleX: number;
  56368. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  56369. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56370. */
  56371. scaleY: number;
  56372. /** Gets or sets the rotation angle (0 by default)
  56373. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56374. */
  56375. rotation: number;
  56376. /** Gets or sets the transformation center on Y axis (0 by default)
  56377. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56378. */
  56379. transformCenterY: number;
  56380. /** Gets or sets the transformation center on X axis (0 by default)
  56381. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  56382. */
  56383. transformCenterX: number;
  56384. /**
  56385. * Gets or sets the horizontal alignment
  56386. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56387. */
  56388. horizontalAlignment: number;
  56389. /**
  56390. * Gets or sets the vertical alignment
  56391. * @see http://doc.babylonjs.com/how_to/gui#alignments
  56392. */
  56393. verticalAlignment: number;
  56394. /**
  56395. * Gets or sets control width
  56396. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56397. */
  56398. width: string | number;
  56399. /**
  56400. * Gets control width in pixel
  56401. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56402. */
  56403. readonly widthInPixels: number;
  56404. /**
  56405. * Gets or sets control height
  56406. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56407. */
  56408. height: string | number;
  56409. /**
  56410. * Gets control height in pixel
  56411. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56412. */
  56413. readonly heightInPixels: number;
  56414. /** Gets or set font family */
  56415. fontFamily: string;
  56416. /** Gets or sets font style */
  56417. fontStyle: string;
  56418. /** Gets or sets font weight */
  56419. fontWeight: string;
  56420. /**
  56421. * Gets or sets style
  56422. * @see http://doc.babylonjs.com/how_to/gui#styles
  56423. */
  56424. style: BABYLON.Nullable<Style>;
  56425. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  56426. /** Gets font size in pixels */
  56427. readonly fontSizeInPixels: number;
  56428. /** Gets or sets font size */
  56429. fontSize: string | number;
  56430. /** Gets or sets foreground color */
  56431. color: string;
  56432. /** Gets or sets z index which is used to reorder controls on the z axis */
  56433. zIndex: number;
  56434. /** Gets or sets a boolean indicating if the control can be rendered */
  56435. notRenderable: boolean;
  56436. /** Gets or sets a boolean indicating if the control is visible */
  56437. isVisible: boolean;
  56438. /** Gets a boolean indicating that the control needs to update its rendering */
  56439. readonly isDirty: boolean;
  56440. /**
  56441. * Gets the current linked mesh (or null if none)
  56442. */
  56443. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  56444. /**
  56445. * Gets or sets a value indicating the padding to use on the left of the control
  56446. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56447. */
  56448. paddingLeft: string | number;
  56449. /**
  56450. * Gets a value indicating the padding in pixels to use on the left of the control
  56451. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56452. */
  56453. readonly paddingLeftInPixels: number;
  56454. /**
  56455. * Gets or sets a value indicating the padding to use on the right of the control
  56456. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56457. */
  56458. paddingRight: string | number;
  56459. /**
  56460. * Gets a value indicating the padding in pixels to use on the right of the control
  56461. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56462. */
  56463. readonly paddingRightInPixels: number;
  56464. /**
  56465. * Gets or sets a value indicating the padding to use on the top of the control
  56466. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56467. */
  56468. paddingTop: string | number;
  56469. /**
  56470. * Gets a value indicating the padding in pixels to use on the top of the control
  56471. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56472. */
  56473. readonly paddingTopInPixels: number;
  56474. /**
  56475. * Gets or sets a value indicating the padding to use on the bottom of the control
  56476. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56477. */
  56478. paddingBottom: string | number;
  56479. /**
  56480. * Gets a value indicating the padding in pixels to use on the bottom of the control
  56481. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56482. */
  56483. readonly paddingBottomInPixels: number;
  56484. /**
  56485. * Gets or sets a value indicating the left coordinate of the control
  56486. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56487. */
  56488. left: string | number;
  56489. /**
  56490. * Gets a value indicating the left coordinate in pixels of the control
  56491. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56492. */
  56493. readonly leftInPixels: number;
  56494. /**
  56495. * Gets or sets a value indicating the top coordinate of the control
  56496. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56497. */
  56498. top: string | number;
  56499. /**
  56500. * Gets a value indicating the top coordinate in pixels of the control
  56501. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  56502. */
  56503. readonly topInPixels: number;
  56504. /**
  56505. * Gets or sets a value indicating the offset on X axis to the linked mesh
  56506. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56507. */
  56508. linkOffsetX: string | number;
  56509. /**
  56510. * Gets a value indicating the offset in pixels on X axis to the linked mesh
  56511. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56512. */
  56513. readonly linkOffsetXInPixels: number;
  56514. /**
  56515. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  56516. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56517. */
  56518. linkOffsetY: string | number;
  56519. /**
  56520. * Gets a value indicating the offset in pixels on Y axis to the linked mesh
  56521. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56522. */
  56523. readonly linkOffsetYInPixels: number;
  56524. /** Gets the center coordinate on X axis */
  56525. readonly centerX: number;
  56526. /** Gets the center coordinate on Y axis */
  56527. readonly centerY: number;
  56528. /** Gets or sets if control is Enabled*/
  56529. isEnabled: boolean;
  56530. /** Gets or sets background color of control if it's disabled*/
  56531. disabledColor: string;
  56532. /**
  56533. * Creates a new control
  56534. * @param name defines the name of the control
  56535. */
  56536. constructor(
  56537. /** defines the name of the control */
  56538. name?: string | undefined);
  56539. /** @hidden */
  56540. protected _getTypeName(): string;
  56541. /**
  56542. * Gets the first ascendant in the hierarchy of the given type
  56543. * @param className defines the required type
  56544. * @returns the ascendant or null if not found
  56545. */
  56546. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  56547. /** @hidden */ resetFontCache(): void;
  56548. /**
  56549. * Determines if a container is an ascendant of the current control
  56550. * @param container defines the container to look for
  56551. * @returns true if the container is one of the ascendant of the control
  56552. */
  56553. isAscendant(container: Control): boolean;
  56554. /**
  56555. * Gets coordinates in local control space
  56556. * @param globalCoordinates defines the coordinates to transform
  56557. * @returns the new coordinates in local space
  56558. */
  56559. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56560. /**
  56561. * Gets coordinates in local control space
  56562. * @param globalCoordinates defines the coordinates to transform
  56563. * @param result defines the target vector2 where to store the result
  56564. * @returns the current control
  56565. */
  56566. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  56567. /**
  56568. * Gets coordinates in parent local control space
  56569. * @param globalCoordinates defines the coordinates to transform
  56570. * @returns the new coordinates in parent local space
  56571. */
  56572. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  56573. /**
  56574. * Move the current control to a vector3 position projected onto the screen.
  56575. * @param position defines the target position
  56576. * @param scene defines the hosting scene
  56577. */
  56578. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  56579. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  56580. /**
  56581. * Will return all controls that have this control as ascendant
  56582. * @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
  56583. * @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
  56584. * @return all child controls
  56585. */
  56586. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  56587. /**
  56588. * Link current control with a target mesh
  56589. * @param mesh defines the mesh to link with
  56590. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  56591. */
  56592. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  56593. /** @hidden */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  56594. /** @hidden */ offsetLeft(offset: number): void;
  56595. /** @hidden */ offsetTop(offset: number): void;
  56596. /** @hidden */ markMatrixAsDirty(): void;
  56597. /** @hidden */ flagDescendantsAsMatrixDirty(): void;
  56598. /** @hidden */ intersectsRect(rect: Measure): boolean;
  56599. /** @hidden */
  56600. protected invalidateRect(): void;
  56601. /** @hidden */ markAsDirty(force?: boolean): void;
  56602. /** @hidden */ markAllAsDirty(): void;
  56603. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  56604. /** @hidden */
  56605. protected _transform(context?: CanvasRenderingContext2D): void;
  56606. /** @hidden */ renderHighlight(context: CanvasRenderingContext2D): void;
  56607. /** @hidden */ renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  56608. /** @hidden */
  56609. protected _applyStates(context: CanvasRenderingContext2D): void;
  56610. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  56611. /** @hidden */
  56612. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56613. protected _evaluateClippingState(parentMeasure: Measure): void;
  56614. /** @hidden */ measure(): void;
  56615. /** @hidden */
  56616. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56617. /** @hidden */
  56618. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56619. /** @hidden */
  56620. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56621. /** @hidden */
  56622. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  56623. private static _ClipMeasure;
  56624. private _tmpMeasureA;
  56625. private _clip;
  56626. /** @hidden */ render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  56627. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  56628. /**
  56629. * Tests if a given coordinates belong to the current control
  56630. * @param x defines x coordinate to test
  56631. * @param y defines y coordinate to test
  56632. * @returns true if the coordinates are inside the control
  56633. */
  56634. contains(x: number, y: number): boolean;
  56635. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  56636. /** @hidden */ onPointerMove(target: Control, coordinates: BABYLON.Vector2): void;
  56637. /** @hidden */ onPointerEnter(target: Control): boolean;
  56638. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  56639. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  56640. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  56641. /** @hidden */ forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  56642. /** @hidden */ processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  56643. private _prepareFont;
  56644. /** Releases associated resources */
  56645. dispose(): void;
  56646. private static _HORIZONTAL_ALIGNMENT_LEFT;
  56647. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  56648. private static _HORIZONTAL_ALIGNMENT_CENTER;
  56649. private static _VERTICAL_ALIGNMENT_TOP;
  56650. private static _VERTICAL_ALIGNMENT_BOTTOM;
  56651. private static _VERTICAL_ALIGNMENT_CENTER;
  56652. /** HORIZONTAL_ALIGNMENT_LEFT */
  56653. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  56654. /** HORIZONTAL_ALIGNMENT_RIGHT */
  56655. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  56656. /** HORIZONTAL_ALIGNMENT_CENTER */
  56657. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  56658. /** VERTICAL_ALIGNMENT_TOP */
  56659. static readonly VERTICAL_ALIGNMENT_TOP: number;
  56660. /** VERTICAL_ALIGNMENT_BOTTOM */
  56661. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  56662. /** VERTICAL_ALIGNMENT_CENTER */
  56663. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  56664. private static _FontHeightSizes;
  56665. /** @hidden */ private static _GetFontOffset(font: string): {
  56666. ascent: number;
  56667. height: number;
  56668. descent: number;
  56669. };
  56670. /**
  56671. * Creates a stack panel that can be used to render headers
  56672. * @param control defines the control to associate with the header
  56673. * @param text defines the text of the header
  56674. * @param size defines the size of the header
  56675. * @param options defines options used to configure the header
  56676. * @returns a new StackPanel
  56677. * @ignore
  56678. * @hidden
  56679. */
  56680. static AddHeader: (control: Control, text: string, size: string | number, options: {
  56681. isHorizontal: boolean;
  56682. controlFirst: boolean;
  56683. }) => any;
  56684. /** @hidden */
  56685. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  56686. }
  56687. }
  56688. declare module BABYLON.GUI {
  56689. /**
  56690. * Root class for 2D containers
  56691. * @see http://doc.babylonjs.com/how_to/gui#containers
  56692. */
  56693. export class Container extends Control {
  56694. name?: string | undefined;
  56695. /** @hidden */
  56696. protected _children: Control[];
  56697. /** @hidden */
  56698. protected _measureForChildren: Measure;
  56699. /** @hidden */
  56700. protected _background: string;
  56701. /** @hidden */
  56702. protected _adaptWidthToChildren: boolean;
  56703. /** @hidden */
  56704. protected _adaptHeightToChildren: boolean;
  56705. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  56706. adaptHeightToChildren: boolean;
  56707. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  56708. adaptWidthToChildren: boolean;
  56709. /** Gets or sets background color */
  56710. background: string;
  56711. /** Gets the list of children */
  56712. readonly children: Control[];
  56713. /**
  56714. * Creates a new Container
  56715. * @param name defines the name of the container
  56716. */
  56717. constructor(name?: string | undefined);
  56718. protected _getTypeName(): string; flagDescendantsAsMatrixDirty(): void;
  56719. /**
  56720. * Gets a child using its name
  56721. * @param name defines the child name to look for
  56722. * @returns the child control if found
  56723. */
  56724. getChildByName(name: string): BABYLON.Nullable<Control>;
  56725. /**
  56726. * Gets a child using its type and its name
  56727. * @param name defines the child name to look for
  56728. * @param type defines the child type to look for
  56729. * @returns the child control if found
  56730. */
  56731. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  56732. /**
  56733. * Search for a specific control in children
  56734. * @param control defines the control to look for
  56735. * @returns true if the control is in child list
  56736. */
  56737. containsControl(control: Control): boolean;
  56738. /**
  56739. * Adds a new control to the current container
  56740. * @param control defines the control to add
  56741. * @returns the current container
  56742. */
  56743. addControl(control: BABYLON.Nullable<Control>): Container;
  56744. /**
  56745. * Removes all controls from the current container
  56746. * @returns the current container
  56747. */
  56748. clearControls(): Container;
  56749. /**
  56750. * Removes a control from the current container
  56751. * @param control defines the control to remove
  56752. * @returns the current container
  56753. */
  56754. removeControl(control: Control): Container;
  56755. /** @hidden */ reOrderControl(control: Control): void;
  56756. /** @hidden */ offsetLeft(offset: number): void;
  56757. /** @hidden */ offsetTop(offset: number): void;
  56758. /** @hidden */ markAllAsDirty(): void;
  56759. /** @hidden */
  56760. protected _localDraw(context: CanvasRenderingContext2D): void;
  56761. /** @hidden */ link(host: AdvancedDynamicTexture): void;
  56762. /** @hidden */
  56763. protected _beforeLayout(): void;
  56764. /** @hidden */
  56765. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56766. /** @hidden */ layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  56767. protected _postMeasure(): void;
  56768. /** @hidden */ draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  56769. /** @hidden */ getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  56770. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  56771. /** @hidden */
  56772. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56773. /** Releases associated resources */
  56774. dispose(): void;
  56775. }
  56776. }
  56777. declare module BABYLON.GUI {
  56778. /** Class used to create rectangle container */
  56779. export class Rectangle extends Container {
  56780. name?: string | undefined;
  56781. private _thickness;
  56782. private _cornerRadius;
  56783. /** Gets or sets border thickness */
  56784. thickness: number;
  56785. /** Gets or sets the corner radius angle */
  56786. cornerRadius: number;
  56787. /**
  56788. * Creates a new Rectangle
  56789. * @param name defines the control name
  56790. */
  56791. constructor(name?: string | undefined);
  56792. protected _getTypeName(): string;
  56793. protected _localDraw(context: CanvasRenderingContext2D): void;
  56794. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56795. private _drawRoundedRect;
  56796. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  56797. }
  56798. }
  56799. declare module BABYLON.GUI {
  56800. /**
  56801. * Enum that determines the text-wrapping mode to use.
  56802. */
  56803. export enum TextWrapping {
  56804. /**
  56805. * Clip the text when it's larger than Control.width; this is the default mode.
  56806. */
  56807. Clip = 0,
  56808. /**
  56809. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  56810. */
  56811. WordWrap = 1,
  56812. /**
  56813. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  56814. */
  56815. Ellipsis = 2
  56816. }
  56817. /**
  56818. * Class used to create text block control
  56819. */
  56820. export class TextBlock extends Control {
  56821. /**
  56822. * Defines the name of the control
  56823. */
  56824. name?: string | undefined;
  56825. private _text;
  56826. private _textWrapping;
  56827. private _textHorizontalAlignment;
  56828. private _textVerticalAlignment;
  56829. private _lines;
  56830. private _resizeToFit;
  56831. private _lineSpacing;
  56832. private _outlineWidth;
  56833. private _outlineColor;
  56834. /**
  56835. * An event triggered after the text is changed
  56836. */
  56837. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  56838. /**
  56839. * An event triggered after the text was broken up into lines
  56840. */
  56841. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  56842. /**
  56843. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  56844. */
  56845. readonly lines: any[];
  56846. /**
  56847. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  56848. */
  56849. /**
  56850. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  56851. */
  56852. resizeToFit: boolean;
  56853. /**
  56854. * Gets or sets a boolean indicating if text must be wrapped
  56855. */
  56856. /**
  56857. * Gets or sets a boolean indicating if text must be wrapped
  56858. */
  56859. textWrapping: TextWrapping | boolean;
  56860. /**
  56861. * Gets or sets text to display
  56862. */
  56863. /**
  56864. * Gets or sets text to display
  56865. */
  56866. text: string;
  56867. /**
  56868. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  56869. */
  56870. /**
  56871. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  56872. */
  56873. textHorizontalAlignment: number;
  56874. /**
  56875. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  56876. */
  56877. /**
  56878. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  56879. */
  56880. textVerticalAlignment: number;
  56881. /**
  56882. * Gets or sets line spacing value
  56883. */
  56884. /**
  56885. * Gets or sets line spacing value
  56886. */
  56887. lineSpacing: string | number;
  56888. /**
  56889. * Gets or sets outlineWidth of the text to display
  56890. */
  56891. /**
  56892. * Gets or sets outlineWidth of the text to display
  56893. */
  56894. outlineWidth: number;
  56895. /**
  56896. * Gets or sets outlineColor of the text to display
  56897. */
  56898. /**
  56899. * Gets or sets outlineColor of the text to display
  56900. */
  56901. outlineColor: string;
  56902. /**
  56903. * Creates a new TextBlock object
  56904. * @param name defines the name of the control
  56905. * @param text defines the text to display (emptry string by default)
  56906. */
  56907. constructor(
  56908. /**
  56909. * Defines the name of the control
  56910. */
  56911. name?: string | undefined, text?: string);
  56912. protected _getTypeName(): string;
  56913. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  56914. private _drawText;
  56915. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  56916. protected _applyStates(context: CanvasRenderingContext2D): void;
  56917. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  56918. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  56919. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  56920. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  56921. protected _renderLines(context: CanvasRenderingContext2D): void;
  56922. /**
  56923. * Given a width constraint applied on the text block, find the expected height
  56924. * @returns expected height
  56925. */
  56926. computeExpectedHeight(): number;
  56927. dispose(): void;
  56928. }
  56929. }
  56930. declare module BABYLON.GUI {
  56931. /**
  56932. * Class used to create 2D images
  56933. */
  56934. export class Image extends Control {
  56935. name?: string | undefined;
  56936. private static _WorkingCanvas;
  56937. private _domImage;
  56938. private _imageWidth;
  56939. private _imageHeight;
  56940. private _loaded;
  56941. private _stretch;
  56942. private _source;
  56943. private _autoScale;
  56944. private _sourceLeft;
  56945. private _sourceTop;
  56946. private _sourceWidth;
  56947. private _sourceHeight;
  56948. private _cellWidth;
  56949. private _cellHeight;
  56950. private _cellId;
  56951. private _populateNinePatchSlicesFromImage;
  56952. private _sliceLeft;
  56953. private _sliceRight;
  56954. private _sliceTop;
  56955. private _sliceBottom;
  56956. private _detectPointerOnOpaqueOnly;
  56957. /**
  56958. * BABYLON.Observable notified when the content is loaded
  56959. */
  56960. onImageLoadedObservable: BABYLON.Observable<Image>;
  56961. /**
  56962. * Gets a boolean indicating that the content is loaded
  56963. */
  56964. readonly isLoaded: boolean;
  56965. /**
  56966. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  56967. */
  56968. populateNinePatchSlicesFromImage: boolean;
  56969. /**
  56970. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  56971. * Beware using this as this will comsume more memory as the image has to be stored twice
  56972. */
  56973. detectPointerOnOpaqueOnly: boolean;
  56974. /**
  56975. * Gets or sets the left value for slicing (9-patch)
  56976. */
  56977. sliceLeft: number;
  56978. /**
  56979. * Gets or sets the right value for slicing (9-patch)
  56980. */
  56981. sliceRight: number;
  56982. /**
  56983. * Gets or sets the top value for slicing (9-patch)
  56984. */
  56985. sliceTop: number;
  56986. /**
  56987. * Gets or sets the bottom value for slicing (9-patch)
  56988. */
  56989. sliceBottom: number;
  56990. /**
  56991. * Gets or sets the left coordinate in the source image
  56992. */
  56993. sourceLeft: number;
  56994. /**
  56995. * Gets or sets the top coordinate in the source image
  56996. */
  56997. sourceTop: number;
  56998. /**
  56999. * Gets or sets the width to capture in the source image
  57000. */
  57001. sourceWidth: number;
  57002. /**
  57003. * Gets or sets the height to capture in the source image
  57004. */
  57005. sourceHeight: number;
  57006. /**
  57007. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  57008. * @see http://doc.babylonjs.com/how_to/gui#image
  57009. */
  57010. autoScale: boolean;
  57011. /** Gets or sets the streching mode used by the image */
  57012. stretch: number;
  57013. /**
  57014. * Gets or sets the internal DOM image used to render the control
  57015. */
  57016. domImage: HTMLImageElement;
  57017. private _onImageLoaded;
  57018. private _extractNinePatchSliceDataFromImage;
  57019. /**
  57020. * Gets or sets image source url
  57021. */
  57022. source: BABYLON.Nullable<string>;
  57023. /**
  57024. * Gets or sets the cell width to use when animation sheet is enabled
  57025. * @see http://doc.babylonjs.com/how_to/gui#image
  57026. */
  57027. cellWidth: number;
  57028. /**
  57029. * Gets or sets the cell height to use when animation sheet is enabled
  57030. * @see http://doc.babylonjs.com/how_to/gui#image
  57031. */
  57032. cellHeight: number;
  57033. /**
  57034. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  57035. * @see http://doc.babylonjs.com/how_to/gui#image
  57036. */
  57037. cellId: number;
  57038. /**
  57039. * Creates a new Image
  57040. * @param name defines the control name
  57041. * @param url defines the image url
  57042. */
  57043. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  57044. /**
  57045. * Tests if a given coordinates belong to the current control
  57046. * @param x defines x coordinate to test
  57047. * @param y defines y coordinate to test
  57048. * @returns true if the coordinates are inside the control
  57049. */
  57050. contains(x: number, y: number): boolean;
  57051. protected _getTypeName(): string;
  57052. /** Force the control to synchronize with its content */
  57053. synchronizeSizeWithContent(): void;
  57054. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57055. private _prepareWorkingCanvasForOpaqueDetection;
  57056. private _drawImage; draw(context: CanvasRenderingContext2D): void;
  57057. private _renderCornerPatch;
  57058. private _renderNinePatch;
  57059. dispose(): void;
  57060. /** STRETCH_NONE */
  57061. static readonly STRETCH_NONE: number;
  57062. /** STRETCH_FILL */
  57063. static readonly STRETCH_FILL: number;
  57064. /** STRETCH_UNIFORM */
  57065. static readonly STRETCH_UNIFORM: number;
  57066. /** STRETCH_EXTEND */
  57067. static readonly STRETCH_EXTEND: number;
  57068. /** NINE_PATCH */
  57069. static readonly STRETCH_NINE_PATCH: number;
  57070. }
  57071. }
  57072. declare module BABYLON.GUI {
  57073. /**
  57074. * Class used to create 2D buttons
  57075. */
  57076. export class Button extends Rectangle {
  57077. name?: string | undefined;
  57078. /**
  57079. * Function called to generate a pointer enter animation
  57080. */
  57081. pointerEnterAnimation: () => void;
  57082. /**
  57083. * Function called to generate a pointer out animation
  57084. */
  57085. pointerOutAnimation: () => void;
  57086. /**
  57087. * Function called to generate a pointer down animation
  57088. */
  57089. pointerDownAnimation: () => void;
  57090. /**
  57091. * Function called to generate a pointer up animation
  57092. */
  57093. pointerUpAnimation: () => void;
  57094. private _image;
  57095. /**
  57096. * Returns the image part of the button (if any)
  57097. */
  57098. readonly image: BABYLON.Nullable<Image>;
  57099. private _textBlock;
  57100. /**
  57101. * Returns the image part of the button (if any)
  57102. */
  57103. readonly textBlock: BABYLON.Nullable<TextBlock>;
  57104. /**
  57105. * Creates a new Button
  57106. * @param name defines the name of the button
  57107. */
  57108. constructor(name?: string | undefined);
  57109. protected _getTypeName(): string;
  57110. /** @hidden */ processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  57111. /** @hidden */ onPointerEnter(target: Control): boolean;
  57112. /** @hidden */ onPointerOut(target: Control, force?: boolean): void;
  57113. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57114. /** @hidden */ onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57115. /**
  57116. * Creates a new button made with an image and a text
  57117. * @param name defines the name of the button
  57118. * @param text defines the text of the button
  57119. * @param imageUrl defines the url of the image
  57120. * @returns a new Button
  57121. */
  57122. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  57123. /**
  57124. * Creates a new button made with an image
  57125. * @param name defines the name of the button
  57126. * @param imageUrl defines the url of the image
  57127. * @returns a new Button
  57128. */
  57129. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  57130. /**
  57131. * Creates a new button made with a text
  57132. * @param name defines the name of the button
  57133. * @param text defines the text of the button
  57134. * @returns a new Button
  57135. */
  57136. static CreateSimpleButton(name: string, text: string): Button;
  57137. /**
  57138. * Creates a new button made with an image and a centered text
  57139. * @param name defines the name of the button
  57140. * @param text defines the text of the button
  57141. * @param imageUrl defines the url of the image
  57142. * @returns a new Button
  57143. */
  57144. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  57145. }
  57146. }
  57147. declare module BABYLON.GUI {
  57148. /**
  57149. * Class used to create a 2D stack panel container
  57150. */
  57151. export class StackPanel extends Container {
  57152. name?: string | undefined;
  57153. private _isVertical;
  57154. private _manualWidth;
  57155. private _manualHeight;
  57156. private _doNotTrackManualChanges;
  57157. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  57158. isVertical: boolean;
  57159. /**
  57160. * Gets or sets panel width.
  57161. * This value should not be set when in horizontal mode as it will be computed automatically
  57162. */
  57163. width: string | number;
  57164. /**
  57165. * Gets or sets panel height.
  57166. * This value should not be set when in vertical mode as it will be computed automatically
  57167. */
  57168. height: string | number;
  57169. /**
  57170. * Creates a new StackPanel
  57171. * @param name defines control name
  57172. */
  57173. constructor(name?: string | undefined);
  57174. protected _getTypeName(): string;
  57175. /** @hidden */
  57176. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57177. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57178. protected _postMeasure(): void;
  57179. }
  57180. }
  57181. declare module BABYLON.GUI {
  57182. /**
  57183. * Class used to represent a 2D checkbox
  57184. */
  57185. export class Checkbox extends Control {
  57186. name?: string | undefined;
  57187. private _isChecked;
  57188. private _background;
  57189. private _checkSizeRatio;
  57190. private _thickness;
  57191. /** Gets or sets border thickness */
  57192. thickness: number;
  57193. /**
  57194. * BABYLON.Observable raised when isChecked property changes
  57195. */
  57196. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57197. /** Gets or sets a value indicating the ratio between overall size and check size */
  57198. checkSizeRatio: number;
  57199. /** Gets or sets background color */
  57200. background: string;
  57201. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57202. isChecked: boolean;
  57203. /**
  57204. * Creates a new CheckBox
  57205. * @param name defines the control name
  57206. */
  57207. constructor(name?: string | undefined);
  57208. protected _getTypeName(): string;
  57209. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57210. /** @hidden */ onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57211. /**
  57212. * Utility function to easily create a checkbox with a header
  57213. * @param title defines the label to use for the header
  57214. * @param onValueChanged defines the callback to call when value changes
  57215. * @returns a StackPanel containing the checkbox and a textBlock
  57216. */
  57217. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  57218. }
  57219. }
  57220. declare module BABYLON.GUI {
  57221. /**
  57222. * Class used to store key control properties
  57223. */
  57224. export class KeyPropertySet {
  57225. /** Width */
  57226. width?: string;
  57227. /** Height */
  57228. height?: string;
  57229. /** Left padding */
  57230. paddingLeft?: string;
  57231. /** Right padding */
  57232. paddingRight?: string;
  57233. /** Top padding */
  57234. paddingTop?: string;
  57235. /** Bottom padding */
  57236. paddingBottom?: string;
  57237. /** Foreground color */
  57238. color?: string;
  57239. /** Background color */
  57240. background?: string;
  57241. }
  57242. /**
  57243. * Class used to create virtual keyboard
  57244. */
  57245. export class VirtualKeyboard extends StackPanel {
  57246. /** BABYLON.Observable raised when a key is pressed */
  57247. onKeyPressObservable: BABYLON.Observable<string>;
  57248. /** Gets or sets default key button width */
  57249. defaultButtonWidth: string;
  57250. /** Gets or sets default key button height */
  57251. defaultButtonHeight: string;
  57252. /** Gets or sets default key button left padding */
  57253. defaultButtonPaddingLeft: string;
  57254. /** Gets or sets default key button right padding */
  57255. defaultButtonPaddingRight: string;
  57256. /** Gets or sets default key button top padding */
  57257. defaultButtonPaddingTop: string;
  57258. /** Gets or sets default key button bottom padding */
  57259. defaultButtonPaddingBottom: string;
  57260. /** Gets or sets default key button foreground color */
  57261. defaultButtonColor: string;
  57262. /** Gets or sets default key button background color */
  57263. defaultButtonBackground: string;
  57264. /** Gets or sets shift button foreground color */
  57265. shiftButtonColor: string;
  57266. /** Gets or sets shift button thickness*/
  57267. selectedShiftThickness: number;
  57268. /** Gets shift key state */
  57269. shiftState: number;
  57270. protected _getTypeName(): string;
  57271. private _createKey;
  57272. /**
  57273. * Adds a new row of keys
  57274. * @param keys defines the list of keys to add
  57275. * @param propertySets defines the associated property sets
  57276. */
  57277. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  57278. /**
  57279. * Set the shift key to a specific state
  57280. * @param shiftState defines the new shift state
  57281. */
  57282. applyShiftState(shiftState: number): void;
  57283. private _currentlyConnectedInputText;
  57284. private _connectedInputTexts;
  57285. private _onKeyPressObserver;
  57286. /** Gets the input text control currently attached to the keyboard */
  57287. readonly connectedInputText: BABYLON.Nullable<InputText>;
  57288. /**
  57289. * Connects the keyboard with an input text control
  57290. *
  57291. * @param input defines the target control
  57292. */
  57293. connect(input: InputText): void;
  57294. /**
  57295. * Disconnects the keyboard from connected InputText controls
  57296. *
  57297. * @param input optionally defines a target control, otherwise all are disconnected
  57298. */
  57299. disconnect(input?: InputText): void;
  57300. private _removeConnectedInputObservables;
  57301. /**
  57302. * Release all resources
  57303. */
  57304. dispose(): void;
  57305. /**
  57306. * Creates a new keyboard using a default layout
  57307. *
  57308. * @param name defines control name
  57309. * @returns a new VirtualKeyboard
  57310. */
  57311. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  57312. }
  57313. }
  57314. declare module BABYLON.GUI {
  57315. /**
  57316. * Class used to create input text control
  57317. */
  57318. export class InputText extends Control implements IFocusableControl {
  57319. name?: string | undefined;
  57320. private _text;
  57321. private _placeholderText;
  57322. private _background;
  57323. private _focusedBackground;
  57324. private _focusedColor;
  57325. private _placeholderColor;
  57326. private _thickness;
  57327. private _margin;
  57328. private _autoStretchWidth;
  57329. private _maxWidth;
  57330. private _isFocused;
  57331. private _blinkTimeout;
  57332. private _blinkIsEven;
  57333. private _cursorOffset;
  57334. private _scrollLeft;
  57335. private _textWidth;
  57336. private _clickedCoordinate;
  57337. private _deadKey;
  57338. private _addKey;
  57339. private _currentKey;
  57340. private _isTextHighlightOn;
  57341. private _textHighlightColor;
  57342. private _highligherOpacity;
  57343. private _highlightedText;
  57344. private _startHighlightIndex;
  57345. private _endHighlightIndex;
  57346. private _cursorIndex;
  57347. private _onFocusSelectAll;
  57348. private _isPointerDown;
  57349. private _onClipboardObserver;
  57350. private _onPointerDblTapObserver;
  57351. /** @hidden */ connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  57352. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  57353. promptMessage: string;
  57354. /** BABYLON.Observable raised when the text changes */
  57355. onTextChangedObservable: BABYLON.Observable<InputText>;
  57356. /** BABYLON.Observable raised just before an entered character is to be added */
  57357. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  57358. /** BABYLON.Observable raised when the control gets the focus */
  57359. onFocusObservable: BABYLON.Observable<InputText>;
  57360. /** BABYLON.Observable raised when the control loses the focus */
  57361. onBlurObservable: BABYLON.Observable<InputText>;
  57362. /**Observable raised when the text is highlighted */
  57363. onTextHighlightObservable: BABYLON.Observable<InputText>;
  57364. /**Observable raised when copy event is triggered */
  57365. onTextCopyObservable: BABYLON.Observable<InputText>;
  57366. /** BABYLON.Observable raised when cut event is triggered */
  57367. onTextCutObservable: BABYLON.Observable<InputText>;
  57368. /** BABYLON.Observable raised when paste event is triggered */
  57369. onTextPasteObservable: BABYLON.Observable<InputText>;
  57370. /** BABYLON.Observable raised when a key event was processed */
  57371. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  57372. /** Gets or sets the maximum width allowed by the control */
  57373. maxWidth: string | number;
  57374. /** Gets the maximum width allowed by the control in pixels */
  57375. readonly maxWidthInPixels: number;
  57376. /** Gets or sets the text highlighter transparency; default: 0.4 */
  57377. highligherOpacity: number;
  57378. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  57379. onFocusSelectAll: boolean;
  57380. /** Gets or sets the text hightlight color */
  57381. textHighlightColor: string;
  57382. /** Gets or sets control margin */
  57383. margin: string;
  57384. /** Gets control margin in pixels */
  57385. readonly marginInPixels: number;
  57386. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  57387. autoStretchWidth: boolean;
  57388. /** Gets or sets border thickness */
  57389. thickness: number;
  57390. /** Gets or sets the background color when focused */
  57391. focusedBackground: string;
  57392. /** Gets or sets the background color when focused */
  57393. focusedColor: string;
  57394. /** Gets or sets the background color */
  57395. background: string;
  57396. /** Gets or sets the placeholder color */
  57397. placeholderColor: string;
  57398. /** Gets or sets the text displayed when the control is empty */
  57399. placeholderText: string;
  57400. /** Gets or sets the dead key flag */
  57401. deadKey: boolean;
  57402. /** Gets or sets the highlight text */
  57403. highlightedText: string;
  57404. /** Gets or sets if the current key should be added */
  57405. addKey: boolean;
  57406. /** Gets or sets the value of the current key being entered */
  57407. currentKey: string;
  57408. /** Gets or sets the text displayed in the control */
  57409. text: string;
  57410. /** Gets or sets control width */
  57411. width: string | number;
  57412. /**
  57413. * Creates a new InputText
  57414. * @param name defines the control name
  57415. * @param text defines the text of the control
  57416. */
  57417. constructor(name?: string | undefined, text?: string);
  57418. /** @hidden */
  57419. onBlur(): void;
  57420. /** @hidden */
  57421. onFocus(): void;
  57422. protected _getTypeName(): string;
  57423. /**
  57424. * Function called to get the list of controls that should not steal the focus from this control
  57425. * @returns an array of controls
  57426. */
  57427. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  57428. /** @hidden */
  57429. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  57430. /** @hidden */
  57431. private _updateValueFromCursorIndex;
  57432. /** @hidden */
  57433. private _processDblClick;
  57434. /** @hidden */
  57435. private _selectAllText;
  57436. /**
  57437. * Handles the keyboard event
  57438. * @param evt Defines the KeyboardEvent
  57439. */
  57440. processKeyboard(evt: KeyboardEvent): void;
  57441. /** @hidden */
  57442. private _onCopyText;
  57443. /** @hidden */
  57444. private _onCutText;
  57445. /** @hidden */
  57446. private _onPasteText; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57447. protected _beforeRenderText(text: string): string;
  57448. dispose(): void;
  57449. }
  57450. }
  57451. declare module BABYLON.GUI {
  57452. /**
  57453. * Class used to create a 2D grid container
  57454. */
  57455. export class Grid extends Container {
  57456. name?: string | undefined;
  57457. private _rowDefinitions;
  57458. private _columnDefinitions;
  57459. private _cells;
  57460. private _childControls;
  57461. /**
  57462. * Gets the number of columns
  57463. */
  57464. readonly columnCount: number;
  57465. /**
  57466. * Gets the number of rows
  57467. */
  57468. readonly rowCount: number;
  57469. /** Gets the list of children */
  57470. readonly children: Control[];
  57471. /**
  57472. * Gets the definition of a specific row
  57473. * @param index defines the index of the row
  57474. * @returns the row definition
  57475. */
  57476. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57477. /**
  57478. * Gets the definition of a specific column
  57479. * @param index defines the index of the column
  57480. * @returns the column definition
  57481. */
  57482. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  57483. /**
  57484. * Adds a new row to the grid
  57485. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57486. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  57487. * @returns the current grid
  57488. */
  57489. addRowDefinition(height: number, isPixel?: boolean): Grid;
  57490. /**
  57491. * Adds a new column to the grid
  57492. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57493. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57494. * @returns the current grid
  57495. */
  57496. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  57497. /**
  57498. * Update a row definition
  57499. * @param index defines the index of the row to update
  57500. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  57501. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  57502. * @returns the current grid
  57503. */
  57504. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  57505. /**
  57506. * Update a column definition
  57507. * @param index defines the index of the column to update
  57508. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  57509. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  57510. * @returns the current grid
  57511. */
  57512. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  57513. /**
  57514. * Gets the list of children stored in a specific cell
  57515. * @param row defines the row to check
  57516. * @param column defines the column to check
  57517. * @returns the list of controls
  57518. */
  57519. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  57520. /**
  57521. * Gets a string representing the child cell info (row x column)
  57522. * @param child defines the control to get info from
  57523. * @returns a string containing the child cell info (row x column)
  57524. */
  57525. getChildCellInfo(child: Control): string;
  57526. private _removeCell;
  57527. private _offsetCell;
  57528. /**
  57529. * Remove a column definition at specified index
  57530. * @param index defines the index of the column to remove
  57531. * @returns the current grid
  57532. */
  57533. removeColumnDefinition(index: number): Grid;
  57534. /**
  57535. * Remove a row definition at specified index
  57536. * @param index defines the index of the row to remove
  57537. * @returns the current grid
  57538. */
  57539. removeRowDefinition(index: number): Grid;
  57540. /**
  57541. * Adds a new control to the current grid
  57542. * @param control defines the control to add
  57543. * @param row defines the row where to add the control (0 by default)
  57544. * @param column defines the column where to add the control (0 by default)
  57545. * @returns the current grid
  57546. */
  57547. addControl(control: Control, row?: number, column?: number): Grid;
  57548. /**
  57549. * Removes a control from the current container
  57550. * @param control defines the control to remove
  57551. * @returns the current container
  57552. */
  57553. removeControl(control: Control): Container;
  57554. /**
  57555. * Creates a new Grid
  57556. * @param name defines control name
  57557. */
  57558. constructor(name?: string | undefined);
  57559. protected _getTypeName(): string;
  57560. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  57561. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; flagDescendantsAsMatrixDirty(): void; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  57562. /** Releases associated resources */
  57563. dispose(): void;
  57564. }
  57565. }
  57566. declare module BABYLON.GUI {
  57567. /** Class used to create color pickers */
  57568. export class ColorPicker extends Control {
  57569. name?: string | undefined;
  57570. private static _Epsilon;
  57571. private _colorWheelCanvas;
  57572. private _value;
  57573. private _tmpColor;
  57574. private _pointerStartedOnSquare;
  57575. private _pointerStartedOnWheel;
  57576. private _squareLeft;
  57577. private _squareTop;
  57578. private _squareSize;
  57579. private _h;
  57580. private _s;
  57581. private _v;
  57582. /**
  57583. * BABYLON.Observable raised when the value changes
  57584. */
  57585. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  57586. /** Gets or sets the color of the color picker */
  57587. value: BABYLON.Color3;
  57588. /**
  57589. * Gets or sets control width
  57590. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57591. */
  57592. width: string | number;
  57593. /**
  57594. * Gets or sets control height
  57595. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  57596. */
  57597. /** Gets or sets control height */
  57598. height: string | number;
  57599. /** Gets or sets control size */
  57600. size: string | number;
  57601. /**
  57602. * Creates a new ColorPicker
  57603. * @param name defines the control name
  57604. */
  57605. constructor(name?: string | undefined);
  57606. protected _getTypeName(): string;
  57607. /** @hidden */
  57608. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57609. private _updateSquareProps;
  57610. private _drawGradientSquare;
  57611. private _drawCircle;
  57612. private _createColorWheelCanvas;
  57613. private _RGBtoHSV;
  57614. private _HSVtoRGB;
  57615. /** @hidden */ draw(context: CanvasRenderingContext2D): void;
  57616. private _pointerIsDown;
  57617. private _updateValueFromPointer;
  57618. private _isPointOnSquare;
  57619. private _isPointOnWheel; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57620. /**
  57621. * This function expands the color picker by creating a color picker dialog with manual
  57622. * color value input and the ability to save colors into an array to be used later in
  57623. * subsequent launches of the dialogue.
  57624. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  57625. * @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.
  57626. * @returns picked color as a hex string and the saved colors array as hex strings.
  57627. */
  57628. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  57629. pickerWidth?: string;
  57630. pickerHeight?: string;
  57631. headerHeight?: string;
  57632. lastColor?: string;
  57633. swatchLimit?: number;
  57634. numSwatchesPerLine?: number;
  57635. savedColors?: Array<string>;
  57636. }): Promise<{
  57637. savedColors?: string[];
  57638. pickedColor: string;
  57639. }>;
  57640. }
  57641. }
  57642. declare module BABYLON.GUI {
  57643. /** Class used to create 2D ellipse containers */
  57644. export class Ellipse extends Container {
  57645. name?: string | undefined;
  57646. private _thickness;
  57647. /** Gets or sets border thickness */
  57648. thickness: number;
  57649. /**
  57650. * Creates a new Ellipse
  57651. * @param name defines the control name
  57652. */
  57653. constructor(name?: string | undefined);
  57654. protected _getTypeName(): string;
  57655. protected _localDraw(context: CanvasRenderingContext2D): void;
  57656. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57657. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  57658. }
  57659. }
  57660. declare module BABYLON.GUI {
  57661. /**
  57662. * Class used to create a password control
  57663. */
  57664. export class InputPassword extends InputText {
  57665. protected _beforeRenderText(text: string): string;
  57666. }
  57667. }
  57668. declare module BABYLON.GUI {
  57669. /** Class used to render 2D lines */
  57670. export class Line extends Control {
  57671. name?: string | undefined;
  57672. private _lineWidth;
  57673. private _x1;
  57674. private _y1;
  57675. private _x2;
  57676. private _y2;
  57677. private _dash;
  57678. private _connectedControl;
  57679. private _connectedControlDirtyObserver;
  57680. /** Gets or sets the dash pattern */
  57681. dash: Array<number>;
  57682. /** Gets or sets the control connected with the line end */
  57683. connectedControl: Control;
  57684. /** Gets or sets start coordinates on X axis */
  57685. x1: string | number;
  57686. /** Gets or sets start coordinates on Y axis */
  57687. y1: string | number;
  57688. /** Gets or sets end coordinates on X axis */
  57689. x2: string | number;
  57690. /** Gets or sets end coordinates on Y axis */
  57691. y2: string | number;
  57692. /** Gets or sets line width */
  57693. lineWidth: number;
  57694. /** Gets or sets horizontal alignment */
  57695. horizontalAlignment: number;
  57696. /** Gets or sets vertical alignment */
  57697. verticalAlignment: number;
  57698. private readonly _effectiveX2;
  57699. private readonly _effectiveY2;
  57700. /**
  57701. * Creates a new Line
  57702. * @param name defines the control name
  57703. */
  57704. constructor(name?: string | undefined);
  57705. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; measure(): void;
  57706. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57707. /**
  57708. * Move one end of the line given 3D cartesian coordinates.
  57709. * @param position Targeted world position
  57710. * @param scene BABYLON.Scene
  57711. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  57712. */
  57713. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  57714. /**
  57715. * Move one end of the line to a position in screen absolute space.
  57716. * @param projectedPosition Position in screen absolute space (X, Y)
  57717. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  57718. */ moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  57719. }
  57720. }
  57721. declare module BABYLON.GUI {
  57722. /**
  57723. * Class used to store a point for a MultiLine object.
  57724. * The point can be pure 2D coordinates, a mesh or a control
  57725. */
  57726. export class MultiLinePoint {
  57727. private _multiLine;
  57728. private _x;
  57729. private _y;
  57730. private _control;
  57731. private _mesh;
  57732. private _controlObserver;
  57733. private _meshObserver;
  57734. /** @hidden */ point: BABYLON.Vector2;
  57735. /**
  57736. * Creates a new MultiLinePoint
  57737. * @param multiLine defines the source MultiLine object
  57738. */
  57739. constructor(multiLine: MultiLine);
  57740. /** Gets or sets x coordinate */
  57741. x: string | number;
  57742. /** Gets or sets y coordinate */
  57743. y: string | number;
  57744. /** Gets or sets the control associated with this point */
  57745. control: BABYLON.Nullable<Control>;
  57746. /** Gets or sets the mesh associated with this point */
  57747. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  57748. /** Resets links */
  57749. resetLinks(): void;
  57750. /**
  57751. * Gets a translation vector
  57752. * @returns the translation vector
  57753. */
  57754. translate(): BABYLON.Vector2;
  57755. private _translatePoint;
  57756. /** Release associated resources */
  57757. dispose(): void;
  57758. }
  57759. }
  57760. declare module BABYLON.GUI {
  57761. /**
  57762. * Class used to create multi line control
  57763. */
  57764. export class MultiLine extends Control {
  57765. name?: string | undefined;
  57766. private _lineWidth;
  57767. private _dash;
  57768. private _points;
  57769. private _minX;
  57770. private _minY;
  57771. private _maxX;
  57772. private _maxY;
  57773. /**
  57774. * Creates a new MultiLine
  57775. * @param name defines the control name
  57776. */
  57777. constructor(name?: string | undefined);
  57778. /** Gets or sets dash pattern */
  57779. dash: Array<number>;
  57780. /**
  57781. * Gets point stored at specified index
  57782. * @param index defines the index to look for
  57783. * @returns the requested point if found
  57784. */
  57785. getAt(index: number): MultiLinePoint;
  57786. /** Function called when a point is updated */
  57787. onPointUpdate: () => void;
  57788. /**
  57789. * Adds new points to the point collection
  57790. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  57791. * @returns the list of created MultiLinePoint
  57792. */
  57793. add(...items: (AbstractMesh | Control | {
  57794. x: string | number;
  57795. y: string | number;
  57796. })[]): MultiLinePoint[];
  57797. /**
  57798. * Adds a new point to the point collection
  57799. * @param item defines the item (mesh, control or 2d coordiantes) to add
  57800. * @returns the created MultiLinePoint
  57801. */
  57802. push(item?: (AbstractMesh | Control | {
  57803. x: string | number;
  57804. y: string | number;
  57805. })): MultiLinePoint;
  57806. /**
  57807. * Remove a specific value or point from the active point collection
  57808. * @param value defines the value or point to remove
  57809. */
  57810. remove(value: number | MultiLinePoint): void;
  57811. /**
  57812. * Resets this object to initial state (no point)
  57813. */
  57814. reset(): void;
  57815. /**
  57816. * Resets all links
  57817. */
  57818. resetLinks(): void;
  57819. /** Gets or sets line width */
  57820. lineWidth: number;
  57821. horizontalAlignment: number;
  57822. verticalAlignment: number;
  57823. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  57824. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; measure(): void;
  57825. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  57826. dispose(): void;
  57827. }
  57828. }
  57829. declare module BABYLON.GUI {
  57830. /**
  57831. * Class used to create radio button controls
  57832. */
  57833. export class RadioButton extends Control {
  57834. name?: string | undefined;
  57835. private _isChecked;
  57836. private _background;
  57837. private _checkSizeRatio;
  57838. private _thickness;
  57839. /** Gets or sets border thickness */
  57840. thickness: number;
  57841. /** Gets or sets group name */
  57842. group: string;
  57843. /** BABYLON.Observable raised when isChecked is changed */
  57844. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  57845. /** Gets or sets a value indicating the ratio between overall size and check size */
  57846. checkSizeRatio: number;
  57847. /** Gets or sets background color */
  57848. background: string;
  57849. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  57850. isChecked: boolean;
  57851. /**
  57852. * Creates a new RadioButton
  57853. * @param name defines the control name
  57854. */
  57855. constructor(name?: string | undefined);
  57856. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  57857. /**
  57858. * Utility function to easily create a radio button with a header
  57859. * @param title defines the label to use for the header
  57860. * @param group defines the group to use for the radio button
  57861. * @param isChecked defines the initial state of the radio button
  57862. * @param onValueChanged defines the callback to call when value changes
  57863. * @returns a StackPanel containing the radio button and a textBlock
  57864. */
  57865. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  57866. }
  57867. }
  57868. declare module BABYLON.GUI {
  57869. /**
  57870. * Class used to create slider controls
  57871. */
  57872. export class BaseSlider extends Control {
  57873. name?: string | undefined;
  57874. protected _thumbWidth: ValueAndUnit;
  57875. private _minimum;
  57876. private _maximum;
  57877. private _value;
  57878. private _isVertical;
  57879. protected _barOffset: ValueAndUnit;
  57880. private _isThumbClamped;
  57881. protected _displayThumb: boolean;
  57882. private _step;
  57883. protected _effectiveBarOffset: number;
  57884. protected _renderLeft: number;
  57885. protected _renderTop: number;
  57886. protected _renderWidth: number;
  57887. protected _renderHeight: number;
  57888. protected _backgroundBoxLength: number;
  57889. protected _backgroundBoxThickness: number;
  57890. protected _effectiveThumbThickness: number;
  57891. /** BABYLON.Observable raised when the sldier value changes */
  57892. onValueChangedObservable: BABYLON.Observable<number>;
  57893. /** Gets or sets a boolean indicating if the thumb must be rendered */
  57894. displayThumb: boolean;
  57895. /** Gets or sets a step to apply to values (0 by default) */
  57896. step: number;
  57897. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  57898. barOffset: string | number;
  57899. /** Gets main bar offset in pixels*/
  57900. readonly barOffsetInPixels: number;
  57901. /** Gets or sets thumb width */
  57902. thumbWidth: string | number;
  57903. /** Gets thumb width in pixels */
  57904. readonly thumbWidthInPixels: number;
  57905. /** Gets or sets minimum value */
  57906. minimum: number;
  57907. /** Gets or sets maximum value */
  57908. maximum: number;
  57909. /** Gets or sets current value */
  57910. value: number;
  57911. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  57912. isVertical: boolean;
  57913. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  57914. isThumbClamped: boolean;
  57915. /**
  57916. * Creates a new BaseSlider
  57917. * @param name defines the control name
  57918. */
  57919. constructor(name?: string | undefined);
  57920. protected _getTypeName(): string;
  57921. protected _getThumbPosition(): number;
  57922. protected _getThumbThickness(type: string): number;
  57923. protected _prepareRenderingData(type: string): void;
  57924. private _pointerIsDown;
  57925. /** @hidden */
  57926. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; onPointerMove(target: Control, coordinates: BABYLON.Vector2): void; onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  57927. }
  57928. }
  57929. declare module BABYLON.GUI {
  57930. /**
  57931. * Class used to create slider controls
  57932. */
  57933. export class Slider extends BaseSlider {
  57934. name?: string | undefined;
  57935. private _background;
  57936. private _borderColor;
  57937. private _isThumbCircle;
  57938. protected _displayValueBar: boolean;
  57939. /** Gets or sets a boolean indicating if the value bar must be rendered */
  57940. displayValueBar: boolean;
  57941. /** Gets or sets border color */
  57942. borderColor: string;
  57943. /** Gets or sets background color */
  57944. background: string;
  57945. /** Gets or sets a boolean indicating if the thumb should be round or square */
  57946. isThumbCircle: boolean;
  57947. /**
  57948. * Creates a new Slider
  57949. * @param name defines the control name
  57950. */
  57951. constructor(name?: string | undefined);
  57952. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  57953. }
  57954. }
  57955. declare module BABYLON.GUI {
  57956. /** Class used to create a RadioGroup
  57957. * which contains groups of radio buttons
  57958. */
  57959. export class SelectorGroup {
  57960. /** name of SelectorGroup */
  57961. name: string;
  57962. private _groupPanel;
  57963. private _selectors;
  57964. private _groupHeader;
  57965. /**
  57966. * Creates a new SelectorGroup
  57967. * @param name of group, used as a group heading
  57968. */
  57969. constructor(
  57970. /** name of SelectorGroup */
  57971. name: string);
  57972. /** Gets the groupPanel of the SelectorGroup */
  57973. readonly groupPanel: StackPanel;
  57974. /** Gets the selectors array */
  57975. readonly selectors: StackPanel[];
  57976. /** Gets and sets the group header */
  57977. header: string;
  57978. /** @hidden */
  57979. private _addGroupHeader;
  57980. /** @hidden*/ getSelector(selectorNb: number): StackPanel | undefined;
  57981. /** Removes the selector at the given position
  57982. * @param selectorNb the position of the selector within the group
  57983. */
  57984. removeSelector(selectorNb: number): void;
  57985. }
  57986. /** Class used to create a CheckboxGroup
  57987. * which contains groups of checkbox buttons
  57988. */
  57989. export class CheckboxGroup extends SelectorGroup {
  57990. /** Adds a checkbox as a control
  57991. * @param text is the label for the selector
  57992. * @param func is the function called when the Selector is checked
  57993. * @param checked is true when Selector is checked
  57994. */
  57995. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  57996. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  57997. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  57998. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  57999. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58000. }
  58001. /** Class used to create a RadioGroup
  58002. * which contains groups of radio buttons
  58003. */
  58004. export class RadioGroup extends SelectorGroup {
  58005. private _selectNb;
  58006. /** Adds a radio button as a control
  58007. * @param label is the label for the selector
  58008. * @param func is the function called when the Selector is checked
  58009. * @param checked is true when Selector is checked
  58010. */
  58011. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  58012. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58013. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58014. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58015. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58016. }
  58017. /** Class used to create a SliderGroup
  58018. * which contains groups of slider buttons
  58019. */
  58020. export class SliderGroup extends SelectorGroup {
  58021. /**
  58022. * Adds a slider to the SelectorGroup
  58023. * @param label is the label for the SliderBar
  58024. * @param func is the function called when the Slider moves
  58025. * @param unit is a string describing the units used, eg degrees or metres
  58026. * @param min is the minimum value for the Slider
  58027. * @param max is the maximum value for the Slider
  58028. * @param value is the start value for the Slider between min and max
  58029. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  58030. */
  58031. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  58032. /** @hidden */ setSelectorLabel(selectorNb: number, label: string): void;
  58033. /** @hidden */ setSelectorLabelColor(selectorNb: number, color: string): void;
  58034. /** @hidden */ setSelectorButtonColor(selectorNb: number, color: string): void;
  58035. /** @hidden */ setSelectorButtonBackground(selectorNb: number, color: string): void;
  58036. }
  58037. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  58038. * @see http://doc.babylonjs.com/how_to/selector
  58039. */
  58040. export class SelectionPanel extends Rectangle {
  58041. /** name of SelectionPanel */
  58042. name: string;
  58043. /** an array of SelectionGroups */
  58044. groups: SelectorGroup[];
  58045. private _panel;
  58046. private _buttonColor;
  58047. private _buttonBackground;
  58048. private _headerColor;
  58049. private _barColor;
  58050. private _barHeight;
  58051. private _spacerHeight;
  58052. private _labelColor;
  58053. private _groups;
  58054. private _bars;
  58055. /**
  58056. * Creates a new SelectionPanel
  58057. * @param name of SelectionPanel
  58058. * @param groups is an array of SelectionGroups
  58059. */
  58060. constructor(
  58061. /** name of SelectionPanel */
  58062. name: string,
  58063. /** an array of SelectionGroups */
  58064. groups?: SelectorGroup[]);
  58065. protected _getTypeName(): string;
  58066. /** Gets or sets the headerColor */
  58067. headerColor: string;
  58068. private _setHeaderColor;
  58069. /** Gets or sets the button color */
  58070. buttonColor: string;
  58071. private _setbuttonColor;
  58072. /** Gets or sets the label color */
  58073. labelColor: string;
  58074. private _setLabelColor;
  58075. /** Gets or sets the button background */
  58076. buttonBackground: string;
  58077. private _setButtonBackground;
  58078. /** Gets or sets the color of separator bar */
  58079. barColor: string;
  58080. private _setBarColor;
  58081. /** Gets or sets the height of separator bar */
  58082. barHeight: string;
  58083. private _setBarHeight;
  58084. /** Gets or sets the height of spacers*/
  58085. spacerHeight: string;
  58086. private _setSpacerHeight;
  58087. /** Adds a bar between groups */
  58088. private _addSpacer;
  58089. /** Add a group to the selection panel
  58090. * @param group is the selector group to add
  58091. */
  58092. addGroup(group: SelectorGroup): void;
  58093. /** Remove the group from the given position
  58094. * @param groupNb is the position of the group in the list
  58095. */
  58096. removeGroup(groupNb: number): void;
  58097. /** Change a group header label
  58098. * @param label is the new group header label
  58099. * @param groupNb is the number of the group to relabel
  58100. * */
  58101. setHeaderName(label: string, groupNb: number): void;
  58102. /** Change selector label to the one given
  58103. * @param label is the new selector label
  58104. * @param groupNb is the number of the groupcontaining the selector
  58105. * @param selectorNb is the number of the selector within a group to relabel
  58106. * */
  58107. relabel(label: string, groupNb: number, selectorNb: number): void;
  58108. /** For a given group position remove the selector at the given position
  58109. * @param groupNb is the number of the group to remove the selector from
  58110. * @param selectorNb is the number of the selector within the group
  58111. */
  58112. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  58113. /** For a given group position of correct type add a checkbox button
  58114. * @param groupNb is the number of the group to remove the selector from
  58115. * @param label is the label for the selector
  58116. * @param func is the function called when the Selector is checked
  58117. * @param checked is true when Selector is checked
  58118. */
  58119. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58120. /** For a given group position of correct type add a radio button
  58121. * @param groupNb is the number of the group to remove the selector from
  58122. * @param label is the label for the selector
  58123. * @param func is the function called when the Selector is checked
  58124. * @param checked is true when Selector is checked
  58125. */
  58126. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  58127. /**
  58128. * For a given slider group add a slider
  58129. * @param groupNb is the number of the group to add the slider to
  58130. * @param label is the label for the Slider
  58131. * @param func is the function called when the Slider moves
  58132. * @param unit is a string describing the units used, eg degrees or metres
  58133. * @param min is the minimum value for the Slider
  58134. * @param max is the maximum value for the Slider
  58135. * @param value is the start value for the Slider between min and max
  58136. * @param onVal is the function used to format the value displayed, eg radians to degrees
  58137. */
  58138. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  58139. }
  58140. }
  58141. declare module BABYLON.GUI {
  58142. /**
  58143. * Class used to hold a the container for ScrollViewer
  58144. * @hidden
  58145. */
  58146. export class _ScrollViewerWindow extends Container {
  58147. parentClientWidth: number;
  58148. parentClientHeight: number;
  58149. /**
  58150. * Creates a new ScrollViewerWindow
  58151. * @param name of ScrollViewerWindow
  58152. */
  58153. constructor(name?: string);
  58154. protected _getTypeName(): string;
  58155. /** @hidden */
  58156. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58157. protected _postMeasure(): void;
  58158. }
  58159. }
  58160. declare module BABYLON.GUI {
  58161. /**
  58162. * Class used to create slider controls
  58163. */
  58164. export class ScrollBar extends BaseSlider {
  58165. name?: string | undefined;
  58166. private _background;
  58167. private _borderColor;
  58168. private _thumbMeasure;
  58169. /** Gets or sets border color */
  58170. borderColor: string;
  58171. /** Gets or sets background color */
  58172. background: string;
  58173. /**
  58174. * Creates a new Slider
  58175. * @param name defines the control name
  58176. */
  58177. constructor(name?: string | undefined);
  58178. protected _getTypeName(): string;
  58179. protected _getThumbThickness(): number; draw(context: CanvasRenderingContext2D): void;
  58180. private _first;
  58181. private _originX;
  58182. private _originY;
  58183. /** @hidden */
  58184. protected _updateValueFromPointer(x: number, y: number): void; onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  58185. }
  58186. }
  58187. declare module BABYLON.GUI {
  58188. /**
  58189. * Class used to hold a viewer window and sliders in a grid
  58190. */
  58191. export class ScrollViewer extends Rectangle {
  58192. private _grid;
  58193. private _horizontalBarSpace;
  58194. private _verticalBarSpace;
  58195. private _dragSpace;
  58196. private _horizontalBar;
  58197. private _verticalBar;
  58198. private _barColor;
  58199. private _barBackground;
  58200. private _barSize;
  58201. private _endLeft;
  58202. private _endTop;
  58203. private _window;
  58204. private _pointerIsOver;
  58205. private _wheelPrecision;
  58206. private _onPointerObserver;
  58207. private _clientWidth;
  58208. private _clientHeight;
  58209. /**
  58210. * Gets the horizontal scrollbar
  58211. */
  58212. readonly horizontalBar: ScrollBar;
  58213. /**
  58214. * Gets the vertical scrollbar
  58215. */
  58216. readonly verticalBar: ScrollBar;
  58217. /**
  58218. * Adds a new control to the current container
  58219. * @param control defines the control to add
  58220. * @returns the current container
  58221. */
  58222. addControl(control: BABYLON.Nullable<Control>): Container;
  58223. /**
  58224. * Removes a control from the current container
  58225. * @param control defines the control to remove
  58226. * @returns the current container
  58227. */
  58228. removeControl(control: Control): Container;
  58229. /** Gets the list of children */
  58230. readonly children: Control[]; flagDescendantsAsMatrixDirty(): void;
  58231. /**
  58232. * Creates a new ScrollViewer
  58233. * @param name of ScrollViewer
  58234. */
  58235. constructor(name?: string);
  58236. /** Reset the scroll viewer window to initial size */
  58237. resetWindow(): void;
  58238. protected _getTypeName(): string;
  58239. private _buildClientSizes;
  58240. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  58241. protected _postMeasure(): void;
  58242. /**
  58243. * Gets or sets the mouse wheel precision
  58244. * from 0 to 1 with a default value of 0.05
  58245. * */
  58246. wheelPrecision: number;
  58247. /** Gets or sets the bar color */
  58248. barColor: string;
  58249. /** Gets or sets the size of the bar */
  58250. barSize: number;
  58251. /** Gets or sets the bar background */
  58252. barBackground: string;
  58253. /** @hidden */
  58254. private _updateScroller; link(host: AdvancedDynamicTexture): void;
  58255. /** @hidden */
  58256. private _attachWheel; renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  58257. /** Releases associated resources */
  58258. dispose(): void;
  58259. }
  58260. }
  58261. declare module BABYLON.GUI {
  58262. /** Class used to render a grid */
  58263. export class DisplayGrid extends Control {
  58264. name?: string | undefined;
  58265. private _cellWidth;
  58266. private _cellHeight;
  58267. private _minorLineTickness;
  58268. private _minorLineColor;
  58269. private _majorLineTickness;
  58270. private _majorLineColor;
  58271. private _majorLineFrequency;
  58272. private _background;
  58273. private _displayMajorLines;
  58274. private _displayMinorLines;
  58275. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  58276. displayMinorLines: boolean;
  58277. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  58278. displayMajorLines: boolean;
  58279. /** Gets or sets background color (Black by default) */
  58280. background: string;
  58281. /** Gets or sets the width of each cell (20 by default) */
  58282. cellWidth: number;
  58283. /** Gets or sets the height of each cell (20 by default) */
  58284. cellHeight: number;
  58285. /** Gets or sets the tickness of minor lines (1 by default) */
  58286. minorLineTickness: number;
  58287. /** Gets or sets the color of minor lines (DarkGray by default) */
  58288. minorLineColor: string;
  58289. /** Gets or sets the tickness of major lines (2 by default) */
  58290. majorLineTickness: number;
  58291. /** Gets or sets the color of major lines (White by default) */
  58292. majorLineColor: string;
  58293. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  58294. majorLineFrequency: number;
  58295. /**
  58296. * Creates a new GridDisplayRectangle
  58297. * @param name defines the control name
  58298. */
  58299. constructor(name?: string | undefined); draw(context: CanvasRenderingContext2D): void;
  58300. protected _getTypeName(): string;
  58301. }
  58302. }
  58303. declare module BABYLON.GUI {
  58304. /**
  58305. * Class used to create slider controls based on images
  58306. */
  58307. export class ImageBasedSlider extends BaseSlider {
  58308. name?: string | undefined;
  58309. private _backgroundImage;
  58310. private _thumbImage;
  58311. private _valueBarImage;
  58312. private _tempMeasure;
  58313. displayThumb: boolean;
  58314. /**
  58315. * Gets or sets the image used to render the background
  58316. */
  58317. backgroundImage: Image;
  58318. /**
  58319. * Gets or sets the image used to render the value bar
  58320. */
  58321. valueBarImage: Image;
  58322. /**
  58323. * Gets or sets the image used to render the thumb
  58324. */
  58325. thumbImage: Image;
  58326. /**
  58327. * Creates a new ImageBasedSlider
  58328. * @param name defines the control name
  58329. */
  58330. constructor(name?: string | undefined);
  58331. protected _getTypeName(): string; draw(context: CanvasRenderingContext2D): void;
  58332. }
  58333. }
  58334. declare module BABYLON.GUI {
  58335. /**
  58336. * Forcing an export so that this code will execute
  58337. * @hidden
  58338. */
  58339. const name = "Statics";
  58340. }
  58341. declare module BABYLON.GUI {
  58342. /**
  58343. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  58344. */
  58345. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  58346. /**
  58347. * Define the instrumented AdvancedDynamicTexture.
  58348. */
  58349. texture: AdvancedDynamicTexture;
  58350. private _captureRenderTime;
  58351. private _renderTime;
  58352. private _captureLayoutTime;
  58353. private _layoutTime;
  58354. private _onBeginRenderObserver;
  58355. private _onEndRenderObserver;
  58356. private _onBeginLayoutObserver;
  58357. private _onEndLayoutObserver;
  58358. /**
  58359. * Gets the perf counter used to capture render time
  58360. */
  58361. readonly renderTimeCounter: BABYLON.PerfCounter;
  58362. /**
  58363. * Gets the perf counter used to capture layout time
  58364. */
  58365. readonly layoutTimeCounter: BABYLON.PerfCounter;
  58366. /**
  58367. * Enable or disable the render time capture
  58368. */
  58369. captureRenderTime: boolean;
  58370. /**
  58371. * Enable or disable the layout time capture
  58372. */
  58373. captureLayoutTime: boolean;
  58374. /**
  58375. * Instantiates a new advanced dynamic texture instrumentation.
  58376. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  58377. * @param texture Defines the AdvancedDynamicTexture to instrument
  58378. */
  58379. constructor(
  58380. /**
  58381. * Define the instrumented AdvancedDynamicTexture.
  58382. */
  58383. texture: AdvancedDynamicTexture);
  58384. /**
  58385. * Dispose and release associated resources.
  58386. */
  58387. dispose(): void;
  58388. }
  58389. }
  58390. declare module BABYLON.GUI {
  58391. /**
  58392. * Class used to create containers for controls
  58393. */
  58394. export class Container3D extends Control3D {
  58395. private _blockLayout;
  58396. /**
  58397. * Gets the list of child controls
  58398. */
  58399. protected _children: Control3D[];
  58400. /**
  58401. * Gets the list of child controls
  58402. */
  58403. readonly children: Array<Control3D>;
  58404. /**
  58405. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  58406. * This is helpful to optimize layout operation when adding multiple children in a row
  58407. */
  58408. blockLayout: boolean;
  58409. /**
  58410. * Creates a new container
  58411. * @param name defines the container name
  58412. */
  58413. constructor(name?: string);
  58414. /**
  58415. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  58416. * @returns the current container
  58417. */
  58418. updateLayout(): Container3D;
  58419. /**
  58420. * Gets a boolean indicating if the given control is in the children of this control
  58421. * @param control defines the control to check
  58422. * @returns true if the control is in the child list
  58423. */
  58424. containsControl(control: Control3D): boolean;
  58425. /**
  58426. * Adds a control to the children of this control
  58427. * @param control defines the control to add
  58428. * @returns the current container
  58429. */
  58430. addControl(control: Control3D): Container3D;
  58431. /**
  58432. * This function will be called everytime a new control is added
  58433. */
  58434. protected _arrangeChildren(): void;
  58435. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58436. /**
  58437. * Removes a control from the children of this control
  58438. * @param control defines the control to remove
  58439. * @returns the current container
  58440. */
  58441. removeControl(control: Control3D): Container3D;
  58442. protected _getTypeName(): string;
  58443. /**
  58444. * Releases all associated resources
  58445. */
  58446. dispose(): void;
  58447. /** Control rotation will remain unchanged */
  58448. static readonly UNSET_ORIENTATION: number;
  58449. /** Control will rotate to make it look at sphere central axis */
  58450. static readonly FACEORIGIN_ORIENTATION: number;
  58451. /** Control will rotate to make it look back at sphere central axis */
  58452. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  58453. /** Control will rotate to look at z axis (0, 0, 1) */
  58454. static readonly FACEFORWARD_ORIENTATION: number;
  58455. /** Control will rotate to look at negative z axis (0, 0, -1) */
  58456. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  58457. }
  58458. }
  58459. declare module BABYLON.GUI {
  58460. /**
  58461. * Class used to manage 3D user interface
  58462. * @see http://doc.babylonjs.com/how_to/gui3d
  58463. */
  58464. export class GUI3DManager implements BABYLON.IDisposable {
  58465. private _scene;
  58466. private _sceneDisposeObserver;
  58467. private _utilityLayer;
  58468. private _rootContainer;
  58469. private _pointerObserver;
  58470. private _pointerOutObserver;
  58471. /** @hidden */ lastPickedControl: Control3D;
  58472. /** @hidden */ lastControlOver: {
  58473. [pointerId: number]: Control3D;
  58474. };
  58475. /** @hidden */ lastControlDown: {
  58476. [pointerId: number]: Control3D;
  58477. };
  58478. /**
  58479. * BABYLON.Observable raised when the point picked by the pointer events changed
  58480. */
  58481. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  58482. /** @hidden */ sharedMaterials: {
  58483. [key: string]: BABYLON.Material;
  58484. };
  58485. /** Gets the hosting scene */
  58486. readonly scene: BABYLON.Scene;
  58487. /** Gets associated utility layer */
  58488. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  58489. /**
  58490. * Creates a new GUI3DManager
  58491. * @param scene
  58492. */
  58493. constructor(scene?: BABYLON.Scene);
  58494. private _handlePointerOut;
  58495. private _doPicking;
  58496. /**
  58497. * Gets the root container
  58498. */
  58499. readonly rootContainer: Container3D;
  58500. /**
  58501. * Gets a boolean indicating if the given control is in the root child list
  58502. * @param control defines the control to check
  58503. * @returns true if the control is in the root child list
  58504. */
  58505. containsControl(control: Control3D): boolean;
  58506. /**
  58507. * Adds a control to the root child list
  58508. * @param control defines the control to add
  58509. * @returns the current manager
  58510. */
  58511. addControl(control: Control3D): GUI3DManager;
  58512. /**
  58513. * Removes a control from the root child list
  58514. * @param control defines the control to remove
  58515. * @returns the current container
  58516. */
  58517. removeControl(control: Control3D): GUI3DManager;
  58518. /**
  58519. * Releases all associated resources
  58520. */
  58521. dispose(): void;
  58522. }
  58523. }
  58524. declare module BABYLON.GUI {
  58525. /**
  58526. * Class used to transport BABYLON.Vector3 information for pointer events
  58527. */
  58528. export class Vector3WithInfo extends BABYLON.Vector3 {
  58529. /** defines the current mouse button index */
  58530. buttonIndex: number;
  58531. /**
  58532. * Creates a new Vector3WithInfo
  58533. * @param source defines the vector3 data to transport
  58534. * @param buttonIndex defines the current mouse button index
  58535. */
  58536. constructor(source: BABYLON.Vector3,
  58537. /** defines the current mouse button index */
  58538. buttonIndex?: number);
  58539. }
  58540. }
  58541. declare module BABYLON.GUI {
  58542. /**
  58543. * Class used as base class for controls
  58544. */
  58545. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  58546. /** Defines the control name */
  58547. name?: string | undefined;
  58548. /** @hidden */ host: GUI3DManager;
  58549. private _node;
  58550. private _downCount;
  58551. private _enterCount;
  58552. private _downPointerIds;
  58553. private _isVisible;
  58554. /** Gets or sets the control position in world space */
  58555. position: BABYLON.Vector3;
  58556. /** Gets or sets the control scaling in world space */
  58557. scaling: BABYLON.Vector3;
  58558. /** Callback used to start pointer enter animation */
  58559. pointerEnterAnimation: () => void;
  58560. /** Callback used to start pointer out animation */
  58561. pointerOutAnimation: () => void;
  58562. /** Callback used to start pointer down animation */
  58563. pointerDownAnimation: () => void;
  58564. /** Callback used to start pointer up animation */
  58565. pointerUpAnimation: () => void;
  58566. /**
  58567. * An event triggered when the pointer move over the control
  58568. */
  58569. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  58570. /**
  58571. * An event triggered when the pointer move out of the control
  58572. */
  58573. onPointerOutObservable: BABYLON.Observable<Control3D>;
  58574. /**
  58575. * An event triggered when the pointer taps the control
  58576. */
  58577. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  58578. /**
  58579. * An event triggered when pointer is up
  58580. */
  58581. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  58582. /**
  58583. * An event triggered when a control is clicked on (with a mouse)
  58584. */
  58585. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  58586. /**
  58587. * An event triggered when pointer enters the control
  58588. */
  58589. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  58590. /**
  58591. * Gets or sets the parent container
  58592. */
  58593. parent: BABYLON.Nullable<Container3D>;
  58594. private _behaviors;
  58595. /**
  58596. * Gets the list of attached behaviors
  58597. * @see http://doc.babylonjs.com/features/behaviour
  58598. */
  58599. readonly behaviors: BABYLON.Behavior<Control3D>[];
  58600. /**
  58601. * Attach a behavior to the control
  58602. * @see http://doc.babylonjs.com/features/behaviour
  58603. * @param behavior defines the behavior to attach
  58604. * @returns the current control
  58605. */
  58606. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58607. /**
  58608. * Remove an attached behavior
  58609. * @see http://doc.babylonjs.com/features/behaviour
  58610. * @param behavior defines the behavior to attach
  58611. * @returns the current control
  58612. */
  58613. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  58614. /**
  58615. * Gets an attached behavior by name
  58616. * @param name defines the name of the behavior to look for
  58617. * @see http://doc.babylonjs.com/features/behaviour
  58618. * @returns null if behavior was not found else the requested behavior
  58619. */
  58620. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  58621. /** Gets or sets a boolean indicating if the control is visible */
  58622. isVisible: boolean;
  58623. /**
  58624. * Creates a new control
  58625. * @param name defines the control name
  58626. */
  58627. constructor(
  58628. /** Defines the control name */
  58629. name?: string | undefined);
  58630. /**
  58631. * Gets a string representing the class name
  58632. */
  58633. readonly typeName: string;
  58634. /**
  58635. * Get the current class name of the control.
  58636. * @returns current class name
  58637. */
  58638. getClassName(): string;
  58639. protected _getTypeName(): string;
  58640. /**
  58641. * Gets the transform node used by this control
  58642. */
  58643. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  58644. /**
  58645. * Gets the mesh used to render this control
  58646. */
  58647. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58648. /**
  58649. * Link the control as child of the given node
  58650. * @param node defines the node to link to. Use null to unlink the control
  58651. * @returns the current control
  58652. */
  58653. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  58654. /** @hidden **/ prepareNode(scene: BABYLON.Scene): void;
  58655. /**
  58656. * Node creation.
  58657. * Can be overriden by children
  58658. * @param scene defines the scene where the node must be attached
  58659. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  58660. */
  58661. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  58662. /**
  58663. * Affect a material to the given mesh
  58664. * @param mesh defines the mesh which will represent the control
  58665. */
  58666. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  58667. /** @hidden */ onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  58668. /** @hidden */ onPointerEnter(target: Control3D): boolean;
  58669. /** @hidden */ onPointerOut(target: Control3D): void;
  58670. /** @hidden */ onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58671. /** @hidden */ onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  58672. /** @hidden */
  58673. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  58674. /** @hidden */ processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  58675. /** @hidden */ disposeNode(): void;
  58676. /**
  58677. * Releases all associated resources
  58678. */
  58679. dispose(): void;
  58680. }
  58681. }
  58682. declare module BABYLON.GUI {
  58683. /**
  58684. * Class used as a root to all buttons
  58685. */
  58686. export class AbstractButton3D extends Control3D {
  58687. /**
  58688. * Creates a new button
  58689. * @param name defines the control name
  58690. */
  58691. constructor(name?: string);
  58692. protected _getTypeName(): string;
  58693. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58694. }
  58695. }
  58696. declare module BABYLON.GUI {
  58697. /**
  58698. * Class used to create a button in 3D
  58699. */
  58700. export class Button3D extends AbstractButton3D {
  58701. /** @hidden */
  58702. protected _currentMaterial: BABYLON.Material;
  58703. private _facadeTexture;
  58704. private _content;
  58705. private _contentResolution;
  58706. private _contentScaleRatio;
  58707. /**
  58708. * Gets or sets the texture resolution used to render content (512 by default)
  58709. */
  58710. contentResolution: BABYLON.int;
  58711. /**
  58712. * Gets or sets the texture scale ratio used to render content (2 by default)
  58713. */
  58714. contentScaleRatio: number;
  58715. protected _disposeFacadeTexture(): void;
  58716. protected _resetContent(): void;
  58717. /**
  58718. * Creates a new button
  58719. * @param name defines the control name
  58720. */
  58721. constructor(name?: string);
  58722. /**
  58723. * Gets or sets the GUI 2D content used to display the button's facade
  58724. */
  58725. content: Control;
  58726. /**
  58727. * Apply the facade texture (created from the content property).
  58728. * This function can be overloaded by child classes
  58729. * @param facadeTexture defines the AdvancedDynamicTexture to use
  58730. */
  58731. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  58732. protected _getTypeName(): string;
  58733. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58734. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  58735. /**
  58736. * Releases all associated resources
  58737. */
  58738. dispose(): void;
  58739. }
  58740. }
  58741. declare module BABYLON.GUI {
  58742. /**
  58743. * Abstract class used to create a container panel deployed on the surface of a volume
  58744. */
  58745. export abstract class VolumeBasedPanel extends Container3D {
  58746. private _columns;
  58747. private _rows;
  58748. private _rowThenColum;
  58749. private _orientation;
  58750. protected _cellWidth: number;
  58751. protected _cellHeight: number;
  58752. /**
  58753. * Gets or sets the distance between elements
  58754. */
  58755. margin: number;
  58756. /**
  58757. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  58758. * | Value | Type | Description |
  58759. * | ----- | ----------------------------------- | ----------- |
  58760. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  58761. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  58762. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  58763. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  58764. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  58765. */
  58766. orientation: number;
  58767. /**
  58768. * Gets or sets the number of columns requested (10 by default).
  58769. * The panel will automatically compute the number of rows based on number of child controls.
  58770. */
  58771. columns: BABYLON.int;
  58772. /**
  58773. * Gets or sets a the number of rows requested.
  58774. * The panel will automatically compute the number of columns based on number of child controls.
  58775. */
  58776. rows: BABYLON.int;
  58777. /**
  58778. * Creates new VolumeBasedPanel
  58779. */
  58780. constructor();
  58781. protected _arrangeChildren(): void;
  58782. /** Child classes must implement this function to provide correct control positioning */
  58783. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  58784. /** Child classes can implement this function to provide additional processing */
  58785. protected _finalProcessing(): void;
  58786. }
  58787. }
  58788. declare module BABYLON.GUI {
  58789. /**
  58790. * Class used to create a container panel deployed on the surface of a cylinder
  58791. */
  58792. export class CylinderPanel extends VolumeBasedPanel {
  58793. private _radius;
  58794. /**
  58795. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  58796. */
  58797. radius: BABYLON.float;
  58798. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  58799. private _cylindricalMapping;
  58800. }
  58801. }
  58802. declare module BABYLON.GUI {
  58803. /** @hidden */
  58804. export var fluentVertexShader: {
  58805. name: string;
  58806. shader: string;
  58807. };
  58808. }
  58809. declare module BABYLON.GUI {
  58810. /** @hidden */
  58811. export var fluentPixelShader: {
  58812. name: string;
  58813. shader: string;
  58814. };
  58815. }
  58816. declare module BABYLON.GUI {
  58817. /** @hidden */
  58818. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  58819. INNERGLOW: boolean;
  58820. BORDER: boolean;
  58821. HOVERLIGHT: boolean;
  58822. TEXTURE: boolean;
  58823. constructor();
  58824. }
  58825. /**
  58826. * Class used to render controls with fluent desgin
  58827. */
  58828. export class FluentMaterial extends BABYLON.PushMaterial {
  58829. /**
  58830. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  58831. */
  58832. innerGlowColorIntensity: number;
  58833. /**
  58834. * Gets or sets the inner glow color (white by default)
  58835. */
  58836. innerGlowColor: BABYLON.Color3;
  58837. /**
  58838. * Gets or sets alpha value (default is 1.0)
  58839. */
  58840. alpha: number;
  58841. /**
  58842. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  58843. */
  58844. albedoColor: BABYLON.Color3;
  58845. /**
  58846. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  58847. */
  58848. renderBorders: boolean;
  58849. /**
  58850. * Gets or sets border width (default is 0.5)
  58851. */
  58852. borderWidth: number;
  58853. /**
  58854. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  58855. */
  58856. edgeSmoothingValue: number;
  58857. /**
  58858. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  58859. */
  58860. borderMinValue: number;
  58861. /**
  58862. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  58863. */
  58864. renderHoverLight: boolean;
  58865. /**
  58866. * Gets or sets the radius used to render the hover light (default is 1.0)
  58867. */
  58868. hoverRadius: number;
  58869. /**
  58870. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  58871. */
  58872. hoverColor: BABYLON.Color4;
  58873. /**
  58874. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  58875. */
  58876. hoverPosition: BABYLON.Vector3;
  58877. private _albedoTexture;
  58878. /** Gets or sets the texture to use for albedo color */
  58879. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  58880. /**
  58881. * Creates a new Fluent material
  58882. * @param name defines the name of the material
  58883. * @param scene defines the hosting scene
  58884. */
  58885. constructor(name: string, scene: BABYLON.Scene);
  58886. needAlphaBlending(): boolean;
  58887. needAlphaTesting(): boolean;
  58888. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  58889. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  58890. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  58891. getActiveTextures(): BABYLON.BaseTexture[];
  58892. hasTexture(texture: BABYLON.BaseTexture): boolean;
  58893. dispose(forceDisposeEffect?: boolean): void;
  58894. clone(name: string): FluentMaterial;
  58895. serialize(): any;
  58896. getClassName(): string;
  58897. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  58898. }
  58899. }
  58900. declare module BABYLON.GUI {
  58901. /**
  58902. * Class used to create a holographic button in 3D
  58903. */
  58904. export class HolographicButton extends Button3D {
  58905. private _backPlate;
  58906. private _textPlate;
  58907. private _frontPlate;
  58908. private _text;
  58909. private _imageUrl;
  58910. private _shareMaterials;
  58911. private _frontMaterial;
  58912. private _backMaterial;
  58913. private _plateMaterial;
  58914. private _pickedPointObserver;
  58915. private _tooltipFade;
  58916. private _tooltipTextBlock;
  58917. private _tooltipTexture;
  58918. private _tooltipMesh;
  58919. private _tooltipHoverObserver;
  58920. private _tooltipOutObserver;
  58921. private _disposeTooltip;
  58922. /**
  58923. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  58924. */
  58925. tooltipText: BABYLON.Nullable<string>;
  58926. /**
  58927. * Gets or sets text for the button
  58928. */
  58929. text: string;
  58930. /**
  58931. * Gets or sets the image url for the button
  58932. */
  58933. imageUrl: string;
  58934. /**
  58935. * Gets the back material used by this button
  58936. */
  58937. readonly backMaterial: FluentMaterial;
  58938. /**
  58939. * Gets the front material used by this button
  58940. */
  58941. readonly frontMaterial: FluentMaterial;
  58942. /**
  58943. * Gets the plate material used by this button
  58944. */
  58945. readonly plateMaterial: BABYLON.StandardMaterial;
  58946. /**
  58947. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  58948. */
  58949. readonly shareMaterials: boolean;
  58950. /**
  58951. * Creates a new button
  58952. * @param name defines the control name
  58953. */
  58954. constructor(name?: string, shareMaterials?: boolean);
  58955. protected _getTypeName(): string;
  58956. private _rebuildContent;
  58957. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58958. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  58959. private _createBackMaterial;
  58960. private _createFrontMaterial;
  58961. private _createPlateMaterial;
  58962. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  58963. /**
  58964. * Releases all associated resources
  58965. */
  58966. dispose(): void;
  58967. }
  58968. }
  58969. declare module BABYLON.GUI {
  58970. /**
  58971. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  58972. */
  58973. export class MeshButton3D extends Button3D {
  58974. /** @hidden */
  58975. protected _currentMesh: BABYLON.Mesh;
  58976. /**
  58977. * Creates a new 3D button based on a mesh
  58978. * @param mesh mesh to become a 3D button
  58979. * @param name defines the control name
  58980. */
  58981. constructor(mesh: BABYLON.Mesh, name?: string);
  58982. protected _getTypeName(): string;
  58983. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  58984. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  58985. }
  58986. }
  58987. declare module BABYLON.GUI {
  58988. /**
  58989. * Class used to create a container panel deployed on the surface of a plane
  58990. */
  58991. export class PlanePanel extends VolumeBasedPanel {
  58992. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  58993. }
  58994. }
  58995. declare module BABYLON.GUI {
  58996. /**
  58997. * Class used to create a container panel where items get randomized planar mapping
  58998. */
  58999. export class ScatterPanel extends VolumeBasedPanel {
  59000. private _iteration;
  59001. /**
  59002. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  59003. */
  59004. iteration: BABYLON.float;
  59005. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59006. private _scatterMapping;
  59007. protected _finalProcessing(): void;
  59008. }
  59009. }
  59010. declare module BABYLON.GUI {
  59011. /**
  59012. * Class used to create a container panel deployed on the surface of a sphere
  59013. */
  59014. export class SpherePanel extends VolumeBasedPanel {
  59015. private _radius;
  59016. /**
  59017. * Gets or sets the radius of the sphere where to project controls (5 by default)
  59018. */
  59019. radius: BABYLON.float;
  59020. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  59021. private _sphericalMapping;
  59022. }
  59023. }
  59024. declare module BABYLON.GUI {
  59025. /**
  59026. * Class used to create a stack panel in 3D on XY plane
  59027. */
  59028. export class StackPanel3D extends Container3D {
  59029. private _isVertical;
  59030. /**
  59031. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  59032. */
  59033. isVertical: boolean;
  59034. /**
  59035. * Gets or sets the distance between elements
  59036. */
  59037. margin: number;
  59038. /**
  59039. * Creates new StackPanel
  59040. * @param isVertical
  59041. */
  59042. constructor(isVertical?: boolean);
  59043. protected _arrangeChildren(): void;
  59044. }
  59045. }
  59046. declare module BABYLON {
  59047. /**
  59048. * Mode that determines the coordinate system to use.
  59049. */
  59050. export enum GLTFLoaderCoordinateSystemMode {
  59051. /**
  59052. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  59053. */
  59054. AUTO = 0,
  59055. /**
  59056. * Sets the useRightHandedSystem flag on the scene.
  59057. */
  59058. FORCE_RIGHT_HANDED = 1
  59059. }
  59060. /**
  59061. * Mode that determines what animations will start.
  59062. */
  59063. export enum GLTFLoaderAnimationStartMode {
  59064. /**
  59065. * No animation will start.
  59066. */
  59067. NONE = 0,
  59068. /**
  59069. * The first animation will start.
  59070. */
  59071. FIRST = 1,
  59072. /**
  59073. * All animations will start.
  59074. */
  59075. ALL = 2
  59076. }
  59077. /**
  59078. * Interface that contains the data for the glTF asset.
  59079. */
  59080. export interface IGLTFLoaderData {
  59081. /**
  59082. * Object that represents the glTF JSON.
  59083. */
  59084. json: Object;
  59085. /**
  59086. * The BIN chunk of a binary glTF.
  59087. */
  59088. bin: Nullable<ArrayBufferView>;
  59089. }
  59090. /**
  59091. * Interface for extending the loader.
  59092. */
  59093. export interface IGLTFLoaderExtension {
  59094. /**
  59095. * The name of this extension.
  59096. */
  59097. readonly name: string;
  59098. /**
  59099. * Defines whether this extension is enabled.
  59100. */
  59101. enabled: boolean;
  59102. }
  59103. /**
  59104. * Loader state.
  59105. */
  59106. export enum GLTFLoaderState {
  59107. /**
  59108. * The asset is loading.
  59109. */
  59110. LOADING = 0,
  59111. /**
  59112. * The asset is ready for rendering.
  59113. */
  59114. READY = 1,
  59115. /**
  59116. * The asset is completely loaded.
  59117. */
  59118. COMPLETE = 2
  59119. }
  59120. /** @hidden */
  59121. export interface IGLTFLoader extends IDisposable {
  59122. readonly state: Nullable<GLTFLoaderState>;
  59123. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  59124. meshes: AbstractMesh[];
  59125. particleSystems: IParticleSystem[];
  59126. skeletons: Skeleton[];
  59127. animationGroups: AnimationGroup[];
  59128. }>;
  59129. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  59130. }
  59131. /**
  59132. * File loader for loading glTF files into a scene.
  59133. */
  59134. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  59135. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59136. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  59137. /**
  59138. * Raised when the asset has been parsed
  59139. */
  59140. onParsedObservable: Observable<IGLTFLoaderData>;
  59141. private _onParsedObserver;
  59142. /**
  59143. * Raised when the asset has been parsed
  59144. */
  59145. onParsed: (loaderData: IGLTFLoaderData) => void;
  59146. /**
  59147. * 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.
  59148. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  59149. * Defaults to true.
  59150. * @hidden
  59151. */
  59152. static IncrementalLoading: boolean;
  59153. /**
  59154. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  59155. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  59156. * @hidden
  59157. */
  59158. static HomogeneousCoordinates: boolean;
  59159. /**
  59160. * The coordinate system mode. Defaults to AUTO.
  59161. */
  59162. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  59163. /**
  59164. * The animation start mode. Defaults to FIRST.
  59165. */
  59166. animationStartMode: GLTFLoaderAnimationStartMode;
  59167. /**
  59168. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  59169. */
  59170. compileMaterials: boolean;
  59171. /**
  59172. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  59173. */
  59174. useClipPlane: boolean;
  59175. /**
  59176. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  59177. */
  59178. compileShadowGenerators: boolean;
  59179. /**
  59180. * Defines if the Alpha blended materials are only applied as coverage.
  59181. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  59182. * If true, no extra effects are applied to transparent pixels.
  59183. */
  59184. transparencyAsCoverage: boolean;
  59185. /**
  59186. * Function called before loading a url referenced by the asset.
  59187. */
  59188. preprocessUrlAsync: (url: string) => Promise<string>;
  59189. /**
  59190. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59191. */
  59192. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  59193. private _onMeshLoadedObserver;
  59194. /**
  59195. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  59196. */
  59197. onMeshLoaded: (mesh: AbstractMesh) => void;
  59198. /**
  59199. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  59200. */
  59201. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  59202. private _onTextureLoadedObserver;
  59203. /**
  59204. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  59205. */
  59206. onTextureLoaded: (texture: BaseTexture) => void;
  59207. /**
  59208. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  59209. */
  59210. readonly onMaterialLoadedObservable: Observable<Material>;
  59211. private _onMaterialLoadedObserver;
  59212. /**
  59213. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  59214. */
  59215. onMaterialLoaded: (material: Material) => void;
  59216. /**
  59217. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  59218. */
  59219. readonly onCameraLoadedObservable: Observable<Camera>;
  59220. private _onCameraLoadedObserver;
  59221. /**
  59222. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  59223. */
  59224. onCameraLoaded: (camera: Camera) => void;
  59225. /**
  59226. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  59227. * For assets with LODs, raised when all of the LODs are complete.
  59228. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59229. */
  59230. readonly onCompleteObservable: Observable<void>;
  59231. private _onCompleteObserver;
  59232. /**
  59233. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  59234. * For assets with LODs, raised when all of the LODs are complete.
  59235. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  59236. */
  59237. onComplete: () => void;
  59238. /**
  59239. * Observable raised when an error occurs.
  59240. */
  59241. readonly onErrorObservable: Observable<any>;
  59242. private _onErrorObserver;
  59243. /**
  59244. * Callback raised when an error occurs.
  59245. */
  59246. onError: (reason: any) => void;
  59247. /**
  59248. * Observable raised after the loader is disposed.
  59249. */
  59250. readonly onDisposeObservable: Observable<void>;
  59251. private _onDisposeObserver;
  59252. /**
  59253. * Callback raised after the loader is disposed.
  59254. */
  59255. onDispose: () => void;
  59256. /**
  59257. * Observable raised after a loader extension is created.
  59258. * Set additional options for a loader extension in this event.
  59259. */
  59260. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  59261. private _onExtensionLoadedObserver;
  59262. /**
  59263. * Callback raised after a loader extension is created.
  59264. */
  59265. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  59266. /**
  59267. * Defines if the loader logging is enabled.
  59268. */
  59269. loggingEnabled: boolean;
  59270. /**
  59271. * Defines if the loader should capture performance counters.
  59272. */
  59273. capturePerformanceCounters: boolean;
  59274. /**
  59275. * Defines if the loader should validate the asset.
  59276. */
  59277. validate: boolean;
  59278. /**
  59279. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  59280. */
  59281. readonly onValidatedObservable: Observable<IGLTFValidationResults>;
  59282. private _onValidatedObserver;
  59283. /**
  59284. * Callback raised after a loader extension is created.
  59285. */
  59286. onValidated: (results: IGLTFValidationResults) => void;
  59287. private _loader;
  59288. /**
  59289. * Name of the loader ("gltf")
  59290. */
  59291. name: string;
  59292. /**
  59293. * Supported file extensions of the loader (.gltf, .glb)
  59294. */
  59295. extensions: ISceneLoaderPluginExtensions;
  59296. /**
  59297. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  59298. */
  59299. dispose(): void;
  59300. /** @hidden */ clear(): void;
  59301. /**
  59302. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  59303. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59304. * @param scene the scene the meshes should be added to
  59305. * @param data the glTF data to load
  59306. * @param rootUrl root url to load from
  59307. * @param onProgress event that fires when loading progress has occured
  59308. * @param fileName Defines the name of the file to load
  59309. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59310. */
  59311. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  59312. meshes: AbstractMesh[];
  59313. particleSystems: IParticleSystem[];
  59314. skeletons: Skeleton[];
  59315. animationGroups: AnimationGroup[];
  59316. }>;
  59317. /**
  59318. * Imports all objects from the loaded glTF data and adds them to the scene
  59319. * @param scene the scene the objects should be added to
  59320. * @param data the glTF data to load
  59321. * @param rootUrl root url to load from
  59322. * @param onProgress event that fires when loading progress has occured
  59323. * @param fileName Defines the name of the file to load
  59324. * @returns a promise which completes when objects have been loaded to the scene
  59325. */
  59326. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  59327. /**
  59328. * Load into an asset container.
  59329. * @param scene The scene to load into
  59330. * @param data The data to import
  59331. * @param rootUrl The root url for scene and resources
  59332. * @param onProgress The callback when the load progresses
  59333. * @param fileName Defines the name of the file to load
  59334. * @returns The loaded asset container
  59335. */
  59336. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  59337. /**
  59338. * If the data string can be loaded directly.
  59339. * @param data string contianing the file data
  59340. * @returns if the data can be loaded directly
  59341. */
  59342. canDirectLoad(data: string): boolean;
  59343. /**
  59344. * Rewrites a url by combining a root url and response url.
  59345. */
  59346. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  59347. /**
  59348. * Instantiates a glTF file loader plugin.
  59349. * @returns the created plugin
  59350. */
  59351. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  59352. /**
  59353. * The loader state or null if the loader is not active.
  59354. */
  59355. readonly loaderState: Nullable<GLTFLoaderState>;
  59356. /**
  59357. * Returns a promise that resolves when the asset is completely loaded.
  59358. * @returns a promise that resolves when the asset is completely loaded.
  59359. */
  59360. whenCompleteAsync(): Promise<void>;
  59361. private _parseAsync;
  59362. private _validateAsync;
  59363. private _getLoader;
  59364. private _unpackBinary;
  59365. private _unpackBinaryV1;
  59366. private _unpackBinaryV2;
  59367. private static _parseVersion;
  59368. private static _compareVersion;
  59369. private static _decodeBufferToText;
  59370. private static readonly _logSpaces;
  59371. private _logIndentLevel;
  59372. private _loggingEnabled;
  59373. /** @hidden */ log: (message: string) => void;
  59374. /** @hidden */ logOpen(message: string): void;
  59375. /** @hidden */ logClose(): void;
  59376. private _logEnabled;
  59377. private _logDisabled;
  59378. private _capturePerformanceCounters;
  59379. /** @hidden */ startPerformanceCounter: (counterName: string) => void;
  59380. /** @hidden */ endPerformanceCounter: (counterName: string) => void;
  59381. private _startPerformanceCounterEnabled;
  59382. private _startPerformanceCounterDisabled;
  59383. private _endPerformanceCounterEnabled;
  59384. private _endPerformanceCounterDisabled;
  59385. }
  59386. }
  59387. declare module BABYLON.GLTF1 {
  59388. /**
  59389. * Enums
  59390. * @hidden
  59391. */
  59392. export enum EComponentType {
  59393. BYTE = 5120,
  59394. UNSIGNED_BYTE = 5121,
  59395. SHORT = 5122,
  59396. UNSIGNED_SHORT = 5123,
  59397. FLOAT = 5126
  59398. }
  59399. /** @hidden */
  59400. export enum EShaderType {
  59401. FRAGMENT = 35632,
  59402. VERTEX = 35633
  59403. }
  59404. /** @hidden */
  59405. export enum EParameterType {
  59406. BYTE = 5120,
  59407. UNSIGNED_BYTE = 5121,
  59408. SHORT = 5122,
  59409. UNSIGNED_SHORT = 5123,
  59410. INT = 5124,
  59411. UNSIGNED_INT = 5125,
  59412. FLOAT = 5126,
  59413. FLOAT_VEC2 = 35664,
  59414. FLOAT_VEC3 = 35665,
  59415. FLOAT_VEC4 = 35666,
  59416. INT_VEC2 = 35667,
  59417. INT_VEC3 = 35668,
  59418. INT_VEC4 = 35669,
  59419. BOOL = 35670,
  59420. BOOL_VEC2 = 35671,
  59421. BOOL_VEC3 = 35672,
  59422. BOOL_VEC4 = 35673,
  59423. FLOAT_MAT2 = 35674,
  59424. FLOAT_MAT3 = 35675,
  59425. FLOAT_MAT4 = 35676,
  59426. SAMPLER_2D = 35678
  59427. }
  59428. /** @hidden */
  59429. export enum ETextureWrapMode {
  59430. CLAMP_TO_EDGE = 33071,
  59431. MIRRORED_REPEAT = 33648,
  59432. REPEAT = 10497
  59433. }
  59434. /** @hidden */
  59435. export enum ETextureFilterType {
  59436. NEAREST = 9728,
  59437. LINEAR = 9728,
  59438. NEAREST_MIPMAP_NEAREST = 9984,
  59439. LINEAR_MIPMAP_NEAREST = 9985,
  59440. NEAREST_MIPMAP_LINEAR = 9986,
  59441. LINEAR_MIPMAP_LINEAR = 9987
  59442. }
  59443. /** @hidden */
  59444. export enum ETextureFormat {
  59445. ALPHA = 6406,
  59446. RGB = 6407,
  59447. RGBA = 6408,
  59448. LUMINANCE = 6409,
  59449. LUMINANCE_ALPHA = 6410
  59450. }
  59451. /** @hidden */
  59452. export enum ECullingType {
  59453. FRONT = 1028,
  59454. BACK = 1029,
  59455. FRONT_AND_BACK = 1032
  59456. }
  59457. /** @hidden */
  59458. export enum EBlendingFunction {
  59459. ZERO = 0,
  59460. ONE = 1,
  59461. SRC_COLOR = 768,
  59462. ONE_MINUS_SRC_COLOR = 769,
  59463. DST_COLOR = 774,
  59464. ONE_MINUS_DST_COLOR = 775,
  59465. SRC_ALPHA = 770,
  59466. ONE_MINUS_SRC_ALPHA = 771,
  59467. DST_ALPHA = 772,
  59468. ONE_MINUS_DST_ALPHA = 773,
  59469. CONSTANT_COLOR = 32769,
  59470. ONE_MINUS_CONSTANT_COLOR = 32770,
  59471. CONSTANT_ALPHA = 32771,
  59472. ONE_MINUS_CONSTANT_ALPHA = 32772,
  59473. SRC_ALPHA_SATURATE = 776
  59474. }
  59475. /** @hidden */
  59476. export interface IGLTFProperty {
  59477. extensions?: {
  59478. [key: string]: any;
  59479. };
  59480. extras?: Object;
  59481. }
  59482. /** @hidden */
  59483. export interface IGLTFChildRootProperty extends IGLTFProperty {
  59484. name?: string;
  59485. }
  59486. /** @hidden */
  59487. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  59488. bufferView: string;
  59489. byteOffset: number;
  59490. byteStride: number;
  59491. count: number;
  59492. type: string;
  59493. componentType: EComponentType;
  59494. max?: number[];
  59495. min?: number[];
  59496. name?: string;
  59497. }
  59498. /** @hidden */
  59499. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  59500. buffer: string;
  59501. byteOffset: number;
  59502. byteLength: number;
  59503. byteStride: number;
  59504. target?: number;
  59505. }
  59506. /** @hidden */
  59507. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  59508. uri: string;
  59509. byteLength?: number;
  59510. type?: string;
  59511. }
  59512. /** @hidden */
  59513. export interface IGLTFShader extends IGLTFChildRootProperty {
  59514. uri: string;
  59515. type: EShaderType;
  59516. }
  59517. /** @hidden */
  59518. export interface IGLTFProgram extends IGLTFChildRootProperty {
  59519. attributes: string[];
  59520. fragmentShader: string;
  59521. vertexShader: string;
  59522. }
  59523. /** @hidden */
  59524. export interface IGLTFTechniqueParameter {
  59525. type: number;
  59526. count?: number;
  59527. semantic?: string;
  59528. node?: string;
  59529. value?: number | boolean | string | Array<any>;
  59530. source?: string;
  59531. babylonValue?: any;
  59532. }
  59533. /** @hidden */
  59534. export interface IGLTFTechniqueCommonProfile {
  59535. lightingModel: string;
  59536. texcoordBindings: Object;
  59537. parameters?: Array<any>;
  59538. }
  59539. /** @hidden */
  59540. export interface IGLTFTechniqueStatesFunctions {
  59541. blendColor?: number[];
  59542. blendEquationSeparate?: number[];
  59543. blendFuncSeparate?: number[];
  59544. colorMask: boolean[];
  59545. cullFace: number[];
  59546. }
  59547. /** @hidden */
  59548. export interface IGLTFTechniqueStates {
  59549. enable: number[];
  59550. functions: IGLTFTechniqueStatesFunctions;
  59551. }
  59552. /** @hidden */
  59553. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  59554. parameters: {
  59555. [key: string]: IGLTFTechniqueParameter;
  59556. };
  59557. program: string;
  59558. attributes: {
  59559. [key: string]: string;
  59560. };
  59561. uniforms: {
  59562. [key: string]: string;
  59563. };
  59564. states: IGLTFTechniqueStates;
  59565. }
  59566. /** @hidden */
  59567. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  59568. technique?: string;
  59569. values: string[];
  59570. }
  59571. /** @hidden */
  59572. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  59573. attributes: {
  59574. [key: string]: string;
  59575. };
  59576. indices: string;
  59577. material: string;
  59578. mode?: number;
  59579. }
  59580. /** @hidden */
  59581. export interface IGLTFMesh extends IGLTFChildRootProperty {
  59582. primitives: IGLTFMeshPrimitive[];
  59583. }
  59584. /** @hidden */
  59585. export interface IGLTFImage extends IGLTFChildRootProperty {
  59586. uri: string;
  59587. }
  59588. /** @hidden */
  59589. export interface IGLTFSampler extends IGLTFChildRootProperty {
  59590. magFilter?: number;
  59591. minFilter?: number;
  59592. wrapS?: number;
  59593. wrapT?: number;
  59594. }
  59595. /** @hidden */
  59596. export interface IGLTFTexture extends IGLTFChildRootProperty {
  59597. sampler: string;
  59598. source: string;
  59599. format?: ETextureFormat;
  59600. internalFormat?: ETextureFormat;
  59601. target?: number;
  59602. type?: number;
  59603. babylonTexture?: Texture;
  59604. }
  59605. /** @hidden */
  59606. export interface IGLTFAmbienLight {
  59607. color?: number[];
  59608. }
  59609. /** @hidden */
  59610. export interface IGLTFDirectionalLight {
  59611. color?: number[];
  59612. }
  59613. /** @hidden */
  59614. export interface IGLTFPointLight {
  59615. color?: number[];
  59616. constantAttenuation?: number;
  59617. linearAttenuation?: number;
  59618. quadraticAttenuation?: number;
  59619. }
  59620. /** @hidden */
  59621. export interface IGLTFSpotLight {
  59622. color?: number[];
  59623. constantAttenuation?: number;
  59624. fallOfAngle?: number;
  59625. fallOffExponent?: number;
  59626. linearAttenuation?: number;
  59627. quadraticAttenuation?: number;
  59628. }
  59629. /** @hidden */
  59630. export interface IGLTFLight extends IGLTFChildRootProperty {
  59631. type: string;
  59632. }
  59633. /** @hidden */
  59634. export interface IGLTFCameraOrthographic {
  59635. xmag: number;
  59636. ymag: number;
  59637. zfar: number;
  59638. znear: number;
  59639. }
  59640. /** @hidden */
  59641. export interface IGLTFCameraPerspective {
  59642. aspectRatio: number;
  59643. yfov: number;
  59644. zfar: number;
  59645. znear: number;
  59646. }
  59647. /** @hidden */
  59648. export interface IGLTFCamera extends IGLTFChildRootProperty {
  59649. type: string;
  59650. }
  59651. /** @hidden */
  59652. export interface IGLTFAnimationChannelTarget {
  59653. id: string;
  59654. path: string;
  59655. }
  59656. /** @hidden */
  59657. export interface IGLTFAnimationChannel {
  59658. sampler: string;
  59659. target: IGLTFAnimationChannelTarget;
  59660. }
  59661. /** @hidden */
  59662. export interface IGLTFAnimationSampler {
  59663. input: string;
  59664. output: string;
  59665. interpolation?: string;
  59666. }
  59667. /** @hidden */
  59668. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  59669. channels?: IGLTFAnimationChannel[];
  59670. parameters?: {
  59671. [key: string]: string;
  59672. };
  59673. samplers?: {
  59674. [key: string]: IGLTFAnimationSampler;
  59675. };
  59676. }
  59677. /** @hidden */
  59678. export interface IGLTFNodeInstanceSkin {
  59679. skeletons: string[];
  59680. skin: string;
  59681. meshes: string[];
  59682. }
  59683. /** @hidden */
  59684. export interface IGLTFSkins extends IGLTFChildRootProperty {
  59685. bindShapeMatrix: number[];
  59686. inverseBindMatrices: string;
  59687. jointNames: string[];
  59688. babylonSkeleton?: Skeleton;
  59689. }
  59690. /** @hidden */
  59691. export interface IGLTFNode extends IGLTFChildRootProperty {
  59692. camera?: string;
  59693. children: string[];
  59694. skin?: string;
  59695. jointName?: string;
  59696. light?: string;
  59697. matrix: number[];
  59698. mesh?: string;
  59699. meshes?: string[];
  59700. rotation?: number[];
  59701. scale?: number[];
  59702. translation?: number[];
  59703. babylonNode?: Node;
  59704. }
  59705. /** @hidden */
  59706. export interface IGLTFScene extends IGLTFChildRootProperty {
  59707. nodes: string[];
  59708. }
  59709. /** @hidden */
  59710. export interface IGLTFRuntime {
  59711. extensions: {
  59712. [key: string]: any;
  59713. };
  59714. accessors: {
  59715. [key: string]: IGLTFAccessor;
  59716. };
  59717. buffers: {
  59718. [key: string]: IGLTFBuffer;
  59719. };
  59720. bufferViews: {
  59721. [key: string]: IGLTFBufferView;
  59722. };
  59723. meshes: {
  59724. [key: string]: IGLTFMesh;
  59725. };
  59726. lights: {
  59727. [key: string]: IGLTFLight;
  59728. };
  59729. cameras: {
  59730. [key: string]: IGLTFCamera;
  59731. };
  59732. nodes: {
  59733. [key: string]: IGLTFNode;
  59734. };
  59735. images: {
  59736. [key: string]: IGLTFImage;
  59737. };
  59738. textures: {
  59739. [key: string]: IGLTFTexture;
  59740. };
  59741. shaders: {
  59742. [key: string]: IGLTFShader;
  59743. };
  59744. programs: {
  59745. [key: string]: IGLTFProgram;
  59746. };
  59747. samplers: {
  59748. [key: string]: IGLTFSampler;
  59749. };
  59750. techniques: {
  59751. [key: string]: IGLTFTechnique;
  59752. };
  59753. materials: {
  59754. [key: string]: IGLTFMaterial;
  59755. };
  59756. animations: {
  59757. [key: string]: IGLTFAnimation;
  59758. };
  59759. skins: {
  59760. [key: string]: IGLTFSkins;
  59761. };
  59762. currentScene?: Object;
  59763. scenes: {
  59764. [key: string]: IGLTFScene;
  59765. };
  59766. extensionsUsed: string[];
  59767. extensionsRequired?: string[];
  59768. buffersCount: number;
  59769. shaderscount: number;
  59770. scene: Scene;
  59771. rootUrl: string;
  59772. loadedBufferCount: number;
  59773. loadedBufferViews: {
  59774. [name: string]: ArrayBufferView;
  59775. };
  59776. loadedShaderCount: number;
  59777. importOnlyMeshes: boolean;
  59778. importMeshesNames?: string[];
  59779. dummyNodes: Node[];
  59780. }
  59781. /** @hidden */
  59782. export interface INodeToRoot {
  59783. bone: Bone;
  59784. node: IGLTFNode;
  59785. id: string;
  59786. }
  59787. /** @hidden */
  59788. export interface IJointNode {
  59789. node: IGLTFNode;
  59790. id: string;
  59791. }
  59792. }
  59793. declare module BABYLON.GLTF1 {
  59794. /**
  59795. * Utils functions for GLTF
  59796. * @hidden
  59797. */
  59798. export class GLTFUtils {
  59799. /**
  59800. * Sets the given "parameter" matrix
  59801. * @param scene: the Scene object
  59802. * @param source: the source node where to pick the matrix
  59803. * @param parameter: the GLTF technique parameter
  59804. * @param uniformName: the name of the shader's uniform
  59805. * @param shaderMaterial: the shader material
  59806. */
  59807. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  59808. /**
  59809. * Sets the given "parameter" matrix
  59810. * @param shaderMaterial: the shader material
  59811. * @param uniform: the name of the shader's uniform
  59812. * @param value: the value of the uniform
  59813. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  59814. */
  59815. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  59816. /**
  59817. * Returns the wrap mode of the texture
  59818. * @param mode: the mode value
  59819. */
  59820. static GetWrapMode(mode: number): number;
  59821. /**
  59822. * Returns the byte stride giving an accessor
  59823. * @param accessor: the GLTF accessor objet
  59824. */
  59825. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  59826. /**
  59827. * Returns the texture filter mode giving a mode value
  59828. * @param mode: the filter mode value
  59829. */
  59830. static GetTextureFilterMode(mode: number): ETextureFilterType;
  59831. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  59832. /**
  59833. * Returns a buffer from its accessor
  59834. * @param gltfRuntime: the GLTF runtime
  59835. * @param accessor: the GLTF accessor
  59836. */
  59837. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  59838. /**
  59839. * Decodes a buffer view into a string
  59840. * @param view: the buffer view
  59841. */
  59842. static DecodeBufferToText(view: ArrayBufferView): string;
  59843. /**
  59844. * Returns the default material of gltf. Related to
  59845. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  59846. * @param scene: the Babylon.js scene
  59847. */
  59848. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  59849. private static _DefaultMaterial;
  59850. }
  59851. }
  59852. declare module BABYLON.GLTF1 {
  59853. /**
  59854. * Implementation of the base glTF spec
  59855. * @hidden
  59856. */
  59857. export class GLTFLoaderBase {
  59858. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  59859. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  59860. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  59861. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  59862. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  59863. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  59864. }
  59865. /**
  59866. * glTF V1 Loader
  59867. * @hidden
  59868. */
  59869. export class GLTFLoader implements IGLTFLoader {
  59870. static Extensions: {
  59871. [name: string]: GLTFLoaderExtension;
  59872. };
  59873. static RegisterExtension(extension: GLTFLoaderExtension): void;
  59874. state: Nullable<GLTFLoaderState>;
  59875. dispose(): void;
  59876. private _importMeshAsync;
  59877. /**
  59878. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  59879. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  59880. * @param scene the scene the meshes should be added to
  59881. * @param data gltf data containing information of the meshes in a loaded file
  59882. * @param rootUrl root url to load from
  59883. * @param onProgress event that fires when loading progress has occured
  59884. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  59885. */
  59886. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  59887. meshes: AbstractMesh[];
  59888. particleSystems: IParticleSystem[];
  59889. skeletons: Skeleton[];
  59890. animationGroups: AnimationGroup[];
  59891. }>;
  59892. private _loadAsync;
  59893. /**
  59894. * Imports all objects from a loaded gltf file and adds them to the scene
  59895. * @param scene the scene the objects should be added to
  59896. * @param data gltf data containing information of the meshes in a loaded file
  59897. * @param rootUrl root url to load from
  59898. * @param onProgress event that fires when loading progress has occured
  59899. * @returns a promise which completes when objects have been loaded to the scene
  59900. */
  59901. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  59902. private _loadShadersAsync;
  59903. private _loadBuffersAsync;
  59904. private _createNodes;
  59905. }
  59906. /** @hidden */
  59907. export abstract class GLTFLoaderExtension {
  59908. private _name;
  59909. constructor(name: string);
  59910. readonly name: string;
  59911. /**
  59912. * Defines an override for loading the runtime
  59913. * Return true to stop further extensions from loading the runtime
  59914. */
  59915. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  59916. /**
  59917. * Defines an onverride for creating gltf runtime
  59918. * Return true to stop further extensions from creating the runtime
  59919. */
  59920. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  59921. /**
  59922. * Defines an override for loading buffers
  59923. * Return true to stop further extensions from loading this buffer
  59924. */
  59925. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  59926. /**
  59927. * Defines an override for loading texture buffers
  59928. * Return true to stop further extensions from loading this texture data
  59929. */
  59930. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  59931. /**
  59932. * Defines an override for creating textures
  59933. * Return true to stop further extensions from loading this texture
  59934. */
  59935. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  59936. /**
  59937. * Defines an override for loading shader strings
  59938. * Return true to stop further extensions from loading this shader data
  59939. */
  59940. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  59941. /**
  59942. * Defines an override for loading materials
  59943. * Return true to stop further extensions from loading this material
  59944. */
  59945. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  59946. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  59947. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  59948. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  59949. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  59950. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  59951. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  59952. private static LoadTextureBufferAsync;
  59953. private static CreateTextureAsync;
  59954. private static ApplyExtensions;
  59955. }
  59956. }
  59957. declare module BABYLON.GLTF1 {
  59958. /** @hidden */
  59959. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  59960. private _bin;
  59961. constructor();
  59962. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  59963. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  59964. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  59965. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  59966. }
  59967. }
  59968. declare module BABYLON.GLTF1 {
  59969. /** @hidden */
  59970. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  59971. constructor();
  59972. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  59973. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  59974. private _loadTexture;
  59975. }
  59976. }
  59977. declare module BABYLON.GLTF2.Loader {
  59978. /**
  59979. * Loader interface with an index field.
  59980. */
  59981. export interface IArrayItem {
  59982. /**
  59983. * The index of this item in the array.
  59984. */
  59985. index: number;
  59986. }
  59987. /**
  59988. * Loader interface with additional members.
  59989. */
  59990. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  59991. /** @hidden */ data?: Promise<ArrayBufferView>;
  59992. /** @hidden */ babylonVertexBuffer?: Promise<VertexBuffer>;
  59993. }
  59994. /**
  59995. * Loader interface with additional members.
  59996. */
  59997. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  59998. }
  59999. /** @hidden */
  60000. export interface _IAnimationSamplerData {
  60001. input: Float32Array;
  60002. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  60003. output: Float32Array;
  60004. }
  60005. /**
  60006. * Loader interface with additional members.
  60007. */
  60008. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  60009. /** @hidden */ data?: Promise<_IAnimationSamplerData>;
  60010. }
  60011. /**
  60012. * Loader interface with additional members.
  60013. */
  60014. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  60015. channels: IAnimationChannel[];
  60016. samplers: IAnimationSampler[];
  60017. /** @hidden */ babylonAnimationGroup?: AnimationGroup;
  60018. }
  60019. /**
  60020. * Loader interface with additional members.
  60021. */
  60022. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  60023. /** @hidden */ data?: Promise<ArrayBufferView>;
  60024. }
  60025. /**
  60026. * Loader interface with additional members.
  60027. */
  60028. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  60029. /** @hidden */ data?: Promise<ArrayBufferView>;
  60030. /** @hidden */ babylonBuffer?: Promise<Buffer>;
  60031. }
  60032. /**
  60033. * Loader interface with additional members.
  60034. */
  60035. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  60036. }
  60037. /**
  60038. * Loader interface with additional members.
  60039. */
  60040. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  60041. /** @hidden */ data?: Promise<ArrayBufferView>;
  60042. }
  60043. /**
  60044. * Loader interface with additional members.
  60045. */
  60046. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  60047. }
  60048. /**
  60049. * Loader interface with additional members.
  60050. */
  60051. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  60052. }
  60053. /**
  60054. * Loader interface with additional members.
  60055. */
  60056. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  60057. baseColorTexture?: ITextureInfo;
  60058. metallicRoughnessTexture?: ITextureInfo;
  60059. }
  60060. /**
  60061. * Loader interface with additional members.
  60062. */
  60063. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  60064. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  60065. normalTexture?: IMaterialNormalTextureInfo;
  60066. occlusionTexture?: IMaterialOcclusionTextureInfo;
  60067. emissiveTexture?: ITextureInfo;
  60068. /** @hidden */ data?: {
  60069. [babylonDrawMode: number]: {
  60070. babylonMaterial: Material;
  60071. babylonMeshes: AbstractMesh[];
  60072. promise: Promise<void>;
  60073. };
  60074. };
  60075. }
  60076. /**
  60077. * Loader interface with additional members.
  60078. */
  60079. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  60080. primitives: IMeshPrimitive[];
  60081. }
  60082. /**
  60083. * Loader interface with additional members.
  60084. */
  60085. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  60086. /** @hidden */ instanceData?: {
  60087. babylonSourceMesh: Mesh;
  60088. promise: Promise<any>;
  60089. };
  60090. }
  60091. /**
  60092. * Loader interface with additional members.
  60093. */
  60094. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  60095. /**
  60096. * The parent glTF node.
  60097. */
  60098. parent?: INode;
  60099. /** @hidden */ babylonTransformNode?: TransformNode;
  60100. /** @hidden */ primitiveBabylonMeshes?: AbstractMesh[];
  60101. /** @hidden */ babylonBones?: Bone[];
  60102. /** @hidden */ numMorphTargets?: number;
  60103. }
  60104. /** @hidden */
  60105. export interface _ISamplerData {
  60106. noMipMaps: boolean;
  60107. samplingMode: number;
  60108. wrapU: number;
  60109. wrapV: number;
  60110. }
  60111. /**
  60112. * Loader interface with additional members.
  60113. */
  60114. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  60115. /** @hidden */ data?: _ISamplerData;
  60116. }
  60117. /**
  60118. * Loader interface with additional members.
  60119. */
  60120. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  60121. }
  60122. /**
  60123. * Loader interface with additional members.
  60124. */
  60125. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  60126. /** @hidden */ data?: {
  60127. babylonSkeleton: Skeleton;
  60128. promise: Promise<void>;
  60129. };
  60130. }
  60131. /**
  60132. * Loader interface with additional members.
  60133. */
  60134. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  60135. }
  60136. /**
  60137. * Loader interface with additional members.
  60138. */
  60139. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  60140. }
  60141. /**
  60142. * Loader interface with additional members.
  60143. */
  60144. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  60145. accessors?: IAccessor[];
  60146. animations?: IAnimation[];
  60147. buffers?: IBuffer[];
  60148. bufferViews?: IBufferView[];
  60149. cameras?: ICamera[];
  60150. images?: IImage[];
  60151. materials?: IMaterial[];
  60152. meshes?: IMesh[];
  60153. nodes?: INode[];
  60154. samplers?: ISampler[];
  60155. scenes?: IScene[];
  60156. skins?: ISkin[];
  60157. textures?: ITexture[];
  60158. }
  60159. }
  60160. declare module BABYLON.GLTF2 {
  60161. /**
  60162. * Interface for a glTF loader extension.
  60163. */
  60164. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  60165. /**
  60166. * Called after the loader state changes to LOADING.
  60167. */
  60168. onLoading?(): void;
  60169. /**
  60170. * Called after the loader state changes to READY.
  60171. */
  60172. onReady?(): void;
  60173. /**
  60174. * Define this method to modify the default behavior when loading scenes.
  60175. * @param context The context when loading the asset
  60176. * @param scene The glTF scene property
  60177. * @returns A promise that resolves when the load is complete or null if not handled
  60178. */
  60179. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  60180. /**
  60181. * Define this method to modify the default behavior when loading nodes.
  60182. * @param context The context when loading the asset
  60183. * @param node The glTF node property
  60184. * @param assign A function called synchronously after parsing the glTF properties
  60185. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  60186. */
  60187. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60188. /**
  60189. * Define this method to modify the default behavior when loading cameras.
  60190. * @param context The context when loading the asset
  60191. * @param camera The glTF camera property
  60192. * @param assign A function called synchronously after parsing the glTF properties
  60193. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  60194. */
  60195. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  60196. /**
  60197. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  60198. * @param context The context when loading the asset
  60199. * @param primitive The glTF mesh primitive property
  60200. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  60201. */ loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60202. /**
  60203. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  60204. * @param context The context when loading the asset
  60205. * @param material The glTF material property
  60206. * @param assign A function called synchronously after parsing the glTF properties
  60207. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  60208. */ loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60209. /**
  60210. * Define this method to modify the default behavior when creating materials.
  60211. * @param context The context when loading the asset
  60212. * @param material The glTF material property
  60213. * @param babylonDrawMode The draw mode for the Babylon material
  60214. * @returns The Babylon material or null if not handled
  60215. */
  60216. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  60217. /**
  60218. * Define this method to modify the default behavior when loading material properties.
  60219. * @param context The context when loading the asset
  60220. * @param material The glTF material property
  60221. * @param babylonMaterial The Babylon material
  60222. * @returns A promise that resolves when the load is complete or null if not handled
  60223. */
  60224. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60225. /**
  60226. * Define this method to modify the default behavior when loading texture infos.
  60227. * @param context The context when loading the asset
  60228. * @param textureInfo The glTF texture info property
  60229. * @param assign A function called synchronously after parsing the glTF properties
  60230. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  60231. */
  60232. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60233. /**
  60234. * Define this method to modify the default behavior when loading animations.
  60235. * @param context The context when loading the asset
  60236. * @param animation The glTF animation property
  60237. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  60238. */
  60239. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60240. /**
  60241. * Define this method to modify the default behavior when loading uris.
  60242. * @param context The context when loading the asset
  60243. * @param property The glTF property associated with the uri
  60244. * @param uri The uri to load
  60245. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  60246. */ loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60247. }
  60248. }
  60249. declare module BABYLON.GLTF2 {
  60250. /**
  60251. * Helper class for working with arrays when loading the glTF asset
  60252. */
  60253. export class ArrayItem {
  60254. /**
  60255. * Gets an item from the given array.
  60256. * @param context The context when loading the asset
  60257. * @param array The array to get the item from
  60258. * @param index The index to the array
  60259. * @returns The array item
  60260. */
  60261. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  60262. /**
  60263. * Assign an `index` field to each item of the given array.
  60264. * @param array The array of items
  60265. */
  60266. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  60267. }
  60268. /**
  60269. * The glTF 2.0 loader
  60270. */
  60271. export class GLTFLoader implements IGLTFLoader {
  60272. /** @hidden */ completePromises: Promise<any>[];
  60273. private _disposed;
  60274. private _parent;
  60275. private _state;
  60276. private _extensions;
  60277. private _rootUrl;
  60278. private _fileName;
  60279. private _uniqueRootUrl;
  60280. private _gltf;
  60281. private _babylonScene;
  60282. private _rootBabylonMesh;
  60283. private _defaultBabylonMaterialData;
  60284. private _progressCallback?;
  60285. private _requests;
  60286. private static readonly _DefaultSampler;
  60287. private static _ExtensionNames;
  60288. private static _ExtensionFactories;
  60289. /**
  60290. * Registers a loader extension.
  60291. * @param name The name of the loader extension.
  60292. * @param factory The factory function that creates the loader extension.
  60293. */
  60294. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  60295. /**
  60296. * Unregisters a loader extension.
  60297. * @param name The name of the loader extenion.
  60298. * @returns A boolean indicating whether the extension has been unregistered
  60299. */
  60300. static UnregisterExtension(name: string): boolean;
  60301. /**
  60302. * Gets the loader state.
  60303. */
  60304. readonly state: Nullable<GLTFLoaderState>;
  60305. /**
  60306. * The glTF object parsed from the JSON.
  60307. */
  60308. readonly gltf: IGLTF;
  60309. /**
  60310. * The Babylon scene when loading the asset.
  60311. */
  60312. readonly babylonScene: Scene;
  60313. /**
  60314. * The root Babylon mesh when loading the asset.
  60315. */
  60316. readonly rootBabylonMesh: Mesh;
  60317. /** @hidden */
  60318. constructor(parent: GLTFFileLoader);
  60319. /** @hidden */
  60320. dispose(): void;
  60321. /** @hidden */
  60322. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60323. meshes: AbstractMesh[];
  60324. particleSystems: IParticleSystem[];
  60325. skeletons: Skeleton[];
  60326. animationGroups: AnimationGroup[];
  60327. }>;
  60328. /** @hidden */
  60329. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60330. private _loadAsync;
  60331. private _loadData;
  60332. private _setupData;
  60333. private _loadExtensions;
  60334. private _checkExtensions;
  60335. private _setState;
  60336. private _createRootNode;
  60337. /**
  60338. * Loads a glTF scene.
  60339. * @param context The context when loading the asset
  60340. * @param scene The glTF scene property
  60341. * @returns A promise that resolves when the load is complete
  60342. */
  60343. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  60344. private _forEachPrimitive;
  60345. private _getMeshes;
  60346. private _getSkeletons;
  60347. private _getAnimationGroups;
  60348. private _startAnimations;
  60349. /**
  60350. * Loads a glTF node.
  60351. * @param context The context when loading the asset
  60352. * @param node The glTF node property
  60353. * @param assign A function called synchronously after parsing the glTF properties
  60354. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  60355. */
  60356. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  60357. private _loadMeshAsync;
  60358. private _loadMeshPrimitiveAsync;
  60359. private _loadVertexDataAsync;
  60360. private _createMorphTargets;
  60361. private _loadMorphTargetsAsync;
  60362. private _loadMorphTargetVertexDataAsync;
  60363. private static _LoadTransform;
  60364. private _loadSkinAsync;
  60365. private _loadBones;
  60366. private _loadBone;
  60367. private _loadSkinInverseBindMatricesDataAsync;
  60368. private _updateBoneMatrices;
  60369. private _getNodeMatrix;
  60370. /**
  60371. * Loads a glTF camera.
  60372. * @param context The context when loading the asset
  60373. * @param camera The glTF camera property
  60374. * @param assign A function called synchronously after parsing the glTF properties
  60375. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  60376. */
  60377. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  60378. private _loadAnimationsAsync;
  60379. /**
  60380. * Loads a glTF animation.
  60381. * @param context The context when loading the asset
  60382. * @param animation The glTF animation property
  60383. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  60384. */
  60385. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  60386. private _loadAnimationChannelAsync;
  60387. private _loadAnimationSamplerAsync;
  60388. private _loadBufferAsync;
  60389. /**
  60390. * Loads a glTF buffer view.
  60391. * @param context The context when loading the asset
  60392. * @param bufferView The glTF buffer view property
  60393. * @returns A promise that resolves with the loaded data when the load is complete
  60394. */
  60395. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  60396. private _loadIndicesAccessorAsync;
  60397. private _loadFloatAccessorAsync;
  60398. private _loadVertexBufferViewAsync;
  60399. private _loadVertexAccessorAsync;
  60400. private _loadMaterialMetallicRoughnessPropertiesAsync;
  60401. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  60402. private _createDefaultMaterial;
  60403. /**
  60404. * Creates a Babylon material from a glTF material.
  60405. * @param context The context when loading the asset
  60406. * @param material The glTF material property
  60407. * @param babylonDrawMode The draw mode for the Babylon material
  60408. * @returns The Babylon material
  60409. */
  60410. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  60411. /**
  60412. * Loads properties from a glTF material into a Babylon material.
  60413. * @param context The context when loading the asset
  60414. * @param material The glTF material property
  60415. * @param babylonMaterial The Babylon material
  60416. * @returns A promise that resolves when the load is complete
  60417. */
  60418. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60419. /**
  60420. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  60421. * @param context The context when loading the asset
  60422. * @param material The glTF material property
  60423. * @param babylonMaterial The Babylon material
  60424. * @returns A promise that resolves when the load is complete
  60425. */
  60426. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  60427. /**
  60428. * Loads the alpha properties from a glTF material into a Babylon material.
  60429. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  60430. * @param context The context when loading the asset
  60431. * @param material The glTF material property
  60432. * @param babylonMaterial The Babylon material
  60433. */
  60434. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  60435. /**
  60436. * Loads a glTF texture info.
  60437. * @param context The context when loading the asset
  60438. * @param textureInfo The glTF texture info property
  60439. * @param assign A function called synchronously after parsing the glTF properties
  60440. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  60441. */
  60442. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  60443. private _loadTextureAsync;
  60444. private _loadSampler;
  60445. /**
  60446. * Loads a glTF image.
  60447. * @param context The context when loading the asset
  60448. * @param image The glTF image property
  60449. * @returns A promise that resolves with the loaded data when the load is complete
  60450. */
  60451. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  60452. /**
  60453. * Loads a glTF uri.
  60454. * @param context The context when loading the asset
  60455. * @param property The glTF property associated with the uri
  60456. * @param uri The base64 or relative uri
  60457. * @returns A promise that resolves with the loaded data when the load is complete
  60458. */
  60459. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  60460. private _onProgress;
  60461. /**
  60462. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  60463. * @param babylonObject the Babylon object with metadata
  60464. * @param pointer the JSON pointer
  60465. */
  60466. static AddPointerMetadata(babylonObject: {
  60467. metadata: any;
  60468. }, pointer: string): void;
  60469. private static _GetTextureWrapMode;
  60470. private static _GetTextureSamplingMode;
  60471. private static _GetTypedArray;
  60472. private static _GetNumComponents;
  60473. private static _ValidateUri;
  60474. private static _GetDrawMode;
  60475. private _compileMaterialsAsync;
  60476. private _compileShadowGeneratorsAsync;
  60477. private _forEachExtensions;
  60478. private _applyExtensions;
  60479. private _extensionsOnLoading;
  60480. private _extensionsOnReady;
  60481. private _extensionsLoadSceneAsync;
  60482. private _extensionsLoadNodeAsync;
  60483. private _extensionsLoadCameraAsync;
  60484. private _extensionsLoadVertexDataAsync;
  60485. private _extensionsLoadMaterialAsync;
  60486. private _extensionsCreateMaterial;
  60487. private _extensionsLoadMaterialPropertiesAsync;
  60488. private _extensionsLoadTextureInfoAsync;
  60489. private _extensionsLoadAnimationAsync;
  60490. private _extensionsLoadUriAsync;
  60491. /**
  60492. * Helper method called by a loader extension to load an glTF extension.
  60493. * @param context The context when loading the asset
  60494. * @param property The glTF property to load the extension from
  60495. * @param extensionName The name of the extension to load
  60496. * @param actionAsync The action to run
  60497. * @returns The promise returned by actionAsync or null if the extension does not exist
  60498. */
  60499. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60500. /**
  60501. * Helper method called by a loader extension to load a glTF extra.
  60502. * @param context The context when loading the asset
  60503. * @param property The glTF property to load the extra from
  60504. * @param extensionName The name of the extension to load
  60505. * @param actionAsync The action to run
  60506. * @returns The promise returned by actionAsync or null if the extra does not exist
  60507. */
  60508. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  60509. /**
  60510. * Increments the indentation level and logs a message.
  60511. * @param message The message to log
  60512. */
  60513. logOpen(message: string): void;
  60514. /**
  60515. * Decrements the indentation level.
  60516. */
  60517. logClose(): void;
  60518. /**
  60519. * Logs a message
  60520. * @param message The message to log
  60521. */
  60522. log(message: string): void;
  60523. /**
  60524. * Starts a performance counter.
  60525. * @param counterName The name of the performance counter
  60526. */
  60527. startPerformanceCounter(counterName: string): void;
  60528. /**
  60529. * Ends a performance counter.
  60530. * @param counterName The name of the performance counter
  60531. */
  60532. endPerformanceCounter(counterName: string): void;
  60533. }
  60534. }
  60535. declare module BABYLON.GLTF2.Loader.Extensions {
  60536. /**
  60537. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  60538. */
  60539. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  60540. /** The name of this extension. */
  60541. readonly name: string;
  60542. /** Defines whether this extension is enabled. */
  60543. enabled: boolean;
  60544. private _loader;
  60545. private _lights?;
  60546. /** @hidden */
  60547. constructor(loader: GLTFLoader);
  60548. /** @hidden */
  60549. dispose(): void;
  60550. /** @hidden */
  60551. onLoading(): void;
  60552. /** @hidden */
  60553. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60554. private _loadLightAsync;
  60555. }
  60556. }
  60557. declare module BABYLON.GLTF2.Loader.Extensions {
  60558. /**
  60559. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  60560. */
  60561. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  60562. /** The name of this extension. */
  60563. readonly name: string;
  60564. /** Defines whether this extension is enabled. */
  60565. enabled: boolean;
  60566. private _loader;
  60567. private _dracoCompression?;
  60568. /** @hidden */
  60569. constructor(loader: GLTFLoader);
  60570. /** @hidden */
  60571. dispose(): void;
  60572. /** @hidden */ loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  60573. }
  60574. }
  60575. declare module BABYLON.GLTF2.Loader.Extensions {
  60576. /**
  60577. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  60578. */
  60579. export class KHR_lights implements IGLTFLoaderExtension {
  60580. /** The name of this extension. */
  60581. readonly name: string;
  60582. /** Defines whether this extension is enabled. */
  60583. enabled: boolean;
  60584. private _loader;
  60585. private _lights?;
  60586. /** @hidden */
  60587. constructor(loader: GLTFLoader);
  60588. /** @hidden */
  60589. dispose(): void;
  60590. /** @hidden */
  60591. onLoading(): void;
  60592. /** @hidden */
  60593. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60594. }
  60595. }
  60596. declare module BABYLON.GLTF2.Loader.Extensions {
  60597. /**
  60598. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  60599. */
  60600. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  60601. /** The name of this extension. */
  60602. readonly name: string;
  60603. /** Defines whether this extension is enabled. */
  60604. enabled: boolean;
  60605. private _loader;
  60606. /** @hidden */
  60607. constructor(loader: GLTFLoader);
  60608. /** @hidden */
  60609. dispose(): void;
  60610. /** @hidden */
  60611. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60612. private _loadSpecularGlossinessPropertiesAsync;
  60613. }
  60614. }
  60615. declare module BABYLON.GLTF2.Loader.Extensions {
  60616. /**
  60617. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  60618. */
  60619. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  60620. /** The name of this extension. */
  60621. readonly name: string;
  60622. /** Defines whether this extension is enabled. */
  60623. enabled: boolean;
  60624. private _loader;
  60625. /** @hidden */
  60626. constructor(loader: GLTFLoader);
  60627. /** @hidden */
  60628. dispose(): void;
  60629. /** @hidden */
  60630. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60631. private _loadUnlitPropertiesAsync;
  60632. }
  60633. }
  60634. declare module BABYLON.GLTF2.Loader.Extensions {
  60635. /**
  60636. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  60637. */
  60638. export class KHR_texture_transform implements IGLTFLoaderExtension {
  60639. /** The name of this extension. */
  60640. readonly name: string;
  60641. /** Defines whether this extension is enabled. */
  60642. enabled: boolean;
  60643. private _loader;
  60644. /** @hidden */
  60645. constructor(loader: GLTFLoader);
  60646. /** @hidden */
  60647. dispose(): void;
  60648. /** @hidden */
  60649. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  60650. }
  60651. }
  60652. declare module BABYLON.GLTF2.Loader.Extensions {
  60653. /**
  60654. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  60655. */
  60656. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  60657. /** The name of this extension. */
  60658. readonly name: string;
  60659. /** Defines whether this extension is enabled. */
  60660. enabled: boolean;
  60661. private _loader;
  60662. private _clips;
  60663. private _emitters;
  60664. /** @hidden */
  60665. constructor(loader: GLTFLoader);
  60666. /** @hidden */
  60667. dispose(): void;
  60668. /** @hidden */
  60669. onLoading(): void;
  60670. /** @hidden */
  60671. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  60672. /** @hidden */
  60673. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60674. /** @hidden */
  60675. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  60676. private _loadClipAsync;
  60677. private _loadEmitterAsync;
  60678. private _getEventAction;
  60679. private _loadAnimationEventAsync;
  60680. }
  60681. }
  60682. declare module BABYLON.GLTF2.Loader.Extensions {
  60683. /**
  60684. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  60685. */
  60686. export class MSFT_lod implements IGLTFLoaderExtension {
  60687. /** The name of this extension. */
  60688. readonly name: string;
  60689. /** Defines whether this extension is enabled. */
  60690. enabled: boolean;
  60691. /**
  60692. * Maximum number of LODs to load, starting from the lowest LOD.
  60693. */
  60694. maxLODsToLoad: number;
  60695. /**
  60696. * Observable raised when all node LODs of one level are loaded.
  60697. * The event data is the index of the loaded LOD starting from zero.
  60698. * Dispose the loader to cancel the loading of the next level of LODs.
  60699. */
  60700. onNodeLODsLoadedObservable: Observable<number>;
  60701. /**
  60702. * Observable raised when all material LODs of one level are loaded.
  60703. * The event data is the index of the loaded LOD starting from zero.
  60704. * Dispose the loader to cancel the loading of the next level of LODs.
  60705. */
  60706. onMaterialLODsLoadedObservable: Observable<number>;
  60707. private _loader;
  60708. private _nodeIndexLOD;
  60709. private _nodeSignalLODs;
  60710. private _nodePromiseLODs;
  60711. private _materialIndexLOD;
  60712. private _materialSignalLODs;
  60713. private _materialPromiseLODs;
  60714. /** @hidden */
  60715. constructor(loader: GLTFLoader);
  60716. /** @hidden */
  60717. dispose(): void;
  60718. /** @hidden */
  60719. onReady(): void;
  60720. /** @hidden */
  60721. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  60722. /** @hidden */ loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  60723. /** @hidden */ loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  60724. /**
  60725. * Gets an array of LOD properties from lowest to highest.
  60726. */
  60727. private _getLODs;
  60728. private _disposeUnusedMaterials;
  60729. }
  60730. }
  60731. declare module BABYLON.GLTF2.Loader.Extensions {
  60732. /** @hidden */
  60733. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  60734. readonly name: string;
  60735. enabled: boolean;
  60736. private _loader;
  60737. constructor(loader: GLTFLoader);
  60738. dispose(): void;
  60739. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60740. }
  60741. }
  60742. declare module BABYLON.GLTF2.Loader.Extensions {
  60743. /** @hidden */
  60744. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  60745. readonly name: string;
  60746. enabled: boolean;
  60747. private _loader;
  60748. constructor(loader: GLTFLoader);
  60749. dispose(): void;
  60750. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  60751. }
  60752. }
  60753. declare module BABYLON {
  60754. /**
  60755. * Class reading and parsing the MTL file bundled with the obj file.
  60756. */
  60757. export class MTLFileLoader {
  60758. /**
  60759. * All material loaded from the mtl will be set here
  60760. */
  60761. materials: StandardMaterial[];
  60762. /**
  60763. * This function will read the mtl file and create each material described inside
  60764. * This function could be improve by adding :
  60765. * -some component missing (Ni, Tf...)
  60766. * -including the specific options available
  60767. *
  60768. * @param scene defines the scene the material will be created in
  60769. * @param data defines the mtl data to parse
  60770. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  60771. */
  60772. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  60773. /**
  60774. * Gets the texture for the material.
  60775. *
  60776. * If the material is imported from input file,
  60777. * We sanitize the url to ensure it takes the textre from aside the material.
  60778. *
  60779. * @param rootUrl The root url to load from
  60780. * @param value The value stored in the mtl
  60781. * @return The Texture
  60782. */
  60783. private static _getTexture;
  60784. }
  60785. /**
  60786. * Options for loading OBJ/MTL files
  60787. */
  60788. type MeshLoadOptions = {
  60789. /**
  60790. * Defines if UVs are optimized by default during load.
  60791. */
  60792. OptimizeWithUV: boolean;
  60793. /**
  60794. * Invert model on y-axis (does a model scaling inversion)
  60795. */
  60796. InvertY: boolean;
  60797. /**
  60798. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  60799. */
  60800. ImportVertexColors: boolean;
  60801. /**
  60802. * Compute the normals for the model, even if normals are present in the file.
  60803. */
  60804. ComputeNormals: boolean;
  60805. /**
  60806. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  60807. */
  60808. SkipMaterials: boolean;
  60809. /**
  60810. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  60811. */
  60812. MaterialLoadingFailsSilently: boolean;
  60813. };
  60814. /**
  60815. * OBJ file type loader.
  60816. * This is a babylon scene loader plugin.
  60817. */
  60818. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  60819. /**
  60820. * Defines if UVs are optimized by default during load.
  60821. */
  60822. static OPTIMIZE_WITH_UV: boolean;
  60823. /**
  60824. * Invert model on y-axis (does a model scaling inversion)
  60825. */
  60826. static INVERT_Y: boolean;
  60827. /**
  60828. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  60829. */
  60830. static IMPORT_VERTEX_COLORS: boolean;
  60831. /**
  60832. * Compute the normals for the model, even if normals are present in the file.
  60833. */
  60834. static COMPUTE_NORMALS: boolean;
  60835. /**
  60836. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  60837. */
  60838. static SKIP_MATERIALS: boolean;
  60839. /**
  60840. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  60841. *
  60842. * Defaults to true for backwards compatibility.
  60843. */
  60844. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  60845. /**
  60846. * Defines the name of the plugin.
  60847. */
  60848. name: string;
  60849. /**
  60850. * Defines the extension the plugin is able to load.
  60851. */
  60852. extensions: string;
  60853. /** @hidden */
  60854. obj: RegExp;
  60855. /** @hidden */
  60856. group: RegExp;
  60857. /** @hidden */
  60858. mtllib: RegExp;
  60859. /** @hidden */
  60860. usemtl: RegExp;
  60861. /** @hidden */
  60862. smooth: RegExp;
  60863. /** @hidden */
  60864. vertexPattern: RegExp;
  60865. /** @hidden */
  60866. normalPattern: RegExp;
  60867. /** @hidden */
  60868. uvPattern: RegExp;
  60869. /** @hidden */
  60870. facePattern1: RegExp;
  60871. /** @hidden */
  60872. facePattern2: RegExp;
  60873. /** @hidden */
  60874. facePattern3: RegExp;
  60875. /** @hidden */
  60876. facePattern4: RegExp;
  60877. /** @hidden */
  60878. facePattern5: RegExp;
  60879. private _meshLoadOptions;
  60880. /**
  60881. * Creates loader for .OBJ files
  60882. *
  60883. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  60884. */
  60885. constructor(meshLoadOptions?: MeshLoadOptions);
  60886. private static readonly currentMeshLoadOptions;
  60887. /**
  60888. * Calls synchronously the MTL file attached to this obj.
  60889. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  60890. * Without this function materials are not displayed in the first frame (but displayed after).
  60891. * In consequence it is impossible to get material information in your HTML file
  60892. *
  60893. * @param url The URL of the MTL file
  60894. * @param rootUrl
  60895. * @param onSuccess Callback function to be called when the MTL file is loaded
  60896. * @private
  60897. */
  60898. private _loadMTL;
  60899. /**
  60900. * Instantiates a OBJ file loader plugin.
  60901. * @returns the created plugin
  60902. */
  60903. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  60904. /**
  60905. * If the data string can be loaded directly.
  60906. *
  60907. * @param data string containing the file data
  60908. * @returns if the data can be loaded directly
  60909. */
  60910. canDirectLoad(data: string): boolean;
  60911. /**
  60912. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  60913. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  60914. * @param scene the scene the meshes should be added to
  60915. * @param data the OBJ data to load
  60916. * @param rootUrl root url to load from
  60917. * @param onProgress event that fires when loading progress has occured
  60918. * @param fileName Defines the name of the file to load
  60919. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  60920. */
  60921. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  60922. meshes: AbstractMesh[];
  60923. particleSystems: IParticleSystem[];
  60924. skeletons: Skeleton[];
  60925. animationGroups: AnimationGroup[];
  60926. }>;
  60927. /**
  60928. * Imports all objects from the loaded OBJ data and adds them to the scene
  60929. * @param scene the scene the objects should be added to
  60930. * @param data the OBJ data to load
  60931. * @param rootUrl root url to load from
  60932. * @param onProgress event that fires when loading progress has occured
  60933. * @param fileName Defines the name of the file to load
  60934. * @returns a promise which completes when objects have been loaded to the scene
  60935. */
  60936. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  60937. /**
  60938. * Load into an asset container.
  60939. * @param scene The scene to load into
  60940. * @param data The data to import
  60941. * @param rootUrl The root url for scene and resources
  60942. * @param onProgress The callback when the load progresses
  60943. * @param fileName Defines the name of the file to load
  60944. * @returns The loaded asset container
  60945. */
  60946. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  60947. /**
  60948. * Read the OBJ file and create an Array of meshes.
  60949. * Each mesh contains all information given by the OBJ and the MTL file.
  60950. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  60951. *
  60952. * @param meshesNames
  60953. * @param scene Scene The scene where are displayed the data
  60954. * @param data String The content of the obj file
  60955. * @param rootUrl String The path to the folder
  60956. * @returns Array<AbstractMesh>
  60957. * @private
  60958. */
  60959. private _parseSolid;
  60960. }
  60961. }
  60962. declare module BABYLON {
  60963. /**
  60964. * STL file type loader.
  60965. * This is a babylon scene loader plugin.
  60966. */
  60967. export class STLFileLoader implements ISceneLoaderPlugin {
  60968. /** @hidden */
  60969. solidPattern: RegExp;
  60970. /** @hidden */
  60971. facetsPattern: RegExp;
  60972. /** @hidden */
  60973. normalPattern: RegExp;
  60974. /** @hidden */
  60975. vertexPattern: RegExp;
  60976. /**
  60977. * Defines the name of the plugin.
  60978. */
  60979. name: string;
  60980. /**
  60981. * Defines the extensions the stl loader is able to load.
  60982. * force data to come in as an ArrayBuffer
  60983. * we'll convert to string if it looks like it's an ASCII .stl
  60984. */
  60985. extensions: ISceneLoaderPluginExtensions;
  60986. /**
  60987. * Import meshes into a scene.
  60988. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  60989. * @param scene The scene to import into
  60990. * @param data The data to import
  60991. * @param rootUrl The root url for scene and resources
  60992. * @param meshes The meshes array to import into
  60993. * @param particleSystems The particle systems array to import into
  60994. * @param skeletons The skeletons array to import into
  60995. * @param onError The callback when import fails
  60996. * @returns True if successful or false otherwise
  60997. */
  60998. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  60999. /**
  61000. * Load into a scene.
  61001. * @param scene The scene to load into
  61002. * @param data The data to import
  61003. * @param rootUrl The root url for scene and resources
  61004. * @param onError The callback when import fails
  61005. * @returns true if successful or false otherwise
  61006. */
  61007. load(scene: Scene, data: any, rootUrl: string): boolean;
  61008. /**
  61009. * Load into an asset container.
  61010. * @param scene The scene to load into
  61011. * @param data The data to import
  61012. * @param rootUrl The root url for scene and resources
  61013. * @param onError The callback when import fails
  61014. * @returns The loaded asset container
  61015. */
  61016. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  61017. private _isBinary;
  61018. private _parseBinary;
  61019. private _parseASCII;
  61020. }
  61021. }
  61022. declare module BABYLON {
  61023. /**
  61024. * Class for generating OBJ data from a Babylon scene.
  61025. */
  61026. export class OBJExport {
  61027. /**
  61028. * Exports the geometry of a Mesh array in .OBJ file format (text)
  61029. * @param mesh defines the list of meshes to serialize
  61030. * @param materials defines if materials should be exported
  61031. * @param matlibname defines the name of the associated mtl file
  61032. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  61033. * @returns the OBJ content
  61034. */
  61035. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  61036. /**
  61037. * Exports the material(s) of a mesh in .MTL file format (text)
  61038. * @param mesh defines the mesh to extract the material from
  61039. * @returns the mtl content
  61040. */
  61041. static MTL(mesh: Mesh): string;
  61042. }
  61043. }
  61044. declare module BABYLON {
  61045. /** @hidden */
  61046. export var __IGLTFExporterExtension: number;
  61047. /**
  61048. * Interface for extending the exporter
  61049. * @hidden
  61050. */
  61051. export interface IGLTFExporterExtension {
  61052. /**
  61053. * The name of this extension
  61054. */
  61055. readonly name: string;
  61056. /**
  61057. * Defines whether this extension is enabled
  61058. */
  61059. enabled: boolean;
  61060. /**
  61061. * Defines whether this extension is required
  61062. */
  61063. required: boolean;
  61064. }
  61065. }
  61066. declare module BABYLON.GLTF2.Exporter {
  61067. /** @hidden */
  61068. export var __IGLTFExporterExtensionV2: number;
  61069. /**
  61070. * Interface for a glTF exporter extension
  61071. * @hidden
  61072. */
  61073. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  61074. /**
  61075. * Define this method to modify the default behavior before exporting a texture
  61076. * @param context The context when loading the asset
  61077. * @param babylonTexture The glTF texture info property
  61078. * @param mimeType The mime-type of the generated image
  61079. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  61080. */
  61081. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61082. /**
  61083. * Define this method to modify the default behavior when exporting texture info
  61084. * @param context The context when loading the asset
  61085. * @param meshPrimitive glTF mesh primitive
  61086. * @param babylonSubMesh Babylon submesh
  61087. * @param binaryWriter glTF serializer binary writer instance
  61088. * @returns nullable IMeshPrimitive promise
  61089. */
  61090. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  61091. /**
  61092. * Define this method to modify the default behavior when exporting a node
  61093. * @param context The context when exporting the node
  61094. * @param node glTF node
  61095. * @param babylonNode BabylonJS node
  61096. * @returns nullable INode promise
  61097. */
  61098. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  61099. /**
  61100. * Called after the exporter state changes to EXPORTING
  61101. */
  61102. onExporting?(): void;
  61103. }
  61104. }
  61105. declare module BABYLON.GLTF2.Exporter {
  61106. /**
  61107. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  61108. * @hidden
  61109. */
  61110. export class _GLTFMaterialExporter {
  61111. /**
  61112. * Represents the dielectric specular values for R, G and B
  61113. */
  61114. private static readonly _DielectricSpecular;
  61115. /**
  61116. * Allows the maximum specular power to be defined for material calculations
  61117. */
  61118. private static readonly _MaxSpecularPower;
  61119. /**
  61120. * Mapping to store textures
  61121. */
  61122. private _textureMap;
  61123. /**
  61124. * Numeric tolerance value
  61125. */
  61126. private static readonly _Epsilon;
  61127. /**
  61128. * Reference to the glTF Exporter
  61129. */
  61130. private _exporter;
  61131. constructor(exporter: _Exporter);
  61132. /**
  61133. * Specifies if two colors are approximately equal in value
  61134. * @param color1 first color to compare to
  61135. * @param color2 second color to compare to
  61136. * @param epsilon threshold value
  61137. */
  61138. private static FuzzyEquals;
  61139. /**
  61140. * Gets the materials from a Babylon scene and converts them to glTF materials
  61141. * @param scene babylonjs scene
  61142. * @param mimeType texture mime type
  61143. * @param images array of images
  61144. * @param textures array of textures
  61145. * @param materials array of materials
  61146. * @param imageData mapping of texture names to base64 textures
  61147. * @param hasTextureCoords specifies if texture coordinates are present on the material
  61148. */ convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61149. /**
  61150. * Makes a copy of the glTF material without the texture parameters
  61151. * @param originalMaterial original glTF material
  61152. * @returns glTF material without texture parameters
  61153. */ stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  61154. /**
  61155. * Specifies if the material has any texture parameters present
  61156. * @param material glTF Material
  61157. * @returns boolean specifying if texture parameters are present
  61158. */ hasTexturesPresent(material: IMaterial): boolean;
  61159. /**
  61160. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  61161. * @param babylonStandardMaterial
  61162. * @returns glTF Metallic Roughness Material representation
  61163. */ convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  61164. /**
  61165. * Computes the metallic factor
  61166. * @param diffuse diffused value
  61167. * @param specular specular value
  61168. * @param oneMinusSpecularStrength one minus the specular strength
  61169. * @returns metallic value
  61170. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  61171. /**
  61172. * Gets the glTF alpha mode from the Babylon Material
  61173. * @param babylonMaterial Babylon Material
  61174. * @returns The Babylon alpha mode value
  61175. */ getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  61176. /**
  61177. * Converts a Babylon Standard Material to a glTF Material
  61178. * @param babylonStandardMaterial BJS Standard Material
  61179. * @param mimeType mime type to use for the textures
  61180. * @param images array of glTF image interfaces
  61181. * @param textures array of glTF texture interfaces
  61182. * @param materials array of glTF material interfaces
  61183. * @param imageData map of image file name to data
  61184. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61185. */ convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61186. /**
  61187. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61188. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  61189. * @param mimeType mime type to use for the textures
  61190. * @param images array of glTF image interfaces
  61191. * @param textures array of glTF texture interfaces
  61192. * @param materials array of glTF material interfaces
  61193. * @param imageData map of image file name to data
  61194. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61195. */ convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61196. /**
  61197. * Converts an image typed array buffer to a base64 image
  61198. * @param buffer typed array buffer
  61199. * @param width width of the image
  61200. * @param height height of the image
  61201. * @param mimeType mimetype of the image
  61202. * @returns base64 image string
  61203. */
  61204. private _createBase64FromCanvasAsync;
  61205. /**
  61206. * Generates a white texture based on the specified width and height
  61207. * @param width width of the texture in pixels
  61208. * @param height height of the texture in pixels
  61209. * @param scene babylonjs scene
  61210. * @returns white texture
  61211. */
  61212. private _createWhiteTexture;
  61213. /**
  61214. * 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
  61215. * @param texture1 first texture to resize
  61216. * @param texture2 second texture to resize
  61217. * @param scene babylonjs scene
  61218. * @returns resized textures or null
  61219. */
  61220. private _resizeTexturesToSameDimensions;
  61221. /**
  61222. * Converts an array of pixels to a Float32Array
  61223. * Throws an error if the pixel format is not supported
  61224. * @param pixels - array buffer containing pixel values
  61225. * @returns Float32 of pixels
  61226. */
  61227. private _convertPixelArrayToFloat32;
  61228. /**
  61229. * Convert Specular Glossiness Textures to Metallic Roughness
  61230. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  61231. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  61232. * @param diffuseTexture texture used to store diffuse information
  61233. * @param specularGlossinessTexture texture used to store specular and glossiness information
  61234. * @param factors specular glossiness material factors
  61235. * @param mimeType the mime type to use for the texture
  61236. * @returns pbr metallic roughness interface or null
  61237. */
  61238. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  61239. /**
  61240. * Converts specular glossiness material properties to metallic roughness
  61241. * @param specularGlossiness interface with specular glossiness material properties
  61242. * @returns interface with metallic roughness material properties
  61243. */
  61244. private _convertSpecularGlossinessToMetallicRoughness;
  61245. /**
  61246. * Calculates the surface reflectance, independent of lighting conditions
  61247. * @param color Color source to calculate brightness from
  61248. * @returns number representing the perceived brightness, or zero if color is undefined
  61249. */
  61250. private _getPerceivedBrightness;
  61251. /**
  61252. * Returns the maximum color component value
  61253. * @param color
  61254. * @returns maximum color component value, or zero if color is null or undefined
  61255. */
  61256. private _getMaxComponent;
  61257. /**
  61258. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  61259. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61260. * @param mimeType mime type to use for the textures
  61261. * @param images array of glTF image interfaces
  61262. * @param textures array of glTF texture interfaces
  61263. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61264. * @param imageData map of image file name to data
  61265. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61266. * @returns glTF PBR Metallic Roughness factors
  61267. */
  61268. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  61269. private _getGLTFTextureSampler;
  61270. private _getGLTFTextureWrapMode;
  61271. private _getGLTFTextureWrapModesSampler;
  61272. /**
  61273. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  61274. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61275. * @param mimeType mime type to use for the textures
  61276. * @param images array of glTF image interfaces
  61277. * @param textures array of glTF texture interfaces
  61278. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  61279. * @param imageData map of image file name to data
  61280. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61281. * @returns glTF PBR Metallic Roughness factors
  61282. */
  61283. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  61284. /**
  61285. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  61286. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  61287. * @param mimeType mime type to use for the textures
  61288. * @param images array of glTF image interfaces
  61289. * @param textures array of glTF texture interfaces
  61290. * @param materials array of glTF material interfaces
  61291. * @param imageData map of image file name to data
  61292. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  61293. */ convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  61294. private setMetallicRoughnessPbrMaterial;
  61295. private getPixelsFromTexture;
  61296. /**
  61297. * Extracts a texture from a Babylon texture into file data and glTF data
  61298. * @param babylonTexture Babylon texture to extract
  61299. * @param mimeType Mime Type of the babylonTexture
  61300. * @return glTF texture info, or null if the texture format is not supported
  61301. */ exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  61302. /**
  61303. * Builds a texture from base64 string
  61304. * @param base64Texture base64 texture string
  61305. * @param baseTextureName Name to use for the texture
  61306. * @param mimeType image mime type for the texture
  61307. * @param images array of images
  61308. * @param textures array of textures
  61309. * @param imageData map of image data
  61310. * @returns glTF texture info, or null if the texture format is not supported
  61311. */
  61312. private _getTextureInfoFromBase64;
  61313. }
  61314. }
  61315. declare module BABYLON {
  61316. /**
  61317. * Class for holding and downloading glTF file data
  61318. */
  61319. export class GLTFData {
  61320. /**
  61321. * Object which contains the file name as the key and its data as the value
  61322. */
  61323. glTFFiles: {
  61324. [fileName: string]: string | Blob;
  61325. };
  61326. /**
  61327. * Initializes the glTF file object
  61328. */
  61329. constructor();
  61330. /**
  61331. * Downloads the glTF data as files based on their names and data
  61332. */
  61333. downloadFiles(): void;
  61334. }
  61335. }
  61336. declare module BABYLON {
  61337. /**
  61338. * Holds a collection of exporter options and parameters
  61339. */
  61340. export interface IExportOptions {
  61341. /**
  61342. * Function which indicates whether a babylon node should be exported or not
  61343. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  61344. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  61345. */
  61346. shouldExportNode?(node: Node): boolean;
  61347. /**
  61348. * The sample rate to bake animation curves
  61349. */
  61350. animationSampleRate?: number;
  61351. /**
  61352. * Begin serialization without waiting for the scene to be ready
  61353. */
  61354. exportWithoutWaitingForScene?: boolean;
  61355. }
  61356. /**
  61357. * Class for generating glTF data from a Babylon scene.
  61358. */
  61359. export class GLTF2Export {
  61360. /**
  61361. * Exports the geometry of the scene to .gltf file format asynchronously
  61362. * @param scene Babylon scene with scene hierarchy information
  61363. * @param filePrefix File prefix to use when generating the glTF file
  61364. * @param options Exporter options
  61365. * @returns Returns an object with a .gltf file and associates texture names
  61366. * as keys and their data and paths as values
  61367. */
  61368. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61369. private static _PreExportAsync;
  61370. private static _PostExportAsync;
  61371. /**
  61372. * Exports the geometry of the scene to .glb file format asychronously
  61373. * @param scene Babylon scene with scene hierarchy information
  61374. * @param filePrefix File prefix to use when generating glb file
  61375. * @param options Exporter options
  61376. * @returns Returns an object with a .glb filename as key and data as value
  61377. */
  61378. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  61379. }
  61380. }
  61381. declare module BABYLON.GLTF2.Exporter {
  61382. /**
  61383. * @hidden
  61384. */
  61385. export class _GLTFUtilities {
  61386. /**
  61387. * Creates a buffer view based on the supplied arguments
  61388. * @param bufferIndex index value of the specified buffer
  61389. * @param byteOffset byte offset value
  61390. * @param byteLength byte length of the bufferView
  61391. * @param byteStride byte distance between conequential elements
  61392. * @param name name of the buffer view
  61393. * @returns bufferView for glTF
  61394. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  61395. /**
  61396. * Creates an accessor based on the supplied arguments
  61397. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  61398. * @param name The name of the accessor
  61399. * @param type The type of the accessor
  61400. * @param componentType The datatype of components in the attribute
  61401. * @param count The number of attributes referenced by this accessor
  61402. * @param byteOffset The offset relative to the start of the bufferView in bytes
  61403. * @param min Minimum value of each component in this attribute
  61404. * @param max Maximum value of each component in this attribute
  61405. * @returns accessor for glTF
  61406. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  61407. /**
  61408. * Calculates the minimum and maximum values of an array of position floats
  61409. * @param positions Positions array of a mesh
  61410. * @param vertexStart Starting vertex offset to calculate min and max values
  61411. * @param vertexCount Number of vertices to check for min and max values
  61412. * @returns min number array and max number array
  61413. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  61414. min: number[];
  61415. max: number[];
  61416. };
  61417. /**
  61418. * Converts a new right-handed Vector3
  61419. * @param vector vector3 array
  61420. * @returns right-handed Vector3
  61421. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  61422. /**
  61423. * Converts a Vector3 to right-handed
  61424. * @param vector Vector3 to convert to right-handed
  61425. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  61426. /**
  61427. * Converts a three element number array to right-handed
  61428. * @param vector number array to convert to right-handed
  61429. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  61430. /**
  61431. * Converts a new right-handed Vector3
  61432. * @param vector vector3 array
  61433. * @returns right-handed Vector3
  61434. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  61435. /**
  61436. * Converts a Vector3 to right-handed
  61437. * @param vector Vector3 to convert to right-handed
  61438. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  61439. /**
  61440. * Converts a three element number array to right-handed
  61441. * @param vector number array to convert to right-handed
  61442. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  61443. /**
  61444. * Converts a Vector4 to right-handed
  61445. * @param vector Vector4 to convert to right-handed
  61446. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  61447. /**
  61448. * Converts a Vector4 to right-handed
  61449. * @param vector Vector4 to convert to right-handed
  61450. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  61451. /**
  61452. * Converts a Quaternion to right-handed
  61453. * @param quaternion Source quaternion to convert to right-handed
  61454. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  61455. /**
  61456. * Converts a Quaternion to right-handed
  61457. * @param quaternion Source quaternion to convert to right-handed
  61458. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  61459. }
  61460. }
  61461. declare module BABYLON.GLTF2.Exporter {
  61462. /**
  61463. * Converts Babylon Scene into glTF 2.0.
  61464. * @hidden
  61465. */
  61466. export class _Exporter {
  61467. /**
  61468. * Stores the glTF to export
  61469. */ glTF: IGLTF;
  61470. /**
  61471. * Stores all generated buffer views, which represents views into the main glTF buffer data
  61472. */ bufferViews: IBufferView[];
  61473. /**
  61474. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  61475. */ accessors: IAccessor[];
  61476. /**
  61477. * Stores all the generated nodes, which contains transform and/or mesh information per node
  61478. */
  61479. private _nodes;
  61480. /**
  61481. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  61482. */
  61483. private _scenes;
  61484. /**
  61485. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  61486. */
  61487. private _meshes;
  61488. /**
  61489. * Stores all the generated material information, which represents the appearance of each primitive
  61490. */ materials: IMaterial[]; materialMap: {
  61491. [materialID: number]: number;
  61492. };
  61493. /**
  61494. * Stores all the generated texture information, which is referenced by glTF materials
  61495. */ textures: ITexture[];
  61496. /**
  61497. * Stores all the generated image information, which is referenced by glTF textures
  61498. */ images: IImage[];
  61499. /**
  61500. * Stores all the texture samplers
  61501. */ samplers: ISampler[];
  61502. /**
  61503. * Stores all the generated animation samplers, which is referenced by glTF animations
  61504. */
  61505. /**
  61506. * Stores the animations for glTF models
  61507. */
  61508. private _animations;
  61509. /**
  61510. * Stores the total amount of bytes stored in the glTF buffer
  61511. */
  61512. private _totalByteLength;
  61513. /**
  61514. * Stores a reference to the Babylon scene containing the source geometry and material information
  61515. */ babylonScene: Scene;
  61516. /**
  61517. * Stores a map of the image data, where the key is the file name and the value
  61518. * is the image data
  61519. */ imageData: {
  61520. [fileName: string]: {
  61521. data: Uint8Array;
  61522. mimeType: ImageMimeType;
  61523. };
  61524. };
  61525. /**
  61526. * Stores a map of the unique id of a node to its index in the node array
  61527. */
  61528. private _nodeMap;
  61529. /**
  61530. * Specifies if the Babylon scene should be converted to right-handed on export
  61531. */ convertToRightHandedSystem: boolean;
  61532. /**
  61533. * Baked animation sample rate
  61534. */
  61535. private _animationSampleRate;
  61536. /**
  61537. * Callback which specifies if a node should be exported or not
  61538. */
  61539. private _shouldExportNode;
  61540. private _localEngine; glTFMaterialExporter: _GLTFMaterialExporter;
  61541. private _extensions;
  61542. private static _ExtensionNames;
  61543. private static _ExtensionFactories;
  61544. 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>>;
  61545. private _forEachExtensions;
  61546. private _extensionsOnExporting;
  61547. /**
  61548. * Load glTF serializer extensions
  61549. */
  61550. private _loadExtensions;
  61551. /**
  61552. * Creates a glTF Exporter instance, which can accept optional exporter options
  61553. * @param babylonScene Babylon scene object
  61554. * @param options Options to modify the behavior of the exporter
  61555. */
  61556. constructor(babylonScene: Scene, options?: IExportOptions);
  61557. /**
  61558. * Registers a glTF exporter extension
  61559. * @param name Name of the extension to export
  61560. * @param factory The factory function that creates the exporter extension
  61561. */
  61562. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  61563. /**
  61564. * Un-registers an exporter extension
  61565. * @param name The name fo the exporter extension
  61566. * @returns A boolean indicating whether the extension has been un-registered
  61567. */
  61568. static UnregisterExtension(name: string): boolean;
  61569. /**
  61570. * Lazy load a local engine with premultiplied alpha set to false
  61571. */ getLocalEngine(): Engine;
  61572. private reorderIndicesBasedOnPrimitiveMode;
  61573. /**
  61574. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  61575. * clock-wise during export to glTF
  61576. * @param submesh BabylonJS submesh
  61577. * @param primitiveMode Primitive mode of the mesh
  61578. * @param sideOrientation the winding order of the submesh
  61579. * @param vertexBufferKind The type of vertex attribute
  61580. * @param meshAttributeArray The vertex attribute data
  61581. * @param byteOffset The offset to the binary data
  61582. * @param binaryWriter The binary data for the glTF file
  61583. */
  61584. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  61585. /**
  61586. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  61587. * clock-wise during export to glTF
  61588. * @param submesh BabylonJS submesh
  61589. * @param primitiveMode Primitive mode of the mesh
  61590. * @param sideOrientation the winding order of the submesh
  61591. * @param vertexBufferKind The type of vertex attribute
  61592. * @param meshAttributeArray The vertex attribute data
  61593. * @param byteOffset The offset to the binary data
  61594. * @param binaryWriter The binary data for the glTF file
  61595. */
  61596. private reorderTriangleFillMode;
  61597. /**
  61598. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  61599. * clock-wise during export to glTF
  61600. * @param submesh BabylonJS submesh
  61601. * @param primitiveMode Primitive mode of the mesh
  61602. * @param sideOrientation the winding order of the submesh
  61603. * @param vertexBufferKind The type of vertex attribute
  61604. * @param meshAttributeArray The vertex attribute data
  61605. * @param byteOffset The offset to the binary data
  61606. * @param binaryWriter The binary data for the glTF file
  61607. */
  61608. private reorderTriangleStripDrawMode;
  61609. /**
  61610. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  61611. * clock-wise during export to glTF
  61612. * @param submesh BabylonJS submesh
  61613. * @param primitiveMode Primitive mode of the mesh
  61614. * @param sideOrientation the winding order of the submesh
  61615. * @param vertexBufferKind The type of vertex attribute
  61616. * @param meshAttributeArray The vertex attribute data
  61617. * @param byteOffset The offset to the binary data
  61618. * @param binaryWriter The binary data for the glTF file
  61619. */
  61620. private reorderTriangleFanMode;
  61621. /**
  61622. * Writes the vertex attribute data to binary
  61623. * @param vertices The vertices to write to the binary writer
  61624. * @param byteOffset The offset into the binary writer to overwrite binary data
  61625. * @param vertexAttributeKind The vertex attribute type
  61626. * @param meshAttributeArray The vertex attribute data
  61627. * @param binaryWriter The writer containing the binary data
  61628. */
  61629. private writeVertexAttributeData;
  61630. /**
  61631. * Writes mesh attribute data to a data buffer
  61632. * Returns the bytelength of the data
  61633. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  61634. * @param meshAttributeArray Array containing the attribute data
  61635. * @param binaryWriter The buffer to write the binary data to
  61636. * @param indices Used to specify the order of the vertex data
  61637. */
  61638. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  61639. /**
  61640. * Generates glTF json data
  61641. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  61642. * @param glTFPrefix Text to use when prefixing a glTF file
  61643. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  61644. * @returns json data as string
  61645. */
  61646. private generateJSON;
  61647. /**
  61648. * Generates data for .gltf and .bin files based on the glTF prefix string
  61649. * @param glTFPrefix Text to use when prefixing a glTF file
  61650. * @returns GLTFData with glTF file data
  61651. */ generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  61652. /**
  61653. * Creates a binary buffer for glTF
  61654. * @returns array buffer for binary data
  61655. */
  61656. private _generateBinaryAsync;
  61657. /**
  61658. * Pads the number to a multiple of 4
  61659. * @param num number to pad
  61660. * @returns padded number
  61661. */
  61662. private _getPadding;
  61663. /**
  61664. * Generates a glb file from the json and binary data
  61665. * Returns an object with the glb file name as the key and data as the value
  61666. * @param glTFPrefix
  61667. * @returns object with glb filename as key and data as value
  61668. */ generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  61669. /**
  61670. * Sets the TRS for each node
  61671. * @param node glTF Node for storing the transformation data
  61672. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  61673. */
  61674. private setNodeTransformation;
  61675. private getVertexBufferFromMesh;
  61676. /**
  61677. * Creates a bufferview based on the vertices type for the Babylon mesh
  61678. * @param kind Indicates the type of vertices data
  61679. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  61680. * @param binaryWriter The buffer to write the bufferview data to
  61681. */
  61682. private createBufferViewKind;
  61683. /**
  61684. * The primitive mode of the Babylon mesh
  61685. * @param babylonMesh The BabylonJS mesh
  61686. */
  61687. private getMeshPrimitiveMode;
  61688. /**
  61689. * Sets the primitive mode of the glTF mesh primitive
  61690. * @param meshPrimitive glTF mesh primitive
  61691. * @param primitiveMode The primitive mode
  61692. */
  61693. private setPrimitiveMode;
  61694. /**
  61695. * Sets the vertex attribute accessor based of the glTF mesh primitive
  61696. * @param meshPrimitive glTF mesh primitive
  61697. * @param attributeKind vertex attribute
  61698. * @returns boolean specifying if uv coordinates are present
  61699. */
  61700. private setAttributeKind;
  61701. /**
  61702. * Sets data for the primitive attributes of each submesh
  61703. * @param mesh glTF Mesh object to store the primitive attribute information
  61704. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  61705. * @param binaryWriter Buffer to write the attribute data to
  61706. */
  61707. private setPrimitiveAttributesAsync;
  61708. /**
  61709. * Creates a glTF scene based on the array of meshes
  61710. * Returns the the total byte offset
  61711. * @param babylonScene Babylon scene to get the mesh data from
  61712. * @param binaryWriter Buffer to write binary data to
  61713. */
  61714. private createSceneAsync;
  61715. /**
  61716. * Creates a mapping of Node unique id to node index and handles animations
  61717. * @param babylonScene Babylon Scene
  61718. * @param nodes Babylon transform nodes
  61719. * @param shouldExportNode Callback specifying if a transform node should be exported
  61720. * @param binaryWriter Buffer to write binary data to
  61721. * @returns Node mapping of unique id to index
  61722. */
  61723. private createNodeMapAndAnimationsAsync;
  61724. /**
  61725. * Creates a glTF node from a Babylon mesh
  61726. * @param babylonMesh Source Babylon mesh
  61727. * @param binaryWriter Buffer for storing geometry data
  61728. * @returns glTF node
  61729. */
  61730. private createNodeAsync;
  61731. }
  61732. /**
  61733. * @hidden
  61734. *
  61735. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  61736. */
  61737. export class _BinaryWriter {
  61738. /**
  61739. * Array buffer which stores all binary data
  61740. */
  61741. private _arrayBuffer;
  61742. /**
  61743. * View of the array buffer
  61744. */
  61745. private _dataView;
  61746. /**
  61747. * byte offset of data in array buffer
  61748. */
  61749. private _byteOffset;
  61750. /**
  61751. * Initialize binary writer with an initial byte length
  61752. * @param byteLength Initial byte length of the array buffer
  61753. */
  61754. constructor(byteLength: number);
  61755. /**
  61756. * Resize the array buffer to the specified byte length
  61757. * @param byteLength
  61758. */
  61759. private resizeBuffer;
  61760. /**
  61761. * Get an array buffer with the length of the byte offset
  61762. * @returns ArrayBuffer resized to the byte offset
  61763. */
  61764. getArrayBuffer(): ArrayBuffer;
  61765. /**
  61766. * Get the byte offset of the array buffer
  61767. * @returns byte offset
  61768. */
  61769. getByteOffset(): number;
  61770. /**
  61771. * Stores an UInt8 in the array buffer
  61772. * @param entry
  61773. * @param byteOffset If defined, specifies where to set the value as an offset.
  61774. */
  61775. setUInt8(entry: number, byteOffset?: number): void;
  61776. /**
  61777. * Gets an UInt32 in the array buffer
  61778. * @param entry
  61779. * @param byteOffset If defined, specifies where to set the value as an offset.
  61780. */
  61781. getUInt32(byteOffset: number): number;
  61782. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  61783. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  61784. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  61785. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  61786. /**
  61787. * Stores a Float32 in the array buffer
  61788. * @param entry
  61789. */
  61790. setFloat32(entry: number, byteOffset?: number): void;
  61791. /**
  61792. * Stores an UInt32 in the array buffer
  61793. * @param entry
  61794. * @param byteOffset If defined, specifies where to set the value as an offset.
  61795. */
  61796. setUInt32(entry: number, byteOffset?: number): void;
  61797. }
  61798. }
  61799. declare module BABYLON.GLTF2.Exporter {
  61800. /**
  61801. * @hidden
  61802. * Interface to store animation data.
  61803. */
  61804. export interface _IAnimationData {
  61805. /**
  61806. * Keyframe data.
  61807. */
  61808. inputs: number[];
  61809. /**
  61810. * Value data.
  61811. */
  61812. outputs: number[][];
  61813. /**
  61814. * Animation interpolation data.
  61815. */
  61816. samplerInterpolation: AnimationSamplerInterpolation;
  61817. /**
  61818. * Minimum keyframe value.
  61819. */
  61820. inputsMin: number;
  61821. /**
  61822. * Maximum keyframe value.
  61823. */
  61824. inputsMax: number;
  61825. }
  61826. /**
  61827. * @hidden
  61828. */
  61829. export interface _IAnimationInfo {
  61830. /**
  61831. * The target channel for the animation
  61832. */
  61833. animationChannelTargetPath: AnimationChannelTargetPath;
  61834. /**
  61835. * The glTF accessor type for the data.
  61836. */
  61837. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  61838. /**
  61839. * Specifies if quaternions should be used.
  61840. */
  61841. useQuaternion: boolean;
  61842. }
  61843. /**
  61844. * @hidden
  61845. * Utility class for generating glTF animation data from BabylonJS.
  61846. */
  61847. export class _GLTFAnimation {
  61848. /**
  61849. * @ignore
  61850. *
  61851. * Creates glTF channel animation from BabylonJS animation.
  61852. * @param babylonTransformNode - BabylonJS mesh.
  61853. * @param animation - animation.
  61854. * @param animationChannelTargetPath - The target animation channel.
  61855. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  61856. * @param useQuaternion - Specifies if quaternions are used.
  61857. * @returns nullable IAnimationData
  61858. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  61859. private static _DeduceAnimationInfo;
  61860. /**
  61861. * @ignore
  61862. * Create node animations from the transform node animations
  61863. * @param babylonNode
  61864. * @param runtimeGLTFAnimation
  61865. * @param idleGLTFAnimations
  61866. * @param nodeMap
  61867. * @param nodes
  61868. * @param binaryWriter
  61869. * @param bufferViews
  61870. * @param accessors
  61871. * @param convertToRightHandedSystem
  61872. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  61873. [key: number]: number;
  61874. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  61875. /**
  61876. * @ignore
  61877. * Create node animations from the animation groups
  61878. * @param babylonScene
  61879. * @param glTFAnimations
  61880. * @param nodeMap
  61881. * @param nodes
  61882. * @param binaryWriter
  61883. * @param bufferViews
  61884. * @param accessors
  61885. * @param convertToRightHandedSystem
  61886. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  61887. [key: number]: number;
  61888. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  61889. private static AddAnimation;
  61890. /**
  61891. * Create a baked animation
  61892. * @param babylonTransformNode BabylonJS mesh
  61893. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  61894. * @param animationChannelTargetPath animation target channel
  61895. * @param minFrame minimum animation frame
  61896. * @param maxFrame maximum animation frame
  61897. * @param fps frames per second of the animation
  61898. * @param inputs input key frames of the animation
  61899. * @param outputs output key frame data of the animation
  61900. * @param convertToRightHandedSystem converts the values to right-handed
  61901. * @param useQuaternion specifies if quaternions should be used
  61902. */
  61903. private static _CreateBakedAnimation;
  61904. private static _ConvertFactorToVector3OrQuaternion;
  61905. private static _SetInterpolatedValue;
  61906. /**
  61907. * Creates linear animation from the animation key frames
  61908. * @param babylonTransformNode BabylonJS mesh
  61909. * @param animation BabylonJS animation
  61910. * @param animationChannelTargetPath The target animation channel
  61911. * @param frameDelta The difference between the last and first frame of the animation
  61912. * @param inputs Array to store the key frame times
  61913. * @param outputs Array to store the key frame data
  61914. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  61915. * @param useQuaternion Specifies if quaternions are used in the animation
  61916. */
  61917. private static _CreateLinearOrStepAnimation;
  61918. /**
  61919. * Creates cubic spline animation from the animation key frames
  61920. * @param babylonTransformNode BabylonJS mesh
  61921. * @param animation BabylonJS animation
  61922. * @param animationChannelTargetPath The target animation channel
  61923. * @param frameDelta The difference between the last and first frame of the animation
  61924. * @param inputs Array to store the key frame times
  61925. * @param outputs Array to store the key frame data
  61926. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  61927. * @param useQuaternion Specifies if quaternions are used in the animation
  61928. */
  61929. private static _CreateCubicSplineAnimation;
  61930. private static _GetBasePositionRotationOrScale;
  61931. /**
  61932. * Adds a key frame value
  61933. * @param keyFrame
  61934. * @param animation
  61935. * @param outputs
  61936. * @param animationChannelTargetPath
  61937. * @param basePositionRotationOrScale
  61938. * @param convertToRightHandedSystem
  61939. * @param useQuaternion
  61940. */
  61941. private static _AddKeyframeValue;
  61942. /**
  61943. * Determine the interpolation based on the key frames
  61944. * @param keyFrames
  61945. * @param animationChannelTargetPath
  61946. * @param useQuaternion
  61947. */
  61948. private static _DeduceInterpolation;
  61949. /**
  61950. * Adds an input tangent or output tangent to the output data
  61951. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  61952. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  61953. * @param outputs The animation data by keyframe
  61954. * @param animationChannelTargetPath The target animation channel
  61955. * @param interpolation The interpolation type
  61956. * @param keyFrame The key frame with the animation data
  61957. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  61958. * @param useQuaternion Specifies if quaternions are used
  61959. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  61960. */
  61961. private static AddSplineTangent;
  61962. /**
  61963. * Get the minimum and maximum key frames' frame values
  61964. * @param keyFrames animation key frames
  61965. * @returns the minimum and maximum key frame value
  61966. */
  61967. private static calculateMinMaxKeyFrames;
  61968. }
  61969. }
  61970. declare module BABYLON.GLTF2.Exporter {
  61971. /** @hidden */
  61972. export var textureTransformPixelShader: {
  61973. name: string;
  61974. shader: string;
  61975. };
  61976. }
  61977. declare module BABYLON.GLTF2.Exporter.Extensions {
  61978. /**
  61979. * @hidden
  61980. */
  61981. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  61982. /** Name of this extension */
  61983. readonly name: string;
  61984. /** Defines whether this extension is enabled */
  61985. enabled: boolean;
  61986. /** Defines whether this extension is required */
  61987. required: boolean;
  61988. /** Reference to the glTF exporter */
  61989. private _exporter;
  61990. constructor(exporter: _Exporter);
  61991. dispose(): void;
  61992. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  61993. /**
  61994. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  61995. * @param babylonTexture
  61996. * @param offset
  61997. * @param rotation
  61998. * @param scale
  61999. * @param scene
  62000. */
  62001. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  62002. }
  62003. }
  62004. declare module BABYLON.GLTF2.Exporter.Extensions {
  62005. /**
  62006. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  62007. */
  62008. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  62009. /** The name of this extension. */
  62010. readonly name: string;
  62011. /** Defines whether this extension is enabled. */
  62012. enabled: boolean;
  62013. /** Defines whether this extension is required */
  62014. required: boolean;
  62015. /** Reference to the glTF exporter */
  62016. private _exporter;
  62017. private _lights;
  62018. /** @hidden */
  62019. constructor(exporter: _Exporter);
  62020. /** @hidden */
  62021. dispose(): void;
  62022. /** @hidden */
  62023. onExporting(): void;
  62024. /**
  62025. * Define this method to modify the default behavior when exporting a node
  62026. * @param context The context when exporting the node
  62027. * @param node glTF node
  62028. * @param babylonNode BabylonJS node
  62029. * @returns nullable INode promise
  62030. */
  62031. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  62032. }
  62033. }
  62034. declare module BABYLON {
  62035. /**
  62036. * Class for generating STL data from a Babylon scene.
  62037. */
  62038. export class STLExport {
  62039. /**
  62040. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  62041. * @param meshes list defines the mesh to serialize
  62042. * @param download triggers the automatic download of the file.
  62043. * @param fileName changes the downloads fileName.
  62044. * @param binary changes the STL to a binary type.
  62045. * @param isLittleEndian toggle for binary type exporter.
  62046. * @returns the STL as UTF8 string
  62047. */
  62048. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  62049. }
  62050. }
  62051. /**
  62052. * @ignoreChildren
  62053. * @ignore
  62054. */
  62055. declare module "babylonjs-gltf2interface" {
  62056. export = BABYLON.GLTF2;
  62057. }
  62058. /**
  62059. * Module for glTF 2.0 Interface
  62060. * @ignoreChildren
  62061. * @ignore
  62062. */
  62063. declare module BABYLON.GLTF2 {
  62064. /**
  62065. * The datatype of the components in the attribute
  62066. */
  62067. const enum AccessorComponentType {
  62068. /**
  62069. * Byte
  62070. */
  62071. BYTE = 5120,
  62072. /**
  62073. * Unsigned Byte
  62074. */
  62075. UNSIGNED_BYTE = 5121,
  62076. /**
  62077. * Short
  62078. */
  62079. SHORT = 5122,
  62080. /**
  62081. * Unsigned Short
  62082. */
  62083. UNSIGNED_SHORT = 5123,
  62084. /**
  62085. * Unsigned Int
  62086. */
  62087. UNSIGNED_INT = 5125,
  62088. /**
  62089. * Float
  62090. */
  62091. FLOAT = 5126,
  62092. }
  62093. /**
  62094. * Specifies if the attirbute is a scalar, vector, or matrix
  62095. */
  62096. const enum AccessorType {
  62097. /**
  62098. * Scalar
  62099. */
  62100. SCALAR = "SCALAR",
  62101. /**
  62102. * Vector2
  62103. */
  62104. VEC2 = "VEC2",
  62105. /**
  62106. * Vector3
  62107. */
  62108. VEC3 = "VEC3",
  62109. /**
  62110. * Vector4
  62111. */
  62112. VEC4 = "VEC4",
  62113. /**
  62114. * Matrix2x2
  62115. */
  62116. MAT2 = "MAT2",
  62117. /**
  62118. * Matrix3x3
  62119. */
  62120. MAT3 = "MAT3",
  62121. /**
  62122. * Matrix4x4
  62123. */
  62124. MAT4 = "MAT4",
  62125. }
  62126. /**
  62127. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62128. */
  62129. const enum AnimationChannelTargetPath {
  62130. /**
  62131. * Translation
  62132. */
  62133. TRANSLATION = "translation",
  62134. /**
  62135. * Rotation
  62136. */
  62137. ROTATION = "rotation",
  62138. /**
  62139. * Scale
  62140. */
  62141. SCALE = "scale",
  62142. /**
  62143. * Weights
  62144. */
  62145. WEIGHTS = "weights",
  62146. }
  62147. /**
  62148. * Interpolation algorithm
  62149. */
  62150. const enum AnimationSamplerInterpolation {
  62151. /**
  62152. * The animated values are linearly interpolated between keyframes
  62153. */
  62154. LINEAR = "LINEAR",
  62155. /**
  62156. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  62157. */
  62158. STEP = "STEP",
  62159. /**
  62160. * The animation's interpolation is computed using a cubic spline with specified tangents
  62161. */
  62162. CUBICSPLINE = "CUBICSPLINE",
  62163. }
  62164. /**
  62165. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62166. */
  62167. const enum CameraType {
  62168. /**
  62169. * A perspective camera containing properties to create a perspective projection matrix
  62170. */
  62171. PERSPECTIVE = "perspective",
  62172. /**
  62173. * An orthographic camera containing properties to create an orthographic projection matrix
  62174. */
  62175. ORTHOGRAPHIC = "orthographic",
  62176. }
  62177. /**
  62178. * The mime-type of the image
  62179. */
  62180. const enum ImageMimeType {
  62181. /**
  62182. * JPEG Mime-type
  62183. */
  62184. JPEG = "image/jpeg",
  62185. /**
  62186. * PNG Mime-type
  62187. */
  62188. PNG = "image/png",
  62189. }
  62190. /**
  62191. * The alpha rendering mode of the material
  62192. */
  62193. const enum MaterialAlphaMode {
  62194. /**
  62195. * The alpha value is ignored and the rendered output is fully opaque
  62196. */
  62197. OPAQUE = "OPAQUE",
  62198. /**
  62199. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  62200. */
  62201. MASK = "MASK",
  62202. /**
  62203. * 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)
  62204. */
  62205. BLEND = "BLEND",
  62206. }
  62207. /**
  62208. * The type of the primitives to render
  62209. */
  62210. const enum MeshPrimitiveMode {
  62211. /**
  62212. * Points
  62213. */
  62214. POINTS = 0,
  62215. /**
  62216. * Lines
  62217. */
  62218. LINES = 1,
  62219. /**
  62220. * Line Loop
  62221. */
  62222. LINE_LOOP = 2,
  62223. /**
  62224. * Line Strip
  62225. */
  62226. LINE_STRIP = 3,
  62227. /**
  62228. * Triangles
  62229. */
  62230. TRIANGLES = 4,
  62231. /**
  62232. * Triangle Strip
  62233. */
  62234. TRIANGLE_STRIP = 5,
  62235. /**
  62236. * Triangle Fan
  62237. */
  62238. TRIANGLE_FAN = 6,
  62239. }
  62240. /**
  62241. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62242. */
  62243. const enum TextureMagFilter {
  62244. /**
  62245. * Nearest
  62246. */
  62247. NEAREST = 9728,
  62248. /**
  62249. * Linear
  62250. */
  62251. LINEAR = 9729,
  62252. }
  62253. /**
  62254. * Minification filter. All valid values correspond to WebGL enums
  62255. */
  62256. const enum TextureMinFilter {
  62257. /**
  62258. * Nearest
  62259. */
  62260. NEAREST = 9728,
  62261. /**
  62262. * Linear
  62263. */
  62264. LINEAR = 9729,
  62265. /**
  62266. * Nearest Mip-Map Nearest
  62267. */
  62268. NEAREST_MIPMAP_NEAREST = 9984,
  62269. /**
  62270. * Linear Mipmap Nearest
  62271. */
  62272. LINEAR_MIPMAP_NEAREST = 9985,
  62273. /**
  62274. * Nearest Mipmap Linear
  62275. */
  62276. NEAREST_MIPMAP_LINEAR = 9986,
  62277. /**
  62278. * Linear Mipmap Linear
  62279. */
  62280. LINEAR_MIPMAP_LINEAR = 9987,
  62281. }
  62282. /**
  62283. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62284. */
  62285. const enum TextureWrapMode {
  62286. /**
  62287. * Clamp to Edge
  62288. */
  62289. CLAMP_TO_EDGE = 33071,
  62290. /**
  62291. * Mirrored Repeat
  62292. */
  62293. MIRRORED_REPEAT = 33648,
  62294. /**
  62295. * Repeat
  62296. */
  62297. REPEAT = 10497,
  62298. }
  62299. /**
  62300. * glTF Property
  62301. */
  62302. interface IProperty {
  62303. /**
  62304. * Dictionary object with extension-specific objects
  62305. */
  62306. extensions?: {
  62307. [key: string]: any;
  62308. };
  62309. /**
  62310. * Application-Specific data
  62311. */
  62312. extras?: any;
  62313. }
  62314. /**
  62315. * glTF Child of Root Property
  62316. */
  62317. interface IChildRootProperty extends IProperty {
  62318. /**
  62319. * The user-defined name of this object
  62320. */
  62321. name?: string;
  62322. }
  62323. /**
  62324. * Indices of those attributes that deviate from their initialization value
  62325. */
  62326. interface IAccessorSparseIndices extends IProperty {
  62327. /**
  62328. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62329. */
  62330. bufferView: number;
  62331. /**
  62332. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62333. */
  62334. byteOffset?: number;
  62335. /**
  62336. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  62337. */
  62338. componentType: AccessorComponentType;
  62339. }
  62340. /**
  62341. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  62342. */
  62343. interface IAccessorSparseValues extends IProperty {
  62344. /**
  62345. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  62346. */
  62347. bufferView: number;
  62348. /**
  62349. * The offset relative to the start of the bufferView in bytes. Must be aligned
  62350. */
  62351. byteOffset?: number;
  62352. }
  62353. /**
  62354. * Sparse storage of attributes that deviate from their initialization value
  62355. */
  62356. interface IAccessorSparse extends IProperty {
  62357. /**
  62358. * The number of attributes encoded in this sparse accessor
  62359. */
  62360. count: number;
  62361. /**
  62362. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  62363. */
  62364. indices: IAccessorSparseIndices;
  62365. /**
  62366. * 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
  62367. */
  62368. values: IAccessorSparseValues;
  62369. }
  62370. /**
  62371. * 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
  62372. */
  62373. interface IAccessor extends IChildRootProperty {
  62374. /**
  62375. * The index of the bufferview
  62376. */
  62377. bufferView?: number;
  62378. /**
  62379. * The offset relative to the start of the bufferView in bytes
  62380. */
  62381. byteOffset?: number;
  62382. /**
  62383. * The datatype of components in the attribute
  62384. */
  62385. componentType: AccessorComponentType;
  62386. /**
  62387. * Specifies whether integer data values should be normalized
  62388. */
  62389. normalized?: boolean;
  62390. /**
  62391. * The number of attributes referenced by this accessor
  62392. */
  62393. count: number;
  62394. /**
  62395. * Specifies if the attribute is a scalar, vector, or matrix
  62396. */
  62397. type: AccessorType;
  62398. /**
  62399. * Maximum value of each component in this attribute
  62400. */
  62401. max?: number[];
  62402. /**
  62403. * Minimum value of each component in this attribute
  62404. */
  62405. min?: number[];
  62406. /**
  62407. * Sparse storage of attributes that deviate from their initialization value
  62408. */
  62409. sparse?: IAccessorSparse;
  62410. }
  62411. /**
  62412. * Targets an animation's sampler at a node's property
  62413. */
  62414. interface IAnimationChannel extends IProperty {
  62415. /**
  62416. * The index of a sampler in this animation used to compute the value for the target
  62417. */
  62418. sampler: number;
  62419. /**
  62420. * The index of the node and TRS property to target
  62421. */
  62422. target: IAnimationChannelTarget;
  62423. }
  62424. /**
  62425. * The index of the node and TRS property that an animation channel targets
  62426. */
  62427. interface IAnimationChannelTarget extends IProperty {
  62428. /**
  62429. * The index of the node to target
  62430. */
  62431. node: number;
  62432. /**
  62433. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  62434. */
  62435. path: AnimationChannelTargetPath;
  62436. }
  62437. /**
  62438. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62439. */
  62440. interface IAnimationSampler extends IProperty {
  62441. /**
  62442. * The index of an accessor containing keyframe input values, e.g., time
  62443. */
  62444. input: number;
  62445. /**
  62446. * Interpolation algorithm
  62447. */
  62448. interpolation?: AnimationSamplerInterpolation;
  62449. /**
  62450. * The index of an accessor, containing keyframe output values
  62451. */
  62452. output: number;
  62453. }
  62454. /**
  62455. * A keyframe animation
  62456. */
  62457. interface IAnimation extends IChildRootProperty {
  62458. /**
  62459. * An array of channels, each of which targets an animation's sampler at a node's property
  62460. */
  62461. channels: IAnimationChannel[];
  62462. /**
  62463. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  62464. */
  62465. samplers: IAnimationSampler[];
  62466. }
  62467. /**
  62468. * Metadata about the glTF asset
  62469. */
  62470. interface IAsset extends IChildRootProperty {
  62471. /**
  62472. * A copyright message suitable for display to credit the content creator
  62473. */
  62474. copyright?: string;
  62475. /**
  62476. * Tool that generated this glTF model. Useful for debugging
  62477. */
  62478. generator?: string;
  62479. /**
  62480. * The glTF version that this asset targets
  62481. */
  62482. version: string;
  62483. /**
  62484. * The minimum glTF version that this asset targets
  62485. */
  62486. minVersion?: string;
  62487. }
  62488. /**
  62489. * A buffer points to binary geometry, animation, or skins
  62490. */
  62491. interface IBuffer extends IChildRootProperty {
  62492. /**
  62493. * 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
  62494. */
  62495. uri?: string;
  62496. /**
  62497. * The length of the buffer in bytes
  62498. */
  62499. byteLength: number;
  62500. }
  62501. /**
  62502. * A view into a buffer generally representing a subset of the buffer
  62503. */
  62504. interface IBufferView extends IChildRootProperty {
  62505. /**
  62506. * The index of the buffer
  62507. */
  62508. buffer: number;
  62509. /**
  62510. * The offset into the buffer in bytes
  62511. */
  62512. byteOffset?: number;
  62513. /**
  62514. * The lenth of the bufferView in bytes
  62515. */
  62516. byteLength: number;
  62517. /**
  62518. * The stride, in bytes
  62519. */
  62520. byteStride?: number;
  62521. }
  62522. /**
  62523. * An orthographic camera containing properties to create an orthographic projection matrix
  62524. */
  62525. interface ICameraOrthographic extends IProperty {
  62526. /**
  62527. * The floating-point horizontal magnification of the view. Must not be zero
  62528. */
  62529. xmag: number;
  62530. /**
  62531. * The floating-point vertical magnification of the view. Must not be zero
  62532. */
  62533. ymag: number;
  62534. /**
  62535. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  62536. */
  62537. zfar: number;
  62538. /**
  62539. * The floating-point distance to the near clipping plane
  62540. */
  62541. znear: number;
  62542. }
  62543. /**
  62544. * A perspective camera containing properties to create a perspective projection matrix
  62545. */
  62546. interface ICameraPerspective extends IProperty {
  62547. /**
  62548. * The floating-point aspect ratio of the field of view
  62549. */
  62550. aspectRatio?: number;
  62551. /**
  62552. * The floating-point vertical field of view in radians
  62553. */
  62554. yfov: number;
  62555. /**
  62556. * The floating-point distance to the far clipping plane
  62557. */
  62558. zfar?: number;
  62559. /**
  62560. * The floating-point distance to the near clipping plane
  62561. */
  62562. znear: number;
  62563. }
  62564. /**
  62565. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  62566. */
  62567. interface ICamera extends IChildRootProperty {
  62568. /**
  62569. * An orthographic camera containing properties to create an orthographic projection matrix
  62570. */
  62571. orthographic?: ICameraOrthographic;
  62572. /**
  62573. * A perspective camera containing properties to create a perspective projection matrix
  62574. */
  62575. perspective?: ICameraPerspective;
  62576. /**
  62577. * Specifies if the camera uses a perspective or orthographic projection
  62578. */
  62579. type: CameraType;
  62580. }
  62581. /**
  62582. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  62583. */
  62584. interface IImage extends IChildRootProperty {
  62585. /**
  62586. * 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
  62587. */
  62588. uri?: string;
  62589. /**
  62590. * The image's MIME type
  62591. */
  62592. mimeType?: ImageMimeType;
  62593. /**
  62594. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  62595. */
  62596. bufferView?: number;
  62597. }
  62598. /**
  62599. * Material Normal Texture Info
  62600. */
  62601. interface IMaterialNormalTextureInfo extends ITextureInfo {
  62602. /**
  62603. * The scalar multiplier applied to each normal vector of the normal texture
  62604. */
  62605. scale?: number;
  62606. }
  62607. /**
  62608. * Material Occlusion Texture Info
  62609. */
  62610. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  62611. /**
  62612. * A scalar multiplier controlling the amount of occlusion applied
  62613. */
  62614. strength?: number;
  62615. }
  62616. /**
  62617. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  62618. */
  62619. interface IMaterialPbrMetallicRoughness {
  62620. /**
  62621. * The material's base color factor
  62622. */
  62623. baseColorFactor?: number[];
  62624. /**
  62625. * The base color texture
  62626. */
  62627. baseColorTexture?: ITextureInfo;
  62628. /**
  62629. * The metalness of the material
  62630. */
  62631. metallicFactor?: number;
  62632. /**
  62633. * The roughness of the material
  62634. */
  62635. roughnessFactor?: number;
  62636. /**
  62637. * The metallic-roughness texture
  62638. */
  62639. metallicRoughnessTexture?: ITextureInfo;
  62640. }
  62641. /**
  62642. * The material appearance of a primitive
  62643. */
  62644. interface IMaterial extends IChildRootProperty {
  62645. /**
  62646. * 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
  62647. */
  62648. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  62649. /**
  62650. * The normal map texture
  62651. */
  62652. normalTexture?: IMaterialNormalTextureInfo;
  62653. /**
  62654. * The occlusion map texture
  62655. */
  62656. occlusionTexture?: IMaterialOcclusionTextureInfo;
  62657. /**
  62658. * The emissive map texture
  62659. */
  62660. emissiveTexture?: ITextureInfo;
  62661. /**
  62662. * 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
  62663. */
  62664. emissiveFactor?: number[];
  62665. /**
  62666. * The alpha rendering mode of the material
  62667. */
  62668. alphaMode?: MaterialAlphaMode;
  62669. /**
  62670. * The alpha cutoff value of the material
  62671. */
  62672. alphaCutoff?: number;
  62673. /**
  62674. * Specifies whether the material is double sided
  62675. */
  62676. doubleSided?: boolean;
  62677. }
  62678. /**
  62679. * Geometry to be rendered with the given material
  62680. */
  62681. interface IMeshPrimitive extends IProperty {
  62682. /**
  62683. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  62684. */
  62685. attributes: {
  62686. [name: string]: number;
  62687. };
  62688. /**
  62689. * The index of the accessor that contains the indices
  62690. */
  62691. indices?: number;
  62692. /**
  62693. * The index of the material to apply to this primitive when rendering
  62694. */
  62695. material?: number;
  62696. /**
  62697. * The type of primitives to render. All valid values correspond to WebGL enums
  62698. */
  62699. mode?: MeshPrimitiveMode;
  62700. /**
  62701. * 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
  62702. */
  62703. targets?: {
  62704. [name: string]: number;
  62705. }[];
  62706. }
  62707. /**
  62708. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  62709. */
  62710. interface IMesh extends IChildRootProperty {
  62711. /**
  62712. * An array of primitives, each defining geometry to be rendered with a material
  62713. */
  62714. primitives: IMeshPrimitive[];
  62715. /**
  62716. * Array of weights to be applied to the Morph Targets
  62717. */
  62718. weights?: number[];
  62719. }
  62720. /**
  62721. * A node in the node hierarchy
  62722. */
  62723. interface INode extends IChildRootProperty {
  62724. /**
  62725. * The index of the camera referenced by this node
  62726. */
  62727. camera?: number;
  62728. /**
  62729. * The indices of this node's children
  62730. */
  62731. children?: number[];
  62732. /**
  62733. * The index of the skin referenced by this node
  62734. */
  62735. skin?: number;
  62736. /**
  62737. * A floating-point 4x4 transformation matrix stored in column-major order
  62738. */
  62739. matrix?: number[];
  62740. /**
  62741. * The index of the mesh in this node
  62742. */
  62743. mesh?: number;
  62744. /**
  62745. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  62746. */
  62747. rotation?: number[];
  62748. /**
  62749. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  62750. */
  62751. scale?: number[];
  62752. /**
  62753. * The node's translation along the x, y, and z axes
  62754. */
  62755. translation?: number[];
  62756. /**
  62757. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  62758. */
  62759. weights?: number[];
  62760. }
  62761. /**
  62762. * Texture sampler properties for filtering and wrapping modes
  62763. */
  62764. interface ISampler extends IChildRootProperty {
  62765. /**
  62766. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  62767. */
  62768. magFilter?: TextureMagFilter;
  62769. /**
  62770. * Minification filter. All valid values correspond to WebGL enums
  62771. */
  62772. minFilter?: TextureMinFilter;
  62773. /**
  62774. * S (U) wrapping mode. All valid values correspond to WebGL enums
  62775. */
  62776. wrapS?: TextureWrapMode;
  62777. /**
  62778. * T (V) wrapping mode. All valid values correspond to WebGL enums
  62779. */
  62780. wrapT?: TextureWrapMode;
  62781. }
  62782. /**
  62783. * The root nodes of a scene
  62784. */
  62785. interface IScene extends IChildRootProperty {
  62786. /**
  62787. * The indices of each root node
  62788. */
  62789. nodes: number[];
  62790. }
  62791. /**
  62792. * Joints and matrices defining a skin
  62793. */
  62794. interface ISkin extends IChildRootProperty {
  62795. /**
  62796. * 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
  62797. */
  62798. inverseBindMatrices?: number;
  62799. /**
  62800. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  62801. */
  62802. skeleton?: number;
  62803. /**
  62804. * 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)
  62805. */
  62806. joints: number[];
  62807. }
  62808. /**
  62809. * A texture and its sampler
  62810. */
  62811. interface ITexture extends IChildRootProperty {
  62812. /**
  62813. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  62814. */
  62815. sampler?: number;
  62816. /**
  62817. * The index of the image used by this texture
  62818. */
  62819. source: number;
  62820. }
  62821. /**
  62822. * Reference to a texture
  62823. */
  62824. interface ITextureInfo extends IProperty {
  62825. /**
  62826. * The index of the texture
  62827. */
  62828. index: number;
  62829. /**
  62830. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  62831. */
  62832. texCoord?: number;
  62833. }
  62834. /**
  62835. * The root object for a glTF asset
  62836. */
  62837. interface IGLTF extends IProperty {
  62838. /**
  62839. * An array of accessors. An accessor is a typed view into a bufferView
  62840. */
  62841. accessors?: IAccessor[];
  62842. /**
  62843. * An array of keyframe animations
  62844. */
  62845. animations?: IAnimation[];
  62846. /**
  62847. * Metadata about the glTF asset
  62848. */
  62849. asset: IAsset;
  62850. /**
  62851. * An array of buffers. A buffer points to binary geometry, animation, or skins
  62852. */
  62853. buffers?: IBuffer[];
  62854. /**
  62855. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  62856. */
  62857. bufferViews?: IBufferView[];
  62858. /**
  62859. * An array of cameras
  62860. */
  62861. cameras?: ICamera[];
  62862. /**
  62863. * Names of glTF extensions used somewhere in this asset
  62864. */
  62865. extensionsUsed?: string[];
  62866. /**
  62867. * Names of glTF extensions required to properly load this asset
  62868. */
  62869. extensionsRequired?: string[];
  62870. /**
  62871. * An array of images. An image defines data used to create a texture
  62872. */
  62873. images?: IImage[];
  62874. /**
  62875. * An array of materials. A material defines the appearance of a primitive
  62876. */
  62877. materials?: IMaterial[];
  62878. /**
  62879. * An array of meshes. A mesh is a set of primitives to be rendered
  62880. */
  62881. meshes?: IMesh[];
  62882. /**
  62883. * An array of nodes
  62884. */
  62885. nodes?: INode[];
  62886. /**
  62887. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  62888. */
  62889. samplers?: ISampler[];
  62890. /**
  62891. * The index of the default scene
  62892. */
  62893. scene?: number;
  62894. /**
  62895. * An array of scenes
  62896. */
  62897. scenes?: IScene[];
  62898. /**
  62899. * An array of skins. A skin is defined by joints and matrices
  62900. */
  62901. skins?: ISkin[];
  62902. /**
  62903. * An array of textures
  62904. */
  62905. textures?: ITexture[];
  62906. }
  62907. /**
  62908. * Interface for glTF validation results
  62909. */
  62910. interface IGLTFValidationResults {
  62911. info: {
  62912. generator: string;
  62913. hasAnimations: boolean;
  62914. hasDefaultScene: boolean;
  62915. hasMaterials: boolean;
  62916. hasMorphTargets: boolean;
  62917. hasSkins: boolean;
  62918. hasTextures: boolean;
  62919. maxAttributesUsed: number;
  62920. primitivesCount: number
  62921. };
  62922. issues: {
  62923. messages: Array<string>;
  62924. numErrors: number;
  62925. numHints: number;
  62926. numInfos: number;
  62927. numWarnings: number;
  62928. truncated: boolean
  62929. };
  62930. mimeType: string;
  62931. uri: string;
  62932. validatedAt: string;
  62933. validatorVersion: string;
  62934. }
  62935. /**
  62936. * Interface for glTF validation options
  62937. */
  62938. interface IGLTFValidationOptions {
  62939. uri?: string;
  62940. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  62941. validateAccessorData?: boolean;
  62942. maxIssues?: number;
  62943. ignoredIssues?: Array<string>;
  62944. severityOverrides?: Object;
  62945. }
  62946. /**
  62947. * glTF validator object Tyyings
  62948. */
  62949. interface IGLTFValidatorTypings {
  62950. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  62951. }
  62952. }
  62953. /**
  62954. * Interface for glTF validation results
  62955. */
  62956. interface IGLTFValidationResults {
  62957. info: {
  62958. generator: string;
  62959. hasAnimations: boolean;
  62960. hasDefaultScene: boolean;
  62961. hasMaterials: boolean;
  62962. hasMorphTargets: boolean;
  62963. hasSkins: boolean;
  62964. hasTextures: boolean;
  62965. maxAttributesUsed: number;
  62966. primitivesCount: number
  62967. };
  62968. issues: {
  62969. messages: Array<string>;
  62970. numErrors: number;
  62971. numHints: number;
  62972. numInfos: number;
  62973. numWarnings: number;
  62974. truncated: boolean
  62975. };
  62976. mimeType: string;
  62977. uri: string;
  62978. validatedAt: string;
  62979. validatorVersion: string;
  62980. }
  62981. /**
  62982. * Interface for glTF validation options
  62983. */
  62984. interface IGLTFValidationOptions {
  62985. uri?: string;
  62986. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  62987. validateAccessorData?: boolean;
  62988. maxIssues?: number;
  62989. ignoredIssues?: Array<string>;
  62990. severityOverrides?: Object;
  62991. }
  62992. /**
  62993. * glTF validator object Tyyings
  62994. */
  62995. interface IGLTFValidatorTypings {
  62996. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  62997. }
  62998. declare module BABYLON {
  62999. /** @hidden */
  63000. export var cellPixelShader: {
  63001. name: string;
  63002. shader: string;
  63003. };
  63004. }
  63005. declare module BABYLON {
  63006. /** @hidden */
  63007. export var cellVertexShader: {
  63008. name: string;
  63009. shader: string;
  63010. };
  63011. }
  63012. declare module BABYLON {
  63013. export class CellMaterial extends BABYLON.PushMaterial {
  63014. private _diffuseTexture;
  63015. diffuseTexture: BABYLON.BaseTexture;
  63016. diffuseColor: BABYLON.Color3; computeHighLevel: boolean;
  63017. computeHighLevel: boolean;
  63018. private _disableLighting;
  63019. disableLighting: boolean;
  63020. private _maxSimultaneousLights;
  63021. maxSimultaneousLights: number;
  63022. private _renderId;
  63023. constructor(name: string, scene: BABYLON.Scene);
  63024. needAlphaBlending(): boolean;
  63025. needAlphaTesting(): boolean;
  63026. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63027. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63028. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63029. getAnimatables(): BABYLON.IAnimatable[];
  63030. getActiveTextures(): BABYLON.BaseTexture[];
  63031. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63032. dispose(forceDisposeEffect?: boolean): void;
  63033. getClassName(): string;
  63034. clone(name: string): CellMaterial;
  63035. serialize(): any;
  63036. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  63037. }
  63038. }
  63039. declare module BABYLON {
  63040. export class CustomShaderStructure {
  63041. FragmentStore: string;
  63042. VertexStore: string;
  63043. constructor();
  63044. }
  63045. export class ShaderSpecialParts {
  63046. constructor();
  63047. Fragment_Begin: string;
  63048. Fragment_Definitions: string;
  63049. Fragment_MainBegin: string;
  63050. Fragment_Custom_Diffuse: string;
  63051. Fragment_Before_Lights: string;
  63052. Fragment_Before_Fog: string;
  63053. Fragment_Custom_Alpha: string;
  63054. Fragment_Before_FragColor: string;
  63055. Vertex_Begin: string;
  63056. Vertex_Definitions: string;
  63057. Vertex_MainBegin: string;
  63058. Vertex_Before_PositionUpdated: string;
  63059. Vertex_Before_NormalUpdated: string;
  63060. Vertex_MainEnd: string;
  63061. }
  63062. export class CustomMaterial extends BABYLON.StandardMaterial {
  63063. static ShaderIndexer: number;
  63064. CustomParts: ShaderSpecialParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63065. FragmentShader: string;
  63066. VertexShader: string;
  63067. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63068. ReviewUniform(name: string, arr: string[]): string[];
  63069. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  63070. constructor(name: string, scene: BABYLON.Scene);
  63071. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  63072. Fragment_Begin(shaderPart: string): CustomMaterial;
  63073. Fragment_Definitions(shaderPart: string): CustomMaterial;
  63074. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  63075. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  63076. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  63077. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  63078. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  63079. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  63080. Vertex_Begin(shaderPart: string): CustomMaterial;
  63081. Vertex_Definitions(shaderPart: string): CustomMaterial;
  63082. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  63083. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  63084. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  63085. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  63086. }
  63087. }
  63088. declare module BABYLON {
  63089. export class ShaderAlebdoParts {
  63090. constructor();
  63091. Fragment_Begin: string;
  63092. Fragment_Definitions: string;
  63093. Fragment_MainBegin: string;
  63094. Fragment_Custom_Albedo: string;
  63095. Fragment_Before_Lights: string;
  63096. Fragment_Before_Fog: string;
  63097. Fragment_Custom_Alpha: string;
  63098. Fragment_Before_FragColor: string;
  63099. Vertex_Begin: string;
  63100. Vertex_Definitions: string;
  63101. Vertex_MainBegin: string;
  63102. Vertex_Before_PositionUpdated: string;
  63103. Vertex_Before_NormalUpdated: string;
  63104. Vertex_MainEnd: string;
  63105. }
  63106. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  63107. static ShaderIndexer: number;
  63108. CustomParts: ShaderAlebdoParts; isCreatedShader: boolean; createdShaderName: string; customUniform: string[]; newUniforms: string[]; newUniformInstances: any[]; newSamplerInstances: BABYLON.Texture[];
  63109. FragmentShader: string;
  63110. VertexShader: string;
  63111. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  63112. ReviewUniform(name: string, arr: string[]): string[];
  63113. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  63114. constructor(name: string, scene: BABYLON.Scene);
  63115. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  63116. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  63117. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  63118. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  63119. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  63120. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  63121. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  63122. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  63123. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  63124. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  63125. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  63126. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  63127. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  63128. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  63129. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  63130. }
  63131. }
  63132. declare module BABYLON {
  63133. /** @hidden */
  63134. export var firePixelShader: {
  63135. name: string;
  63136. shader: string;
  63137. };
  63138. }
  63139. declare module BABYLON {
  63140. /** @hidden */
  63141. export var fireVertexShader: {
  63142. name: string;
  63143. shader: string;
  63144. };
  63145. }
  63146. declare module BABYLON {
  63147. export class FireMaterial extends BABYLON.PushMaterial {
  63148. private _diffuseTexture;
  63149. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63150. private _distortionTexture;
  63151. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63152. private _opacityTexture;
  63153. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  63154. diffuseColor: BABYLON.Color3;
  63155. speed: number;
  63156. private _scaledDiffuse;
  63157. private _renderId;
  63158. private _lastTime;
  63159. constructor(name: string, scene: BABYLON.Scene);
  63160. needAlphaBlending(): boolean;
  63161. needAlphaTesting(): boolean;
  63162. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63163. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63164. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63165. getAnimatables(): BABYLON.IAnimatable[];
  63166. getActiveTextures(): BABYLON.BaseTexture[];
  63167. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63168. getClassName(): string;
  63169. dispose(forceDisposeEffect?: boolean): void;
  63170. clone(name: string): FireMaterial;
  63171. serialize(): any;
  63172. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  63173. }
  63174. }
  63175. declare module BABYLON {
  63176. /** @hidden */
  63177. export var furPixelShader: {
  63178. name: string;
  63179. shader: string;
  63180. };
  63181. }
  63182. declare module BABYLON {
  63183. /** @hidden */
  63184. export var furVertexShader: {
  63185. name: string;
  63186. shader: string;
  63187. };
  63188. }
  63189. declare module BABYLON {
  63190. export class FurMaterial extends BABYLON.PushMaterial {
  63191. private _diffuseTexture;
  63192. diffuseTexture: BABYLON.BaseTexture;
  63193. private _heightTexture;
  63194. heightTexture: BABYLON.BaseTexture;
  63195. diffuseColor: BABYLON.Color3;
  63196. furLength: number;
  63197. furAngle: number;
  63198. furColor: BABYLON.Color3;
  63199. furOffset: number;
  63200. furSpacing: number;
  63201. furGravity: BABYLON.Vector3;
  63202. furSpeed: number;
  63203. furDensity: number;
  63204. furOcclusion: number;
  63205. furTexture: BABYLON.DynamicTexture;
  63206. private _disableLighting;
  63207. disableLighting: boolean;
  63208. private _maxSimultaneousLights;
  63209. maxSimultaneousLights: number;
  63210. highLevelFur: boolean; meshes: BABYLON.AbstractMesh[];
  63211. private _renderId;
  63212. private _furTime;
  63213. constructor(name: string, scene: BABYLON.Scene);
  63214. furTime: number;
  63215. needAlphaBlending(): boolean;
  63216. needAlphaTesting(): boolean;
  63217. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63218. updateFur(): void;
  63219. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63220. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63221. getAnimatables(): BABYLON.IAnimatable[];
  63222. getActiveTextures(): BABYLON.BaseTexture[];
  63223. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63224. dispose(forceDisposeEffect?: boolean): void;
  63225. clone(name: string): FurMaterial;
  63226. serialize(): any;
  63227. getClassName(): string;
  63228. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  63229. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  63230. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  63231. }
  63232. }
  63233. declare module BABYLON {
  63234. /** @hidden */
  63235. export var gradientPixelShader: {
  63236. name: string;
  63237. shader: string;
  63238. };
  63239. }
  63240. declare module BABYLON {
  63241. /** @hidden */
  63242. export var gradientVertexShader: {
  63243. name: string;
  63244. shader: string;
  63245. };
  63246. }
  63247. declare module BABYLON {
  63248. export class GradientMaterial extends BABYLON.PushMaterial {
  63249. private _maxSimultaneousLights;
  63250. maxSimultaneousLights: number;
  63251. topColor: BABYLON.Color3;
  63252. topColorAlpha: number;
  63253. bottomColor: BABYLON.Color3;
  63254. bottomColorAlpha: number;
  63255. offset: number;
  63256. scale: number;
  63257. smoothness: number;
  63258. private _disableLighting;
  63259. disableLighting: boolean;
  63260. private _renderId;
  63261. constructor(name: string, scene: BABYLON.Scene);
  63262. needAlphaBlending(): boolean;
  63263. needAlphaTesting(): boolean;
  63264. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63265. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63266. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63267. getAnimatables(): BABYLON.IAnimatable[];
  63268. dispose(forceDisposeEffect?: boolean): void;
  63269. clone(name: string): GradientMaterial;
  63270. serialize(): any;
  63271. getClassName(): string;
  63272. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  63273. }
  63274. }
  63275. declare module BABYLON {
  63276. /** @hidden */
  63277. export var gridPixelShader: {
  63278. name: string;
  63279. shader: string;
  63280. };
  63281. }
  63282. declare module BABYLON {
  63283. /** @hidden */
  63284. export var gridVertexShader: {
  63285. name: string;
  63286. shader: string;
  63287. };
  63288. }
  63289. declare module BABYLON {
  63290. /**
  63291. * The grid materials allows you to wrap any shape with a grid.
  63292. * Colors are customizable.
  63293. */
  63294. export class GridMaterial extends BABYLON.PushMaterial {
  63295. /**
  63296. * Main color of the grid (e.g. between lines)
  63297. */
  63298. mainColor: BABYLON.Color3;
  63299. /**
  63300. * Color of the grid lines.
  63301. */
  63302. lineColor: BABYLON.Color3;
  63303. /**
  63304. * The scale of the grid compared to unit.
  63305. */
  63306. gridRatio: number;
  63307. /**
  63308. * Allows setting an offset for the grid lines.
  63309. */
  63310. gridOffset: BABYLON.Vector3;
  63311. /**
  63312. * The frequency of thicker lines.
  63313. */
  63314. majorUnitFrequency: number;
  63315. /**
  63316. * The visibility of minor units in the grid.
  63317. */
  63318. minorUnitVisibility: number;
  63319. /**
  63320. * The grid opacity outside of the lines.
  63321. */
  63322. opacity: number;
  63323. /**
  63324. * Determine RBG output is premultiplied by alpha value.
  63325. */
  63326. preMultiplyAlpha: boolean;
  63327. private _opacityTexture;
  63328. opacityTexture: BABYLON.BaseTexture;
  63329. private _gridControl;
  63330. private _renderId;
  63331. /**
  63332. * constructor
  63333. * @param name The name given to the material in order to identify it afterwards.
  63334. * @param scene The scene the material is used in.
  63335. */
  63336. constructor(name: string, scene: BABYLON.Scene);
  63337. /**
  63338. * Returns wehter or not the grid requires alpha blending.
  63339. */
  63340. needAlphaBlending(): boolean;
  63341. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63342. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63343. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63344. /**
  63345. * Dispose the material and its associated resources.
  63346. * @param forceDisposeEffect will also dispose the used effect when true
  63347. */
  63348. dispose(forceDisposeEffect?: boolean): void;
  63349. clone(name: string): GridMaterial;
  63350. serialize(): any;
  63351. getClassName(): string;
  63352. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  63353. }
  63354. }
  63355. declare module BABYLON {
  63356. /** @hidden */
  63357. export var lavaPixelShader: {
  63358. name: string;
  63359. shader: string;
  63360. };
  63361. }
  63362. declare module BABYLON {
  63363. /** @hidden */
  63364. export var lavaVertexShader: {
  63365. name: string;
  63366. shader: string;
  63367. };
  63368. }
  63369. declare module BABYLON {
  63370. export class LavaMaterial extends BABYLON.PushMaterial {
  63371. private _diffuseTexture;
  63372. diffuseTexture: BABYLON.BaseTexture;
  63373. noiseTexture: BABYLON.BaseTexture;
  63374. fogColor: BABYLON.Color3;
  63375. speed: number;
  63376. movingSpeed: number;
  63377. lowFrequencySpeed: number;
  63378. fogDensity: number;
  63379. private _lastTime;
  63380. diffuseColor: BABYLON.Color3;
  63381. private _disableLighting;
  63382. disableLighting: boolean;
  63383. private _unlit;
  63384. unlit: boolean;
  63385. private _maxSimultaneousLights;
  63386. maxSimultaneousLights: number;
  63387. private _scaledDiffuse;
  63388. private _renderId;
  63389. constructor(name: string, scene: BABYLON.Scene);
  63390. needAlphaBlending(): boolean;
  63391. needAlphaTesting(): boolean;
  63392. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63393. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63394. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63395. getAnimatables(): BABYLON.IAnimatable[];
  63396. getActiveTextures(): BABYLON.BaseTexture[];
  63397. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63398. dispose(forceDisposeEffect?: boolean): void;
  63399. clone(name: string): LavaMaterial;
  63400. serialize(): any;
  63401. getClassName(): string;
  63402. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  63403. }
  63404. }
  63405. declare module BABYLON {
  63406. /** @hidden */
  63407. export var mixPixelShader: {
  63408. name: string;
  63409. shader: string;
  63410. };
  63411. }
  63412. declare module BABYLON {
  63413. /** @hidden */
  63414. export var mixVertexShader: {
  63415. name: string;
  63416. shader: string;
  63417. };
  63418. }
  63419. declare module BABYLON {
  63420. export class MixMaterial extends BABYLON.PushMaterial {
  63421. /**
  63422. * Mix textures
  63423. */
  63424. private _mixTexture1;
  63425. mixTexture1: BABYLON.BaseTexture;
  63426. private _mixTexture2;
  63427. mixTexture2: BABYLON.BaseTexture;
  63428. /**
  63429. * Diffuse textures
  63430. */
  63431. private _diffuseTexture1;
  63432. diffuseTexture1: BABYLON.Texture;
  63433. private _diffuseTexture2;
  63434. diffuseTexture2: BABYLON.Texture;
  63435. private _diffuseTexture3;
  63436. diffuseTexture3: BABYLON.Texture;
  63437. private _diffuseTexture4;
  63438. diffuseTexture4: BABYLON.Texture;
  63439. private _diffuseTexture5;
  63440. diffuseTexture5: BABYLON.Texture;
  63441. private _diffuseTexture6;
  63442. diffuseTexture6: BABYLON.Texture;
  63443. private _diffuseTexture7;
  63444. diffuseTexture7: BABYLON.Texture;
  63445. private _diffuseTexture8;
  63446. diffuseTexture8: BABYLON.Texture;
  63447. /**
  63448. * Uniforms
  63449. */
  63450. diffuseColor: BABYLON.Color3;
  63451. specularColor: BABYLON.Color3;
  63452. specularPower: number;
  63453. private _disableLighting;
  63454. disableLighting: boolean;
  63455. private _maxSimultaneousLights;
  63456. maxSimultaneousLights: number;
  63457. private _renderId;
  63458. constructor(name: string, scene: BABYLON.Scene);
  63459. needAlphaBlending(): boolean;
  63460. needAlphaTesting(): boolean;
  63461. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63462. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63463. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63464. getAnimatables(): BABYLON.IAnimatable[];
  63465. getActiveTextures(): BABYLON.BaseTexture[];
  63466. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63467. dispose(forceDisposeEffect?: boolean): void;
  63468. clone(name: string): MixMaterial;
  63469. serialize(): any;
  63470. getClassName(): string;
  63471. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  63472. }
  63473. }
  63474. declare module BABYLON {
  63475. /** @hidden */
  63476. export var normalPixelShader: {
  63477. name: string;
  63478. shader: string;
  63479. };
  63480. }
  63481. declare module BABYLON {
  63482. /** @hidden */
  63483. export var normalVertexShader: {
  63484. name: string;
  63485. shader: string;
  63486. };
  63487. }
  63488. declare module BABYLON {
  63489. export class NormalMaterial extends BABYLON.PushMaterial {
  63490. private _diffuseTexture;
  63491. diffuseTexture: BABYLON.BaseTexture;
  63492. diffuseColor: BABYLON.Color3;
  63493. private _disableLighting;
  63494. disableLighting: boolean;
  63495. private _maxSimultaneousLights;
  63496. maxSimultaneousLights: number;
  63497. private _renderId;
  63498. constructor(name: string, scene: BABYLON.Scene);
  63499. needAlphaBlending(): boolean;
  63500. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  63501. needAlphaTesting(): boolean;
  63502. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63503. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63504. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63505. getAnimatables(): BABYLON.IAnimatable[];
  63506. getActiveTextures(): BABYLON.BaseTexture[];
  63507. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63508. dispose(forceDisposeEffect?: boolean): void;
  63509. clone(name: string): NormalMaterial;
  63510. serialize(): any;
  63511. getClassName(): string;
  63512. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  63513. }
  63514. }
  63515. declare module BABYLON {
  63516. /** @hidden */
  63517. export var shadowOnlyPixelShader: {
  63518. name: string;
  63519. shader: string;
  63520. };
  63521. }
  63522. declare module BABYLON {
  63523. /** @hidden */
  63524. export var shadowOnlyVertexShader: {
  63525. name: string;
  63526. shader: string;
  63527. };
  63528. }
  63529. declare module BABYLON {
  63530. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  63531. private _renderId;
  63532. private _activeLight;
  63533. constructor(name: string, scene: BABYLON.Scene);
  63534. shadowColor: BABYLON.Color3;
  63535. needAlphaBlending(): boolean;
  63536. needAlphaTesting(): boolean;
  63537. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63538. activeLight: BABYLON.IShadowLight;
  63539. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63540. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63541. clone(name: string): ShadowOnlyMaterial;
  63542. serialize(): any;
  63543. getClassName(): string;
  63544. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  63545. }
  63546. }
  63547. declare module BABYLON {
  63548. /** @hidden */
  63549. export var simplePixelShader: {
  63550. name: string;
  63551. shader: string;
  63552. };
  63553. }
  63554. declare module BABYLON {
  63555. /** @hidden */
  63556. export var simpleVertexShader: {
  63557. name: string;
  63558. shader: string;
  63559. };
  63560. }
  63561. declare module BABYLON {
  63562. export class SimpleMaterial extends BABYLON.PushMaterial {
  63563. private _diffuseTexture;
  63564. diffuseTexture: BABYLON.BaseTexture;
  63565. diffuseColor: BABYLON.Color3;
  63566. private _disableLighting;
  63567. disableLighting: boolean;
  63568. private _maxSimultaneousLights;
  63569. maxSimultaneousLights: number;
  63570. private _renderId;
  63571. constructor(name: string, scene: BABYLON.Scene);
  63572. needAlphaBlending(): boolean;
  63573. needAlphaTesting(): boolean;
  63574. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63575. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63576. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63577. getAnimatables(): BABYLON.IAnimatable[];
  63578. getActiveTextures(): BABYLON.BaseTexture[];
  63579. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63580. dispose(forceDisposeEffect?: boolean): void;
  63581. clone(name: string): SimpleMaterial;
  63582. serialize(): any;
  63583. getClassName(): string;
  63584. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  63585. }
  63586. }
  63587. declare module BABYLON {
  63588. /** @hidden */
  63589. export var skyPixelShader: {
  63590. name: string;
  63591. shader: string;
  63592. };
  63593. }
  63594. declare module BABYLON {
  63595. /** @hidden */
  63596. export var skyVertexShader: {
  63597. name: string;
  63598. shader: string;
  63599. };
  63600. }
  63601. declare module BABYLON {
  63602. /**
  63603. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  63604. * @see https://doc.babylonjs.com/extensions/sky
  63605. */
  63606. export class SkyMaterial extends BABYLON.PushMaterial {
  63607. /**
  63608. * Defines the overall luminance of sky in interval ]0, 1[.
  63609. */
  63610. luminance: number;
  63611. /**
  63612. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  63613. */
  63614. turbidity: number;
  63615. /**
  63616. * Defines the sky appearance (light intensity).
  63617. */
  63618. rayleigh: number;
  63619. /**
  63620. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  63621. */
  63622. mieCoefficient: number;
  63623. /**
  63624. * Defines the amount of haze particles following the Mie scattering theory.
  63625. */
  63626. mieDirectionalG: number;
  63627. /**
  63628. * Defines the distance of the sun according to the active scene camera.
  63629. */
  63630. distance: number;
  63631. /**
  63632. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  63633. * "inclined".
  63634. */
  63635. inclination: number;
  63636. /**
  63637. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  63638. * an object direction and a reference direction.
  63639. */
  63640. azimuth: number;
  63641. /**
  63642. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  63643. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  63644. */
  63645. sunPosition: BABYLON.Vector3;
  63646. /**
  63647. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  63648. * .sunPosition property.
  63649. */
  63650. useSunPosition: boolean;
  63651. /**
  63652. * Defines an offset vector used to get a horizon offset.
  63653. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  63654. */
  63655. cameraOffset: BABYLON.Vector3;
  63656. private _cameraPosition;
  63657. private _renderId;
  63658. /**
  63659. * Instantiates a new sky material.
  63660. * This material allows to create dynamic and texture free
  63661. * effects for skyboxes by taking care of the atmosphere state.
  63662. * @see https://doc.babylonjs.com/extensions/sky
  63663. * @param name Define the name of the material in the scene
  63664. * @param scene Define the scene the material belong to
  63665. */
  63666. constructor(name: string, scene: BABYLON.Scene);
  63667. /**
  63668. * Specifies if the material will require alpha blending
  63669. * @returns a boolean specifying if alpha blending is needed
  63670. */
  63671. needAlphaBlending(): boolean;
  63672. /**
  63673. * Specifies if this material should be rendered in alpha test mode
  63674. * @returns false as the sky material doesn't need alpha testing.
  63675. */
  63676. needAlphaTesting(): boolean;
  63677. /**
  63678. * Get the texture used for alpha test purpose.
  63679. * @returns null as the sky material has no texture.
  63680. */
  63681. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63682. /**
  63683. * Get if the submesh is ready to be used and all its information available.
  63684. * Child classes can use it to update shaders
  63685. * @param mesh defines the mesh to check
  63686. * @param subMesh defines which submesh to check
  63687. * @param useInstances specifies that instances should be used
  63688. * @returns a boolean indicating that the submesh is ready or not
  63689. */
  63690. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63691. /**
  63692. * Binds the submesh to this material by preparing the effect and shader to draw
  63693. * @param world defines the world transformation matrix
  63694. * @param mesh defines the mesh containing the submesh
  63695. * @param subMesh defines the submesh to bind the material to
  63696. */
  63697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63698. /**
  63699. * Get the list of animatables in the material.
  63700. * @returns the list of animatables object used in the material
  63701. */
  63702. getAnimatables(): BABYLON.IAnimatable[];
  63703. /**
  63704. * Disposes the material
  63705. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  63706. */
  63707. dispose(forceDisposeEffect?: boolean): void;
  63708. /**
  63709. * Makes a duplicate of the material, and gives it a new name
  63710. * @param name defines the new name for the duplicated material
  63711. * @returns the cloned material
  63712. */
  63713. clone(name: string): SkyMaterial;
  63714. /**
  63715. * Serializes this material in a JSON representation
  63716. * @returns the serialized material object
  63717. */
  63718. serialize(): any;
  63719. /**
  63720. * Gets the current class name of the material e.g. "SkyMaterial"
  63721. * Mainly use in serialization.
  63722. * @returns the class name
  63723. */
  63724. getClassName(): string;
  63725. /**
  63726. * Creates a sky material from parsed material data
  63727. * @param source defines the JSON representation of the material
  63728. * @param scene defines the hosting scene
  63729. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  63730. * @returns a new sky material
  63731. */
  63732. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  63733. }
  63734. }
  63735. declare module BABYLON {
  63736. /** @hidden */
  63737. export var terrainPixelShader: {
  63738. name: string;
  63739. shader: string;
  63740. };
  63741. }
  63742. declare module BABYLON {
  63743. /** @hidden */
  63744. export var terrainVertexShader: {
  63745. name: string;
  63746. shader: string;
  63747. };
  63748. }
  63749. declare module BABYLON {
  63750. export class TerrainMaterial extends BABYLON.PushMaterial {
  63751. private _mixTexture;
  63752. mixTexture: BABYLON.BaseTexture;
  63753. private _diffuseTexture1;
  63754. diffuseTexture1: BABYLON.Texture;
  63755. private _diffuseTexture2;
  63756. diffuseTexture2: BABYLON.Texture;
  63757. private _diffuseTexture3;
  63758. diffuseTexture3: BABYLON.Texture;
  63759. private _bumpTexture1;
  63760. bumpTexture1: BABYLON.Texture;
  63761. private _bumpTexture2;
  63762. bumpTexture2: BABYLON.Texture;
  63763. private _bumpTexture3;
  63764. bumpTexture3: BABYLON.Texture;
  63765. diffuseColor: BABYLON.Color3;
  63766. specularColor: BABYLON.Color3;
  63767. specularPower: number;
  63768. private _disableLighting;
  63769. disableLighting: boolean;
  63770. private _maxSimultaneousLights;
  63771. maxSimultaneousLights: number;
  63772. private _renderId;
  63773. constructor(name: string, scene: BABYLON.Scene);
  63774. needAlphaBlending(): boolean;
  63775. needAlphaTesting(): boolean;
  63776. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63777. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63778. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63779. getAnimatables(): BABYLON.IAnimatable[];
  63780. getActiveTextures(): BABYLON.BaseTexture[];
  63781. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63782. dispose(forceDisposeEffect?: boolean): void;
  63783. clone(name: string): TerrainMaterial;
  63784. serialize(): any;
  63785. getClassName(): string;
  63786. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  63787. }
  63788. }
  63789. declare module BABYLON {
  63790. /** @hidden */
  63791. export var triplanarPixelShader: {
  63792. name: string;
  63793. shader: string;
  63794. };
  63795. }
  63796. declare module BABYLON {
  63797. /** @hidden */
  63798. export var triplanarVertexShader: {
  63799. name: string;
  63800. shader: string;
  63801. };
  63802. }
  63803. declare module BABYLON {
  63804. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  63805. mixTexture: BABYLON.BaseTexture;
  63806. private _diffuseTextureX;
  63807. diffuseTextureX: BABYLON.BaseTexture;
  63808. private _diffuseTextureY;
  63809. diffuseTextureY: BABYLON.BaseTexture;
  63810. private _diffuseTextureZ;
  63811. diffuseTextureZ: BABYLON.BaseTexture;
  63812. private _normalTextureX;
  63813. normalTextureX: BABYLON.BaseTexture;
  63814. private _normalTextureY;
  63815. normalTextureY: BABYLON.BaseTexture;
  63816. private _normalTextureZ;
  63817. normalTextureZ: BABYLON.BaseTexture;
  63818. tileSize: number;
  63819. diffuseColor: BABYLON.Color3;
  63820. specularColor: BABYLON.Color3;
  63821. specularPower: number;
  63822. private _disableLighting;
  63823. disableLighting: boolean;
  63824. private _maxSimultaneousLights;
  63825. maxSimultaneousLights: number;
  63826. private _renderId;
  63827. constructor(name: string, scene: BABYLON.Scene);
  63828. needAlphaBlending(): boolean;
  63829. needAlphaTesting(): boolean;
  63830. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63831. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63832. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63833. getAnimatables(): BABYLON.IAnimatable[];
  63834. getActiveTextures(): BABYLON.BaseTexture[];
  63835. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63836. dispose(forceDisposeEffect?: boolean): void;
  63837. clone(name: string): TriPlanarMaterial;
  63838. serialize(): any;
  63839. getClassName(): string;
  63840. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  63841. }
  63842. }
  63843. declare module BABYLON {
  63844. /** @hidden */
  63845. export var waterPixelShader: {
  63846. name: string;
  63847. shader: string;
  63848. };
  63849. }
  63850. declare module BABYLON {
  63851. /** @hidden */
  63852. export var waterVertexShader: {
  63853. name: string;
  63854. shader: string;
  63855. };
  63856. }
  63857. declare module BABYLON {
  63858. export class WaterMaterial extends BABYLON.PushMaterial {
  63859. renderTargetSize: BABYLON.Vector2;
  63860. private _bumpTexture;
  63861. bumpTexture: BABYLON.BaseTexture;
  63862. diffuseColor: BABYLON.Color3;
  63863. specularColor: BABYLON.Color3;
  63864. specularPower: number;
  63865. private _disableLighting;
  63866. disableLighting: boolean;
  63867. private _maxSimultaneousLights;
  63868. maxSimultaneousLights: number;
  63869. /**
  63870. * @param {number}: Represents the wind force
  63871. */
  63872. windForce: number;
  63873. /**
  63874. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  63875. */
  63876. windDirection: BABYLON.Vector2;
  63877. /**
  63878. * @param {number}: Wave height, represents the height of the waves
  63879. */
  63880. waveHeight: number;
  63881. /**
  63882. * @param {number}: Bump height, represents the bump height related to the bump map
  63883. */
  63884. bumpHeight: number;
  63885. /**
  63886. * @param {boolean}: Add a smaller moving bump to less steady waves.
  63887. */
  63888. private _bumpSuperimpose;
  63889. bumpSuperimpose: boolean;
  63890. /**
  63891. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  63892. */
  63893. private _fresnelSeparate;
  63894. fresnelSeparate: boolean;
  63895. /**
  63896. * @param {boolean}: bump Waves modify the reflection.
  63897. */
  63898. private _bumpAffectsReflection;
  63899. bumpAffectsReflection: boolean;
  63900. /**
  63901. * @param {number}: The water color blended with the refraction (near)
  63902. */
  63903. waterColor: BABYLON.Color3;
  63904. /**
  63905. * @param {number}: The blend factor related to the water color
  63906. */
  63907. colorBlendFactor: number;
  63908. /**
  63909. * @param {number}: The water color blended with the reflection (far)
  63910. */
  63911. waterColor2: BABYLON.Color3;
  63912. /**
  63913. * @param {number}: The blend factor related to the water color (reflection, far)
  63914. */
  63915. colorBlendFactor2: number;
  63916. /**
  63917. * @param {number}: Represents the maximum length of a wave
  63918. */
  63919. waveLength: number;
  63920. /**
  63921. * @param {number}: Defines the waves speed
  63922. */
  63923. waveSpeed: number;
  63924. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  63925. private _mesh;
  63926. private _refractionRTT;
  63927. private _reflectionRTT;
  63928. private _reflectionTransform;
  63929. private _lastTime;
  63930. private _lastDeltaTime;
  63931. private _renderId;
  63932. private _useLogarithmicDepth;
  63933. private _waitingRenderList;
  63934. /**
  63935. * Gets a boolean indicating that current material needs to register RTT
  63936. */
  63937. readonly hasRenderTargetTextures: boolean;
  63938. /**
  63939. * Constructor
  63940. */
  63941. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  63942. useLogarithmicDepth: boolean;
  63943. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  63944. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  63945. addToRenderList(node: any): void;
  63946. enableRenderTargets(enable: boolean): void;
  63947. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  63948. readonly renderTargetsEnabled: boolean;
  63949. needAlphaBlending(): boolean;
  63950. needAlphaTesting(): boolean;
  63951. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  63952. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  63953. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  63954. private _createRenderTargets;
  63955. getAnimatables(): BABYLON.IAnimatable[];
  63956. getActiveTextures(): BABYLON.BaseTexture[];
  63957. hasTexture(texture: BABYLON.BaseTexture): boolean;
  63958. dispose(forceDisposeEffect?: boolean): void;
  63959. clone(name: string): WaterMaterial;
  63960. serialize(): any;
  63961. getClassName(): string;
  63962. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  63963. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  63964. }
  63965. }
  63966. declare module BABYLON {
  63967. /** @hidden */
  63968. export var asciiartPixelShader: {
  63969. name: string;
  63970. shader: string;
  63971. };
  63972. }
  63973. declare module BABYLON {
  63974. /**
  63975. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  63976. *
  63977. * It basically takes care rendering the font front the given font size to a texture.
  63978. * This is used later on in the postprocess.
  63979. */
  63980. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  63981. private _font;
  63982. private _text;
  63983. private _charSize;
  63984. /**
  63985. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  63986. */
  63987. readonly charSize: number;
  63988. /**
  63989. * Create a new instance of the Ascii Art FontTexture class
  63990. * @param name the name of the texture
  63991. * @param font the font to use, use the W3C CSS notation
  63992. * @param text the caracter set to use in the rendering.
  63993. * @param scene the scene that owns the texture
  63994. */
  63995. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  63996. /**
  63997. * Gets the max char width of a font.
  63998. * @param font the font to use, use the W3C CSS notation
  63999. * @return the max char width
  64000. */
  64001. private getFontWidth;
  64002. /**
  64003. * Gets the max char height of a font.
  64004. * @param font the font to use, use the W3C CSS notation
  64005. * @return the max char height
  64006. */
  64007. private getFontHeight;
  64008. /**
  64009. * Clones the current AsciiArtTexture.
  64010. * @return the clone of the texture.
  64011. */
  64012. clone(): AsciiArtFontTexture;
  64013. /**
  64014. * Parses a json object representing the texture and returns an instance of it.
  64015. * @param source the source JSON representation
  64016. * @param scene the scene to create the texture for
  64017. * @return the parsed texture
  64018. */
  64019. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  64020. }
  64021. /**
  64022. * Option available in the Ascii Art Post Process.
  64023. */
  64024. export interface IAsciiArtPostProcessOptions {
  64025. /**
  64026. * The font to use following the w3c font definition.
  64027. */
  64028. font?: string;
  64029. /**
  64030. * The character set to use in the postprocess.
  64031. */
  64032. characterSet?: string;
  64033. /**
  64034. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64035. * This number is defined between 0 and 1;
  64036. */
  64037. mixToTile?: number;
  64038. /**
  64039. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64040. * This number is defined between 0 and 1;
  64041. */
  64042. mixToNormal?: number;
  64043. }
  64044. /**
  64045. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  64046. *
  64047. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64048. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  64049. */
  64050. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  64051. /**
  64052. * The font texture used to render the char in the post process.
  64053. */
  64054. private _asciiArtFontTexture;
  64055. /**
  64056. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  64057. * This number is defined between 0 and 1;
  64058. */
  64059. mixToTile: number;
  64060. /**
  64061. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  64062. * This number is defined between 0 and 1;
  64063. */
  64064. mixToNormal: number;
  64065. /**
  64066. * Instantiates a new Ascii Art Post Process.
  64067. * @param name the name to give to the postprocess
  64068. * @camera the camera to apply the post process to.
  64069. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  64070. */
  64071. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  64072. }
  64073. }
  64074. declare module BABYLON {
  64075. /** @hidden */
  64076. export var digitalrainPixelShader: {
  64077. name: string;
  64078. shader: string;
  64079. };
  64080. }
  64081. declare module BABYLON {
  64082. /**
  64083. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  64084. *
  64085. * It basically takes care rendering the font front the given font size to a texture.
  64086. * This is used later on in the postprocess.
  64087. */
  64088. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  64089. private _font;
  64090. private _text;
  64091. private _charSize;
  64092. /**
  64093. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  64094. */
  64095. readonly charSize: number;
  64096. /**
  64097. * Create a new instance of the Digital Rain FontTexture class
  64098. * @param name the name of the texture
  64099. * @param font the font to use, use the W3C CSS notation
  64100. * @param text the caracter set to use in the rendering.
  64101. * @param scene the scene that owns the texture
  64102. */
  64103. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  64104. /**
  64105. * Gets the max char width of a font.
  64106. * @param font the font to use, use the W3C CSS notation
  64107. * @return the max char width
  64108. */
  64109. private getFontWidth;
  64110. /**
  64111. * Gets the max char height of a font.
  64112. * @param font the font to use, use the W3C CSS notation
  64113. * @return the max char height
  64114. */
  64115. private getFontHeight;
  64116. /**
  64117. * Clones the current DigitalRainFontTexture.
  64118. * @return the clone of the texture.
  64119. */
  64120. clone(): DigitalRainFontTexture;
  64121. /**
  64122. * Parses a json object representing the texture and returns an instance of it.
  64123. * @param source the source JSON representation
  64124. * @param scene the scene to create the texture for
  64125. * @return the parsed texture
  64126. */
  64127. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  64128. }
  64129. /**
  64130. * Option available in the Digital Rain Post Process.
  64131. */
  64132. export interface IDigitalRainPostProcessOptions {
  64133. /**
  64134. * The font to use following the w3c font definition.
  64135. */
  64136. font?: string;
  64137. /**
  64138. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64139. * This number is defined between 0 and 1;
  64140. */
  64141. mixToTile?: number;
  64142. /**
  64143. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64144. * This number is defined between 0 and 1;
  64145. */
  64146. mixToNormal?: number;
  64147. }
  64148. /**
  64149. * DigitalRainPostProcess helps rendering everithing in digital rain.
  64150. *
  64151. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64152. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  64153. */
  64154. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  64155. /**
  64156. * The font texture used to render the char in the post process.
  64157. */
  64158. private _digitalRainFontTexture;
  64159. /**
  64160. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  64161. * This number is defined between 0 and 1;
  64162. */
  64163. mixToTile: number;
  64164. /**
  64165. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  64166. * This number is defined between 0 and 1;
  64167. */
  64168. mixToNormal: number;
  64169. /**
  64170. * Instantiates a new Digital Rain Post Process.
  64171. * @param name the name to give to the postprocess
  64172. * @camera the camera to apply the post process to.
  64173. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  64174. */
  64175. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  64176. }
  64177. }
  64178. declare module BABYLON {
  64179. /** @hidden */
  64180. export var oceanPostProcessPixelShader: {
  64181. name: string;
  64182. shader: string;
  64183. };
  64184. }
  64185. declare module BABYLON {
  64186. /**
  64187. * Option available in the Ocean Post Process.
  64188. */
  64189. export interface IOceanPostProcessOptions {
  64190. /**
  64191. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64192. */
  64193. reflectionSize?: number | {
  64194. width: number;
  64195. height: number;
  64196. } | {
  64197. ratio: number;
  64198. };
  64199. /**
  64200. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  64201. */
  64202. refractionSize?: number | {
  64203. width: number;
  64204. height: number;
  64205. } | {
  64206. ratio: number;
  64207. };
  64208. }
  64209. /**
  64210. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  64211. *
  64212. * Simmply add it to your scene and let the nerd that lives in you have fun.
  64213. * Example usage:
  64214. * var pp = new OceanPostProcess("myOcean", camera);
  64215. * pp.reflectionEnabled = true;
  64216. * pp.refractionEnabled = true;
  64217. */
  64218. export class OceanPostProcess extends BABYLON.PostProcess {
  64219. /**
  64220. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  64221. */
  64222. /**
  64223. * Sets weither or not the real-time reflection is enabled on the ocean.
  64224. * Is set to true, the reflection mirror texture will be used as reflection texture.
  64225. */
  64226. reflectionEnabled: boolean;
  64227. /**
  64228. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  64229. */
  64230. /**
  64231. * Sets weither or not the real-time refraction is enabled on the ocean.
  64232. * Is set to true, the refraction render target texture will be used as refraction texture.
  64233. */
  64234. refractionEnabled: boolean;
  64235. /**
  64236. * Gets wether or not the post-processes is supported by the running hardware.
  64237. * This requires draw buffer supports.
  64238. */
  64239. readonly isSupported: boolean;
  64240. /**
  64241. * This is the reflection mirror texture used to display reflections on the ocean.
  64242. * By default, render list is empty.
  64243. */
  64244. reflectionTexture: BABYLON.MirrorTexture;
  64245. /**
  64246. * This is the refraction render target texture used to display refraction on the ocean.
  64247. * By default, render list is empty.
  64248. */
  64249. refractionTexture: BABYLON.RenderTargetTexture;
  64250. private _time;
  64251. private _cameraRotation;
  64252. private _cameraViewMatrix;
  64253. private _reflectionEnabled;
  64254. private _refractionEnabled;
  64255. private _geometryRenderer;
  64256. /**
  64257. * Instantiates a new Ocean Post Process.
  64258. * @param name the name to give to the postprocess.
  64259. * @camera the camera to apply the post process to.
  64260. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  64261. */
  64262. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  64263. /**
  64264. * Returns the appropriate defines according to the current configuration.
  64265. */
  64266. private _getDefines;
  64267. /**
  64268. * Computes the current camera rotation as the shader requires a camera rotation.
  64269. */
  64270. private _computeCameraRotation;
  64271. }
  64272. }
  64273. declare module BABYLON {
  64274. /** @hidden */
  64275. export var brickProceduralTexturePixelShader: {
  64276. name: string;
  64277. shader: string;
  64278. };
  64279. }
  64280. declare module BABYLON {
  64281. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  64282. private _numberOfBricksHeight;
  64283. private _numberOfBricksWidth;
  64284. private _jointColor;
  64285. private _brickColor;
  64286. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64287. updateShaderUniforms(): void;
  64288. numberOfBricksHeight: number;
  64289. numberOfBricksWidth: number;
  64290. jointColor: BABYLON.Color3;
  64291. brickColor: BABYLON.Color3;
  64292. /**
  64293. * Serializes this brick procedural texture
  64294. * @returns a serialized brick procedural texture object
  64295. */
  64296. serialize(): any;
  64297. /**
  64298. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  64299. * @param parsedTexture defines parsed texture data
  64300. * @param scene defines the current scene
  64301. * @param rootUrl defines the root URL containing brick procedural texture information
  64302. * @returns a parsed Brick Procedural BABYLON.Texture
  64303. */
  64304. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  64305. }
  64306. }
  64307. declare module BABYLON {
  64308. /** @hidden */
  64309. export var cloudProceduralTexturePixelShader: {
  64310. name: string;
  64311. shader: string;
  64312. };
  64313. }
  64314. declare module BABYLON {
  64315. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  64316. private _skyColor;
  64317. private _cloudColor;
  64318. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64319. updateShaderUniforms(): void;
  64320. skyColor: BABYLON.Color4;
  64321. cloudColor: BABYLON.Color4;
  64322. /**
  64323. * Serializes this cloud procedural texture
  64324. * @returns a serialized cloud procedural texture object
  64325. */
  64326. serialize(): any;
  64327. /**
  64328. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  64329. * @param parsedTexture defines parsed texture data
  64330. * @param scene defines the current scene
  64331. * @param rootUrl defines the root URL containing cloud procedural texture information
  64332. * @returns a parsed Cloud Procedural BABYLON.Texture
  64333. */
  64334. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  64335. }
  64336. }
  64337. declare module BABYLON {
  64338. /** @hidden */
  64339. export var fireProceduralTexturePixelShader: {
  64340. name: string;
  64341. shader: string;
  64342. };
  64343. }
  64344. declare module BABYLON {
  64345. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  64346. private _time;
  64347. private _speed;
  64348. private _autoGenerateTime;
  64349. private _fireColors;
  64350. private _alphaThreshold;
  64351. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64352. updateShaderUniforms(): void;
  64353. render(useCameraPostProcess?: boolean): void;
  64354. static readonly PurpleFireColors: BABYLON.Color3[];
  64355. static readonly GreenFireColors: BABYLON.Color3[];
  64356. static readonly RedFireColors: BABYLON.Color3[];
  64357. static readonly BlueFireColors: BABYLON.Color3[];
  64358. autoGenerateTime: boolean;
  64359. fireColors: BABYLON.Color3[];
  64360. time: number;
  64361. speed: BABYLON.Vector2;
  64362. alphaThreshold: number;
  64363. /**
  64364. * Serializes this fire procedural texture
  64365. * @returns a serialized fire procedural texture object
  64366. */
  64367. serialize(): any;
  64368. /**
  64369. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  64370. * @param parsedTexture defines parsed texture data
  64371. * @param scene defines the current scene
  64372. * @param rootUrl defines the root URL containing fire procedural texture information
  64373. * @returns a parsed Fire Procedural BABYLON.Texture
  64374. */
  64375. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  64376. }
  64377. }
  64378. declare module BABYLON {
  64379. /** @hidden */
  64380. export var grassProceduralTexturePixelShader: {
  64381. name: string;
  64382. shader: string;
  64383. };
  64384. }
  64385. declare module BABYLON {
  64386. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  64387. private _grassColors;
  64388. private _groundColor;
  64389. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64390. updateShaderUniforms(): void;
  64391. grassColors: BABYLON.Color3[];
  64392. groundColor: BABYLON.Color3;
  64393. /**
  64394. * Serializes this grass procedural texture
  64395. * @returns a serialized grass procedural texture object
  64396. */
  64397. serialize(): any;
  64398. /**
  64399. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  64400. * @param parsedTexture defines parsed texture data
  64401. * @param scene defines the current scene
  64402. * @param rootUrl defines the root URL containing grass procedural texture information
  64403. * @returns a parsed Grass Procedural BABYLON.Texture
  64404. */
  64405. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  64406. }
  64407. }
  64408. declare module BABYLON {
  64409. /** @hidden */
  64410. export var marbleProceduralTexturePixelShader: {
  64411. name: string;
  64412. shader: string;
  64413. };
  64414. }
  64415. declare module BABYLON {
  64416. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  64417. private _numberOfTilesHeight;
  64418. private _numberOfTilesWidth;
  64419. private _amplitude;
  64420. private _jointColor;
  64421. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64422. updateShaderUniforms(): void;
  64423. numberOfTilesHeight: number;
  64424. amplitude: number;
  64425. numberOfTilesWidth: number;
  64426. jointColor: BABYLON.Color3;
  64427. /**
  64428. * Serializes this marble procedural texture
  64429. * @returns a serialized marble procedural texture object
  64430. */
  64431. serialize(): any;
  64432. /**
  64433. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  64434. * @param parsedTexture defines parsed texture data
  64435. * @param scene defines the current scene
  64436. * @param rootUrl defines the root URL containing marble procedural texture information
  64437. * @returns a parsed Marble Procedural BABYLON.Texture
  64438. */
  64439. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  64440. }
  64441. }
  64442. declare module BABYLON {
  64443. /** @hidden */
  64444. export var normalMapProceduralTexturePixelShader: {
  64445. name: string;
  64446. shader: string;
  64447. };
  64448. }
  64449. declare module BABYLON {
  64450. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  64451. private _baseTexture;
  64452. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64453. updateShaderUniforms(): void;
  64454. render(useCameraPostProcess?: boolean): void;
  64455. resize(size: any, generateMipMaps: any): void;
  64456. baseTexture: BABYLON.Texture;
  64457. /**
  64458. * Serializes this normal map procedural texture
  64459. * @returns a serialized normal map procedural texture object
  64460. */
  64461. serialize(): any;
  64462. /**
  64463. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  64464. * @param parsedTexture defines parsed texture data
  64465. * @param scene defines the current scene
  64466. * @param rootUrl defines the root URL containing normal map procedural texture information
  64467. * @returns a parsed Normal Map Procedural BABYLON.Texture
  64468. */
  64469. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  64470. }
  64471. }
  64472. declare module BABYLON {
  64473. /** @hidden */
  64474. export var perlinNoiseProceduralTexturePixelShader: {
  64475. name: string;
  64476. shader: string;
  64477. };
  64478. }
  64479. declare module BABYLON {
  64480. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  64481. time: number;
  64482. timeScale: number;
  64483. translationSpeed: number;
  64484. private _currentTranslation;
  64485. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64486. updateShaderUniforms(): void;
  64487. render(useCameraPostProcess?: boolean): void;
  64488. resize(size: any, generateMipMaps: any): void;
  64489. /**
  64490. * Serializes this perlin noise procedural texture
  64491. * @returns a serialized perlin noise procedural texture object
  64492. */
  64493. serialize(): any;
  64494. /**
  64495. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  64496. * @param parsedTexture defines parsed texture data
  64497. * @param scene defines the current scene
  64498. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  64499. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  64500. */
  64501. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  64502. }
  64503. }
  64504. declare module BABYLON {
  64505. /** @hidden */
  64506. export var roadProceduralTexturePixelShader: {
  64507. name: string;
  64508. shader: string;
  64509. };
  64510. }
  64511. declare module BABYLON {
  64512. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  64513. private _roadColor;
  64514. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64515. updateShaderUniforms(): void;
  64516. roadColor: BABYLON.Color3;
  64517. /**
  64518. * Serializes this road procedural texture
  64519. * @returns a serialized road procedural texture object
  64520. */
  64521. serialize(): any;
  64522. /**
  64523. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  64524. * @param parsedTexture defines parsed texture data
  64525. * @param scene defines the current scene
  64526. * @param rootUrl defines the root URL containing road procedural texture information
  64527. * @returns a parsed Road Procedural BABYLON.Texture
  64528. */
  64529. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  64530. }
  64531. }
  64532. declare module BABYLON {
  64533. /** @hidden */
  64534. export var starfieldProceduralTexturePixelShader: {
  64535. name: string;
  64536. shader: string;
  64537. };
  64538. }
  64539. declare module BABYLON {
  64540. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  64541. private _time;
  64542. private _alpha;
  64543. private _beta;
  64544. private _zoom;
  64545. private _formuparam;
  64546. private _stepsize;
  64547. private _tile;
  64548. private _brightness;
  64549. private _darkmatter;
  64550. private _distfading;
  64551. private _saturation;
  64552. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64553. updateShaderUniforms(): void;
  64554. time: number;
  64555. alpha: number;
  64556. beta: number;
  64557. formuparam: number;
  64558. stepsize: number;
  64559. zoom: number;
  64560. tile: number;
  64561. brightness: number;
  64562. darkmatter: number;
  64563. distfading: number;
  64564. saturation: number;
  64565. /**
  64566. * Serializes this starfield procedural texture
  64567. * @returns a serialized starfield procedural texture object
  64568. */
  64569. serialize(): any;
  64570. /**
  64571. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  64572. * @param parsedTexture defines parsed texture data
  64573. * @param scene defines the current scene
  64574. * @param rootUrl defines the root URL containing startfield procedural texture information
  64575. * @returns a parsed Starfield Procedural BABYLON.Texture
  64576. */
  64577. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  64578. }
  64579. }
  64580. declare module BABYLON {
  64581. /** @hidden */
  64582. export var woodProceduralTexturePixelShader: {
  64583. name: string;
  64584. shader: string;
  64585. };
  64586. }
  64587. declare module BABYLON {
  64588. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  64589. private _ampScale;
  64590. private _woodColor;
  64591. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  64592. updateShaderUniforms(): void;
  64593. ampScale: number;
  64594. woodColor: BABYLON.Color3;
  64595. /**
  64596. * Serializes this wood procedural texture
  64597. * @returns a serialized wood procedural texture object
  64598. */
  64599. serialize(): any;
  64600. /**
  64601. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  64602. * @param parsedTexture defines parsed texture data
  64603. * @param scene defines the current scene
  64604. * @param rootUrl defines the root URL containing wood procedural texture information
  64605. * @returns a parsed Wood Procedural BABYLON.Texture
  64606. */
  64607. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  64608. }
  64609. }